Permalink
Browse files

Merge pull request #1 from devnetsa/master

Make it work with Ruby 2.0.0
  • Loading branch information...
2 parents f7196ca + 7858599 commit 9f9ac96de91d49d285d1d5d5a995b90eb8f437db @darkofabijan darkofabijan committed Dec 23, 2013
Showing with 89 additions and 81 deletions.
  1. +6 −2 Gemfile
  2. +67 −65 Gemfile.lock
  3. +4 −13 coming_soon.rb
  4. +12 −1 views/backstage.erb
View
@@ -2,8 +2,7 @@ source 'http://rubygems.org'
gem 'sinatra'
gem 'rack'
-gem 'activerecord', '3.0.3'
-gem 'fastercsv'
+gem 'activerecord', '4.0.2'
group :test do
gem 'database_cleaner'
@@ -12,3 +11,8 @@ group :test do
gem 'cucumber-sinatra'
gem 'cucumber'
end
+
+group :development do
+ gem 'sqlite3'
+ gem 'shotgun'
+end
View
@@ -1,92 +1,94 @@
GEM
remote: http://rubygems.org/
specs:
- activemodel (3.0.3)
- activesupport (= 3.0.3)
- builder (~> 2.1.2)
- i18n (~> 0.4)
- activerecord (3.0.3)
- activemodel (= 3.0.3)
- activesupport (= 3.0.3)
- arel (~> 2.0.2)
- tzinfo (~> 0.3.23)
- activesupport (3.0.3)
- arel (2.0.7)
- builder (2.1.2)
- capybara (0.4.1.1)
- celerity (>= 0.7.9)
- culerity (>= 0.2.4)
+ activemodel (4.0.2)
+ activesupport (= 4.0.2)
+ builder (~> 3.1.0)
+ activerecord (4.0.2)
+ activemodel (= 4.0.2)
+ activerecord-deprecated_finders (~> 1.0.2)
+ activesupport (= 4.0.2)
+ arel (~> 4.0.0)
+ activerecord-deprecated_finders (1.0.3)
+ activesupport (4.0.2)
+ i18n (~> 0.6, >= 0.6.4)
+ minitest (~> 4.2)
+ multi_json (~> 1.3)
+ thread_safe (~> 0.1)
+ tzinfo (~> 0.3.37)
+ arel (4.0.1)
+ atomic (1.1.14)
+ builder (3.1.4)
+ capybara (2.2.0)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
- selenium-webdriver (>= 0.0.27)
- xpath (~> 0.1.3)
- celerity (0.8.7)
- childprocess (0.1.6)
- ffi (~> 0.6.3)
- cucumber (0.8.5)
- builder (~> 2.1.2)
- diff-lcs (~> 1.1.2)
- gherkin (~> 2.1.4)
- json_pure (~> 1.4.3)
- term-ansicolor (~> 1.0.4)
- cucumber-sinatra (0.3.0)
+ xpath (~> 2.0)
+ cucumber (1.3.10)
+ builder (>= 2.1.2)
+ diff-lcs (>= 1.1.3)
+ gherkin (~> 2.12)
+ multi_json (>= 1.7.5, < 2.0)
+ multi_test (>= 0.0.2)
+ cucumber-sinatra (0.5.0)
templater (>= 1.0.0)
- culerity (0.2.15)
- database_cleaner (0.5.2)
- diff-lcs (1.1.2)
- extlib (0.9.15)
- fastercsv (1.5.3)
- ffi (0.6.3)
- rake (>= 0.8.7)
- gherkin (2.1.5)
- trollop (~> 1.16.2)
- highline (1.5.0)
- i18n (0.5.0)
- json_pure (1.4.6)
- mime-types (1.16)
- nokogiri (1.4.4)
- rack (1.2.1)
- rack-test (0.5.7)
+ database_cleaner (1.2.0)
+ diff-lcs (1.2.5)
+ extlib (0.9.16)
+ gherkin (2.12.2)
+ multi_json (~> 1.3)
+ highline (1.6.20)
+ i18n (0.6.9)
+ mime-types (2.0)
+ mini_portile (0.5.2)
+ minitest (4.7.5)
+ multi_json (1.8.2)
+ multi_test (0.0.2)
+ nokogiri (1.6.0)
+ mini_portile (~> 0.5.0)
+ rack (1.5.2)
+ rack-protection (1.5.1)
+ rack
+ rack-test (0.6.2)
rack (>= 1.0)
- rake (0.8.7)
- rspec (2.4.0)
- rspec-core (~> 2.4.0)
- rspec-expectations (~> 2.4.0)
- rspec-mocks (~> 2.4.0)
- rspec-core (2.4.0)
- rspec-expectations (2.4.0)
- diff-lcs (~> 1.1.2)
- rspec-mocks (2.4.0)
- rubyzip (0.9.4)
- selenium-webdriver (0.1.2)
- childprocess (~> 0.1.5)
- ffi (~> 0.6.3)
- json_pure
- rubyzip
- sinatra (1.0)
+ rspec (2.14.1)
+ rspec-core (~> 2.14.0)
+ rspec-expectations (~> 2.14.0)
+ rspec-mocks (~> 2.14.0)
+ rspec-core (2.14.7)
+ rspec-expectations (2.14.4)
+ diff-lcs (>= 1.1.3, < 2.0)
+ rspec-mocks (2.14.4)
+ shotgun (0.9)
rack (>= 1.0)
+ sinatra (1.4.4)
+ rack (~> 1.4)
+ rack-protection (~> 1.4)
+ tilt (~> 1.3, >= 1.3.4)
+ sqlite3 (1.3.8)
templater (1.0.0)
diff-lcs (>= 1.1.2)
extlib (>= 0.9.5)
highline (>= 1.4.0)
- term-ansicolor (1.0.5)
- trollop (1.16.2)
- tzinfo (0.3.24)
- xpath (0.1.3)
+ thread_safe (0.1.3)
+ atomic
+ tilt (1.4.1)
+ tzinfo (0.3.38)
+ xpath (2.0.0)
nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
- activerecord (= 3.0.3)
+ activerecord (= 4.0.2)
capybara
cucumber
cucumber-sinatra
database_cleaner
- fastercsv
rack
rspec
+ shotgun
sinatra
+ sqlite3
View
@@ -1,17 +1,7 @@
require 'sinatra/base'
require 'active_record'
-require 'fastercsv'
require 'csv'
-if CSV.const_defined? :Reader
- # Ruby 1.8
- require 'fastercsv'
- CSVKLASS = FasterCSV
-else
- # Ruby 1.9, FasterCSV merged in stdlib
- CSVKLASS = CSV
-end
-
def load_configuration(file, name)
if !File.exist?(file)
@@ -39,7 +29,7 @@ class ComingSoon < Sinatra::Base
class User < ActiveRecord::Base
validates_presence_of :email
validates_uniqueness_of :email
- validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
+ validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
end
before do
@@ -54,7 +44,7 @@ class User < ActiveRecord::Base
post '/create' do
redirect "/?m=email_blank" if params[:email].blank?
- if User.count(:conditions => { :email => params[:email] }) > 0
+ if User.where(:email => params[:email]).count > 0
redirect "/?m=email_taken"
end
@@ -70,12 +60,13 @@ class User < ActiveRecord::Base
get '/backstage' do
protected!
@user_count = User.count
+ @users = User.all
erb :backstage
end
get '/backstage/csv' do
protected!
- csv_content = FasterCSV.generate do |csv|
+ csv_content = CSV.generate do |csv|
User.find_each do |user|
csv << [user.email]
end
View
@@ -1,5 +1,16 @@
<h1><%= @app_name %> backstage</h1>
<h2><%= pluralize(@user_count, "person", "people") %> signed up.</h2>
-
+<table cellspacing="3">
+ <tr>
+ <th>#</th>
+ <th>email</th>
+ </tr>
+ <% @users.each do |user| %>
+ <tr>
+ <td><%= user.id %></td>
+ <td><%= user.email %></td>
+ </tr>
+ <% end %>
+</table>
<a href="/backstage/csv">Download emails in a CSV file</a>

0 comments on commit 9f9ac96

Please sign in to comment.