-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
b0c8eb6
commit fa7defa
Showing
13 changed files
with
165 additions
and
7 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,8 @@ | ||
source :gemcutter | ||
|
||
gem "sinatra" | ||
gem "haml" | ||
gem "ar-octopus", "0.0.29", :require => "octopus" | ||
gem "activerecord", '>= 2.3' | ||
gem "sqlite3-ruby", ">= 1.3.1" | ||
gem "sinatra-activerecord", :git => "git://github.com/tchandy/sinatra-activerecord.git" |
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,30 @@ | ||
GIT | ||
remote: git://github.com/tchandy/sinatra-activerecord.git | ||
revision: 47726c2 | ||
specs: | ||
sinatra-activerecord (0.1.2) | ||
|
||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
activerecord (2.3.8) | ||
activesupport (= 2.3.8) | ||
activesupport (2.3.8) | ||
ar-octopus (0.0.29) | ||
activerecord (>= 2.3) | ||
haml (3.0.15) | ||
rack (1.2.1) | ||
sinatra (1.0) | ||
rack (>= 1.0) | ||
sqlite3-ruby (1.3.1) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
activerecord (>= 2.3) | ||
ar-octopus (= 0.0.29) | ||
haml | ||
sinatra | ||
sinatra-activerecord! | ||
sqlite3-ruby (>= 1.3.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,21 @@ | ||
# Octopus Sinatra Example | ||
|
||
This is a sample application using octopus + sinatra. This app demonstrate the basics of octopus running outside Rails. | ||
|
||
## How to Run: | ||
<pre> | ||
git clone | ||
cd octopus_sinatra | ||
bundle install | ||
rake db:migrate | ||
rackup | ||
</pre> | ||
|
||
## Thanks | ||
|
||
This project is sponsored by the <a href="http://www.rubysoc.org">Ruby Summer of Code</a>, | ||
and my mentors <a href="http://github.com/mperham">Mike Perham</a> and <a href="http://github.com/amitagarwal">Amit Agarwal</a>. | ||
|
||
## Copyright | ||
|
||
Copyright (c) 2010 Thiago Pradi, released under the MIT license. |
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,10 @@ | ||
# require your app file first | ||
require "rubygems" | ||
require 'server' | ||
require 'rubygems' | ||
require 'bundler' | ||
Bundler.setup | ||
|
||
require 'sinatra' | ||
require 'server' | ||
require 'sinatra/activerecord/rake' |
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,7 @@ | ||
require 'rubygems' | ||
require 'bundler' | ||
Bundler.setup | ||
|
||
require 'sinatra' | ||
require 'server' | ||
run Sinatra::Application |
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
octopus: | ||
shards: | ||
america: | ||
adapter: sqlite | ||
adapter: sqlite3 | ||
database: america.sqlite3 | ||
europe: | ||
adapter: sqlite | ||
adapter: sqlite3 | ||
database: europe.sqlite3 | ||
asia: | ||
adapter: asia | ||
adapter: sqlite3 | ||
database: asia.sqlite3 |
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
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,16 @@ | ||
class CreateUsers < ActiveRecord::Migration | ||
using(:master, :europe, :asia, :america) | ||
|
||
def self.up | ||
create_table :users, :force => true do |t| | ||
t.string :name | ||
t.timestamps | ||
end | ||
|
||
User.create(:name => "User #{rand}") | ||
end | ||
|
||
def self.down | ||
drop_table :users | ||
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
require "rubygems" | ||
gem 'activerecord', '2.3.8' | ||
require "sinatra" | ||
require "database_connection" | ||
require 'haml' | ||
|
||
get "/" do | ||
|
||
haml :welcome | ||
end | ||
|
||
get "/database/:shard" do | ||
Octopus.using(params[:shard].to_sym) do | ||
|
||
end | ||
haml :database | ||
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,28 @@ | ||
!!! Strict | ||
%html | ||
%head | ||
%meta{'http-equiv' => 'Content-Type', :content => 'text/html; charset=utf-8'} | ||
%title Sinatra Octopus Example | ||
%body | ||
#container | ||
#header | ||
%h1 Sinatra Octopus Example | ||
#user-navigation | ||
%ul.wat-cf | ||
Octopus + Sinatra = Awesome! | ||
<div id="main-navigation"> | ||
<ul class="wat-cf"></ul> | ||
</div> | ||
#wrapper.wat-cf | ||
.flash | ||
#main | ||
Infos about your shard: | ||
%p= "Name: #{params[:shard]}" | ||
%p | ||
= OrmInfo.build(params[:shard]) | ||
- User.using(params[:shard].to_sym).all.each do |user| | ||
%p= "User Id: #{user.id} Name: #{user.name}" | ||
#footer | ||
.block | ||
<p>Copyright © #{ Time.now.year } Thiago Pradi.</p> | ||
#sidebar |
Empty file.
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,30 @@ | ||
!!! Strict | ||
%html | ||
%head | ||
%meta{'http-equiv' => 'Content-Type', :content => 'text/html; charset=utf-8'} | ||
%title Sinatra Octopus Example | ||
%body | ||
#container | ||
#header | ||
%h1 Sinatra Octopus Example | ||
#user-navigation | ||
%ul.wat-cf | ||
Octopus + Sinatra = Awesome! | ||
<div id="main-navigation"> | ||
<ul class="wat-cf"></ul> | ||
</div> | ||
#wrapper.wat-cf | ||
.flash | ||
#main | ||
Hi! Welcome to the sinatra replication Example! Please select what shard you want to use: | ||
%p | ||
%a{:href => '/database/america'} America | ||
%p | ||
%a{:href => '/database/europe'} Europe | ||
%p | ||
%a{:href => '/database/asia'} Asia | ||
#footer | ||
.block | ||
<p>Copyright © #{ Time.now.year } Thiago Pradi.</p> | ||
#sidebar | ||
|
Empty file.