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.
- data/CHANGELOG +36 -49
- data/README.rdoc +2 -1
- data/guides/assets/stylesheets/fixes.css +16 -0
- data/guides/rails_guides.rb +2 -2
- data/guides/rails_guides/generator.rb +8 -3
- data/guides/rails_guides/textile_extensions.rb +4 -2
- data/guides/source/2_2_release_notes.textile +3 -3
- data/guides/source/2_3_release_notes.textile +2 -2
- data/guides/source/3_0_release_notes.textile +14 -14
- data/guides/source/action_controller_overview.textile +54 -79
- data/guides/source/action_mailer_basics.textile +39 -9
- data/guides/source/action_view_overview.textile +257 -211
- data/guides/source/active_record_basics.textile +1 -1
- data/guides/source/active_record_querying.textile +217 -27
- data/guides/source/active_record_validations_callbacks.textile +94 -25
- data/guides/source/active_support_core_extensions.textile +109 -77
- data/guides/source/ajax_on_rails.textile +15 -150
- data/guides/source/api_documentation_guidelines.textile +12 -12
- data/guides/source/association_basics.textile +74 -60
- data/guides/source/caching_with_rails.textile +59 -60
- data/guides/source/command_line.textile +46 -47
- data/guides/source/configuring.textile +55 -37
- data/guides/source/contribute.textile +7 -7
- data/guides/source/contributing_to_ruby_on_rails.textile +14 -23
- data/guides/source/credits.html.erb +3 -3
- data/guides/source/debugging_rails_applications.textile +59 -46
- data/guides/source/form_helpers.textile +76 -31
- data/guides/source/generators.textile +39 -40
- data/guides/source/getting_started.textile +73 -94
- data/guides/source/i18n.textile +64 -58
- data/guides/source/index.html.erb +3 -3
- data/guides/source/initialization.textile +634 -3284
- data/guides/source/layout.html.erb +6 -7
- data/guides/source/layouts_and_rendering.textile +59 -60
- data/guides/source/migrations.textile +63 -59
- data/guides/source/nested_model_forms.textile +2 -2
- data/guides/source/performance_testing.textile +16 -16
- data/guides/source/plugins.textile +236 -1280
- data/guides/source/rails_application_templates.textile +37 -29
- data/guides/source/rails_on_rack.textile +4 -9
- data/guides/source/routing.textile +96 -75
- data/guides/source/ruby_on_rails_guides_guidelines.textile +19 -12
- data/guides/source/security.textile +57 -30
- data/guides/source/testing.textile +26 -24
- data/guides/w3c_validator.rb +2 -2
- data/lib/rails.rb +1 -7
- data/lib/rails/application.rb +46 -76
- data/lib/rails/application/bootstrap.rb +6 -11
- data/lib/rails/application/configuration.rb +43 -40
- data/lib/rails/application/finisher.rb +16 -4
- data/lib/rails/application/railties.rb +6 -24
- data/lib/rails/application/routes_reloader.rb +45 -0
- data/lib/rails/backtrace_cleaner.rb +1 -1
- data/lib/rails/cli.rb +7 -5
- data/lib/rails/commands.rb +27 -2
- data/lib/rails/commands/application.rb +14 -1
- data/lib/rails/commands/benchmarker.rb +3 -1
- data/lib/rails/commands/dbconsole.rb +2 -2
- data/lib/rails/commands/destroy.rb +3 -1
- data/lib/rails/commands/generate.rb +3 -1
- data/lib/rails/commands/plugin.rb +2 -7
- data/lib/rails/commands/plugin_new.rb +10 -0
- data/lib/rails/commands/profiler.rb +3 -1
- data/lib/rails/commands/server.rb +4 -0
- data/lib/rails/configuration.rb +8 -81
- data/lib/rails/console/app.rb +2 -2
- data/lib/rails/engine.rb +460 -78
- data/lib/rails/engine/configuration.rb +46 -49
- data/lib/rails/engine/railties.rb +33 -0
- data/lib/rails/generators.rb +11 -5
- data/lib/rails/generators/actions.rb +2 -27
- data/lib/rails/generators/app_base.rb +216 -0
- data/lib/rails/generators/base.rb +3 -2
- data/lib/rails/generators/erb/scaffold/templates/index.html.erb +1 -1
- data/lib/rails/generators/generated_attribute.rb +2 -1
- data/lib/rails/generators/migration.rb +6 -2
- data/lib/rails/generators/named_base.rb +79 -3
- data/lib/rails/generators/rails/app/app_generator.rb +44 -209
- data/lib/rails/generators/rails/app/templates/Gemfile +15 -31
- data/lib/rails/generators/rails/app/templates/README +2 -2
- data/lib/rails/generators/rails/app/templates/Rakefile +1 -1
- data/lib/rails/generators/rails/app/templates/{public → app/assets}/images/rails.png +0 -0
- data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +8 -0
- data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css +5 -0
- data/lib/rails/generators/rails/app/templates/app/mailers/.empty_directory +0 -0
- data/lib/rails/generators/rails/app/templates/app/models/.empty_directory +0 -0
- data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +4 -4
- data/lib/rails/generators/rails/app/templates/config/application.rb +19 -3
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml +4 -4
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml +11 -6
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml +3 -3
- data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml +1 -1
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +1 -2
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +14 -11
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +5 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +12 -0
- data/lib/rails/generators/rails/app/templates/config/locales/en.yml +1 -1
- data/lib/rails/generators/rails/app/templates/config/routes.rb +1 -1
- data/lib/rails/generators/rails/app/templates/db/{seeds.rb → seeds.rb.tt} +2 -2
- data/lib/rails/generators/rails/app/templates/public/index.html +10 -8
- data/lib/rails/generators/rails/app/templates/public/stylesheets/.empty_directory +0 -0
- data/lib/rails/generators/rails/app/templates/test/fixtures/.empty_directory +0 -0
- data/lib/rails/generators/rails/app/templates/test/functional/.empty_directory +0 -0
- data/lib/rails/generators/rails/app/templates/test/integration/.empty_directory +0 -0
- data/lib/rails/generators/rails/app/templates/test/{test_helper.rb.tt → test_helper.rb} +0 -0
- data/lib/rails/generators/rails/app/templates/test/unit/.empty_directory +0 -0
- data/lib/rails/generators/rails/assets/USAGE +20 -0
- data/lib/rails/generators/rails/assets/assets_generator.rb +39 -0
- data/lib/rails/generators/rails/assets/templates/javascript.js +2 -0
- data/lib/rails/generators/rails/assets/templates/javascript.js.coffee +3 -0
- data/lib/rails/generators/rails/assets/templates/stylesheet.css +4 -0
- data/lib/rails/generators/rails/assets/templates/stylesheet.css.scss +5 -0
- data/lib/rails/generators/rails/controller/controller_generator.rb +1 -1
- data/lib/rails/generators/rails/controller/templates/controller.rb +2 -0
- data/lib/rails/generators/rails/generator/generator_generator.rb +2 -2
- data/lib/rails/generators/rails/generator/templates/templates/.empty_directory +0 -0
- data/lib/rails/generators/rails/helper/templates/helper.rb +2 -0
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +7 -0
- data/lib/rails/generators/rails/plugin/templates/Rakefile.tt +4 -4
- data/lib/rails/generators/rails/plugin_new/USAGE +10 -0
- data/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +303 -0
- data/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec +9 -0
- data/lib/rails/generators/rails/plugin_new/templates/Gemfile +11 -0
- data/lib/rails/generators/rails/plugin_new/templates/MIT-LICENSE +20 -0
- data/lib/rails/generators/rails/plugin_new/templates/README.rdoc +3 -0
- data/lib/rails/generators/rails/plugin_new/templates/Rakefile +21 -0
- data/lib/rails/generators/rails/plugin_new/templates/app/controllers/%name%/application_controller.rb.tt +4 -0
- data/lib/rails/generators/rails/plugin_new/templates/app/helpers/%name%/application_helper.rb.tt +4 -0
- data/lib/rails/generators/rails/plugin_new/templates/app/models/.empty_directory +0 -0
- data/lib/rails/generators/rails/plugin_new/templates/config/routes.rb +6 -0
- data/lib/rails/generators/rails/plugin_new/templates/gitignore +6 -0
- data/lib/rails/generators/rails/plugin_new/templates/lib/%name%.rb +6 -0
- data/lib/rails/generators/rails/plugin_new/templates/lib/%name%/engine.rb +7 -0
- data/lib/rails/generators/rails/plugin_new/templates/lib/tasks/%name%_tasks.rake +4 -0
- data/lib/rails/generators/rails/plugin_new/templates/rails/application.rb +16 -0
- data/lib/rails/generators/rails/plugin_new/templates/rails/boot.rb +10 -0
- data/lib/rails/generators/rails/plugin_new/templates/rails/routes.rb +4 -0
- data/lib/rails/generators/rails/plugin_new/templates/script/rails.tt +5 -0
- data/lib/rails/generators/rails/plugin_new/templates/test/%name%_test.rb +7 -0
- data/lib/rails/generators/rails/plugin_new/templates/test/integration/navigation_test.rb +12 -0
- data/lib/rails/generators/rails/plugin_new/templates/test/test_helper.rb +10 -0
- data/lib/rails/generators/rails/resource/resource_generator.rb +2 -2
- data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +20 -1
- data/lib/rails/generators/rails/{stylesheets → scaffold}/templates/scaffold.css +0 -0
- data/lib/rails/generators/rails/scaffold/templates/scaffold.css.scss +58 -0
- data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +21 -19
- data/lib/rails/generators/resource_helpers.rb +3 -3
- data/lib/rails/generators/test_case.rb +2 -20
- data/lib/rails/generators/test_unit/controller/templates/functional_test.rb +5 -4
- data/lib/rails/generators/test_unit/helper/templates/helper_test.rb +2 -0
- data/lib/rails/generators/test_unit/integration/templates/integration_test.rb +3 -4
- data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb +5 -4
- data/lib/rails/generators/test_unit/model/templates/fixtures.yml +1 -1
- data/lib/rails/generators/test_unit/model/templates/unit_test.rb +5 -4
- data/lib/rails/generators/test_unit/observer/templates/unit_test.rb +5 -4
- data/lib/rails/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +3 -4
- data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb +7 -5
- data/lib/rails/info.rb +0 -1
- data/lib/rails/paths.rb +119 -65
- data/lib/rails/plugin.rb +18 -19
- data/lib/rails/rack/log_tailer.rb +1 -1
- data/lib/rails/railtie.rb +50 -47
- data/lib/rails/railtie/configurable.rb +20 -10
- data/lib/rails/railtie/configuration.rb +20 -19
- data/lib/rails/source_annotation_extractor.rb +5 -5
- data/lib/rails/tasks.rb +1 -0
- data/lib/rails/tasks/assets.rake +10 -0
- data/lib/rails/tasks/documentation.rake +2 -8
- data/lib/rails/tasks/engine.rake +69 -0
- data/lib/rails/tasks/framework.rake +4 -21
- data/lib/rails/tasks/misc.rake +1 -1
- data/lib/rails/tasks/routes.rake +2 -1
- data/lib/rails/test_help.rb +17 -1
- data/lib/rails/test_unit/railtie.rb +1 -1
- data/lib/rails/test_unit/testing.rake +8 -3
- data/lib/rails/version.rb +3 -3
- metadata +128 -100
- checksums.yaml +0 -7
- data/lib/rails/application/configurable.rb +0 -19
- data/lib/rails/console/sandbox.rb +0 -6
- data/lib/rails/deprecation.rb +0 -41
- data/lib/rails/engine/configurable.rb +0 -25
- data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml +0 -62
- data/lib/rails/generators/rails/app/templates/public/javascripts/application.js +0 -2
- data/lib/rails/generators/rails/app/templates/public/javascripts/controls.js +0 -965
- data/lib/rails/generators/rails/app/templates/public/javascripts/dragdrop.js +0 -974
- data/lib/rails/generators/rails/app/templates/public/javascripts/effects.js +0 -1123
- data/lib/rails/generators/rails/app/templates/public/javascripts/prototype.js +0 -6001
- data/lib/rails/generators/rails/app/templates/public/javascripts/rails.js +0 -202
- data/lib/rails/generators/rails/stylesheets/USAGE +0 -5
- data/lib/rails/generators/rails/stylesheets/stylesheets_generator.rb +0 -9
- data/lib/rails/info_routes.rb +0 -3
data/lib/rails/railtie.rb
CHANGED
@@ -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
|
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)
|
12
|
-
# them is responsible
|
13
|
-
#
|
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
|
17
|
+
# or after boot, then Railtie is needed.
|
18
18
|
#
|
19
|
-
# For example,
|
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
|
24
|
-
# * adding
|
25
|
-
# * setting up a subscriber
|
26
|
-
# * adding rake tasks
|
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
|
-
#
|
31
|
-
# Railtie
|
32
|
-
# during
|
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
|
-
#
|
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
|
-
#
|
38
|
-
#
|
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
|
-
#
|
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
|
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,
|
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(
|
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
|
-
|
5
|
-
base.extend ClassMethods
|
6
|
-
end
|
4
|
+
extend ActiveSupport::Concern
|
7
5
|
|
8
6
|
module ClassMethods
|
9
|
-
|
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
|
10
|
+
raise "You cannot inherit from a #{self.superclass.name} child"
|
15
11
|
end
|
16
|
-
end
|
17
12
|
|
18
|
-
|
19
|
-
|
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
|
-
#
|
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
|
-
@@
|
33
|
-
if block_given?
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
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+, +.
|
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+, +.
|
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+, +.
|
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
|
data/lib/rails/tasks.rb
CHANGED
@@ -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
|
-
|
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 <
|
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
|
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 :
|
63
|
+
invoke_from_app_generator :create_javascript_files
|
81
64
|
end
|
82
65
|
|
83
66
|
# desc "Adds new scripts to the application script/ directory"
|