railties 3.0.20 → 3.1.0.beta1

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 +36 -49
  2. data/README.rdoc +2 -1
  3. data/guides/assets/stylesheets/fixes.css +16 -0
  4. data/guides/rails_guides.rb +2 -2
  5. data/guides/rails_guides/generator.rb +8 -3
  6. data/guides/rails_guides/textile_extensions.rb +4 -2
  7. data/guides/source/2_2_release_notes.textile +3 -3
  8. data/guides/source/2_3_release_notes.textile +2 -2
  9. data/guides/source/3_0_release_notes.textile +14 -14
  10. data/guides/source/action_controller_overview.textile +54 -79
  11. data/guides/source/action_mailer_basics.textile +39 -9
  12. data/guides/source/action_view_overview.textile +257 -211
  13. data/guides/source/active_record_basics.textile +1 -1
  14. data/guides/source/active_record_querying.textile +217 -27
  15. data/guides/source/active_record_validations_callbacks.textile +94 -25
  16. data/guides/source/active_support_core_extensions.textile +109 -77
  17. data/guides/source/ajax_on_rails.textile +15 -150
  18. data/guides/source/api_documentation_guidelines.textile +12 -12
  19. data/guides/source/association_basics.textile +74 -60
  20. data/guides/source/caching_with_rails.textile +59 -60
  21. data/guides/source/command_line.textile +46 -47
  22. data/guides/source/configuring.textile +55 -37
  23. data/guides/source/contribute.textile +7 -7
  24. data/guides/source/contributing_to_ruby_on_rails.textile +14 -23
  25. data/guides/source/credits.html.erb +3 -3
  26. data/guides/source/debugging_rails_applications.textile +59 -46
  27. data/guides/source/form_helpers.textile +76 -31
  28. data/guides/source/generators.textile +39 -40
  29. data/guides/source/getting_started.textile +73 -94
  30. data/guides/source/i18n.textile +64 -58
  31. data/guides/source/index.html.erb +3 -3
  32. data/guides/source/initialization.textile +634 -3284
  33. data/guides/source/layout.html.erb +6 -7
  34. data/guides/source/layouts_and_rendering.textile +59 -60
  35. data/guides/source/migrations.textile +63 -59
  36. data/guides/source/nested_model_forms.textile +2 -2
  37. data/guides/source/performance_testing.textile +16 -16
  38. data/guides/source/plugins.textile +236 -1280
  39. data/guides/source/rails_application_templates.textile +37 -29
  40. data/guides/source/rails_on_rack.textile +4 -9
  41. data/guides/source/routing.textile +96 -75
  42. data/guides/source/ruby_on_rails_guides_guidelines.textile +19 -12
  43. data/guides/source/security.textile +57 -30
  44. data/guides/source/testing.textile +26 -24
  45. data/guides/w3c_validator.rb +2 -2
  46. data/lib/rails.rb +1 -7
  47. data/lib/rails/application.rb +46 -76
  48. data/lib/rails/application/bootstrap.rb +6 -11
  49. data/lib/rails/application/configuration.rb +43 -40
  50. data/lib/rails/application/finisher.rb +16 -4
  51. data/lib/rails/application/railties.rb +6 -24
  52. data/lib/rails/application/routes_reloader.rb +45 -0
  53. data/lib/rails/backtrace_cleaner.rb +1 -1
  54. data/lib/rails/cli.rb +7 -5
  55. data/lib/rails/commands.rb +27 -2
  56. data/lib/rails/commands/application.rb +14 -1
  57. data/lib/rails/commands/benchmarker.rb +3 -1
  58. data/lib/rails/commands/dbconsole.rb +2 -2
  59. data/lib/rails/commands/destroy.rb +3 -1
  60. data/lib/rails/commands/generate.rb +3 -1
  61. data/lib/rails/commands/plugin.rb +2 -7
  62. data/lib/rails/commands/plugin_new.rb +10 -0
  63. data/lib/rails/commands/profiler.rb +3 -1
  64. data/lib/rails/commands/server.rb +4 -0
  65. data/lib/rails/configuration.rb +8 -81
  66. data/lib/rails/console/app.rb +2 -2
  67. data/lib/rails/engine.rb +460 -78
  68. data/lib/rails/engine/configuration.rb +46 -49
  69. data/lib/rails/engine/railties.rb +33 -0
  70. data/lib/rails/generators.rb +11 -5
  71. data/lib/rails/generators/actions.rb +2 -27
  72. data/lib/rails/generators/app_base.rb +216 -0
  73. data/lib/rails/generators/base.rb +3 -2
  74. data/lib/rails/generators/erb/scaffold/templates/index.html.erb +1 -1
  75. data/lib/rails/generators/generated_attribute.rb +2 -1
  76. data/lib/rails/generators/migration.rb +6 -2
  77. data/lib/rails/generators/named_base.rb +79 -3
  78. data/lib/rails/generators/rails/app/app_generator.rb +44 -209
  79. data/lib/rails/generators/rails/app/templates/Gemfile +15 -31
  80. data/lib/rails/generators/rails/app/templates/README +2 -2
  81. data/lib/rails/generators/rails/app/templates/Rakefile +1 -1
  82. data/lib/rails/generators/rails/app/templates/{public → app/assets}/images/rails.png +0 -0
  83. data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +8 -0
  84. data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css +5 -0
  85. data/lib/rails/generators/rails/app/templates/app/mailers/.empty_directory +0 -0
  86. data/lib/rails/generators/rails/app/templates/app/models/.empty_directory +0 -0
  87. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +4 -4
  88. data/lib/rails/generators/rails/app/templates/config/application.rb +19 -3
  89. data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml +4 -4
  90. data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml +11 -6
  91. data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml +3 -3
  92. data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml +1 -1
  93. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +1 -2
  94. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +14 -11
  95. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +5 -1
  96. data/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt +1 -1
  97. data/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +12 -0
  98. data/lib/rails/generators/rails/app/templates/config/locales/en.yml +1 -1
  99. data/lib/rails/generators/rails/app/templates/config/routes.rb +1 -1
  100. data/lib/rails/generators/rails/app/templates/db/{seeds.rb → seeds.rb.tt} +2 -2
  101. data/lib/rails/generators/rails/app/templates/public/index.html +10 -8
  102. data/lib/rails/generators/rails/app/templates/public/stylesheets/.empty_directory +0 -0
  103. data/lib/rails/generators/rails/app/templates/test/fixtures/.empty_directory +0 -0
  104. data/lib/rails/generators/rails/app/templates/test/functional/.empty_directory +0 -0
  105. data/lib/rails/generators/rails/app/templates/test/integration/.empty_directory +0 -0
  106. data/lib/rails/generators/rails/app/templates/test/{test_helper.rb.tt → test_helper.rb} +0 -0
  107. data/lib/rails/generators/rails/app/templates/test/unit/.empty_directory +0 -0
  108. data/lib/rails/generators/rails/assets/USAGE +20 -0
  109. data/lib/rails/generators/rails/assets/assets_generator.rb +39 -0
  110. data/lib/rails/generators/rails/assets/templates/javascript.js +2 -0
  111. data/lib/rails/generators/rails/assets/templates/javascript.js.coffee +3 -0
  112. data/lib/rails/generators/rails/assets/templates/stylesheet.css +4 -0
  113. data/lib/rails/generators/rails/assets/templates/stylesheet.css.scss +5 -0
  114. data/lib/rails/generators/rails/controller/controller_generator.rb +1 -1
  115. data/lib/rails/generators/rails/controller/templates/controller.rb +2 -0
  116. data/lib/rails/generators/rails/generator/generator_generator.rb +2 -2
  117. data/lib/rails/generators/rails/generator/templates/templates/.empty_directory +0 -0
  118. data/lib/rails/generators/rails/helper/templates/helper.rb +2 -0
  119. data/lib/rails/generators/rails/plugin/plugin_generator.rb +7 -0
  120. data/lib/rails/generators/rails/plugin/templates/Rakefile.tt +4 -4
  121. data/lib/rails/generators/rails/plugin_new/USAGE +10 -0
  122. data/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +303 -0
  123. data/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec +9 -0
  124. data/lib/rails/generators/rails/plugin_new/templates/Gemfile +11 -0
  125. data/lib/rails/generators/rails/plugin_new/templates/MIT-LICENSE +20 -0
  126. data/lib/rails/generators/rails/plugin_new/templates/README.rdoc +3 -0
  127. data/lib/rails/generators/rails/plugin_new/templates/Rakefile +21 -0
  128. data/lib/rails/generators/rails/plugin_new/templates/app/controllers/%name%/application_controller.rb.tt +4 -0
  129. data/lib/rails/generators/rails/plugin_new/templates/app/helpers/%name%/application_helper.rb.tt +4 -0
  130. data/lib/rails/generators/rails/plugin_new/templates/app/models/.empty_directory +0 -0
  131. data/lib/rails/generators/rails/plugin_new/templates/config/routes.rb +6 -0
  132. data/lib/rails/generators/rails/plugin_new/templates/gitignore +6 -0
  133. data/lib/rails/generators/rails/plugin_new/templates/lib/%name%.rb +6 -0
  134. data/lib/rails/generators/rails/plugin_new/templates/lib/%name%/engine.rb +7 -0
  135. data/lib/rails/generators/rails/plugin_new/templates/lib/tasks/%name%_tasks.rake +4 -0
  136. data/lib/rails/generators/rails/plugin_new/templates/rails/application.rb +16 -0
  137. data/lib/rails/generators/rails/plugin_new/templates/rails/boot.rb +10 -0
  138. data/lib/rails/generators/rails/plugin_new/templates/rails/routes.rb +4 -0
  139. data/lib/rails/generators/rails/plugin_new/templates/script/rails.tt +5 -0
  140. data/lib/rails/generators/rails/plugin_new/templates/test/%name%_test.rb +7 -0
  141. data/lib/rails/generators/rails/plugin_new/templates/test/integration/navigation_test.rb +12 -0
  142. data/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb +10 -0
  143. data/lib/rails/generators/rails/resource/resource_generator.rb +2 -2
  144. data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +20 -1
  145. data/lib/rails/generators/rails/{stylesheets → scaffold}/templates/scaffold.css +0 -0
  146. data/lib/rails/generators/rails/scaffold/templates/scaffold.css.scss +58 -0
  147. data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +21 -19
  148. data/lib/rails/generators/resource_helpers.rb +3 -3
  149. data/lib/rails/generators/test_case.rb +2 -20
  150. data/lib/rails/generators/test_unit/controller/templates/functional_test.rb +5 -4
  151. data/lib/rails/generators/test_unit/helper/templates/helper_test.rb +2 -0
  152. data/lib/rails/generators/test_unit/integration/templates/integration_test.rb +3 -4
  153. data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb +5 -4
  154. data/lib/rails/generators/test_unit/model/templates/fixtures.yml +1 -1
  155. data/lib/rails/generators/test_unit/model/templates/unit_test.rb +5 -4
  156. data/lib/rails/generators/test_unit/observer/templates/unit_test.rb +5 -4
  157. data/lib/rails/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +3 -4
  158. data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb +7 -5
  159. data/lib/rails/info.rb +0 -1
  160. data/lib/rails/paths.rb +119 -65
  161. data/lib/rails/plugin.rb +18 -19
  162. data/lib/rails/rack/log_tailer.rb +1 -1
  163. data/lib/rails/railtie.rb +50 -47
  164. data/lib/rails/railtie/configurable.rb +20 -10
  165. data/lib/rails/railtie/configuration.rb +20 -19
  166. data/lib/rails/source_annotation_extractor.rb +5 -5
  167. data/lib/rails/tasks.rb +1 -0
  168. data/lib/rails/tasks/assets.rake +10 -0
  169. data/lib/rails/tasks/documentation.rake +2 -8
  170. data/lib/rails/tasks/engine.rake +69 -0
  171. data/lib/rails/tasks/framework.rake +4 -21
  172. data/lib/rails/tasks/misc.rake +1 -1
  173. data/lib/rails/tasks/routes.rake +2 -1
  174. data/lib/rails/test_help.rb +17 -1
  175. data/lib/rails/test_unit/railtie.rb +1 -1
  176. data/lib/rails/test_unit/testing.rake +8 -3
  177. data/lib/rails/version.rb +3 -3
  178. metadata +128 -100
  179. checksums.yaml +0 -7
  180. data/lib/rails/application/configurable.rb +0 -19
  181. data/lib/rails/console/sandbox.rb +0 -6
  182. data/lib/rails/deprecation.rb +0 -41
  183. data/lib/rails/engine/configurable.rb +0 -25
  184. data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml +0 -62
  185. data/lib/rails/generators/rails/app/templates/public/javascripts/application.js +0 -2
  186. data/lib/rails/generators/rails/app/templates/public/javascripts/controls.js +0 -965
  187. data/lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js +0 -974
  188. data/lib/rails/generators/rails/app/templates/public/javascripts/effects.js +0 -1123
  189. data/lib/rails/generators/rails/app/templates/public/javascripts/prototype.js +0 -6001
  190. data/lib/rails/generators/rails/app/templates/public/javascripts/rails.js +0 -202
  191. data/lib/rails/generators/rails/stylesheets/USAGE +0 -5
  192. data/lib/rails/generators/rails/stylesheets/stylesheets_generator.rb +0 -9
  193. data/lib/rails/info_routes.rb +0 -3
@@ -19,7 +19,7 @@ module Rails
19
19
  def tail!
20
20
  @file.seek @cursor
21
21
 
22
- if !@file.eof?
22
+ unless @file.eof?
23
23
  contents = @file.read
24
24
  @cursor = @file.tell
25
25
  $stdout.print contents
@@ -1,58 +1,45 @@
1
1
  require 'rails/initializable'
2
2
  require 'rails/configuration'
3
3
  require 'active_support/inflector'
4
- require 'active_support/deprecation'
5
4
 
6
5
  module Rails
7
- # Railtie is the core of the Rails Framework and provides several hooks to extend
6
+ # Railtie is the core of the Rails framework and provides several hooks to extend
8
7
  # Rails and/or modify the initialization process.
9
8
  #
10
9
  # Every major component of Rails (Action Mailer, Action Controller,
11
- # Action View, Active Record and Active Resource) are all Railties, so each of
12
- # them is responsible to set their own initialization. This makes, for example,
13
- # Rails absent of any Active Record hook, allowing any other ORM framework to hook in.
10
+ # Action View, Active Record and Active Resource) is a Railtie. Each of
11
+ # them is responsible for their own initialization. This makes Rails itself
12
+ # absent of any component hooks, allowing other components to be used in
13
+ # place of any of the Rails defaults.
14
14
  #
15
15
  # Developing a Rails extension does _not_ require any implementation of
16
16
  # Railtie, but if you need to interact with the Rails framework during
17
- # or after boot, then Railtie is what you need to do that interaction.
17
+ # or after boot, then Railtie is needed.
18
18
  #
19
- # For example, the following would need you to implement Railtie in your
20
- # plugin:
19
+ # For example, an extension doing any of the following would require Railtie:
21
20
  #
22
21
  # * creating initializers
23
- # * configuring a Rails framework or the Application, like setting a generator
24
- # * adding Rails config.* keys to the environment
25
- # * setting up a subscriber to the Rails +ActiveSupport::Notifications+
26
- # * adding rake tasks into rails
22
+ # * configuring a Rails framework for the application, like setting a generator
23
+ # * adding config.* keys to the environment
24
+ # * setting up a subscriber with ActiveSupport::Notifications
25
+ # * adding rake tasks
27
26
  #
28
27
  # == Creating your Railtie
29
28
  #
30
- # Implementing Railtie in your Rails extension is done by creating a class
31
- # Railtie that has your extension name and making sure that this gets loaded
32
- # during boot time of the Rails stack.
29
+ # To extend Rails using Railtie, create a Railtie class which inherits
30
+ # from Rails::Railtie within your extension's namespace. This class must be
31
+ # loaded during the Rails boot process.
33
32
  #
34
- # You can do this however you wish, but here is an example if you want to provide
35
- # it for a gem that can be used with or without Rails:
33
+ # The following example demonstrates an extension which can be used with or without Rails.
36
34
  #
37
- # * Create a file (say, lib/my_gem/railtie.rb) which contains class Railtie inheriting from
38
- # Rails::Railtie and is namespaced to your gem:
39
- #
40
- # # lib/my_gem/railtie.rb
41
- # module MyGem
42
- # class Railtie < Rails::Railtie
43
- # end
35
+ # # lib/my_gem/railtie.rb
36
+ # module MyGem
37
+ # class Railtie < Rails::Railtie
44
38
  # end
39
+ # end
45
40
  #
46
- # * Require your own gem as well as rails in this file:
47
- #
48
- # # lib/my_gem/railtie.rb
49
- # require 'my_gem'
50
- # require 'rails'
51
- #
52
- # module MyGem
53
- # class Railtie < Rails::Railtie
54
- # end
55
- # end
41
+ # # lib/my_gem.rb
42
+ # require 'my_gem/railtie' if defined?(Rails)
56
43
  #
57
44
  # == Initializers
58
45
  #
@@ -87,7 +74,7 @@ module Rails
87
74
  # config.app_generators.orm :my_railtie_orm
88
75
  #
89
76
  # # Add a to_prepare block which is executed once in production
90
- # # and before which request in development
77
+ # # and before each request in development
91
78
  # config.to_prepare do
92
79
  # MyRailtie.setup!
93
80
  # end
@@ -131,25 +118,19 @@ module Rails
131
118
  ABSTRACT_RAILTIES = %w(Rails::Railtie Rails::Plugin Rails::Engine Rails::Application)
132
119
 
133
120
  class << self
121
+ private :new
122
+
134
123
  def subclasses
135
124
  @subclasses ||= []
136
125
  end
137
126
 
138
127
  def inherited(base)
139
128
  unless base.abstract_railtie?
140
- base.send(:include, self::Configurable)
129
+ base.send(:include, Railtie::Configurable)
141
130
  subclasses << base
142
131
  end
143
132
  end
144
133
 
145
- def railtie_name(*)
146
- ActiveSupport::Deprecation.warn "railtie_name is deprecated and has no effect", caller
147
- end
148
-
149
- def log_subscriber(*)
150
- ActiveSupport::Deprecation.warn "log_subscriber is deprecated and has no effect", caller
151
- end
152
-
153
134
  def rake_tasks(&blk)
154
135
  @rake_tasks ||= []
155
136
  @rake_tasks << blk if blk
@@ -171,18 +152,40 @@ module Rails
171
152
  def abstract_railtie?
172
153
  ABSTRACT_RAILTIES.include?(name)
173
154
  end
155
+
156
+ def railtie_name(name = nil)
157
+ @railtie_name = name.to_s if name
158
+ @railtie_name ||= generate_railtie_name(self.name)
159
+ end
160
+
161
+ protected
162
+ def generate_railtie_name(class_or_module)
163
+ ActiveSupport::Inflector.underscore(class_or_module).gsub("/", "_")
164
+ end
165
+ end
166
+
167
+ delegate :railtie_name, :to => "self.class"
168
+
169
+ def config
170
+ @config ||= Railtie::Configuration.new
174
171
  end
175
172
 
176
173
  def eager_load!
177
174
  end
178
175
 
179
- def load_console
180
- self.class.console.each(&:call)
176
+ def load_console(sandbox=false)
177
+ self.class.console.each { |block| block.call(sandbox) }
181
178
  end
182
179
 
183
180
  def load_tasks
184
- self.class.extend Rake::DSL if defined? Rake::DSL
185
181
  self.class.rake_tasks.each(&:call)
182
+
183
+ # load also tasks from all superclasses
184
+ klass = self.class.superclass
185
+ while klass.respond_to?(:rake_tasks)
186
+ klass.rake_tasks.each { |t| self.instance_exec(&t) }
187
+ klass = klass.superclass
188
+ end
186
189
  end
187
190
 
188
191
  def load_generators
@@ -1,22 +1,32 @@
1
1
  module Rails
2
2
  class Railtie
3
3
  module Configurable
4
- def self.included(base)
5
- base.extend ClassMethods
6
- end
4
+ extend ActiveSupport::Concern
7
5
 
8
6
  module ClassMethods
9
- def config
10
- @config ||= Railtie::Configuration.new
11
- end
7
+ delegate :config, :to => :instance
12
8
 
13
9
  def inherited(base)
14
- raise "You cannot inherit from a Rails::Railtie child"
10
+ raise "You cannot inherit from a #{self.superclass.name} child"
15
11
  end
16
- end
17
12
 
18
- def config
19
- self.class.config
13
+ def instance
14
+ @instance ||= new
15
+ end
16
+
17
+ def respond_to?(*args)
18
+ super || instance.respond_to?(*args)
19
+ end
20
+
21
+ def configure(&block)
22
+ class_eval(&block)
23
+ end
24
+
25
+ protected
26
+
27
+ def method_missing(*args, &block)
28
+ instance.send(*args, &block)
29
+ end
20
30
  end
21
31
  end
22
32
  end
@@ -16,48 +16,49 @@ module Rails
16
16
  @@app_middleware ||= Rails::Configuration::MiddlewareStackProxy.new
17
17
  end
18
18
 
19
- # Holds generators configuration:
20
- #
21
- # config.app_generators do |g|
22
- # g.orm :datamapper, :migration => true
23
- # g.template_engine :haml
24
- # g.test_framework :rspec
25
- # end
26
- #
27
- # If you want to disable color in console, do:
28
- #
29
- # config.app_generators.colorize_logging = false
19
+ # This allows you to modify application's generators from Railties.
30
20
  #
21
+ # Values set on app_generators will become defaults for application, unless
22
+ # application overwrites them.
31
23
  def app_generators
32
- @@generators ||= Rails::Configuration::Generators.new
33
- if block_given?
34
- yield @@generators
35
- else
36
- @@generators
37
- end
24
+ @@app_generators ||= Rails::Configuration::Generators.new
25
+ yield(@@app_generators) if block_given?
26
+ @@app_generators
27
+ end
28
+
29
+ def generators(&block) #:nodoc
30
+ ActiveSupport::Deprecation.warn "config.generators in Rails::Railtie is deprecated. Please use config.app_generators instead."
31
+ app_generators(&block)
38
32
  end
39
- alias :generators :app_generators
40
33
 
34
+ # First configurable block to run. Called before any initializers are run.
41
35
  def before_configuration(&block)
42
36
  ActiveSupport.on_load(:before_configuration, :yield => true, &block)
43
37
  end
44
38
 
39
+ # Third configurable block to run. Does not run if config.cache_classes
40
+ # set to false.
45
41
  def before_eager_load(&block)
46
42
  ActiveSupport.on_load(:before_eager_load, :yield => true, &block)
47
43
  end
48
44
 
45
+ # Second configurable block to run. Called before frameworks initialize.
49
46
  def before_initialize(&block)
50
47
  ActiveSupport.on_load(:before_initialize, :yield => true, &block)
51
48
  end
52
49
 
50
+ # Last configurable block to run. Called after frameworks initialize.
53
51
  def after_initialize(&block)
54
52
  ActiveSupport.on_load(:after_initialize, :yield => true, &block)
55
53
  end
56
54
 
55
+ # Array of callbacks defined by #to_prepare.
57
56
  def to_prepare_blocks
58
57
  @@to_prepare_blocks ||= []
59
58
  end
60
59
 
60
+ # Defines generic callbacks to run before #after_initialize. Useful for
61
+ # Rails::Railtie subclasses.
61
62
  def to_prepare(&blk)
62
63
  to_prepare_blocks << blk if blk
63
64
  end
@@ -79,4 +80,4 @@ module Rails
79
80
  end
80
81
  end
81
82
  end
82
- end
83
+ end
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # Annotations are looked for in comments and modulus whitespace they have to
13
13
  # start with the tag optionally followed by a colon. Everything up to the end
14
- # of the line (or closing ERb comment tag) is considered to be their text.
14
+ # of the line (or closing ERB comment tag) is considered to be their text.
15
15
  class SourceAnnotationExtractor
16
16
  class Annotation < Struct.new(:line, :tag, :text)
17
17
 
@@ -30,7 +30,7 @@ class SourceAnnotationExtractor
30
30
 
31
31
  # Prints all annotations with tag +tag+ under the root directories +app+, +lib+,
32
32
  # and +test+ (recursively). Only filenames with extension +.builder+, +.rb+,
33
- # +.rxml+, +.rjs+, +.rhtml+, or +.erb+ are taken into account. The +options+
33
+ # +.rxml+, +.rhtml+, or +.erb+ are taken into account. The +options+
34
34
  # hash is passed to each annotation's +to_s+.
35
35
  #
36
36
  # This class method is the single entry point for the rake tasks.
@@ -47,7 +47,7 @@ class SourceAnnotationExtractor
47
47
 
48
48
  # Returns a hash that maps filenames under +dirs+ (recursively) to arrays
49
49
  # with their annotations. Only files with annotations are included, and only
50
- # those with extension +.builder+, +.rb+, +.rxml+, +.rjs+, +.rhtml+, and +.erb+
50
+ # those with extension +.builder+, +.rb+, +.rxml+, +.rhtml+, and +.erb+
51
51
  # are taken into account.
52
52
  def find(dirs=%w(app lib test))
53
53
  dirs.inject({}) { |h, dir| h.update(find_in(dir)) }
@@ -55,7 +55,7 @@ class SourceAnnotationExtractor
55
55
 
56
56
  # Returns a hash that maps filenames under +dir+ (recursively) to arrays
57
57
  # with their annotations. Only files with annotations are included, and only
58
- # those with extension +.builder+, +.rb+, +.rxml+, +.rjs+, +.rhtml+, and +.erb+
58
+ # those with extension +.builder+, +.rb+, +.rxml+, +.rhtml+, and +.erb+
59
59
  # are taken into account.
60
60
  def find_in(dir)
61
61
  results = {}
@@ -99,4 +99,4 @@ class SourceAnnotationExtractor
99
99
  puts
100
100
  end
101
101
  end
102
- end
102
+ end
@@ -3,6 +3,7 @@ $VERBOSE = nil
3
3
  # Load Rails rakefile extensions
4
4
  %w(
5
5
  annotations
6
+ assets
6
7
  documentation
7
8
  framework
8
9
  log
@@ -0,0 +1,10 @@
1
+ namespace :assets do
2
+ desc "Compile all the assets named in config.assets.precompile"
3
+ task :precompile => :environment do
4
+ # Give assets access to asset_path
5
+ ActionView::Helpers::SprocketsHelper
6
+
7
+ assets = Rails.application.config.assets.precompile
8
+ Rails.application.assets.precompile(*assets)
9
+ end
10
+ end
@@ -1,13 +1,7 @@
1
- begin
2
- require 'rdoc/task'
3
- rescue LoadError
4
- require 'rdoc/rdoc'
5
- require 'rake/rdoctask'
6
- RDoc::Task = Rake::RDocTask
7
- end
1
+ require 'rake/rdoctask'
8
2
 
9
3
  # Monkey-patch to remove redoc'ing and clobber descriptions to cut down on rake -T noise
10
- class RDocTaskWithoutDescriptions < RDoc::Task
4
+ class RDocTaskWithoutDescriptions < Rake::RDocTask
11
5
  def define
12
6
  task rdoc_task_name
13
7
 
@@ -0,0 +1,69 @@
1
+ task "load_app" do
2
+ namespace :app do
3
+ load APP_RAKEFILE
4
+ end
5
+
6
+ if !defined?(ENGINE_PATH) || !ENGINE_PATH
7
+ ENGINE_PATH = find_engine_path(APP_RAKEFILE)
8
+ end
9
+ end
10
+
11
+ def app_task(name)
12
+ task name => [:load_app, "app:db:#{name}"]
13
+ end
14
+
15
+ namespace :db do
16
+ app_task "reset"
17
+
18
+ desc "Migrate the database (options: VERSION=x, VERBOSE=false)."
19
+ app_task "migrate"
20
+ app_task "migrate:up"
21
+ app_task "migrate:down"
22
+ app_task "migrate:redo"
23
+ app_task "migrate:reset"
24
+
25
+ desc "Display status of migrations"
26
+ app_task "migrate:status"
27
+
28
+ desc 'Create the database from config/database.yml for the current Rails.env (use db:create:all to create all dbs in the config)'
29
+ app_task "create"
30
+ app_task "create:all"
31
+
32
+ desc 'Drops the database for the current Rails.env (use db:drop:all to drop all databases)'
33
+ app_task "drop"
34
+ app_task "drop:all"
35
+
36
+ desc "Load fixtures into the current environment's database."
37
+ app_task "fixtures:load"
38
+
39
+ desc "Rolls the schema back to the previous version (specify steps w/ STEP=n)."
40
+ app_task "rollback"
41
+
42
+ desc "Create a db/schema.rb file that can be portably used against any DB supported by AR"
43
+ app_task "schema:dump"
44
+
45
+ desc "Load a schema.rb file into the database"
46
+ app_task "schema:load"
47
+
48
+ desc "Load the seed data from db/seeds.rb"
49
+ app_task "seed"
50
+
51
+ desc "Create the database, load the schema, and initialize with the seed data (use db:reset to also drop the db first)"
52
+ app_task "setup"
53
+
54
+ desc "Dump the database structure to an SQL file"
55
+ app_task "structure:dump"
56
+
57
+ desc "Retrieves the current schema version number"
58
+ app_task "version"
59
+ end
60
+
61
+ def find_engine_path(path)
62
+ return if path == "/"
63
+
64
+ if Rails::Engine.find(path)
65
+ path
66
+ else
67
+ find_engine_path(File.expand_path('..', path))
68
+ end
69
+ end
@@ -1,32 +1,15 @@
1
1
  namespace :rails do
2
- namespace :freeze do
3
- # desc "The rails:freeze:gems is deprecated, please use bundle install instead"
4
- task :gems do
5
- abort "The rails:freeze:gems is deprecated, please use bundle install instead"
6
- end
7
-
8
- # desc 'The freeze:edge command has been deprecated, specify the path setting in your app Gemfile instead and bundle install'
9
- task :edge do
10
- abort 'The freeze:edge command has been deprecated, specify the path setting in your app Gemfile instead and bundle install'
11
- end
12
- end
13
-
14
- # desc 'The unfreeze command has been deprecated, please use bundler commands instead'
15
- task :unfreeze do
16
- abort 'The unfreeze command has been deprecated, please use bundler commands instead'
17
- end
18
-
19
2
  desc "Update both configs and public/javascripts from Rails (or use just update:javascripts or update:configs)"
20
3
  task :update => [ "update:configs", "update:javascripts", "update:scripts", "update:application_controller" ]
21
4
 
22
- desc "Applies the template supplied by LOCATION=(/path/to/template) or URL"
5
+ desc "Applies the template supplied by LOCATION=/path/to/template"
23
6
  task :template do
24
7
  template = ENV["LOCATION"]
25
- raise "No LOCATION value given. Please set LOCATION either as path to a file or a URL" if template.blank?
26
8
  template = File.expand_path(template) if template !~ %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://}
9
+
27
10
  require 'rails/generators'
28
11
  require 'rails/generators/rails/app/app_generator'
29
- generator = Rails::Generators::AppGenerator.new [Rails.root], {}, :destination_root => Rails.root
12
+ generator = Rails::Generators::AppGenerator.new [ Rails.root ], {}, :destination_root => Rails.root
30
13
  generator.apply template, :verbose => false
31
14
  end
32
15
 
@@ -77,7 +60,7 @@ namespace :rails do
77
60
 
78
61
  # desc "Update Prototype javascripts from your current rails install"
79
62
  task :javascripts do
80
- invoke_from_app_generator :create_prototype_files
63
+ invoke_from_app_generator :create_javascript_files
81
64
  end
82
65
 
83
66
  # desc "Adds new scripts to the application script/ directory"