carlosbrando-remarkable 0.0.99

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. data/History.txt +6 -0
  2. data/Manifest.txt +124 -0
  3. data/PostInstall.txt +7 -0
  4. data/README.rdoc +48 -0
  5. data/Rakefile +29 -0
  6. data/init.rb +1 -0
  7. data/lib/remarkable.rb +13 -0
  8. data/lib/remarkable/active_record/active_record.rb +21 -0
  9. data/lib/remarkable/active_record/helpers.rb +16 -0
  10. data/lib/remarkable/active_record/macros/associations/belong_to.rb +81 -0
  11. data/lib/remarkable/active_record/macros/associations/have_and_belong_to_many.rb +77 -0
  12. data/lib/remarkable/active_record/macros/associations/have_many.rb +160 -0
  13. data/lib/remarkable/active_record/macros/associations/have_one.rb +133 -0
  14. data/lib/remarkable/active_record/macros/database/have_db_column.rb +81 -0
  15. data/lib/remarkable/active_record/macros/database/have_db_columns.rb +73 -0
  16. data/lib/remarkable/active_record/macros/database/have_indices.rb +75 -0
  17. data/lib/remarkable/active_record/macros/validations/allow_values_for.rb +103 -0
  18. data/lib/remarkable/active_record/macros/validations/ensure_length_at_least.rb +97 -0
  19. data/lib/remarkable/active_record/macros/validations/ensure_length_in_range.rb +134 -0
  20. data/lib/remarkable/active_record/macros/validations/ensure_length_is.rb +106 -0
  21. data/lib/remarkable/active_record/macros/validations/ensure_value_in_range.rb +117 -0
  22. data/lib/remarkable/active_record/macros/validations/have_class_methods.rb +74 -0
  23. data/lib/remarkable/active_record/macros/validations/have_instance_methods.rb +74 -0
  24. data/lib/remarkable/active_record/macros/validations/have_named_scope.rb +148 -0
  25. data/lib/remarkable/active_record/macros/validations/have_readonly_attributes.rb +81 -0
  26. data/lib/remarkable/active_record/macros/validations/only_allow_numeric_values_for.rb +89 -0
  27. data/lib/remarkable/active_record/macros/validations/protect_attributes.rb +89 -0
  28. data/lib/remarkable/active_record/macros/validations/require_acceptance_of.rb +94 -0
  29. data/lib/remarkable/active_record/macros/validations/require_attributes.rb +94 -0
  30. data/lib/remarkable/active_record/macros/validations/require_unique_attributes.rb +146 -0
  31. data/lib/remarkable/controller/controller.rb +15 -0
  32. data/lib/remarkable/controller/helpers.rb +48 -0
  33. data/lib/remarkable/controller/macros/assign_to.rb +110 -0
  34. data/lib/remarkable/controller/macros/filter_params.rb +52 -0
  35. data/lib/remarkable/controller/macros/redirect_to.rb +24 -0
  36. data/lib/remarkable/controller/macros/render_a_form.rb +23 -0
  37. data/lib/remarkable/controller/macros/render_template.rb +18 -0
  38. data/lib/remarkable/controller/macros/render_with_layout.rb +61 -0
  39. data/lib/remarkable/controller/macros/respond_with.rb +86 -0
  40. data/lib/remarkable/controller/macros/respond_with_content_type.rb +45 -0
  41. data/lib/remarkable/controller/macros/return_from_session.rb +45 -0
  42. data/lib/remarkable/controller/macros/route.rb +91 -0
  43. data/lib/remarkable/controller/macros/set_the_flash_to.rb +58 -0
  44. data/lib/remarkable/example/example_methods.rb +32 -0
  45. data/lib/remarkable/private_helpers.rb +123 -0
  46. data/rails/init.rb +1 -0
  47. data/script/console +10 -0
  48. data/script/destroy +14 -0
  49. data/script/generate +14 -0
  50. data/spec/controllers/posts_controller_spec.rb +166 -0
  51. data/spec/controllers/users_controller_spec.rb +14 -0
  52. data/spec/fixtures/addresses.yml +3 -0
  53. data/spec/fixtures/friendships.yml +0 -0
  54. data/spec/fixtures/posts.yml +5 -0
  55. data/spec/fixtures/products.yml +0 -0
  56. data/spec/fixtures/taggings.yml +0 -0
  57. data/spec/fixtures/tags.yml +9 -0
  58. data/spec/fixtures/users.yml +6 -0
  59. data/spec/models/address_spec.rb +21 -0
  60. data/spec/models/dog_spec.rb +17 -0
  61. data/spec/models/flea_spec.rb +9 -0
  62. data/spec/models/friendship_spec.rb +13 -0
  63. data/spec/models/post_spec.rb +35 -0
  64. data/spec/models/product_spec.rb +57 -0
  65. data/spec/models/tag_spec.rb +21 -0
  66. data/spec/models/tagging_spec.rb +13 -0
  67. data/spec/models/user_spec.rb +107 -0
  68. data/spec/rails_root/app/controllers/application.rb +25 -0
  69. data/spec/rails_root/app/controllers/posts_controller.rb +85 -0
  70. data/spec/rails_root/app/controllers/users_controller.rb +84 -0
  71. data/spec/rails_root/app/helpers/application_helper.rb +3 -0
  72. data/spec/rails_root/app/helpers/posts_helper.rb +2 -0
  73. data/spec/rails_root/app/helpers/users_helper.rb +2 -0
  74. data/spec/rails_root/app/models/address.rb +7 -0
  75. data/spec/rails_root/app/models/dog.rb +5 -0
  76. data/spec/rails_root/app/models/flea.rb +3 -0
  77. data/spec/rails_root/app/models/friendship.rb +4 -0
  78. data/spec/rails_root/app/models/post.rb +12 -0
  79. data/spec/rails_root/app/models/product.rb +12 -0
  80. data/spec/rails_root/app/models/tag.rb +8 -0
  81. data/spec/rails_root/app/models/tagging.rb +4 -0
  82. data/spec/rails_root/app/models/user.rb +28 -0
  83. data/spec/rails_root/app/views/layouts/posts.rhtml +17 -0
  84. data/spec/rails_root/app/views/layouts/users.rhtml +17 -0
  85. data/spec/rails_root/app/views/layouts/wide.html.erb +1 -0
  86. data/spec/rails_root/app/views/posts/edit.rhtml +27 -0
  87. data/spec/rails_root/app/views/posts/index.rhtml +25 -0
  88. data/spec/rails_root/app/views/posts/new.rhtml +26 -0
  89. data/spec/rails_root/app/views/posts/show.rhtml +18 -0
  90. data/spec/rails_root/app/views/users/edit.rhtml +22 -0
  91. data/spec/rails_root/app/views/users/index.rhtml +22 -0
  92. data/spec/rails_root/app/views/users/new.rhtml +21 -0
  93. data/spec/rails_root/app/views/users/show.rhtml +13 -0
  94. data/spec/rails_root/config/boot.rb +109 -0
  95. data/spec/rails_root/config/database.yml +4 -0
  96. data/spec/rails_root/config/environment.rb +14 -0
  97. data/spec/rails_root/config/environments/sqlite3.rb +0 -0
  98. data/spec/rails_root/config/initializers/new_rails_defaults.rb +15 -0
  99. data/spec/rails_root/config/initializers/shoulda.rb +8 -0
  100. data/spec/rails_root/config/routes.rb +6 -0
  101. data/spec/rails_root/db/migrate/001_create_users.rb +18 -0
  102. data/spec/rails_root/db/migrate/002_create_posts.rb +13 -0
  103. data/spec/rails_root/db/migrate/003_create_taggings.rb +12 -0
  104. data/spec/rails_root/db/migrate/004_create_tags.rb +11 -0
  105. data/spec/rails_root/db/migrate/005_create_dogs.rb +12 -0
  106. data/spec/rails_root/db/migrate/006_create_addresses.rb +14 -0
  107. data/spec/rails_root/db/migrate/007_create_fleas.rb +11 -0
  108. data/spec/rails_root/db/migrate/008_create_dogs_fleas.rb +12 -0
  109. data/spec/rails_root/db/migrate/009_create_products.rb +17 -0
  110. data/spec/rails_root/db/migrate/010_create_friendships.rb +14 -0
  111. data/spec/rails_root/db/schema.rb +0 -0
  112. data/spec/rails_root/log/.keep +0 -0
  113. data/spec/rails_root/public/.htaccess +40 -0
  114. data/spec/rails_root/public/404.html +30 -0
  115. data/spec/rails_root/public/422.html +30 -0
  116. data/spec/rails_root/public/500.html +30 -0
  117. data/spec/rails_root/script/console +3 -0
  118. data/spec/rails_root/script/generate +3 -0
  119. data/spec/rails_root/vendor/plugins/.keep +0 -0
  120. data/spec/rcov.opts +2 -0
  121. data/spec/spec.opts +4 -0
  122. data/spec/spec_helper.rb +58 -0
  123. data/tasks/rspec.rake +21 -0
  124. metadata +216 -0
@@ -0,0 +1,84 @@
1
+ class UsersController < ApplicationController
2
+
3
+ filter_parameter_logging :ssn
4
+
5
+ # GET /users
6
+ # GET /users.xml
7
+ def index
8
+ @users = User.find(:all)
9
+
10
+ respond_to do |format|
11
+ format.html # index.rhtml
12
+ format.xml { render :xml => @users.to_xml }
13
+ end
14
+ end
15
+
16
+ # GET /users/1
17
+ # GET /users/1.xml
18
+ def show
19
+ @user = User.find(params[:id])
20
+
21
+ respond_to do |format|
22
+ format.html # show.rhtml
23
+ format.xml { render :xml => @user.to_xml }
24
+ end
25
+ end
26
+
27
+ # GET /users/new
28
+ def new
29
+ @user = User.new
30
+ end
31
+
32
+ # GET /users/1;edit
33
+ def edit
34
+ @user = User.find(params[:id])
35
+ end
36
+
37
+ # POST /users
38
+ # POST /users.xml
39
+ def create
40
+ @user = User.new(params[:user])
41
+
42
+ respond_to do |format|
43
+ if @user.save
44
+ flash[:notice] = 'User was successfully created.'
45
+ format.html { redirect_to user_url(@user) }
46
+ format.xml { head :created, :location => user_url(@user) }
47
+ else
48
+ format.html { render :action => "new" }
49
+ format.xml { render :xml => @user.errors.to_xml }
50
+ end
51
+ end
52
+ end
53
+
54
+ # PUT /users/1
55
+ # PUT /users/1.xml
56
+ def update
57
+ @user = User.find(params[:id])
58
+
59
+ respond_to do |format|
60
+ if @user.update_attributes(params[:user])
61
+ flash[:notice] = 'User was successfully updated.'
62
+ format.html { redirect_to user_url(@user) }
63
+ format.xml { head :ok }
64
+ else
65
+ format.html { render :action => "edit" }
66
+ format.xml { render :xml => @user.errors.to_xml }
67
+ end
68
+ end
69
+ end
70
+
71
+ # DELETE /users/1
72
+ # DELETE /users/1.xml
73
+ def destroy
74
+ @user = User.find(params[:id])
75
+ @user.destroy
76
+
77
+ flash[:notice] = "User was removed"
78
+
79
+ respond_to do |format|
80
+ format.html { redirect_to users_url }
81
+ format.xml { head :ok }
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,3 @@
1
+ # Methods added to this helper will be available to all templates in the application.
2
+ module ApplicationHelper
3
+ end
@@ -0,0 +1,2 @@
1
+ module PostsHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module UsersHelper
2
+ end
@@ -0,0 +1,7 @@
1
+ class Address < ActiveRecord::Base
2
+ belongs_to :addressable, :polymorphic => true
3
+ validates_uniqueness_of :title, :scope => [:addressable_type, :addressable_id]
4
+
5
+ validates_length_of :zip, :minimum => 5
6
+ validates_numericality_of :zip
7
+ end
@@ -0,0 +1,5 @@
1
+ class Dog < ActiveRecord::Base
2
+ belongs_to :user, :foreign_key => :owner_id
3
+ belongs_to :address
4
+ has_and_belongs_to_many :fleas, :join_table => :fleas
5
+ end
@@ -0,0 +1,3 @@
1
+ class Flea < ActiveRecord::Base
2
+ has_and_belongs_to_many :dogs
3
+ end
@@ -0,0 +1,4 @@
1
+ class Friendship < ActiveRecord::Base
2
+ belongs_to :user
3
+ belongs_to :friend, :class_name => "User"
4
+ end
@@ -0,0 +1,12 @@
1
+ class Post < ActiveRecord::Base
2
+ belongs_to :user
3
+ belongs_to :owner, :foreign_key => :user_id, :class_name => 'User'
4
+ has_many :taggings
5
+ has_many :tags, :through => :taggings
6
+ has_many :through_tags, :through => :taggings, :source => :tag
7
+
8
+ validates_uniqueness_of :title
9
+ validates_presence_of :title
10
+ validates_presence_of :body, :message => 'Seriously... wtf'
11
+ validates_numericality_of :user_id
12
+ end
@@ -0,0 +1,12 @@
1
+ class Product < ActiveRecord::Base
2
+ validates_presence_of :title
3
+
4
+ validates_inclusion_of :price, :in => 0..99, :unless => :tangible
5
+ validates_format_of :size, :with => /^\d+\D+$/, :unless => :tangible
6
+
7
+ validates_presence_of :price, :if => :tangible
8
+ validates_inclusion_of :price, :in => 1..9999, :if => :tangible
9
+ validates_inclusion_of :weight, :in => 1..100, :if => :tangible
10
+ validates_format_of :size, :with => /.+x.+x.+/, :if => :tangible
11
+ validates_length_of :size, :in => 5..20, :if => :tangible
12
+ end
@@ -0,0 +1,8 @@
1
+ class Tag < ActiveRecord::Base
2
+ has_many :taggings, :dependent => :destroy
3
+ has_many :posts, :through => :taggings
4
+
5
+ validates_length_of :name, :minimum => 2
6
+
7
+ attr_accessible :name
8
+ end
@@ -0,0 +1,4 @@
1
+ class Tagging < ActiveRecord::Base
2
+ belongs_to :post
3
+ belongs_to :tag
4
+ end
@@ -0,0 +1,28 @@
1
+ class User < ActiveRecord::Base
2
+ has_many :posts
3
+ has_many :dogs, :foreign_key => :owner_id
4
+
5
+ has_many :friendships
6
+ has_many :friends, :through => :friendships
7
+
8
+ has_one :address, :as => :addressable, :dependent => :destroy
9
+
10
+ named_scope :old, :conditions => "age > 50"
11
+ named_scope :eighteen, :conditions => { :age => 18 }
12
+ named_scope :recent, lambda {|count| { :limit => count } }
13
+
14
+ def self.recent_via_method(count)
15
+ scoped(:limit => count)
16
+ end
17
+
18
+ attr_protected :password
19
+ attr_readonly :name
20
+
21
+ validates_format_of :email, :with => /\w*@\w*.com/
22
+ validates_length_of :email, :in => 1..100
23
+ validates_inclusion_of :age, :in => 1..100
24
+ validates_acceptance_of :eula
25
+ validates_uniqueness_of :email, :scope => :name
26
+ validates_length_of :ssn, :is => 9, :message => "Social Security Number is not the right length"
27
+ validates_numericality_of :ssn
28
+ end
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7
+ <title>Posts: <%= controller.action_name %></title>
8
+ <%= stylesheet_link_tag 'scaffold' %>
9
+ </head>
10
+ <body>
11
+
12
+ <p style="color: green"><%= flash[:notice] %></p>
13
+
14
+ <%= yield %>
15
+
16
+ </body>
17
+ </html>
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7
+ <title>Users: <%= controller.action_name %></title>
8
+ <%= stylesheet_link_tag 'scaffold' %>
9
+ </head>
10
+ <body>
11
+
12
+ <p style="color: green"><%= flash[:notice] %></p>
13
+
14
+ <%= yield %>
15
+
16
+ </body>
17
+ </html>
@@ -0,0 +1 @@
1
+ <html><%= yield %></html>
@@ -0,0 +1,27 @@
1
+ <h1>Editing post</h1>
2
+
3
+ <%= error_messages_for :post %>
4
+
5
+ <% form_for(:post, :url => user_post_path(@post.user, @post), :html => { :method => :put }) do |f| %>
6
+ <p>
7
+ <b>User</b><br />
8
+ <%= f.text_field :user_id %>
9
+ </p>
10
+
11
+ <p>
12
+ <b>Title</b><br />
13
+ <%= f.text_field :title %>
14
+ </p>
15
+
16
+ <p>
17
+ <b>Body</b><br />
18
+ <%= f.text_area :body %>
19
+ </p>
20
+
21
+ <p>
22
+ <%= submit_tag "Update" %>
23
+ </p>
24
+ <% end %>
25
+
26
+ <%= link_to 'Show', user_post_path(@post.user, @post) %> |
27
+ <%= link_to 'Back', user_posts_path(@post.user) %>
@@ -0,0 +1,25 @@
1
+ <h1>Listing posts</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>User</th>
6
+ <th>Title</th>
7
+ <th>Body</th>
8
+ </tr>
9
+
10
+ <% for post in @posts %>
11
+ <tr>
12
+ <td><%=h post.user_id %></td>
13
+ <td><%=h post.title %></td>
14
+ <td><%=h post.body %></td>
15
+ <td><%= link_to 'Show', user_post_path(post.user, post) %></td>
16
+ <td><%= link_to 'Edit', edit_user_post_path(post.user, post) %></td>
17
+ <td><%= link_to 'Destroy', user_post_path(post.user, post), :confirm => 'Are you sure?',
18
+ :method => :delete %></td>
19
+ </tr>
20
+ <% end %>
21
+ </table>
22
+
23
+ <br />
24
+
25
+ <%= link_to 'New post', new_user_post_path(post.user) %>
@@ -0,0 +1,26 @@
1
+ <h1>New post</h1>
2
+
3
+ <%= error_messages_for :post %>
4
+
5
+ <% form_for(:post, :url => user_posts_path(@user)) do |f| %>
6
+ <p>
7
+ <b>User</b><br />
8
+ <%= f.text_field :user_id %>
9
+ </p>
10
+
11
+ <p>
12
+ <b>Title</b><br />
13
+ <%= f.text_field :title %>
14
+ </p>
15
+
16
+ <p>
17
+ <b>Body</b><br />
18
+ <%= f.text_area :body %>
19
+ </p>
20
+
21
+ <p>
22
+ <%= submit_tag "Create" %>
23
+ </p>
24
+ <% end %>
25
+
26
+ <%= link_to 'Back', user_posts_path(@user) %>
@@ -0,0 +1,18 @@
1
+ <p>
2
+ <b>User:</b>
3
+ <%=h @post.user_id %>
4
+ </p>
5
+
6
+ <p>
7
+ <b>Title:</b>
8
+ <%=h @post.title %>
9
+ </p>
10
+
11
+ <p>
12
+ <b>Body:</b>
13
+ <%=h @post.body %>
14
+ </p>
15
+
16
+
17
+ <%= link_to 'Edit', edit_user_post_path(@post.user, @post) %> |
18
+ <%= link_to 'Back', user_posts_path(@post.user) %>
@@ -0,0 +1,22 @@
1
+ <h1>Editing user</h1>
2
+
3
+ <%= error_messages_for :user %>
4
+
5
+ <% form_for(:user, :url => user_path(@user), :html => { :method => :put }) do |f| %>
6
+ <p>
7
+ <b>Email</b><br />
8
+ <%= f.text_field :email %>
9
+ </p>
10
+
11
+ <p>
12
+ <b>Age</b><br />
13
+ <%= f.text_field :age %>
14
+ </p>
15
+
16
+ <p>
17
+ <%= submit_tag "Update" %>
18
+ </p>
19
+ <% end %>
20
+
21
+ <%= link_to 'Show', user_path(@user) %> |
22
+ <%= link_to 'Back', users_path %>
@@ -0,0 +1,22 @@
1
+ <h1>Listing users</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Email</th>
6
+ <th>Age</th>
7
+ </tr>
8
+
9
+ <% for user in @users %>
10
+ <tr>
11
+ <td><%=h user.email %></td>
12
+ <td><%=h user.age %></td>
13
+ <td><%= link_to 'Show', user_path(user) %></td>
14
+ <td><%= link_to 'Edit', edit_user_path(user) %></td>
15
+ <td><%= link_to 'Destroy', user_path(user), :confirm => 'Are you sure?', :method => :delete %></td>
16
+ </tr>
17
+ <% end %>
18
+ </table>
19
+
20
+ <br />
21
+
22
+ <%= link_to 'New user', new_user_path %>
@@ -0,0 +1,21 @@
1
+ <h1>New user</h1>
2
+
3
+ <%= error_messages_for :user %>
4
+
5
+ <% form_for(:user, :url => users_path) do |f| %>
6
+ <p>
7
+ <b>Email</b><br />
8
+ <%= f.text_field :email %>
9
+ </p>
10
+
11
+ <p>
12
+ <b>Age</b><br />
13
+ <%= f.text_field :age %>
14
+ </p>
15
+
16
+ <p>
17
+ <%= submit_tag "Create" %>
18
+ </p>
19
+ <% end %>
20
+
21
+ <%= link_to 'Back', users_path %>
@@ -0,0 +1,13 @@
1
+ <p>
2
+ <b>Email:</b>
3
+ <%=h @user.email %>
4
+ </p>
5
+
6
+ <p>
7
+ <b>Age:</b>
8
+ <%=h @user.age %>
9
+ </p>
10
+
11
+
12
+ <%= link_to 'Edit', edit_user_path(@user) %> |
13
+ <%= link_to 'Back', users_path %>
@@ -0,0 +1,109 @@
1
+ # Don't change this file!
2
+ # Configure your app in config/environment.rb and config/environments/*.rb
3
+
4
+ RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5
+
6
+ module Rails
7
+ class << self
8
+ def boot!
9
+ unless booted?
10
+ preinitialize
11
+ pick_boot.run
12
+ end
13
+ end
14
+
15
+ def booted?
16
+ defined? Rails::Initializer
17
+ end
18
+
19
+ def pick_boot
20
+ (vendor_rails? ? VendorBoot : GemBoot).new
21
+ end
22
+
23
+ def vendor_rails?
24
+ File.exist?("#{RAILS_ROOT}/vendor/rails")
25
+ end
26
+
27
+ def preinitialize
28
+ load(preinitializer_path) if File.exist?(preinitializer_path)
29
+ end
30
+
31
+ def preinitializer_path
32
+ "#{RAILS_ROOT}/config/preinitializer.rb"
33
+ end
34
+ end
35
+
36
+ class Boot
37
+ def run
38
+ load_initializer
39
+ Rails::Initializer.run(:set_load_path)
40
+ end
41
+ end
42
+
43
+ class VendorBoot < Boot
44
+ def load_initializer
45
+ require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46
+ Rails::Initializer.run(:install_gem_spec_stubs)
47
+ end
48
+ end
49
+
50
+ class GemBoot < Boot
51
+ def load_initializer
52
+ self.class.load_rubygems
53
+ load_rails_gem
54
+ require 'initializer'
55
+ end
56
+
57
+ def load_rails_gem
58
+ if version = self.class.gem_version
59
+ gem 'rails', version
60
+ else
61
+ gem 'rails'
62
+ end
63
+ rescue Gem::LoadError => load_error
64
+ $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
65
+ exit 1
66
+ end
67
+
68
+ class << self
69
+ def rubygems_version
70
+ Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
71
+ end
72
+
73
+ def gem_version
74
+ if defined? RAILS_GEM_VERSION
75
+ RAILS_GEM_VERSION
76
+ elsif ENV.include?('RAILS_GEM_VERSION')
77
+ ENV['RAILS_GEM_VERSION']
78
+ else
79
+ parse_gem_version(read_environment_rb)
80
+ end
81
+ end
82
+
83
+ def load_rubygems
84
+ require 'rubygems'
85
+
86
+ unless rubygems_version >= '0.9.4'
87
+ $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.)
88
+ exit 1
89
+ end
90
+
91
+ rescue LoadError
92
+ $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org)
93
+ exit 1
94
+ end
95
+
96
+ def parse_gem_version(text)
97
+ $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
98
+ end
99
+
100
+ private
101
+ def read_environment_rb
102
+ File.read("#{RAILS_ROOT}/config/environment.rb")
103
+ end
104
+ end
105
+ end
106
+ end
107
+
108
+ # All that for this:
109
+ Rails.boot!