erails 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. data/CHANGELOG +3 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README +309 -0
  4. data/Rakefile +339 -0
  5. data/bin/about +4 -0
  6. data/bin/console +3 -0
  7. data/bin/dbconsole +3 -0
  8. data/bin/destroy +3 -0
  9. data/bin/erails +19 -0
  10. data/bin/generate +3 -0
  11. data/bin/performance/benchmarker +3 -0
  12. data/bin/performance/profiler +3 -0
  13. data/bin/performance/request +3 -0
  14. data/bin/plugin +3 -0
  15. data/bin/process/inspector +3 -0
  16. data/bin/process/reaper +3 -0
  17. data/bin/process/spawner +3 -0
  18. data/bin/runner +3 -0
  19. data/bin/server +3 -0
  20. data/builtin/rails_info/rails/info.rb +125 -0
  21. data/builtin/rails_info/rails/info_controller.rb +9 -0
  22. data/builtin/rails_info/rails/info_helper.rb +2 -0
  23. data/builtin/rails_info/rails_info_controller.rb +2 -0
  24. data/configs/apache.conf +40 -0
  25. data/configs/databases/frontbase.yml +28 -0
  26. data/configs/databases/mysql.yml +54 -0
  27. data/configs/databases/oracle.yml +39 -0
  28. data/configs/databases/postgresql.yml +48 -0
  29. data/configs/databases/sqlite2.yml +16 -0
  30. data/configs/databases/sqlite3.yml +19 -0
  31. data/configs/empty.log +0 -0
  32. data/configs/initializers/inflections.rb +10 -0
  33. data/configs/initializers/mime_types.rb +5 -0
  34. data/configs/initializers/new_rails_defaults.rb +17 -0
  35. data/configs/lighttpd.conf +54 -0
  36. data/configs/routes.rb +43 -0
  37. data/dispatches/dispatch.fcgi +24 -0
  38. data/dispatches/dispatch.rb +10 -0
  39. data/dispatches/gateway.cgi +97 -0
  40. data/doc/README_FOR_APP +2 -0
  41. data/environments/boot.rb +109 -0
  42. data/environments/development.rb +16 -0
  43. data/environments/environment.rb +71 -0
  44. data/environments/production.rb +22 -0
  45. data/environments/test.rb +22 -0
  46. data/fresh_rakefile +10 -0
  47. data/helpers/application.rb +15 -0
  48. data/helpers/application_helper.rb +3 -0
  49. data/helpers/test_helper.rb +38 -0
  50. data/html/404.html +30 -0
  51. data/html/422.html +30 -0
  52. data/html/500.html +30 -0
  53. data/html/favicon.ico +0 -0
  54. data/html/images/rails.png +0 -0
  55. data/html/index.html +274 -0
  56. data/html/javascripts/application.js +2 -0
  57. data/html/robots.txt +5 -0
  58. data/lib/code_statistics.rb +107 -0
  59. data/lib/commands/about.rb +3 -0
  60. data/lib/commands/console.rb +32 -0
  61. data/lib/commands/dbconsole.rb +67 -0
  62. data/lib/commands/destroy.rb +6 -0
  63. data/lib/commands/generate.rb +6 -0
  64. data/lib/commands/ncgi/listener +86 -0
  65. data/lib/commands/ncgi/tracker +69 -0
  66. data/lib/commands/performance/benchmarker.rb +24 -0
  67. data/lib/commands/performance/profiler.rb +50 -0
  68. data/lib/commands/performance/request.rb +6 -0
  69. data/lib/commands/plugin.rb +950 -0
  70. data/lib/commands/process/inspector.rb +68 -0
  71. data/lib/commands/process/reaper.rb +149 -0
  72. data/lib/commands/process/spawner.rb +219 -0
  73. data/lib/commands/process/spinner.rb +57 -0
  74. data/lib/commands/runner.rb +48 -0
  75. data/lib/commands/server.rb +39 -0
  76. data/lib/commands/servers/base.rb +31 -0
  77. data/lib/commands/servers/lighttpd.rb +94 -0
  78. data/lib/commands/servers/mongrel.rb +69 -0
  79. data/lib/commands/servers/new_mongrel.rb +16 -0
  80. data/lib/commands/servers/webrick.rb +66 -0
  81. data/lib/commands/update.rb +4 -0
  82. data/lib/commands.rb +17 -0
  83. data/lib/console_app.rb +30 -0
  84. data/lib/console_sandbox.rb +6 -0
  85. data/lib/console_with_helpers.rb +26 -0
  86. data/lib/dispatcher.rb +24 -0
  87. data/lib/fcgi_handler.rb +239 -0
  88. data/lib/initializer.rb +926 -0
  89. data/lib/rails/gem_builder.rb +21 -0
  90. data/lib/rails/gem_dependency.rb +129 -0
  91. data/lib/rails/mongrel_server/commands.rb +342 -0
  92. data/lib/rails/mongrel_server/handler.rb +55 -0
  93. data/lib/rails/plugin/loader.rb +152 -0
  94. data/lib/rails/plugin/locator.rb +100 -0
  95. data/lib/rails/plugin.rb +116 -0
  96. data/lib/rails/version.rb +9 -0
  97. data/lib/rails_generator/base.rb +263 -0
  98. data/lib/rails_generator/commands.rb +622 -0
  99. data/lib/rails_generator/generated_attribute.rb +42 -0
  100. data/lib/rails_generator/generators/applications/app/USAGE +9 -0
  101. data/lib/rails_generator/generators/applications/app/app_generator.rb +174 -0
  102. data/lib/rails_generator/generators/components/controller/USAGE +29 -0
  103. data/lib/rails_generator/generators/components/controller/controller_generator.rb +37 -0
  104. data/lib/rails_generator/generators/components/controller/templates/controller.rb +7 -0
  105. data/lib/rails_generator/generators/components/controller/templates/functional_test.rb +8 -0
  106. data/lib/rails_generator/generators/components/controller/templates/helper.rb +2 -0
  107. data/lib/rails_generator/generators/components/controller/templates/view.html.erb +2 -0
  108. data/lib/rails_generator/generators/components/integration_test/USAGE +8 -0
  109. data/lib/rails_generator/generators/components/integration_test/integration_test_generator.rb +16 -0
  110. data/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb +10 -0
  111. data/lib/rails_generator/generators/components/mailer/USAGE +16 -0
  112. data/lib/rails_generator/generators/components/mailer/mailer_generator.rb +30 -0
  113. data/lib/rails_generator/generators/components/mailer/templates/fixture.erb +3 -0
  114. data/lib/rails_generator/generators/components/mailer/templates/fixture.rhtml +0 -0
  115. data/lib/rails_generator/generators/components/mailer/templates/mailer.rb +15 -0
  116. data/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +21 -0
  117. data/lib/rails_generator/generators/components/mailer/templates/view.erb +3 -0
  118. data/lib/rails_generator/generators/components/mailer/templates/view.rhtml +0 -0
  119. data/lib/rails_generator/generators/components/migration/USAGE +29 -0
  120. data/lib/rails_generator/generators/components/migration/migration_generator.rb +20 -0
  121. data/lib/rails_generator/generators/components/migration/templates/migration.rb +11 -0
  122. data/lib/rails_generator/generators/components/model/USAGE +27 -0
  123. data/lib/rails_generator/generators/components/model/model_generator.rb +45 -0
  124. data/lib/rails_generator/generators/components/model/templates/fixtures.yml +19 -0
  125. data/lib/rails_generator/generators/components/model/templates/migration.rb +16 -0
  126. data/lib/rails_generator/generators/components/model/templates/model.rb +2 -0
  127. data/lib/rails_generator/generators/components/model/templates/unit_test.rb +8 -0
  128. data/lib/rails_generator/generators/components/observer/USAGE +13 -0
  129. data/lib/rails_generator/generators/components/observer/observer_generator.rb +16 -0
  130. data/lib/rails_generator/generators/components/observer/templates/observer.rb +2 -0
  131. data/lib/rails_generator/generators/components/observer/templates/unit_test.rb +8 -0
  132. data/lib/rails_generator/generators/components/plugin/USAGE +25 -0
  133. data/lib/rails_generator/generators/components/plugin/plugin_generator.rb +39 -0
  134. data/lib/rails_generator/generators/components/plugin/templates/MIT-LICENSE +20 -0
  135. data/lib/rails_generator/generators/components/plugin/templates/README +13 -0
  136. data/lib/rails_generator/generators/components/plugin/templates/Rakefile +22 -0
  137. data/lib/rails_generator/generators/components/plugin/templates/USAGE +8 -0
  138. data/lib/rails_generator/generators/components/plugin/templates/generator.rb +8 -0
  139. data/lib/rails_generator/generators/components/plugin/templates/init.rb +1 -0
  140. data/lib/rails_generator/generators/components/plugin/templates/install.rb +1 -0
  141. data/lib/rails_generator/generators/components/plugin/templates/plugin.rb +1 -0
  142. data/lib/rails_generator/generators/components/plugin/templates/tasks.rake +4 -0
  143. data/lib/rails_generator/generators/components/plugin/templates/uninstall.rb +1 -0
  144. data/lib/rails_generator/generators/components/plugin/templates/unit_test.rb +8 -0
  145. data/lib/rails_generator/generators/components/resource/USAGE +23 -0
  146. data/lib/rails_generator/generators/components/resource/resource_generator.rb +74 -0
  147. data/lib/rails_generator/generators/components/resource/templates/controller.rb +2 -0
  148. data/lib/rails_generator/generators/components/resource/templates/functional_test.rb +8 -0
  149. data/lib/rails_generator/generators/components/resource/templates/helper.rb +2 -0
  150. data/lib/rails_generator/generators/components/scaffold/USAGE +25 -0
  151. data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +93 -0
  152. data/lib/rails_generator/generators/components/scaffold/templates/controller.rb +85 -0
  153. data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +45 -0
  154. data/lib/rails_generator/generators/components/scaffold/templates/helper.rb +2 -0
  155. data/lib/rails_generator/generators/components/scaffold/templates/layout.html.erb +17 -0
  156. data/lib/rails_generator/generators/components/scaffold/templates/style.css +54 -0
  157. data/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb +18 -0
  158. data/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb +24 -0
  159. data/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb +17 -0
  160. data/lib/rails_generator/generators/components/scaffold/templates/view_show.html.erb +10 -0
  161. data/lib/rails_generator/generators/components/session_migration/USAGE +10 -0
  162. data/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb +18 -0
  163. data/lib/rails_generator/generators/components/session_migration/templates/migration.rb +16 -0
  164. data/lib/rails_generator/lookup.rb +249 -0
  165. data/lib/rails_generator/manifest.rb +53 -0
  166. data/lib/rails_generator/options.rb +150 -0
  167. data/lib/rails_generator/scripts/destroy.rb +30 -0
  168. data/lib/rails_generator/scripts/generate.rb +7 -0
  169. data/lib/rails_generator/scripts/update.rb +12 -0
  170. data/lib/rails_generator/scripts.rb +89 -0
  171. data/lib/rails_generator/secret_key_generator.rb +164 -0
  172. data/lib/rails_generator/simple_logger.rb +46 -0
  173. data/lib/rails_generator/spec.rb +44 -0
  174. data/lib/rails_generator.rb +43 -0
  175. data/lib/railties_path.rb +1 -0
  176. data/lib/ruby_version_check.rb +17 -0
  177. data/lib/rubyprof_ext.rb +35 -0
  178. data/lib/source_annotation_extractor.rb +102 -0
  179. data/lib/tasks/annotations.rake +23 -0
  180. data/lib/tasks/databases.rake +389 -0
  181. data/lib/tasks/documentation.rake +80 -0
  182. data/lib/tasks/framework.rake +105 -0
  183. data/lib/tasks/gems.rake +64 -0
  184. data/lib/tasks/log.rake +9 -0
  185. data/lib/tasks/misc.rake +57 -0
  186. data/lib/tasks/rails.rb +8 -0
  187. data/lib/tasks/routes.rake +17 -0
  188. data/lib/tasks/statistics.rake +18 -0
  189. data/lib/tasks/testing.rake +118 -0
  190. data/lib/tasks/tmp.rake +37 -0
  191. data/lib/test_help.rb +28 -0
  192. data/lib/webrick_server.rb +165 -0
  193. metadata +356 -0
data/CHANGELOG ADDED
@@ -0,0 +1,3 @@
1
+ *2.1.2 (October 30rd, 2008)*
2
+
3
+ * Added the possibility to select in environment.rb the template engine (:erb or :haml), if :haml, will be added a new gem dependency! [DAddYE]
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2004-2008 David Heinemeier Hansson
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,309 @@
1
+ == Welcome to Enhanced Rails
2
+
3
+ Rails is a web-application framework that includes everything needed to create
4
+ database-backed web applications according to the Model-View-Control pattern.
5
+
6
+ This pattern splits the view (also called the presentation) into "dumb" templates
7
+ that are primarily responsible for inserting pre-built data in between HTML tags.
8
+ The model contains the "smart" domain objects (such as Account, Product, Person,
9
+ Post) that holds all the business logic and knows how to persist themselves to
10
+ a database. The controller handles the incoming requests (such as Save New Account,
11
+ Update Product, Show Post) by manipulating the model and directing data to the view.
12
+
13
+ In Rails, the model is handled by what's called an object-relational mapping
14
+ layer entitled Active Record. This layer allows you to present the data from
15
+ database rows as objects and embellish these data objects with business logic
16
+ methods. You can read more about Active Record in
17
+ link:files/vendor/erails/activerecord/README.html.
18
+
19
+ The controller and view are handled by the Action Pack, which handles both
20
+ layers by its two parts: Action View and Action Controller. These two layers
21
+ are bundled in a single package due to their heavy interdependence. This is
22
+ unlike the relationship between the Active Record and Action Pack that is much
23
+ more separate. Each of these packages can be used independently outside of
24
+ Rails. You can read more about Action Pack in
25
+ link:files/vendor/erails/eactionpack/README.html.
26
+
27
+ == Focus of Enhanced Rails
28
+
29
+ Enhanced Rails is:
30
+
31
+ 1. Javascript Agnostic
32
+ 2. Template Engine Agnostic
33
+
34
+ There are some important difference between rails and Erails
35
+
36
+ In rails you can render ajax update with rjs, like that:
37
+
38
+ render :update do |page|
39
+ page << "alert('hello world')"
40
+ end
41
+
42
+ with Erails you can do that:
43
+
44
+ render :js => "alert('hello world')"
45
+
46
+ with Erails if you make an ajax request, and your controller has two view like index.js.erb and index.html.erb, will be rendered index.js.erb
47
+
48
+ One of the most important functionality Enhanced Rails is the autosetting of content-type of a response.
49
+
50
+ If we need to render sample.<tt>html</tt>.erb, eRails lookup for mime by extension <tt>html</tt> if found set their content-type in the response.
51
+
52
+ sample.json.erb => Mime::JSON
53
+ sample.csv.erb => Mime::CSV
54
+
55
+ If, for example, we have already registered a mime type like:
56
+
57
+ Mime::Type.register "text/richtext", :rtf
58
+ sample.rtf.erb => Mime::RTF
59
+
60
+ If the mime RTF is not registered, then the content type of the reponse was:
61
+
62
+ sample.rtf.erb => Mime::HTML
63
+
64
+ With Enhanced Rails, is not necessay use respond_to, it usefull if we have only one view for an action like the old way:
65
+
66
+ def index
67
+ respond_to { |format| format.js } # This was necessary in rails for setting the correct content-type of response
68
+ end
69
+
70
+ With Enhanced Rails, if whe have index.<tt>js</tt>.erb, the content-type is the Mime Type for <tt>js</tt>, so in this
71
+ case is not necessary write any thing.
72
+
73
+ With Enhanced Rails, you can set your template engine, this can be erb or haml and you can set it in environment.rb like:
74
+
75
+ config.template_engine = :haml
76
+
77
+ and if you don't have haml you can do
78
+
79
+ rake gem:install
80
+
81
+ == Getting Started
82
+
83
+ 1. At the command prompt, start a new Rails application using the <tt>rails</tt> command
84
+ and your application name. Ex: erails myapp
85
+ 2. Change directory into myapp and start the web server: <tt>script/server</tt> (run with --help for options)
86
+ 3. Go to http://localhost:3000/ and get "Welcome aboard: You're riding the Rails!"
87
+ 4. Follow the guidelines to start developing your application
88
+
89
+
90
+ == Web Servers
91
+
92
+ By default, Rails will try to use Mongrel and lighttpd if they are installed, otherwise
93
+ Rails will use WEBrick, the webserver that ships with Ruby. When you run script/server,
94
+ Rails will check if Mongrel exists, then lighttpd and finally fall back to WEBrick. This ensures
95
+ that you can always get up and running quickly.
96
+
97
+ Mongrel is a Ruby-based webserver with a C component (which requires compilation) that is
98
+ suitable for development and deployment of Rails applications. If you have Ruby Gems installed,
99
+ getting up and running with mongrel is as easy as: <tt>gem install mongrel</tt>.
100
+ More info at: http://mongrel.rubyforge.org
101
+
102
+ If Mongrel is not installed, Rails will look for lighttpd. It's considerably faster than
103
+ Mongrel and WEBrick and also suited for production use, but requires additional
104
+ installation and currently only works well on OS X/Unix (Windows users are encouraged
105
+ to start with Mongrel). We recommend version 1.4.11 and higher. You can download it from
106
+ http://www.lighttpd.net.
107
+
108
+ And finally, if neither Mongrel or lighttpd are installed, Rails will use the built-in Ruby
109
+ web server, WEBrick. WEBrick is a small Ruby web server suitable for development, but not
110
+ for production.
111
+
112
+ But of course its also possible to run Rails on any platform that supports FCGI.
113
+ Apache, LiteSpeed, IIS are just a few. For more information on FCGI,
114
+ please visit: http://wiki.rubyonrails.com/rails/pages/FastCGI
115
+
116
+
117
+ == Apache .htaccess example
118
+
119
+ # General Apache options
120
+ AddHandler fastcgi-script .fcgi
121
+ AddHandler cgi-script .cgi
122
+ Options +FollowSymLinks +ExecCGI
123
+
124
+ # If you don't want Rails to look in certain directories,
125
+ # use the following rewrite rules so that Apache won't rewrite certain requests
126
+ #
127
+ # Example:
128
+ # RewriteCond %{REQUEST_URI} ^/notrails.*
129
+ # RewriteRule .* - [L]
130
+
131
+ # Redirect all requests not available on the filesystem to Rails
132
+ # By default the cgi dispatcher is used which is very slow
133
+ #
134
+ # For better performance replace the dispatcher with the fastcgi one
135
+ #
136
+ # Example:
137
+ # RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
138
+ RewriteEngine On
139
+
140
+ # If your Rails application is accessed via an Alias directive,
141
+ # then you MUST also set the RewriteBase in this htaccess file.
142
+ #
143
+ # Example:
144
+ # Alias /myrailsapp /path/to/myrailsapp/public
145
+ # RewriteBase /myrailsapp
146
+
147
+ RewriteRule ^$ index.html [QSA]
148
+ RewriteRule ^([^.]+)$ $1.html [QSA]
149
+ RewriteCond %{REQUEST_FILENAME} !-f
150
+ RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
151
+
152
+ # In case Rails experiences terminal errors
153
+ # Instead of displaying this message you can supply a file here which will be rendered instead
154
+ #
155
+ # Example:
156
+ # ErrorDocument 500 /500.html
157
+
158
+ ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
159
+
160
+
161
+ == Debugging Rails
162
+
163
+ Sometimes your application goes wrong. Fortunately there are a lot of tools that
164
+ will help you debug it and get it back on the rails.
165
+
166
+ First area to check is the application log files. Have "tail -f" commands running
167
+ on the server.log and development.log. Rails will automatically display debugging
168
+ and runtime information to these files. Debugging info will also be shown in the
169
+ browser on requests from 127.0.0.1.
170
+
171
+ You can also log your own messages directly into the log file from your code using
172
+ the Ruby logger class from inside your controllers. Example:
173
+
174
+ class WeblogController < ActionController::Base
175
+ def destroy
176
+ @weblog = Weblog.find(params[:id])
177
+ @weblog.destroy
178
+ logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
179
+ end
180
+ end
181
+
182
+ The result will be a message in your log file along the lines of:
183
+
184
+ Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1
185
+
186
+ More information on how to use the logger is at http://www.ruby-doc.org/core/
187
+
188
+ Also, Ruby documentation can be found at http://www.ruby-lang.org/ including:
189
+
190
+ * The Learning Ruby (Pickaxe) Book: http://www.ruby-doc.org/docs/ProgrammingRuby/
191
+ * Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
192
+
193
+ These two online (and free) books will bring you up to speed on the Ruby language
194
+ and also on programming in general.
195
+
196
+
197
+ == Debugger
198
+
199
+ Debugger support is available through the debugger command when you start your Mongrel or
200
+ Webrick server with --debugger. This means that you can break out of execution at any point
201
+ in the code, investigate and change the model, AND then resume execution!
202
+ You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'
203
+ Example:
204
+
205
+ class WeblogController < ActionController::Base
206
+ def index
207
+ @posts = Post.find(:all)
208
+ debugger
209
+ end
210
+ end
211
+
212
+ So the controller will accept the action, run the first line, then present you
213
+ with a IRB prompt in the server window. Here you can do things like:
214
+
215
+ >> @posts.inspect
216
+ => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
217
+ #<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
218
+ >> @posts.first.title = "hello from a debugger"
219
+ => "hello from a debugger"
220
+
221
+ ...and even better is that you can examine how your runtime objects actually work:
222
+
223
+ >> f = @posts.first
224
+ => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
225
+ >> f.
226
+ Display all 152 possibilities? (y or n)
227
+
228
+ Finally, when you're ready to resume execution, you enter "cont"
229
+
230
+
231
+ == Console
232
+
233
+ You can interact with the domain model by starting the console through <tt>script/console</tt>.
234
+ Here you'll have all parts of the application configured, just like it is when the
235
+ application is running. You can inspect domain models, change values, and save to the
236
+ database. Starting the script without arguments will launch it in the development environment.
237
+ Passing an argument will specify a different environment, like <tt>script/console production</tt>.
238
+
239
+ To reload your controllers and models after launching the console run <tt>reload!</tt>
240
+
241
+ == dbconsole
242
+
243
+ You can go to the command line of your database directly through <tt>script/dbconsole</tt>.
244
+ You would be connected to the database with the credentials defined in database.yml.
245
+ Starting the script without arguments will connect you to the development database. Passing an
246
+ argument will connect you to a different database, like <tt>script/dbconsole production</tt>.
247
+ Currently works for mysql, postgresql and sqlite.
248
+
249
+ == Description of Contents
250
+
251
+ app
252
+ Holds all the code that's specific to this particular application.
253
+
254
+ app/controllers
255
+ Holds controllers that should be named like weblogs_controller.rb for
256
+ automated URL mapping. All controllers should descend from ApplicationController
257
+ which itself descends from ActionController::Base.
258
+
259
+ app/models
260
+ Holds models that should be named like post.rb.
261
+ Most models will descend from ActiveRecord::Base.
262
+
263
+ app/views
264
+ Holds the template files for the view that should be named like
265
+ weblogs/index.html.erb for the WeblogsController#index action. All views use eRuby
266
+ syntax.
267
+
268
+ app/views/layouts
269
+ Holds the template files for layouts to be used with views. This models the common
270
+ header/footer method of wrapping views. In your views, define a layout using the
271
+ <tt>layout :default</tt> and create a file named default.html.erb. Inside default.html.erb,
272
+ call <% yield %> to render the view using this layout.
273
+
274
+ app/helpers
275
+ Holds view helpers that should be named like weblogs_helper.rb. These are generated
276
+ for you automatically when using script/generate for controllers. Helpers can be used to
277
+ wrap functionality for your views into methods.
278
+
279
+ config
280
+ Configuration files for the Rails environment, the routing map, the database, and other dependencies.
281
+
282
+ db
283
+ Contains the database schema in schema.rb. db/migrate contains all
284
+ the sequence of Migrations for your schema.
285
+
286
+ doc
287
+ This directory is where your application documentation will be stored when generated
288
+ using <tt>rake doc:app</tt>
289
+
290
+ lib
291
+ Application specific libraries. Basically, any kind of custom code that doesn't
292
+ belong under controllers, models, or helpers. This directory is in the load path.
293
+
294
+ public
295
+ The directory available for the web server. Contains subdirectories for images, stylesheets,
296
+ and javascripts. Also contains the dispatchers and the default HTML files. This should be
297
+ set as the DOCUMENT_ROOT of your web server.
298
+
299
+ script
300
+ Helper scripts for automation and generation.
301
+
302
+ test
303
+ Unit and functional tests along with fixtures. When using the script/generate scripts, template
304
+ test files will be generated for you and placed in this directory.
305
+
306
+ vendor
307
+ External libraries that the application depends on. Also includes the plugins subdirectory.
308
+ If the app has frozen rails, those gems also go here, under vendor/rails/.
309
+ This directory is in the load path.
data/Rakefile ADDED
@@ -0,0 +1,339 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+ require 'rake/gempackagetask'
5
+ require 'rake/contrib/sshpublisher'
6
+ require 'rake/contrib/rubyforgepublisher'
7
+
8
+ require 'date'
9
+ require 'rbconfig'
10
+
11
+ require File.join(File.dirname(__FILE__), 'lib/rails', 'version')
12
+
13
+ PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
14
+ PKG_NAME = 'erails'
15
+ PKG_VERSION = Rails::VERSION::STRING + PKG_BUILD
16
+ PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
17
+ PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}"
18
+
19
+ RELEASE_NAME = "REL #{PKG_VERSION}"
20
+
21
+ RUBY_FORGE_PROJECT = "erails"
22
+ RUBY_FORGE_USER = "DAddYE"
23
+
24
+
25
+ task :default => :test
26
+
27
+ ## This is required until the regular test task
28
+ ## below passes. It's not ideal, but at least
29
+ ## we can see the failures
30
+ task :test do
31
+ Dir['test/**/*_test.rb'].all? do |file|
32
+ system("ruby -Itest #{file}")
33
+ end or raise "Failures"
34
+ end
35
+
36
+ Rake::TestTask.new("regular_test") do |t|
37
+ t.libs << 'test'
38
+ t.pattern = 'test/**/*_test.rb'
39
+ t.warning = true
40
+ t.verbose = true
41
+ end
42
+
43
+
44
+ BASE_DIRS = %w(
45
+ app
46
+ config/environments
47
+ config/initializers
48
+ components
49
+ db
50
+ doc
51
+ log
52
+ lib
53
+ lib/tasks
54
+ public
55
+ script
56
+ script/performance
57
+ script/process
58
+ test
59
+ vendor
60
+ vendor/plugins
61
+ tmp/sessions
62
+ tmp/cache
63
+ tmp/sockets
64
+ tmp/pids
65
+ )
66
+
67
+ APP_DIRS = %w( models controllers helpers views views/layouts )
68
+ PUBLIC_DIRS = %w( images javascripts stylesheets )
69
+ TEST_DIRS = %w( fixtures unit functional mocks mocks/development mocks/test )
70
+
71
+ LOG_FILES = %w( server.log development.log test.log production.log )
72
+ HTML_FILES = %w( 422.html 404.html 500.html index.html robots.txt favicon.ico images/rails.png
73
+ javascripts/application.js )
74
+ BIN_FILES = %w( about console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner process/inspector runner server plugin )
75
+
76
+ VENDOR_LIBS = %w( eactionpack activerecord actionmailer activesupport activeresource erailties )
77
+
78
+
79
+ desc "Generates a fresh Erails package with documentation"
80
+ task :fresh_rails => [ :clean, :make_dir_structure, :initialize_file_stubs, :copy_vendor_libraries, :copy_ties_content, :generate_documentation ]
81
+
82
+ desc "Generates a fresh Erails package using GEMs with documentation"
83
+ task :fresh_gem_rails => [ :clean, :make_dir_structure, :initialize_file_stubs, :copy_ties_content, :copy_gem_environment ]
84
+
85
+ desc "Generates a fresh Erails package without documentation (faster)"
86
+ task :fresh_rails_without_docs => [ :clean, :make_dir_structure, :initialize_file_stubs, :copy_vendor_libraries, :copy_ties_content ]
87
+
88
+ desc "Generates a fresh Erails package without documentation (faster)"
89
+ task :fresh_rails_without_docs_using_links => [ :clean, :make_dir_structure, :initialize_file_stubs, :link_vendor_libraries, :copy_ties_content ]
90
+
91
+ desc "Generates minimal Erails package using symlinks"
92
+ task :dev => [ :clean, :make_dir_structure, :initialize_file_stubs, :link_vendor_libraries, :copy_ties_content ]
93
+
94
+ desc "Packages the fresh Erails package with documentation"
95
+ task :package => [ :clean, :fresh_rails ] do
96
+ system %{cd ..; tar -czvf #{PKG_NAME}-#{PKG_VERSION}.tgz #{PKG_NAME}}
97
+ system %{cd ..; zip -r #{PKG_NAME}-#{PKG_VERSION}.zip #{PKG_NAME}}
98
+ end
99
+
100
+ task :clean do
101
+ rm_rf PKG_DESTINATION
102
+ end
103
+
104
+ # Make directory structure ----------------------------------------------------------------
105
+
106
+ def make_dest_dirs(dirs, path = '.')
107
+ mkdir_p dirs.map { |dir| File.join(PKG_DESTINATION, path.to_s, dir) }
108
+ end
109
+
110
+ desc "Make the directory structure for the new Rails application"
111
+ task :make_dir_structure => [ :make_base_dirs, :make_app_dirs, :make_public_dirs, :make_test_dirs ]
112
+
113
+ task(:make_base_dirs) { make_dest_dirs BASE_DIRS }
114
+ task(:make_app_dirs) { make_dest_dirs APP_DIRS, 'app' }
115
+ task(:make_public_dirs) { make_dest_dirs PUBLIC_DIRS, 'public' }
116
+ task(:make_test_dirs) { make_dest_dirs TEST_DIRS, 'test' }
117
+
118
+
119
+ # Initialize file stubs -------------------------------------------------------------------
120
+
121
+ desc "Initialize empty file stubs (such as for logging)"
122
+ task :initialize_file_stubs => [ :initialize_log_files ]
123
+
124
+ task :initialize_log_files do
125
+ log_dir = File.join(PKG_DESTINATION, 'log')
126
+ chmod 0777, log_dir
127
+ LOG_FILES.each do |log_file|
128
+ log_path = File.join(log_dir, log_file)
129
+ touch log_path
130
+ chmod 0666, log_path
131
+ end
132
+ end
133
+
134
+
135
+ # Copy Vendors ----------------------------------------------------------------------------
136
+
137
+ desc "Copy in all the Rails packages to vendor"
138
+ task :copy_vendor_libraries do
139
+ mkdir File.join(PKG_DESTINATION, 'vendor', 'erails')
140
+ VENDOR_LIBS.each { |dir| cp_r File.join('..', dir), File.join(PKG_DESTINATION, 'vendor', 'erails', dir) }
141
+ FileUtils.rm_r(Dir.glob(File.join(PKG_DESTINATION, 'vendor', 'rails', "**", ".svn")))
142
+ end
143
+
144
+ desc "Link in all the Rails packages to vendor"
145
+ task :link_vendor_libraries do
146
+ mkdir File.join(PKG_DESTINATION, 'vendor', 'erails')
147
+ VENDOR_LIBS.each { |dir| ln_s File.join('..', '..', '..', dir), File.join(PKG_DESTINATION, 'vendor', 'erails', dir) }
148
+ end
149
+
150
+
151
+ # Copy Ties Content -----------------------------------------------------------------------
152
+
153
+ desc "Make copies of all the default content of ties"
154
+ task :copy_ties_content => [
155
+ :copy_rootfiles, :copy_dispatches, :copy_html_files, :copy_application,
156
+ :copy_configs, :copy_binfiles, :copy_test_helpers, :copy_app_doc_readme ]
157
+
158
+ task :copy_dispatches do
159
+ copy_with_rewritten_ruby_path("dispatches/dispatch.rb", "#{PKG_DESTINATION}/public/dispatch.rb")
160
+ chmod 0755, "#{PKG_DESTINATION}/public/dispatch.rb"
161
+
162
+ copy_with_rewritten_ruby_path("dispatches/dispatch.rb", "#{PKG_DESTINATION}/public/dispatch.cgi")
163
+ chmod 0755, "#{PKG_DESTINATION}/public/dispatch.cgi"
164
+
165
+ copy_with_rewritten_ruby_path("dispatches/dispatch.fcgi", "#{PKG_DESTINATION}/public/dispatch.fcgi")
166
+ chmod 0755, "#{PKG_DESTINATION}/public/dispatch.fcgi"
167
+
168
+ # copy_with_rewritten_ruby_path("dispatches/gateway.cgi", "#{PKG_DESTINATION}/public/gateway.cgi")
169
+ # chmod 0755, "#{PKG_DESTINATION}/public/gateway.cgi"
170
+ end
171
+
172
+ task :copy_html_files do
173
+ HTML_FILES.each { |file| cp File.join('html', file), File.join(PKG_DESTINATION, 'public', file) }
174
+ end
175
+
176
+ task :copy_application do
177
+ cp "helpers/application.rb", "#{PKG_DESTINATION}/app/controllers/application.rb"
178
+ cp "helpers/application_helper.rb", "#{PKG_DESTINATION}/app/helpers/application_helper.rb"
179
+ end
180
+
181
+ task :copy_configs do
182
+ app_name = "rails"
183
+ socket = nil
184
+ require 'erb'
185
+ File.open("#{PKG_DESTINATION}/config/database.yml", 'w') {|f| f.write ERB.new(IO.read("configs/databases/mysql.yml"), nil, '-').result(binding)}
186
+
187
+ cp "configs/routes.rb", "#{PKG_DESTINATION}/config/routes.rb"
188
+
189
+ cp "configs/initializers/inflections.rb", "#{PKG_DESTINATION}/config/initializers/inflections.rb"
190
+ cp "configs/initializers/mime_types.rb", "#{PKG_DESTINATION}/config/initializers/mime_types.rb"
191
+
192
+ cp "environments/boot.rb", "#{PKG_DESTINATION}/config/boot.rb"
193
+ cp "environments/environment.rb", "#{PKG_DESTINATION}/config/environment.rb"
194
+ cp "environments/production.rb", "#{PKG_DESTINATION}/config/environments/production.rb"
195
+ cp "environments/development.rb", "#{PKG_DESTINATION}/config/environments/development.rb"
196
+ cp "environments/test.rb", "#{PKG_DESTINATION}/config/environments/test.rb"
197
+ end
198
+
199
+ task :copy_binfiles do
200
+ BIN_FILES.each do |file|
201
+ dest_file = File.join(PKG_DESTINATION, 'script', file)
202
+ copy_with_rewritten_ruby_path(File.join('bin', file), dest_file)
203
+ chmod 0755, dest_file
204
+ end
205
+ end
206
+
207
+ task :copy_rootfiles do
208
+ cp "fresh_rakefile", "#{PKG_DESTINATION}/Rakefile"
209
+ cp "README", "#{PKG_DESTINATION}/README"
210
+ cp "CHANGELOG", "#{PKG_DESTINATION}/CHANGELOG"
211
+ end
212
+
213
+ task :copy_test_helpers do
214
+ cp "helpers/test_helper.rb", "#{PKG_DESTINATION}/test/test_helper.rb"
215
+ end
216
+
217
+ task :copy_app_doc_readme do
218
+ cp "doc/README_FOR_APP", "#{PKG_DESTINATION}/doc/README_FOR_APP"
219
+ end
220
+
221
+ def copy_with_rewritten_ruby_path(src_file, dest_file)
222
+ ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
223
+
224
+ File.open(dest_file, 'w') do |df|
225
+ File.open(src_file) do |sf|
226
+ line = sf.gets
227
+ if (line =~ /#!.+ruby\s*/) != nil
228
+ df.puts("#!#{ruby}")
229
+ else
230
+ df.puts(line)
231
+ end
232
+ df.write(sf.read)
233
+ end
234
+ end
235
+ end
236
+
237
+
238
+ # Generate documentation ------------------------------------------------------------------
239
+
240
+ desc "Generate documentation for the framework and for the empty application"
241
+ task :generate_documentation => [ :generate_app_doc, :generate_rails_framework_doc ]
242
+
243
+ task :generate_rails_framework_doc do
244
+ system %{cd #{PKG_DESTINATION}; rake doc:rails}
245
+ end
246
+
247
+ task :generate_app_doc do
248
+ cp "doc/README_FOR_APP", "#{PKG_DESTINATION}/doc/README_FOR_APP"
249
+ system %{cd #{PKG_DESTINATION}; rake doc:app}
250
+ end
251
+
252
+ Rake::RDocTask.new { |rdoc|
253
+ rdoc.rdoc_dir = 'doc'
254
+ rdoc.title = "Enhanced Railties -- Gluing the Engine to the Rails"
255
+ rdoc.options << '--line-numbers' << '--inline-source' << '--accessor' << 'cattr_accessor=object'
256
+ rdoc.options << '--charset' << 'utf-8'
257
+ rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo'
258
+ rdoc.rdoc_files.include('README', 'CHANGELOG')
259
+ rdoc.rdoc_files.include('lib/*.rb')
260
+ rdoc.rdoc_files.include('lib/rails/*.rb')
261
+ rdoc.rdoc_files.include('lib/rails_generator/*.rb')
262
+ rdoc.rdoc_files.include('lib/commands/**/*.rb')
263
+ }
264
+
265
+ # Generate GEM ----------------------------------------------------------------------------
266
+
267
+ task :copy_gem_environment do
268
+ cp "environments/environment.rb", "#{PKG_DESTINATION}/config/environment.rb"
269
+ chmod 0755, dest_file
270
+ end
271
+
272
+
273
+ PKG_FILES = FileList[
274
+ '[a-zA-Z]*',
275
+ 'bin/**/*',
276
+ 'builtin/**/*',
277
+ 'configs/**/*',
278
+ 'doc/**/*',
279
+ 'dispatches/**/*',
280
+ 'environments/**/*',
281
+ 'helpers/**/*',
282
+ 'generators/**/*',
283
+ 'html/**/*',
284
+ 'lib/**/*'
285
+ ] - [ 'test' ]
286
+
287
+ spec = Gem::Specification.new do |s|
288
+ s.platform = Gem::Platform::RUBY
289
+ s.name = 'erails'
290
+ s.version = PKG_VERSION
291
+ s.summary = "Enhanced Web-application framework template, javascript agnostic, control-flow layer, and ORM."
292
+ s.description = <<-EOF
293
+ Enhanced Rails is a framework for building web-application template and javascript agnostic
294
+ on top of either MySQL, PostgreSQL, SQLite, DB2, SQL Server, or Oracle with eRuby- or Builder-based templates.
295
+ EOF
296
+
297
+ s.add_dependency('rake', '>= 0.8.1')
298
+ s.add_dependency('activesupport', '= 2.1.2' + PKG_BUILD)
299
+ s.add_dependency('activerecord', '= 2.1.2' + PKG_BUILD)
300
+ s.add_dependency('eactionpack', '= 2.1.2' + PKG_BUILD)
301
+ s.add_dependency('actionmailer', '= 2.1.2' + PKG_BUILD)
302
+ s.add_dependency('activeresource', '= 2.1.2' + PKG_BUILD)
303
+
304
+ s.rdoc_options << '--exclude' << '.'
305
+ s.has_rdoc = false
306
+
307
+ s.files = PKG_FILES.to_a.delete_if {|f| f.include?('.svn')}
308
+ s.require_path = 'lib'
309
+ s.bindir = "bin" # Use these for applications.
310
+ s.executables = ["erails"]
311
+ s.default_executable = "erails"
312
+
313
+ s.author = "Davide D'Agostino"
314
+ s.email = "info@lipsiasoft.com"
315
+ s.homepage = "http://www.rubyonrails.org"
316
+ s.rubyforge_project = "erails"
317
+ end
318
+
319
+ Rake::GemPackageTask.new(spec) do |pkg|
320
+ pkg.gem_spec = spec
321
+ end
322
+
323
+
324
+ # Publishing -------------------------------------------------------
325
+ desc "Publish the rails gem"
326
+ task :pgem => [:gem] do
327
+ Rake::SshFilePublisher.new("root@server1.lipsiasoft.com", "/var/www/apps/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
328
+ end
329
+
330
+ desc "Publish the release files to RubyForge."
331
+ task :release => [ :package ] do
332
+ require 'rubyforge'
333
+
334
+ packages = %w( gem ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" }
335
+
336
+ rubyforge = RubyForge.new
337
+ rubyforge.login
338
+ rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages)
339
+ end
data/bin/about ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
4
+ require 'commands/about'
data/bin/console ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/console'
data/bin/dbconsole ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../config/boot'
3
+ require 'commands/dbconsole'