Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2fc585b
Showing
12 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
LANG=en_US.UTF-8 | ||
RACK_ENV=development |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
db/*.sql* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rvm use ruby-1.9.2@demo.db-replication --create |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
source "http://rubygems.org" | ||
|
||
gem 'thin' | ||
gem 'sinatra' | ||
gem 'activerecord' | ||
|
||
group :development, :test do | ||
gem 'foreman' | ||
gem 'sqlite3' | ||
gem 'rake' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
activemodel (3.0.9) | ||
activesupport (= 3.0.9) | ||
builder (~> 2.1.2) | ||
i18n (~> 0.5.0) | ||
activerecord (3.0.9) | ||
activemodel (= 3.0.9) | ||
activesupport (= 3.0.9) | ||
arel (~> 2.0.10) | ||
tzinfo (~> 0.3.23) | ||
activesupport (3.0.9) | ||
arel (2.0.10) | ||
builder (2.1.2) | ||
daemons (1.1.3) | ||
eventmachine (0.12.10) | ||
foreman (0.18.0) | ||
term-ansicolor (~> 1.0.5) | ||
thor (>= 0.13.6) | ||
i18n (0.5.0) | ||
rack (1.2.2) | ||
rake (0.9.2) | ||
sinatra (1.2.6) | ||
rack (~> 1.1) | ||
tilt (< 2.0, >= 1.2.2) | ||
sqlite3 (1.3.3) | ||
term-ansicolor (1.0.5) | ||
thin (1.2.11) | ||
daemons (>= 1.0.9) | ||
eventmachine (>= 0.12.6) | ||
rack (>= 1.0.0) | ||
thor (0.14.6) | ||
tilt (1.3) | ||
tzinfo (0.3.28) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
activerecord | ||
foreman | ||
rake | ||
sinatra | ||
sqlite3 | ||
thin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: bundle exec thin start -p $PORT -e $RACK_ENV |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace :db do | ||
|
||
task :environment do | ||
load 'config.rb' | ||
end | ||
|
||
desc "Migrate the database" | ||
task(:migrate => :environment) do | ||
ActiveRecord::Migrator.migrate("db/migrate") | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require 'active_record' | ||
require 'logger' | ||
|
||
dbconfig = YAML.load(File.read('config/database.yml')) | ||
ActiveRecord::Base.establish_connection dbconfig[ENV['RACK_ENV'] || 'development'] | ||
|
||
ActiveRecord::Base.logger = Logger.new(STDOUT) | ||
ActiveRecord::Migration.verbose = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require "rubygems" | ||
require "bundler" | ||
Bundler.setup | ||
|
||
require 'sinatra/base' | ||
load 'config.rb' | ||
|
||
class Hit < ActiveRecord::Base | ||
end | ||
|
||
class DbReplicationDemoApp < Sinatra::Base | ||
|
||
get "/" do | ||
Hit.create(:ip => request.ip) | ||
"Hi #{request.ip}" | ||
end | ||
end | ||
|
||
run DbReplicationDemoApp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
development: | ||
adapter: sqlite3 | ||
database: db/development.sqlite3 | ||
pool: 5 | ||
timeout: 5000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class Init < ActiveRecord::Migration | ||
def self.up | ||
create_table "hits" do |t| | ||
t.string "ip" | ||
t.datetime "created_at" | ||
end | ||
end | ||
|
||
def self.down | ||
drop_table "hits" | ||
end | ||
end | ||
|