rails 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rails might be problematic. Click here for more details.

Files changed (177) hide show
  1. data/CHANGELOG +1020 -10
  2. data/MIT-LICENSE +1 -1
  3. data/README +110 -60
  4. data/Rakefile +74 -139
  5. data/bin/about +1 -1
  6. data/bin/console +1 -1
  7. data/bin/destroy +1 -1
  8. data/bin/generate +1 -1
  9. data/bin/performance/request +3 -0
  10. data/bin/plugin +1 -1
  11. data/bin/process/{spinner → inspector} +1 -1
  12. data/bin/rails +10 -12
  13. data/bin/runner +1 -1
  14. data/bin/server +1 -1
  15. data/{lib/rails_info.rb → builtin/rails_info/rails/info.rb} +33 -14
  16. data/builtin/rails_info/rails/info_controller.rb +9 -0
  17. data/builtin/rails_info/rails/info_helper.rb +2 -0
  18. data/builtin/rails_info/rails_info_controller.rb +2 -0
  19. data/configs/apache.conf +1 -1
  20. data/configs/databases/frontbase.yml +28 -0
  21. data/configs/databases/mysql.yml +54 -0
  22. data/configs/databases/oracle.yml +39 -0
  23. data/configs/databases/postgresql.yml +48 -0
  24. data/configs/databases/sqlite2.yml +16 -0
  25. data/configs/databases/sqlite3.yml +19 -0
  26. data/configs/initializers/inflections.rb +10 -0
  27. data/configs/initializers/mime_types.rb +5 -0
  28. data/configs/lighttpd.conf +29 -15
  29. data/configs/routes.rb +27 -11
  30. data/doc/README_FOR_APP +1 -1
  31. data/environments/boot.rb +103 -14
  32. data/environments/development.rb +5 -6
  33. data/environments/environment.rb +36 -30
  34. data/environments/production.rb +2 -3
  35. data/environments/test.rb +5 -2
  36. data/fresh_rakefile +2 -2
  37. data/helpers/application.rb +8 -2
  38. data/helpers/test_helper.rb +10 -0
  39. data/html/404.html +27 -5
  40. data/html/422.html +30 -0
  41. data/html/500.html +27 -5
  42. data/html/index.html +6 -6
  43. data/html/javascripts/application.js +2 -0
  44. data/html/javascripts/controls.js +532 -319
  45. data/html/javascripts/dragdrop.js +521 -133
  46. data/html/javascripts/effects.js +708 -442
  47. data/html/javascripts/prototype.js +3393 -953
  48. data/html/robots.txt +5 -1
  49. data/lib/code_statistics.rb +2 -2
  50. data/lib/commands/console.rb +18 -9
  51. data/lib/commands/performance/profiler.rb +25 -9
  52. data/lib/commands/performance/request.rb +6 -0
  53. data/lib/commands/plugin.rb +196 -96
  54. data/lib/commands/process/inspector.rb +68 -0
  55. data/lib/commands/process/reaper.rb +90 -71
  56. data/lib/commands/process/spawner.rb +188 -21
  57. data/lib/commands/process/spinner.rb +3 -3
  58. data/lib/commands/runner.rb +28 -7
  59. data/lib/commands/server.rb +20 -9
  60. data/lib/commands/servers/base.rb +31 -0
  61. data/lib/commands/servers/lighttpd.rb +60 -26
  62. data/lib/commands/servers/mongrel.rb +69 -0
  63. data/lib/commands/servers/webrick.rb +18 -11
  64. data/lib/console_app.rb +30 -0
  65. data/lib/console_sandbox.rb +2 -2
  66. data/lib/console_with_helpers.rb +26 -0
  67. data/lib/dispatcher.rb +3 -78
  68. data/lib/fcgi_handler.rb +98 -64
  69. data/lib/initializer.rb +323 -194
  70. data/lib/rails/plugin/loader.rb +150 -0
  71. data/lib/rails/plugin/locator.rb +78 -0
  72. data/lib/rails/plugin.rb +84 -0
  73. data/lib/{rails_version.rb → rails/version.rb} +1 -1
  74. data/lib/rails_generator/base.rb +85 -25
  75. data/lib/rails_generator/commands.rb +122 -40
  76. data/lib/rails_generator/generated_attribute.rb +42 -0
  77. data/lib/rails_generator/generators/applications/app/USAGE +0 -7
  78. data/lib/rails_generator/generators/applications/app/app_generator.rb +67 -28
  79. data/lib/rails_generator/generators/components/controller/USAGE +11 -12
  80. data/lib/rails_generator/generators/components/controller/controller_generator.rb +2 -3
  81. data/lib/rails_generator/generators/components/controller/templates/functional_test.rb +1 -11
  82. data/lib/rails_generator/generators/components/controller/templates/{view.rhtml → view.html.erb} +0 -0
  83. data/lib/rails_generator/generators/components/integration_test/USAGE +8 -0
  84. data/lib/rails_generator/generators/components/integration_test/integration_test_generator.rb +16 -0
  85. data/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb +10 -0
  86. data/lib/rails_generator/generators/components/mailer/USAGE +9 -11
  87. data/lib/rails_generator/generators/components/mailer/mailer_generator.rb +10 -8
  88. data/lib/rails_generator/generators/components/mailer/templates/fixture.erb +3 -0
  89. data/lib/rails_generator/generators/components/mailer/templates/fixture.rhtml +0 -3
  90. data/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +9 -25
  91. data/lib/rails_generator/generators/components/mailer/templates/view.erb +3 -0
  92. data/lib/rails_generator/generators/components/mailer/templates/view.rhtml +0 -3
  93. data/lib/rails_generator/generators/components/migration/USAGE +23 -8
  94. data/lib/rails_generator/generators/components/migration/migration_generator.rb +15 -2
  95. data/lib/rails_generator/generators/components/migration/templates/migration.rb +7 -3
  96. data/lib/rails_generator/generators/components/model/USAGE +21 -11
  97. data/lib/rails_generator/generators/components/model/model_generator.rb +28 -1
  98. data/lib/rails_generator/generators/components/model/templates/fixtures.yml +18 -4
  99. data/lib/rails_generator/generators/components/model/templates/migration.rb +16 -0
  100. data/lib/rails_generator/generators/components/model/templates/unit_test.rb +2 -4
  101. data/lib/rails_generator/generators/components/observer/USAGE +13 -0
  102. data/lib/rails_generator/generators/components/observer/observer_generator.rb +16 -0
  103. data/lib/rails_generator/generators/components/observer/templates/observer.rb +2 -0
  104. data/lib/rails_generator/generators/components/observer/templates/unit_test.rb +8 -0
  105. data/lib/rails_generator/generators/components/plugin/USAGE +10 -18
  106. data/lib/rails_generator/generators/components/plugin/plugin_generator.rb +6 -0
  107. data/lib/rails_generator/generators/components/plugin/templates/MIT-LICENSE +20 -0
  108. data/lib/rails_generator/generators/components/plugin/templates/README +10 -1
  109. data/lib/rails_generator/generators/components/plugin/templates/Rakefile +1 -1
  110. data/lib/rails_generator/generators/components/plugin/templates/USAGE +1 -1
  111. data/lib/rails_generator/generators/components/plugin/templates/init.rb +1 -1
  112. data/lib/rails_generator/generators/components/plugin/templates/install.rb +1 -0
  113. data/lib/rails_generator/generators/components/plugin/templates/plugin.rb +1 -1
  114. data/lib/rails_generator/generators/components/plugin/templates/tasks.rake +1 -1
  115. data/lib/rails_generator/generators/components/plugin/templates/uninstall.rb +1 -0
  116. data/lib/rails_generator/generators/components/resource/USAGE +23 -0
  117. data/lib/rails_generator/generators/components/resource/resource_generator.rb +74 -0
  118. data/lib/rails_generator/generators/components/resource/templates/controller.rb +2 -0
  119. data/lib/rails_generator/generators/components/resource/templates/functional_test.rb +8 -0
  120. data/lib/rails_generator/generators/components/resource/templates/helper.rb +2 -0
  121. data/lib/rails_generator/generators/components/scaffold/USAGE +24 -31
  122. data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +45 -137
  123. data/lib/rails_generator/generators/components/scaffold/templates/controller.rb +65 -34
  124. data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +23 -76
  125. data/lib/rails_generator/generators/components/scaffold/templates/layout.html.erb +17 -0
  126. data/lib/rails_generator/generators/components/scaffold/templates/style.css +5 -5
  127. data/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb +19 -0
  128. data/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb +24 -0
  129. data/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb +18 -0
  130. data/lib/rails_generator/generators/components/scaffold/templates/view_show.html.erb +10 -0
  131. data/lib/rails_generator/generators/components/session_migration/USAGE +6 -11
  132. data/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb +7 -1
  133. data/lib/rails_generator/generators/components/session_migration/templates/migration.rb +8 -7
  134. data/lib/rails_generator/lookup.rb +46 -12
  135. data/lib/rails_generator/options.rb +11 -8
  136. data/lib/rails_generator/scripts/destroy.rb +23 -0
  137. data/lib/rails_generator/scripts.rb +7 -4
  138. data/lib/rails_generator/secret_key_generator.rb +160 -0
  139. data/lib/rails_generator/spec.rb +1 -1
  140. data/lib/rails_generator.rb +1 -1
  141. data/lib/railties_path.rb +1 -1
  142. data/lib/ruby_version_check.rb +17 -0
  143. data/lib/source_annotation_extractor.rb +62 -0
  144. data/lib/tasks/annotations.rake +23 -0
  145. data/lib/tasks/databases.rake +328 -133
  146. data/lib/tasks/documentation.rake +72 -68
  147. data/lib/tasks/framework.rake +99 -58
  148. data/lib/tasks/log.rake +9 -0
  149. data/lib/tasks/misc.rake +2 -17
  150. data/lib/tasks/rails.rb +2 -2
  151. data/lib/tasks/routes.rake +17 -0
  152. data/lib/tasks/statistics.rake +10 -8
  153. data/lib/tasks/testing.rake +99 -31
  154. data/lib/tasks/tmp.rake +37 -0
  155. data/lib/test_help.rb +8 -5
  156. data/lib/webrick_server.rb +11 -16
  157. metadata +312 -272
  158. data/bin/breakpointer +0 -3
  159. data/builtin/controllers/rails_info_controller.rb +0 -11
  160. data/configs/database.yml +0 -85
  161. data/lib/binding_of_caller.rb +0 -85
  162. data/lib/breakpoint.rb +0 -523
  163. data/lib/breakpoint_client.rb +0 -196
  164. data/lib/commands/breakpointer.rb +0 -1
  165. data/lib/rails_generator/generators/components/scaffold/templates/form.rhtml +0 -3
  166. data/lib/rails_generator/generators/components/scaffold/templates/form_scaffolding.rhtml +0 -1
  167. data/lib/rails_generator/generators/components/scaffold/templates/layout.rhtml +0 -13
  168. data/lib/rails_generator/generators/components/scaffold/templates/view_edit.rhtml +0 -9
  169. data/lib/rails_generator/generators/components/scaffold/templates/view_list.rhtml +0 -27
  170. data/lib/rails_generator/generators/components/scaffold/templates/view_new.rhtml +0 -8
  171. data/lib/rails_generator/generators/components/scaffold/templates/view_show.rhtml +0 -8
  172. data/lib/rails_generator/generators/components/web_service/USAGE +0 -28
  173. data/lib/rails_generator/generators/components/web_service/templates/api_definition.rb +0 -5
  174. data/lib/rails_generator/generators/components/web_service/templates/controller.rb +0 -8
  175. data/lib/rails_generator/generators/components/web_service/templates/functional_test.rb +0 -19
  176. data/lib/rails_generator/generators/components/web_service/web_service_generator.rb +0 -29
  177. data/lib/tasks/javascripts.rake +0 -6
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2004 David Heinemeier Hansson
1
+ Copyright (c) 2004-2007 David Heinemeier Hansson
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README CHANGED
@@ -13,7 +13,7 @@ Product, Show Post) by manipulating the model and directing data to the view.
13
13
  In Rails, the model is handled by what's called an object-relational mapping
14
14
  layer entitled Active Record. This layer allows you to present the data from
15
15
  database rows as objects and embellish these data objects with business logic
16
- methods. You can read more about Active Record in
16
+ methods. You can read more about Active Record in
17
17
  link:files/vendor/rails/activerecord/README.html.
18
18
 
19
19
  The controller and view are handled by the Action Pack, which handles both
@@ -21,132 +21,182 @@ layers by its two parts: Action View and Action Controller. These two layers
21
21
  are bundled in a single package due to their heavy interdependence. This is
22
22
  unlike the relationship between the Active Record and Action Pack that is much
23
23
  more separate. Each of these packages can be used independently outside of
24
- Rails. You can read more about Action Pack in
24
+ Rails. You can read more about Action Pack in
25
25
  link:files/vendor/rails/actionpack/README.html.
26
26
 
27
27
 
28
- == Getting started
28
+ == Getting Started
29
29
 
30
- 1. Run the WEBrick servlet: <tt>ruby script/server</tt> (run with --help for options)
31
- ...or if you have lighttpd installed: <tt>ruby script/lighttpd</tt> (it's faster)
32
- 2. Go to http://localhost:3000/ and get "Congratulations, you've put Ruby on Rails!"
33
- 3. Follow the guidelines on the "Congratulations, you've put Ruby on Rails!" screen
30
+ 1. At the command prompt, start a new Rails application using the <tt>rails</tt> command
31
+ and your application name. Ex: rails myapp
32
+ (If you've downloaded Rails in a complete tgz or zip, this step is already done)
33
+ 2. Change directory into myapp and start the web server: <tt>script/server</tt> (run with --help for options)
34
+ 3. Go to http://localhost:3000/ and get "Welcome aboard: You’re riding the Rails!"
35
+ 4. Follow the guidelines to start developing your application
34
36
 
35
37
 
36
- == Example for Apache conf
38
+ == Web Servers
37
39
 
38
- <VirtualHost *:80>
39
- ServerName rails
40
- DocumentRoot /path/application/public/
41
- ErrorLog /path/application/log/server.log
42
-
43
- <Directory /path/application/public/>
44
- Options ExecCGI FollowSymLinks
45
- AllowOverride all
46
- Allow from all
47
- Order allow,deny
48
- </Directory>
49
- </VirtualHost>
40
+ By default, Rails will try to use Mongrel and lighttpd if they are installed, otherwise
41
+ Rails will use WEBrick, the webserver that ships with Ruby. When you run script/server,
42
+ Rails will check if Mongrel exists, then lighttpd and finally fall back to WEBrick. This ensures
43
+ that you can always get up and running quickly.
50
44
 
51
- NOTE: Be sure that CGIs can be executed in that directory as well. So ExecCGI
52
- should be on and ".cgi" should respond. All requests from 127.0.0.1 go
53
- through CGI, so no Apache restart is necessary for changes. All other requests
54
- go through FCGI (or mod_ruby), which requires a restart to show changes.
45
+ Mongrel is a Ruby-based webserver with a C component (which requires compilation) that is
46
+ suitable for development and deployment of Rails applications. If you have Ruby Gems installed,
47
+ getting up and running with mongrel is as easy as: <tt>gem install mongrel</tt>.
48
+ More info at: http://mongrel.rubyforge.org
49
+
50
+ If Mongrel is not installed, Rails will look for lighttpd. It's considerably faster than
51
+ Mongrel and WEBrick and also suited for production use, but requires additional
52
+ installation and currently only works well on OS X/Unix (Windows users are encouraged
53
+ to start with Mongrel). We recommend version 1.4.11 and higher. You can download it from
54
+ http://www.lighttpd.net.
55
+
56
+ And finally, if neither Mongrel or lighttpd are installed, Rails will use the built-in Ruby
57
+ web server, WEBrick. WEBrick is a small Ruby web server suitable for development, but not
58
+ for production.
59
+
60
+ But of course its also possible to run Rails on any platform that supports FCGI.
61
+ Apache, LiteSpeed, IIS are just a few. For more information on FCGI,
62
+ please visit: http://wiki.rubyonrails.com/rails/pages/FastCGI
55
63
 
56
64
 
57
65
  == Debugging Rails
58
66
 
59
- Have "tail -f" commands running on both the server.log, production.log, and
60
- test.log files. Rails will automatically display debugging and runtime
61
- information to these files. Debugging info will also be shown in the browser
62
- on requests from 127.0.0.1.
67
+ Sometimes your application goes wrong. Fortunately there are a lot of tools that
68
+ will help you debug it and get it back on the rails.
69
+
70
+ First area to check is the application log files. Have "tail -f" commands running
71
+ on the server.log and development.log. Rails will automatically display debugging
72
+ and runtime information to these files. Debugging info will also be shown in the
73
+ browser on requests from 127.0.0.1.
74
+
75
+ You can also log your own messages directly into the log file from your code using
76
+ the Ruby logger class from inside your controllers. Example:
77
+
78
+ class WeblogController < ActionController::Base
79
+ def destroy
80
+ @weblog = Weblog.find(params[:id])
81
+ @weblog.destroy
82
+ logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
83
+ end
84
+ end
85
+
86
+ The result will be a message in your log file along the lines of:
87
+
88
+ Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1
89
+
90
+ More information on how to use the logger is at http://www.ruby-doc.org/core/
63
91
 
92
+ Also, Ruby documentation can be found at http://www.ruby-lang.org/ including:
64
93
 
65
- == Breakpoints
94
+ * The Learning Ruby (Pickaxe) Book: http://www.ruby-doc.org/docs/ProgrammingRuby/
95
+ * Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
66
96
 
67
- Breakpoint support is available through the script/breakpointer client. This
68
- means that you can break out of execution at any point in the code, investigate
69
- and change the model, AND then resume execution! Example:
97
+ These two online (and free) books will bring you up to speed on the Ruby language
98
+ and also on programming in general.
99
+
100
+
101
+ == Debugger
102
+
103
+ Debugger support is available through the debugger command when you start your Mongrel or
104
+ Webrick server with --debugger. This means that you can break out of execution at any point
105
+ in the code, investigate and change the model, AND then resume execution! Example:
70
106
 
71
107
  class WeblogController < ActionController::Base
72
108
  def index
73
- @posts = Post.find_all
74
- breakpoint "Breaking out from the list"
109
+ @posts = Post.find(:all)
110
+ debugger
75
111
  end
76
112
  end
77
-
78
- So the controller will accept the action, run the first line, then present you
79
- with a IRB prompt in the breakpointer window. Here you can do things like:
80
113
 
81
- Executing breakpoint "Breaking out from the list" at .../webrick_server.rb:16 in 'breakpoint'
114
+ So the controller will accept the action, run the first line, then present you
115
+ with a IRB prompt in the server window. Here you can do things like:
82
116
 
83
117
  >> @posts.inspect
84
- => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
118
+ => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
85
119
  #<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
86
- >> @posts.first.title = "hello from a breakpoint"
87
- => "hello from a breakpoint"
120
+ >> @posts.first.title = "hello from a debugger"
121
+ => "hello from a debugger"
88
122
 
89
123
  ...and even better is that you can examine how your runtime objects actually work:
90
124
 
91
- >> f = @posts.first
125
+ >> f = @posts.first
92
126
  => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
93
127
  >> f.
94
128
  Display all 152 possibilities? (y or n)
95
129
 
96
- Finally, when you're ready to resume execution, you press CTRL-D
130
+ Finally, when you're ready to resume execution, you enter "cont"
97
131
 
98
132
 
99
133
  == Console
100
134
 
101
- You can interact with the domain model by starting the console through script/console.
135
+ You can interact with the domain model by starting the console through <tt>script/console</tt>.
102
136
  Here you'll have all parts of the application configured, just like it is when the
103
137
  application is running. You can inspect domain models, change values, and save to the
104
138
  database. Starting the script without arguments will launch it in the development environment.
105
- Passing an argument will specify a different environment, like <tt>console production</tt>.
139
+ Passing an argument will specify a different environment, like <tt>script/console production</tt>.
140
+
141
+ To reload your controllers and models after launching the console run <tt>reload!</tt>
106
142
 
107
143
 
108
- == Description of contents
144
+ == Description of Contents
109
145
 
110
146
  app
111
147
  Holds all the code that's specific to this particular application.
112
148
 
113
149
  app/controllers
114
- Holds controllers that should be named like weblog_controller.rb for
115
- automated URL mapping. All controllers should descend from
116
- ActionController::Base.
150
+ Holds controllers that should be named like weblogs_controller.rb for
151
+ automated URL mapping. All controllers should descend from ApplicationController
152
+ which itself descends from ActionController::Base.
117
153
 
118
154
  app/models
119
155
  Holds models that should be named like post.rb.
120
156
  Most models will descend from ActiveRecord::Base.
121
-
157
+
122
158
  app/views
123
159
  Holds the template files for the view that should be named like
124
- weblog/index.rhtml for the WeblogController#index action. All views use eRuby
125
- syntax. This directory can also be used to keep stylesheets, images, and so on
126
- that can be symlinked to public.
127
-
160
+ weblogs/index.erb for the WeblogsController#index action. All views use eRuby
161
+ syntax.
162
+
163
+ app/views/layouts
164
+ Holds the template files for layouts to be used with views. This models the common
165
+ header/footer method of wrapping views. In your views, define a layout using the
166
+ <tt>layout :default</tt> and create a file named default.erb. Inside default.erb,
167
+ call <% yield %> to render the view using this layout.
168
+
128
169
  app/helpers
129
- Holds view helpers that should be named like weblog_helper.rb.
170
+ Holds view helpers that should be named like weblogs_helper.rb. These are generated
171
+ for you automatically when using script/generate for controllers. Helpers can be used to
172
+ wrap functionality for your views into methods.
130
173
 
131
174
  config
132
175
  Configuration files for the Rails environment, the routing map, the database, and other dependencies.
133
176
 
134
- components
135
- Self-contained mini-applications that can bundle together controllers, models, and views.
177
+ db
178
+ Contains the database schema in schema.rb. db/migrate contains all
179
+ the sequence of Migrations for your schema.
180
+
181
+ doc
182
+ This directory is where your application documentation will be stored when generated
183
+ using <tt>rake doc:app</tt>
136
184
 
137
185
  lib
138
186
  Application specific libraries. Basically, any kind of custom code that doesn't
139
187
  belong under controllers, models, or helpers. This directory is in the load path.
140
-
188
+
141
189
  public
142
190
  The directory available for the web server. Contains subdirectories for images, stylesheets,
143
- and javascripts. Also contains the dispatchers and the default HTML files.
191
+ and javascripts. Also contains the dispatchers and the default HTML files. This should be
192
+ set as the DOCUMENT_ROOT of your web server.
144
193
 
145
194
  script
146
195
  Helper scripts for automation and generation.
147
196
 
148
197
  test
149
- Unit and functional tests along with fixtures.
198
+ Unit and functional tests along with fixtures. When using the script/generate scripts, template
199
+ test files will be generated for you and placed in this directory.
150
200
 
151
201
  vendor
152
202
  External libraries that the application depends on. Also includes the plugins subdirectory.
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ require 'rake/contrib/rubyforgepublisher'
7
7
  require 'date'
8
8
  require 'rbconfig'
9
9
 
10
- require File.join(File.dirname(__FILE__), 'lib', 'rails_version')
10
+ require File.join(File.dirname(__FILE__), 'lib/rails', 'version')
11
11
 
12
12
  PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
13
13
  PKG_NAME = 'rails'
@@ -21,25 +21,59 @@ RUBY_FORGE_PROJECT = "rails"
21
21
  RUBY_FORGE_USER = "webster132"
22
22
 
23
23
 
24
- # Rake::TestTask.new("test") do |t|
25
- # t.libs << 'test'
26
- # t.pattern = 'test/*_test.rb'
27
- # t.verbose = true
28
- # end
24
+ task :default => :test
25
+
26
+ ## This is required until the regular test task
27
+ ## below passes. It's not ideal, but at least
28
+ ## we can see the failures
29
+ task :test do
30
+ Dir['test/**/*_test.rb'].all? do |file|
31
+ system("ruby #{file}")
32
+ end or raise "Failures"
33
+ end
34
+
35
+ Rake::TestTask.new("regular_test") do |t|
36
+ t.libs << 'test'
37
+ t.pattern = 'test/**/*_test.rb'
38
+ t.warning = true
39
+ t.verbose = true
40
+ end
29
41
 
30
42
 
31
- BASE_DIRS = %w( app config/environments components db doc log lib lib/tasks public script script/performance script/process test vendor vendor/plugins )
43
+ BASE_DIRS = %w(
44
+ app
45
+ config/environments
46
+ config/initializers
47
+ components
48
+ db
49
+ doc
50
+ log
51
+ lib
52
+ lib/tasks
53
+ public
54
+ script
55
+ script/performance
56
+ script/process
57
+ test
58
+ vendor
59
+ vendor/plugins
60
+ tmp/sessions
61
+ tmp/cache
62
+ tmp/sockets
63
+ tmp/pids
64
+ )
65
+
32
66
  APP_DIRS = %w( models controllers helpers views views/layouts )
33
67
  PUBLIC_DIRS = %w( images javascripts stylesheets )
34
68
  TEST_DIRS = %w( fixtures unit functional mocks mocks/development mocks/test )
35
69
 
36
70
  LOG_FILES = %w( server.log development.log test.log production.log )
37
- HTML_FILES = %w( 404.html 500.html index.html robots.txt favicon.ico images/rails.png
38
- javascripts/prototype.js
71
+ HTML_FILES = %w( 422.html 404.html 500.html index.html robots.txt favicon.ico images/rails.png
72
+ javascripts/prototype.js javascripts/application.js
39
73
  javascripts/effects.js javascripts/dragdrop.js javascripts/controls.js )
40
- BIN_FILES = %w( about breakpointer console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner process/spinner runner server plugin )
74
+ BIN_FILES = %w( about console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner process/inspector runner server plugin )
41
75
 
42
- VENDOR_LIBS = %w( actionpack activerecord actionmailer activesupport actionwebservice railties )
76
+ VENDOR_LIBS = %w( actionpack activerecord actionmailer activesupport activeresource railties )
43
77
 
44
78
 
45
79
  desc "Generates a fresh Rails package with documentation"
@@ -71,7 +105,7 @@ end
71
105
 
72
106
  desc "Updates railties to the latest version of the javascript spinoffs"
73
107
  task :update_js do
74
- for js in %w( prototype controls dragdrop effects slider )
108
+ for js in %w( prototype controls dragdrop effects )
75
109
  rm "html/javascripts/#{js}.js"
76
110
  cp "./../actionpack/lib/action_view/helpers/javascripts/#{js}.js", "html/javascripts"
77
111
  end
@@ -79,8 +113,8 @@ end
79
113
 
80
114
  # Make directory structure ----------------------------------------------------------------
81
115
 
82
- def make_dest_dirs(dirs, path = nil)
83
- mkdir_p dirs.map { |dir| File.join(PKG_DESTINATION, path, dir) }
116
+ def make_dest_dirs(dirs, path = '.')
117
+ mkdir_p dirs.map { |dir| File.join(PKG_DESTINATION, path.to_s, dir) }
84
118
  end
85
119
 
86
120
  desc "Make the directory structure for the new Rails application"
@@ -114,6 +148,7 @@ desc "Copy in all the Rails packages to vendor"
114
148
  task :copy_vendor_libraries do
115
149
  mkdir File.join(PKG_DESTINATION, 'vendor', 'rails')
116
150
  VENDOR_LIBS.each { |dir| cp_r File.join('..', dir), File.join(PKG_DESTINATION, 'vendor', 'rails', dir) }
151
+ FileUtils.rm_r(Dir.glob(File.join(PKG_DESTINATION, 'vendor', 'rails', "**", ".svn")))
117
152
  end
118
153
 
119
154
  desc "Link in all the Rails packages to vendor"
@@ -158,17 +193,20 @@ task :copy_configs do
158
193
  app_name = "rails"
159
194
  socket = nil
160
195
  require 'erb'
161
- File.open("#{PKG_DESTINATION}/config/database.yml", 'w') {|f| f.write ERB.new(IO.read("configs/database.yml"), nil, '-').result(binding)}
196
+ File.open("#{PKG_DESTINATION}/config/database.yml", 'w') {|f| f.write ERB.new(IO.read("configs/databases/mysql.yml"), nil, '-').result(binding)}
162
197
 
163
198
  cp "configs/routes.rb", "#{PKG_DESTINATION}/config/routes.rb"
164
199
 
165
200
  cp "configs/apache.conf", "#{PKG_DESTINATION}/public/.htaccess"
166
201
 
167
- cp "environments/boot.rb", "#{PKG_DESTINATION}/config/boot.rb"
202
+ cp "configs/initializers/inflections.rb", "#{PKG_DESTINATION}/config/initializers/inflections.rb"
203
+ cp "configs/initializers/mime_types.rb", "#{PKG_DESTINATION}/config/initializers/mime_types.rb"
204
+
205
+ cp "environments/boot.rb", "#{PKG_DESTINATION}/config/boot.rb"
168
206
  cp "environments/environment.rb", "#{PKG_DESTINATION}/config/environment.rb"
169
- cp "environments/production.rb", "#{PKG_DESTINATION}/config/environments/production.rb"
207
+ cp "environments/production.rb", "#{PKG_DESTINATION}/config/environments/production.rb"
170
208
  cp "environments/development.rb", "#{PKG_DESTINATION}/config/environments/development.rb"
171
- cp "environments/test.rb", "#{PKG_DESTINATION}/config/environments/test.rb"
209
+ cp "environments/test.rb", "#{PKG_DESTINATION}/config/environments/test.rb"
172
210
  end
173
211
 
174
212
  task :copy_binfiles do
@@ -222,18 +260,19 @@ desc "Generate documentation for the framework and for the empty application"
222
260
  task :generate_documentation => [ :generate_app_doc, :generate_rails_framework_doc ]
223
261
 
224
262
  task :generate_rails_framework_doc do
225
- system %{cd #{PKG_DESTINATION}; rake apidoc}
263
+ system %{cd #{PKG_DESTINATION}; rake doc:rails}
226
264
  end
227
265
 
228
266
  task :generate_app_doc do
229
267
  File.cp "doc/README_FOR_APP", "#{PKG_DESTINATION}/doc/README_FOR_APP"
230
- system %{cd #{PKG_DESTINATION}; rake appdoc}
268
+ system %{cd #{PKG_DESTINATION}; rake doc:app}
231
269
  end
232
270
 
233
271
  Rake::RDocTask.new { |rdoc|
234
272
  rdoc.rdoc_dir = 'doc'
235
273
  rdoc.title = "Railties -- Gluing the Engine to the Rails"
236
- rdoc.options << '--line-numbers --inline-source --accessor cattr_accessor=object'
274
+ rdoc.options << '--line-numbers' << '--inline-source' << '--accessor' << 'cattr_accessor=object'
275
+ rdoc.options << '--charset' << 'utf-8'
237
276
  rdoc.template = "#{ENV['template']}.rb" if ENV['template']
238
277
  rdoc.rdoc_files.include('README', 'CHANGELOG')
239
278
  rdoc.rdoc_files.include('lib/*.rb')
@@ -261,7 +300,7 @@ PKG_FILES = FileList[
261
300
  'generators/**/*',
262
301
  'html/**/*',
263
302
  'lib/**/*'
264
- ]
303
+ ] - [ 'test' ]
265
304
 
266
305
  spec = Gem::Specification.new do |s|
267
306
  s.name = 'rails'
@@ -272,19 +311,18 @@ spec = Gem::Specification.new do |s|
272
311
  on top of either MySQL, PostgreSQL, SQLite, DB2, SQL Server, or Oracle with eRuby- or Builder-based templates.
273
312
  EOF
274
313
 
275
- s.add_dependency('rake', '>= 0.6.2')
276
- s.add_dependency('activesupport', '= 1.2.5' + PKG_BUILD)
277
- s.add_dependency('activerecord', '= 1.13.2' + PKG_BUILD)
278
- s.add_dependency('actionpack', '= 1.11.2' + PKG_BUILD)
279
- s.add_dependency('actionmailer', '= 1.1.5' + PKG_BUILD)
280
- s.add_dependency('actionwebservice', '= 1.0.0' + PKG_BUILD)
314
+ s.add_dependency('rake', '>= 0.7.2')
315
+ s.add_dependency('activesupport', '= 2.0.0' + PKG_BUILD)
316
+ s.add_dependency('activerecord', '= 2.0.0' + PKG_BUILD)
317
+ s.add_dependency('actionpack', '= 2.0.0' + PKG_BUILD)
318
+ s.add_dependency('actionmailer', '= 2.0.0' + PKG_BUILD)
319
+ s.add_dependency('activeresource', '= 2.0.0' + PKG_BUILD)
281
320
 
282
321
  s.rdoc_options << '--exclude' << '.'
283
322
  s.has_rdoc = false
284
323
 
285
324
  s.files = PKG_FILES.to_a.delete_if {|f| f.include?('.svn')}
286
325
  s.require_path = 'lib'
287
-
288
326
  s.bindir = "bin" # Use these for applications.
289
327
  s.executables = ["rails"]
290
328
  s.default_executable = "rails"
@@ -296,6 +334,7 @@ spec = Gem::Specification.new do |s|
296
334
  end
297
335
 
298
336
  Rake::GemPackageTask.new(spec) do |pkg|
337
+ pkg.gem_spec = spec
299
338
  end
300
339
 
301
340
 
@@ -307,116 +346,12 @@ task :pgem => [:gem] do
307
346
  end
308
347
 
309
348
  desc "Publish the release files to RubyForge."
310
- task :release => [:gem] do
311
- files = ["gem"].map { |ext| "pkg/#{PKG_FILE_NAME}.#{ext}" }
312
-
313
- if RUBY_FORGE_PROJECT then
314
- require 'net/http'
315
- require 'open-uri'
316
-
317
- project_uri = "http://rubyforge.org/projects/#{RUBY_FORGE_PROJECT}/"
318
- project_data = open(project_uri) { |data| data.read }
319
- group_id = project_data[/[?&]group_id=(\d+)/, 1]
320
- raise "Couldn't get group id" unless group_id
321
-
322
- # This echos password to shell which is a bit sucky
323
- if ENV["RUBY_FORGE_PASSWORD"]
324
- password = ENV["RUBY_FORGE_PASSWORD"]
325
- else
326
- print "#{RUBY_FORGE_USER}@rubyforge.org's password: "
327
- password = STDIN.gets.chomp
328
- end
349
+ task :release => [ :package ] do
350
+ require 'rubyforge'
329
351
 
330
- login_response = Net::HTTP.start("rubyforge.org", 80) do |http|
331
- data = [
332
- "login=1",
333
- "form_loginname=#{RUBY_FORGE_USER}",
334
- "form_pw=#{password}"
335
- ].join("&")
336
- http.post("/account/login.php", data)
337
- end
338
-
339
- cookie = login_response["set-cookie"]
340
- raise "Login failed" unless cookie
341
- headers = { "Cookie" => cookie }
342
-
343
- release_uri = "http://rubyforge.org/frs/admin/?group_id=#{group_id}"
344
- release_data = open(release_uri, headers) { |data| data.read }
345
- package_id = release_data[/[?&]package_id=(\d+)/, 1]
346
- raise "Couldn't get package id" unless package_id
347
-
348
- first_file = true
349
- release_id = ""
350
-
351
- files.each do |filename|
352
- basename = File.basename(filename)
353
- file_ext = File.extname(filename)
354
- file_data = File.open(filename, "rb") { |file| file.read }
355
-
356
- puts "Releasing #{basename}..."
357
-
358
- release_response = Net::HTTP.start("rubyforge.org", 80) do |http|
359
- release_date = Time.now.strftime("%Y-%m-%d %H:%M")
360
- type_map = {
361
- ".zip" => "3000",
362
- ".tgz" => "3110",
363
- ".gz" => "3110",
364
- ".gem" => "1400"
365
- }; type_map.default = "9999"
366
- type = type_map[file_ext]
367
- boundary = "rubyqMY6QN9bp6e4kS21H4y0zxcvoor"
368
-
369
- query_hash = if first_file then
370
- {
371
- "group_id" => group_id,
372
- "package_id" => package_id,
373
- "release_name" => RELEASE_NAME,
374
- "release_date" => release_date,
375
- "type_id" => type,
376
- "processor_id" => "8000", # Any
377
- "release_notes" => "",
378
- "release_changes" => "",
379
- "preformatted" => "1",
380
- "submit" => "1"
381
- }
382
- else
383
- {
384
- "group_id" => group_id,
385
- "release_id" => release_id,
386
- "package_id" => package_id,
387
- "step2" => "1",
388
- "type_id" => type,
389
- "processor_id" => "8000", # Any
390
- "submit" => "Add This File"
391
- }
392
- end
393
-
394
- query = "?" + query_hash.map do |(name, value)|
395
- [name, URI.encode(value)].join("=")
396
- end.join("&")
397
-
398
- data = [
399
- "--" + boundary,
400
- "Content-Disposition: form-data; name=\"userfile\"; filename=\"#{basename}\"",
401
- "Content-Type: application/octet-stream",
402
- "Content-Transfer-Encoding: binary",
403
- "", file_data, ""
404
- ].join("\x0D\x0A")
405
-
406
- release_headers = headers.merge(
407
- "Content-Type" => "multipart/form-data; boundary=#{boundary}"
408
- )
409
-
410
- target = first_file ? "/frs/admin/qrs.php" : "/frs/admin/editrelease.php"
411
- http.post(target + query, data, release_headers)
412
- end
352
+ packages = %w( gem ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" }
413
353
 
414
- if first_file then
415
- release_id = release_response.body[/release_id=(\d+)/, 1]
416
- raise("Couldn't get release id") unless release_id
417
- end
418
-
419
- first_file = false
420
- end
421
- end
354
+ rubyforge = RubyForge.new
355
+ rubyforge.login
356
+ rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages)
422
357
  end
data/bin/about CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
  require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/about'
3
+ require 'commands/about'
data/bin/console CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
  require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/console'
3
+ require 'commands/console'
data/bin/destroy CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
  require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/destroy'
3
+ require 'commands/destroy'
data/bin/generate CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
  require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/generate'
3
+ require 'commands/generate'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../../config/boot'
3
+ require 'commands/performance/request'
data/bin/plugin CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
  require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/plugin'
3
+ require 'commands/plugin'
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
  require File.dirname(__FILE__) + '/../../config/boot'
3
- require 'commands/process/spinner'
3
+ require 'commands/process/inspector'
data/bin/rails CHANGED
@@ -1,21 +1,19 @@
1
- min_release = "1.8.2 (2004-12-25)"
2
- ruby_release = "#{RUBY_VERSION} (#{RUBY_RELEASE_DATE})"
3
- if ruby_release < min_release
4
- abort <<-end_message
5
-
6
- Rails requires Ruby version #{min_release} or later.
7
- You're running #{ruby_release}; please upgrade to continue.
1
+ require File.dirname(__FILE__) + '/../lib/ruby_version_check'
2
+ Signal.trap("INT") { puts; exit }
8
3
 
9
- end_message
4
+ require File.dirname(__FILE__) + '/../lib/rails/version'
5
+ if %w(--version -v).include? ARGV.first
6
+ puts "Rails #{Rails::VERSION::STRING}"
7
+ exit(0)
10
8
  end
11
9
 
12
- Signal.trap("INT") { puts; exit }
13
-
14
- require File.dirname(__FILE__) + '/../lib/rails_version'
15
- abort "Rails #{Rails::VERSION::STRING}" if %w(--version -v).include? ARGV.first
10
+ freeze = ARGV.any? { |option| %w(--freeze -f).include?(option) }
11
+ app_path = ARGV.first
16
12
 
17
13
  require File.dirname(__FILE__) + '/../lib/rails_generator'
18
14
 
19
15
  require 'rails_generator/scripts/generate'
20
16
  Rails::Generator::Base.use_application_sources!
21
17
  Rails::Generator::Scripts::Generate.new.run(ARGV, :generator => 'app')
18
+
19
+ Dir.chdir(app_path) { `rake rails:freeze:gems`; puts "froze" } if freeze
data/bin/runner CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
  require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/runner'
3
+ require 'commands/runner'