Permalink
Browse files

Fix examples

  • Loading branch information...
lifo committed Feb 18, 2011
1 parent e19e094 commit 7e4e4533e1794eb3ed46048d9a706cf4c5d895d7
Showing with 21 additions and 87 deletions.
  1. +3 −0 Gemfile
  2. +16 −0 Gemfile.lock
  3. +0 −71 examples/full.ru
  4. +0 −15 examples/hello_world.rb
  5. +2 −1 examples/hello_world.ru
View
@@ -11,6 +11,9 @@ group :test do
end
group :example do
+ gem 'activerecord', '3.0.4'
+ gem 'mysql2'
+
gem 'rainbows'
gem 'yajl-ruby', :require => 'yajl'
gem 'http_router'
View
@@ -9,13 +9,26 @@ PATH
GEM
remote: http://rubygems.org/
specs:
+ activemodel (3.0.4)
+ activesupport (= 3.0.4)
+ builder (~> 2.1.2)
+ i18n (~> 0.4)
+ activerecord (3.0.4)
+ activemodel (= 3.0.4)
+ activesupport (= 3.0.4)
+ arel (~> 2.0.2)
+ tzinfo (~> 0.3.23)
activesupport (3.0.4)
+ arel (2.0.8)
+ builder (2.1.2)
daemons (1.1.0)
eventmachine (0.12.10)
http_router (0.5.3)
rack (>= 1.0.0)
url_mount (~> 0.2.1)
+ i18n (0.5.0)
kgio (2.3.2)
+ mysql2 (0.2.6)
rack (1.2.1)
rainbows (3.1.0)
rack (~> 1.1)
@@ -24,6 +37,7 @@ GEM
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
+ tzinfo (0.3.24)
unicorn (3.4.0)
kgio (~> 2.2)
rack
@@ -35,10 +49,12 @@ PLATFORMS
ruby
DEPENDENCIES
+ activerecord (= 3.0.4)
activesupport (= 3.0.4)
cramp!
eventmachine (~> 0.12.10)
http_router
+ mysql2
rack (~> 1.2.1)
rainbows
thin (~> 1.2.7)
View
@@ -1,71 +0,0 @@
-require File.join(File.dirname(__FILE__), "../vendor/gems/environment")
-$: << File.join(File.dirname(__FILE__), "../lib")
-
-require 'cramp'
-require 'cramp/model'
-
-Cramp::Model.init(:username => 'root', :database => 'arel_development')
-
-class User < Cramp::Model::Base
- attribute :id, :type => Integer, :primary_key => true
- attribute :name
-
- validates_presence_of :name
-end
-
-class UsersController < Cramp::Action
- before_start :verify_id, :find_user
-
- def verify_id
- if params[:id].nil? || params[:id] !~ /\d+/
- halt 500, {}, "Bad Request"
- else
- yield
- end
- end
-
- def find_user
- User.where(User[:id].eq(params[:id])).first do |user|
- if @user = user
- yield
- else
- halt 404, {}, "User not found"
- end
- end
- end
-
- # Sends a space ( ' ' ) to the client for keeping the connection alive. Default : Every 15 seconds
- keep_connection_alive :every => 1
-
- # Polls every 1 second by default
- periodic_timer :poll_user
-
- on_start :start_benchmark
- on_finish :stop_benchmark
-
- def poll_user
- User.where(User[:id].eq(@user.id)).first _(:on_user_find)
- end
-
- def on_user_find(user)
- if @user.name != user.name
- render "User's name changed from #{@user.name} to #{user.name}"
- finish
- end
- end
-
- def start_benchmark
- @time = Time.now
- end
-
- def stop_benchmark
- puts "It took #{Time.now - @time} seconds"
- end
-end
-
-routes = Usher::Interface.for(:rack) do
- add('/users/:id').to(UsersController)
-end
-
-# rainbows -E deployment -c rainbows.conf full.ru
-run routes
View
@@ -1,15 +0,0 @@
-require "rubygems"
-require "bundler"
-Bundler.setup(:default, :example)
-
-require 'cramp'
-require 'thin'
-
-class WelcomeController < Cramp::Action
- def start
- render "Hello World"
- finish
- end
-end
-
-Rack::Handler::Thin.run WelcomeController, :Port => 3000
View
@@ -11,5 +11,6 @@ class WelcomeController < Cramp::Action
end
end
-# rainbows -E deployment -c rainbows.conf hello_world.ru
+# bundle exec thin -V -R examples/hello_world.ru start
+# bundle exec rainbows -E deployment -c examples/rainbows.conf examples/hello_world.ru
run WelcomeController

0 comments on commit 7e4e453

Please sign in to comment.