railties 3.1.12 → 3.2.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +2292 -41
- data/README.rdoc +14 -5
- data/bin/rails +7 -0
- data/guides/code/getting_started/Gemfile +27 -0
- data/guides/code/getting_started/README.rdoc +261 -0
- data/guides/code/getting_started/Rakefile +7 -0
- data/guides/code/getting_started/app/assets/images/rails.png +0 -0
- data/guides/code/getting_started/app/assets/javascripts/application.js +9 -0
- data/guides/code/getting_started/app/assets/javascripts/comments.js.coffee +3 -0
- data/guides/code/getting_started/app/assets/javascripts/home.js.coffee +3 -0
- data/guides/code/getting_started/app/assets/javascripts/posts.js.coffee +3 -0
- data/guides/code/getting_started/app/assets/stylesheets/application.css +7 -0
- data/guides/code/getting_started/app/assets/stylesheets/comments.css.scss +3 -0
- data/guides/code/getting_started/app/assets/stylesheets/home.css.scss +3 -0
- data/guides/code/getting_started/app/assets/stylesheets/posts.css.scss +3 -0
- data/guides/code/getting_started/app/assets/stylesheets/scaffolds.css.scss +56 -0
- data/guides/code/getting_started/app/controllers/application_controller.rb +3 -0
- data/guides/code/getting_started/app/controllers/comments_controller.rb +16 -0
- data/guides/code/getting_started/app/controllers/home_controller.rb +5 -0
- data/guides/code/getting_started/app/controllers/posts_controller.rb +84 -0
- data/guides/code/getting_started/app/helpers/application_helper.rb +2 -0
- data/guides/code/getting_started/app/helpers/comments_helper.rb +2 -0
- data/guides/code/getting_started/app/helpers/home_helper.rb +2 -0
- data/guides/code/getting_started/app/helpers/posts_helper.rb +5 -0
- data/guides/code/getting_started/app/models/comment.rb +3 -0
- data/guides/code/getting_started/app/models/post.rb +11 -0
- data/guides/code/getting_started/app/models/tag.rb +3 -0
- data/guides/code/getting_started/app/views/comments/_comment.html.erb +15 -0
- data/guides/code/getting_started/app/views/comments/_form.html.erb +13 -0
- data/guides/code/getting_started/app/views/home/index.html.erb +2 -0
- data/guides/code/getting_started/app/views/layouts/application.html.erb +14 -0
- data/guides/code/getting_started/app/views/posts/_form.html.erb +32 -0
- data/guides/code/getting_started/app/views/posts/edit.html.erb +6 -0
- data/guides/code/getting_started/app/views/posts/index.html.erb +27 -0
- data/guides/code/getting_started/app/views/posts/new.html.erb +5 -0
- data/guides/code/getting_started/app/views/posts/show.html.erb +31 -0
- data/guides/code/getting_started/app/views/tags/_form.html.erb +12 -0
- data/guides/code/getting_started/config.ru +4 -0
- data/guides/code/getting_started/config/application.rb +53 -0
- data/guides/code/getting_started/config/boot.rb +6 -0
- data/guides/code/getting_started/config/database.yml +25 -0
- data/guides/code/getting_started/config/environment.rb +5 -0
- data/guides/code/getting_started/config/environments/development.rb +37 -0
- data/guides/code/getting_started/config/environments/production.rb +67 -0
- data/guides/code/getting_started/config/environments/test.rb +37 -0
- data/guides/code/getting_started/config/initializers/backtrace_silencers.rb +7 -0
- data/guides/code/getting_started/config/initializers/inflections.rb +10 -0
- data/guides/code/getting_started/config/initializers/mime_types.rb +5 -0
- data/guides/code/getting_started/config/initializers/secret_token.rb +7 -0
- data/guides/code/getting_started/config/initializers/session_store.rb +8 -0
- data/guides/code/getting_started/config/initializers/wrap_parameters.rb +14 -0
- data/guides/code/getting_started/config/locales/en.yml +5 -0
- data/guides/code/getting_started/config/routes.rb +64 -0
- data/guides/code/getting_started/db/migrate/20110901012504_create_posts.rb +11 -0
- data/guides/code/getting_started/db/migrate/20110901012815_create_comments.rb +12 -0
- data/guides/code/getting_started/db/migrate/20110901013701_create_tags.rb +11 -0
- data/guides/code/getting_started/db/schema.rb +43 -0
- data/guides/code/getting_started/db/seeds.rb +7 -0
- data/guides/code/getting_started/doc/README_FOR_APP +2 -0
- data/guides/code/getting_started/public/404.html +26 -0
- data/guides/code/getting_started/public/422.html +26 -0
- data/guides/code/getting_started/public/500.html +26 -0
- data/guides/code/getting_started/public/favicon.ico +0 -0
- data/guides/code/getting_started/public/robots.txt +5 -0
- data/guides/code/getting_started/script/rails +6 -0
- data/guides/code/getting_started/test/fixtures/comments.yml +11 -0
- data/guides/code/getting_started/test/fixtures/posts.yml +11 -0
- data/guides/code/getting_started/test/fixtures/tags.yml +9 -0
- data/guides/code/getting_started/test/functional/comments_controller_test.rb +7 -0
- data/guides/code/getting_started/test/functional/home_controller_test.rb +9 -0
- data/guides/code/getting_started/test/functional/posts_controller_test.rb +49 -0
- data/guides/code/getting_started/test/performance/browsing_test.rb +12 -0
- data/guides/code/getting_started/test/test_helper.rb +13 -0
- data/guides/code/getting_started/test/unit/comment_test.rb +7 -0
- data/guides/code/getting_started/test/unit/helpers/comments_helper_test.rb +4 -0
- data/guides/code/getting_started/test/unit/helpers/home_helper_test.rb +4 -0
- data/guides/code/getting_started/test/unit/helpers/posts_helper_test.rb +4 -0
- data/guides/code/getting_started/test/unit/post_test.rb +7 -0
- data/guides/code/getting_started/test/unit/tag_test.rb +7 -0
- data/guides/rails_guides/generator.rb +2 -1
- data/guides/source/3_0_release_notes.textile +2 -2
- data/guides/source/3_1_release_notes.textile +3 -110
- data/guides/source/action_controller_overview.textile +11 -13
- data/guides/source/action_mailer_basics.textile +7 -18
- data/guides/source/action_view_overview.textile +78 -9
- data/guides/source/active_model_basics.textile +205 -0
- data/guides/source/active_record_basics.textile +31 -31
- data/guides/source/active_record_querying.textile +288 -67
- data/guides/source/active_record_validations_callbacks.textile +69 -75
- data/guides/source/active_resource_basics.textile +48 -2
- data/guides/source/active_support_core_extensions.textile +145 -24
- data/guides/source/ajax_on_rails.textile +65 -7
- data/guides/source/api_documentation_guidelines.textile +0 -6
- data/guides/source/asset_pipeline.textile +2 -2
- data/guides/source/association_basics.textile +25 -34
- data/guides/source/caching_with_rails.textile +12 -17
- data/guides/source/command_line.textile +29 -19
- data/guides/source/configuring.textile +40 -18
- data/guides/source/contributing_to_ruby_on_rails.textile +11 -18
- data/guides/source/debugging_rails_applications.textile +10 -21
- data/guides/source/engines.textile +618 -0
- data/guides/source/form_helpers.textile +1 -12
- data/guides/source/generators.textile +9 -11
- data/guides/source/getting_started.textile +152 -152
- data/guides/source/i18n.textile +4 -5
- data/guides/source/index.html.erb +0 -1
- data/guides/source/initialization.textile +26 -26
- data/guides/source/layouts_and_rendering.textile +97 -61
- data/guides/source/migrations.textile +380 -161
- data/guides/source/performance_testing.textile +4 -10
- data/guides/source/plugins.textile +11 -19
- data/guides/source/rails_application_templates.textile +12 -4
- data/guides/source/rails_on_rack.textile +25 -19
- data/guides/source/routing.textile +6 -13
- data/guides/source/ruby_on_rails_guides_guidelines.textile +0 -5
- data/guides/source/security.textile +11 -15
- data/guides/source/testing.textile +1 -9
- data/lib/rails/application.rb +107 -42
- data/lib/rails/application/bootstrap.rb +12 -11
- data/lib/rails/application/configuration.rb +27 -21
- data/lib/rails/application/finisher.rb +40 -17
- data/lib/rails/application/route_inspector.rb +75 -0
- data/lib/rails/application/routes_reloader.rb +15 -4
- data/lib/rails/code_statistics.rb +16 -5
- data/lib/rails/commands.rb +6 -5
- data/lib/rails/commands/application.rb +8 -1
- data/lib/rails/commands/console.rb +2 -0
- data/lib/rails/commands/dbconsole.rb +2 -2
- data/lib/rails/commands/destroy.rb +0 -2
- data/lib/rails/commands/generate.rb +3 -3
- data/lib/rails/commands/plugin.rb +161 -159
- data/lib/rails/commands/plugin_new.rb +3 -2
- data/lib/rails/commands/runner.rb +4 -0
- data/lib/rails/console/app.rb +26 -22
- data/lib/rails/console/helpers.rb +9 -5
- data/lib/rails/engine.rb +70 -34
- data/lib/rails/engine/commands.rb +39 -0
- data/lib/rails/engine/configuration.rb +1 -1
- data/lib/rails/generators.rb +3 -14
- data/lib/rails/generators/actions.rb +36 -9
- data/lib/rails/generators/app_base.rb +34 -38
- data/lib/rails/generators/base.rb +4 -4
- data/lib/rails/generators/generated_attribute.rb +1 -1
- data/lib/rails/generators/named_base.rb +1 -3
- data/lib/rails/generators/rails/app/USAGE +6 -0
- data/lib/rails/generators/rails/app/app_generator.rb +6 -2
- data/lib/rails/generators/rails/app/templates/Gemfile +4 -3
- data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +9 -3
- data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css +11 -5
- 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 +1 -1
- data/lib/rails/generators/rails/app/templates/config/application.rb +11 -0
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml +1 -1
- data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml +1 -1
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +10 -1
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +10 -1
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +6 -6
- data/lib/rails/generators/rails/app/templates/config/initializers/inflections.rb +5 -0
- data/lib/rails/generators/rails/app/templates/config/routes.rb +1 -1
- data/lib/rails/generators/rails/app/templates/public/500.html +0 -1
- data/lib/rails/generators/rails/app/templates/public/index.html +1 -1
- 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/unit/.empty_directory +0 -0
- data/lib/rails/generators/rails/controller/templates/controller.rb +1 -1
- data/lib/rails/generators/rails/generator/templates/templates/.empty_directory +0 -0
- data/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +17 -5
- data/lib/rails/generators/rails/plugin_new/templates/Rakefile +1 -0
- data/lib/rails/generators/rails/plugin_new/templates/app/mailers/.empty_directory +0 -0
- data/lib/rails/generators/rails/plugin_new/templates/app/models/.empty_directory +0 -0
- data/lib/rails/generators/rails/plugin_new/templates/app/views/layouts/%name%/application.html.erb.tt +1 -1
- data/lib/rails/generators/rails/plugin_new/templates/gitignore +4 -3
- data/lib/rails/generators/rails/plugin_new/templates/lib/%name%/engine.rb +1 -1
- data/lib/rails/generators/rails/plugin_new/templates/rails/application.rb +1 -1
- data/lib/rails/generators/rails/plugin_new/templates/script/rails.tt +5 -3
- data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +2 -2
- data/lib/rails/generators/rails/task/USAGE +9 -0
- data/lib/rails/generators/rails/task/task_generator.rb +12 -0
- data/lib/rails/generators/rails/task/templates/task.rb +8 -0
- data/lib/rails/generators/resource_helpers.rb +3 -3
- data/lib/rails/generators/test_unit/integration/templates/integration_test.rb +0 -2
- data/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb +4 -4
- data/lib/rails/paths.rb +11 -38
- data/lib/rails/rack/debugger.rb +3 -4
- data/lib/rails/rack/logger.rb +26 -12
- data/lib/rails/railtie.rb +6 -1
- data/lib/rails/railtie/configuration.rb +12 -5
- data/lib/rails/source_annotation_extractor.rb +12 -10
- data/lib/rails/tasks/documentation.rake +3 -1
- data/lib/rails/tasks/engine.rake +1 -0
- data/lib/rails/tasks/misc.rake +1 -1
- data/lib/rails/tasks/routes.rake +3 -23
- data/lib/rails/test_help.rb +1 -2
- data/lib/rails/test_unit/testing.rake +8 -4
- data/lib/rails/version.rb +3 -3
- metadata +131 -61
- checksums.yaml +0 -7
- data/lib/rails/generators/rails/plugin/USAGE +0 -13
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +0 -54
- data/lib/rails/generators/rails/plugin/templates/MIT-LICENSE.tt +0 -20
- data/lib/rails/generators/rails/plugin/templates/README.tt +0 -13
- data/lib/rails/generators/rails/plugin/templates/Rakefile.tt +0 -23
- data/lib/rails/generators/rails/plugin/templates/init.rb +0 -1
- data/lib/rails/generators/rails/plugin/templates/install.rb +0 -1
- data/lib/rails/generators/rails/plugin/templates/lib/%file_name%.rb.tt +0 -1
- data/lib/rails/generators/rails/plugin/templates/lib/tasks/%file_name%_tasks.rake.tt +0 -4
- data/lib/rails/generators/rails/plugin/templates/uninstall.rb +0 -1
@@ -0,0 +1,12 @@
|
|
1
|
+
module Rails
|
2
|
+
module Generators
|
3
|
+
class TaskGenerator < NamedBase
|
4
|
+
argument :actions, :type => :array, :default => [], :banner => "action action"
|
5
|
+
|
6
|
+
def create_task_files
|
7
|
+
template 'task.rb', File.join('lib/tasks', "#{file_name}.rake")
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -64,8 +64,8 @@ module Rails
|
|
64
64
|
end
|
65
65
|
|
66
66
|
begin
|
67
|
-
"#{options[:orm].to_s.
|
68
|
-
rescue NameError
|
67
|
+
"#{options[:orm].to_s.camelize}::Generators::ActiveModel".constantize
|
68
|
+
rescue NameError
|
69
69
|
Rails::Generators::ActiveModel
|
70
70
|
end
|
71
71
|
end
|
@@ -73,7 +73,7 @@ module Rails
|
|
73
73
|
|
74
74
|
# Initialize ORM::Generators::ActiveModel to access instance methods.
|
75
75
|
def orm_instance(name=singular_table_name)
|
76
|
-
@orm_instance ||=
|
76
|
+
@orm_instance ||= orm_class.new(name)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
@@ -26,23 +26,23 @@ class <%= controller_class_name %>ControllerTest < ActionController::TestCase
|
|
26
26
|
end
|
27
27
|
|
28
28
|
test "should show <%= singular_table_name %>" do
|
29
|
-
get :show, <%= key_value :id, "@#{singular_table_name}
|
29
|
+
get :show, <%= key_value :id, "@#{singular_table_name}" %>
|
30
30
|
assert_response :success
|
31
31
|
end
|
32
32
|
|
33
33
|
test "should get edit" do
|
34
|
-
get :edit, <%= key_value :id, "@#{singular_table_name}
|
34
|
+
get :edit, <%= key_value :id, "@#{singular_table_name}" %>
|
35
35
|
assert_response :success
|
36
36
|
end
|
37
37
|
|
38
38
|
test "should update <%= singular_table_name %>" do
|
39
|
-
put :update, <%= key_value :id, "@#{singular_table_name}
|
39
|
+
put :update, <%= key_value :id, "@#{singular_table_name}" %>, <%= key_value singular_table_name, "@#{singular_table_name}.attributes" %>
|
40
40
|
assert_redirected_to <%= singular_table_name %>_path(assigns(:<%= singular_table_name %>))
|
41
41
|
end
|
42
42
|
|
43
43
|
test "should destroy <%= singular_table_name %>" do
|
44
44
|
assert_difference('<%= class_name %>.count', -1) do
|
45
|
-
delete :destroy, <%= key_value :id, "@#{singular_table_name}
|
45
|
+
delete :destroy, <%= key_value :id, "@#{singular_table_name}" %>
|
46
46
|
end
|
47
47
|
|
48
48
|
assert_redirected_to <%= index_helper %>_path
|
data/lib/rails/paths.rb
CHANGED
@@ -2,39 +2,21 @@ require 'set'
|
|
2
2
|
|
3
3
|
module Rails
|
4
4
|
module Paths
|
5
|
-
|
6
|
-
def method_missing(id, *args)
|
7
|
-
match = id.to_s.match(/^(.*)=$/)
|
8
|
-
full = [@current, $1 || id].compact.join("/")
|
9
|
-
|
10
|
-
ActiveSupport::Deprecation.warn 'Accessing paths using dot style as in `config.paths.app.controller` is deprecated. Please use ' <<
|
11
|
-
'`config.paths["app/controller"]` style instead.'
|
12
|
-
|
13
|
-
if match || args.any?
|
14
|
-
@root[full] = Path.new(@root, full, *args)
|
15
|
-
elsif path = @root[full]
|
16
|
-
path
|
17
|
-
else
|
18
|
-
super
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
# This object is an extended hash that behaves as root of the Rails::Paths system.
|
5
|
+
# This object is an extended hash that behaves as root of the <tt>Rails::Paths</tt> system.
|
24
6
|
# It allows you to collect information about how you want to structure your application
|
25
7
|
# paths by a Hash like API. It requires you to give a physical path on initialization.
|
26
8
|
#
|
27
|
-
# root = Root.new
|
9
|
+
# root = Root.new "/rails"
|
28
10
|
# root.add "app/controllers", :eager_load => true
|
29
11
|
#
|
30
12
|
# The command above creates a new root object and add "app/controllers" as a path.
|
31
|
-
# This means we can get a Path object back like below:
|
13
|
+
# This means we can get a +Rails::Paths::Path+ object back like below:
|
32
14
|
#
|
33
15
|
# path = root["app/controllers"]
|
34
16
|
# path.eager_load? # => true
|
35
17
|
# path.is_a?(Rails::Paths::Path) # => true
|
36
18
|
#
|
37
|
-
# The Path object is simply an array and allows you to easily add extra paths:
|
19
|
+
# The +Path+ object is simply an array and allows you to easily add extra paths:
|
38
20
|
#
|
39
21
|
# path.is_a?(Array) # => true
|
40
22
|
# path.inspect # => ["app/controllers"]
|
@@ -42,32 +24,30 @@ module Rails
|
|
42
24
|
# path << "lib/controllers"
|
43
25
|
# path.inspect # => ["app/controllers", "lib/controllers"]
|
44
26
|
#
|
45
|
-
# Notice that when you add a path using
|
46
|
-
# contains the path with the same path value given to
|
27
|
+
# Notice that when you add a path using +add+, the path object created already
|
28
|
+
# contains the path with the same path value given to +add+. In some situations,
|
47
29
|
# you may not want this behavior, so you can give :with as option.
|
48
30
|
#
|
49
31
|
# root.add "config/routes", :with => "config/routes.rb"
|
50
32
|
# root["config/routes"].inspect # => ["config/routes.rb"]
|
51
33
|
#
|
52
|
-
# The
|
34
|
+
# The +add+ method accepts the following options as arguments:
|
53
35
|
# eager_load, autoload, autoload_once and glob.
|
54
36
|
#
|
55
|
-
# Finally, the Path object also provides a few helpers:
|
37
|
+
# Finally, the +Path+ object also provides a few helpers:
|
56
38
|
#
|
57
|
-
# root = Root.new
|
58
|
-
# root.path = "/rails"
|
39
|
+
# root = Root.new "/rails"
|
59
40
|
# root.add "app/controllers"
|
60
41
|
#
|
61
42
|
# root["app/controllers"].expanded # => ["/rails/app/controllers"]
|
62
43
|
# root["app/controllers"].existent # => ["/rails/app/controllers"]
|
63
44
|
#
|
64
|
-
# Check the Path documentation for more information.
|
45
|
+
# Check the <tt>Rails::Paths::Path</tt> documentation for more information.
|
65
46
|
class Root < ::Hash
|
66
|
-
include PathParent
|
67
47
|
attr_accessor :path
|
68
48
|
|
69
49
|
def initialize(path)
|
70
|
-
raise if path.is_a?(Array)
|
50
|
+
raise "Argument should be a String of the physical root path" if path.is_a?(Array)
|
71
51
|
@current = nil
|
72
52
|
@path = path
|
73
53
|
@root = self
|
@@ -121,8 +101,6 @@ module Rails
|
|
121
101
|
end
|
122
102
|
|
123
103
|
class Path < Array
|
124
|
-
include PathParent
|
125
|
-
|
126
104
|
attr_reader :path
|
127
105
|
attr_accessor :glob
|
128
106
|
|
@@ -198,11 +176,6 @@ module Rails
|
|
198
176
|
expanded.select { |d| File.directory?(d) }
|
199
177
|
end
|
200
178
|
|
201
|
-
def paths
|
202
|
-
ActiveSupport::Deprecation.warn "paths is deprecated. Please call expand instead."
|
203
|
-
expanded
|
204
|
-
end
|
205
|
-
|
206
179
|
alias to_a expanded
|
207
180
|
end
|
208
181
|
end
|
data/lib/rails/rack/debugger.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'active_support/core_ext/kernel/requires'
|
2
|
-
|
3
1
|
module Rails
|
4
2
|
module Rack
|
5
3
|
class Debugger
|
@@ -8,11 +6,12 @@ module Rails
|
|
8
6
|
|
9
7
|
ARGV.clear # clear ARGV so that rails server options aren't passed to IRB
|
10
8
|
|
11
|
-
|
9
|
+
require 'ruby-debug'
|
10
|
+
|
12
11
|
::Debugger.start
|
13
12
|
::Debugger.settings[:autoeval] = true if ::Debugger.respond_to?(:settings)
|
14
13
|
puts "=> Debugger enabled"
|
15
|
-
rescue
|
14
|
+
rescue LoadError
|
16
15
|
puts "You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'"
|
17
16
|
exit
|
18
17
|
end
|
data/lib/rails/rack/logger.rb
CHANGED
@@ -1,32 +1,46 @@
|
|
1
1
|
require 'active_support/core_ext/time/conversions'
|
2
|
+
require 'active_support/core_ext/object/blank'
|
2
3
|
|
3
4
|
module Rails
|
4
5
|
module Rack
|
5
6
|
# Log the request started and flush all loggers after it.
|
6
7
|
class Logger < ActiveSupport::LogSubscriber
|
7
|
-
def initialize(app)
|
8
|
-
@app = app
|
8
|
+
def initialize(app, tags=nil)
|
9
|
+
@app, @tags = app, tags.presence
|
9
10
|
end
|
10
11
|
|
11
12
|
def call(env)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
if @tags
|
14
|
+
Rails.logger.tagged(compute_tags(env)) { call_app(env) }
|
15
|
+
else
|
16
|
+
call_app(env)
|
17
|
+
end
|
16
18
|
end
|
17
19
|
|
18
20
|
protected
|
19
21
|
|
20
|
-
def
|
22
|
+
def call_app(env)
|
21
23
|
request = ActionDispatch::Request.new(env)
|
22
24
|
path = request.filtered_path
|
23
|
-
|
24
|
-
|
25
|
-
|
25
|
+
Rails.logger.info "\n\nStarted #{request.request_method} \"#{path}\" for #{request.ip} at #{Time.now.to_default_s}"
|
26
|
+
@app.call(env)
|
27
|
+
ensure
|
28
|
+
ActiveSupport::LogSubscriber.flush_all!
|
26
29
|
end
|
27
30
|
|
28
|
-
def
|
29
|
-
|
31
|
+
def compute_tags(env)
|
32
|
+
request = ActionDispatch::Request.new(env)
|
33
|
+
|
34
|
+
@tags.collect do |tag|
|
35
|
+
case tag
|
36
|
+
when Proc
|
37
|
+
tag.call(request)
|
38
|
+
when Symbol
|
39
|
+
request.send(tag)
|
40
|
+
else
|
41
|
+
tag
|
42
|
+
end
|
43
|
+
end
|
30
44
|
end
|
31
45
|
end
|
32
46
|
end
|
data/lib/rails/railtie.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'rails/initializable'
|
2
2
|
require 'rails/configuration'
|
3
3
|
require 'active_support/inflector'
|
4
|
+
require 'active_support/core_ext/module/introspection'
|
4
5
|
require 'active_support/core_ext/module/delegation'
|
5
6
|
|
6
7
|
module Rails
|
@@ -180,7 +181,7 @@ module Rails
|
|
180
181
|
|
181
182
|
def load_tasks(app=self)
|
182
183
|
extend Rake::DSL if defined? Rake::DSL
|
183
|
-
self.class.rake_tasks.each { |block|
|
184
|
+
self.class.rake_tasks.each { |block| self.instance_exec(app, &block) }
|
184
185
|
|
185
186
|
# load also tasks from all superclasses
|
186
187
|
klass = self.class.superclass
|
@@ -193,5 +194,9 @@ module Rails
|
|
193
194
|
def load_generators(app=self)
|
194
195
|
self.class.generators.each { |block| block.call(app) }
|
195
196
|
end
|
197
|
+
|
198
|
+
def railtie_namespace
|
199
|
+
@railtie_namespace ||= self.class.parents.detect { |n| n.respond_to?(:railtie_namespace) }
|
200
|
+
end
|
196
201
|
end
|
197
202
|
end
|
@@ -7,6 +7,18 @@ module Rails
|
|
7
7
|
@@options ||= {}
|
8
8
|
end
|
9
9
|
|
10
|
+
# Add files that should be watched for change.
|
11
|
+
def watchable_files
|
12
|
+
@@watchable_files ||= []
|
13
|
+
end
|
14
|
+
|
15
|
+
# Add directories that should be watched for change.
|
16
|
+
# The key of the hashes should be directories and the values should
|
17
|
+
# be an array of extensions to match in each directory.
|
18
|
+
def watchable_dirs
|
19
|
+
@@watchable_dirs ||= {}
|
20
|
+
end
|
21
|
+
|
10
22
|
# This allows you to modify the application's middlewares from Engines.
|
11
23
|
#
|
12
24
|
# All operations you run on the app_middleware will be replayed on the
|
@@ -26,11 +38,6 @@ module Rails
|
|
26
38
|
@@app_generators
|
27
39
|
end
|
28
40
|
|
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)
|
32
|
-
end
|
33
|
-
|
34
41
|
# First configurable block to run. Called before any initializers are run.
|
35
42
|
def before_configuration(&block)
|
36
43
|
ActiveSupport.on_load(:before_configuration, :yield => true, &block)
|
@@ -28,9 +28,9 @@ class SourceAnnotationExtractor
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
# Prints all annotations with tag +tag+ under the root directories +app+, +lib+,
|
32
|
-
# and +test+ (recursively). Only filenames with extension
|
33
|
-
# +.
|
31
|
+
# Prints all annotations with tag +tag+ under the root directories +app+, +config+, +lib+,
|
32
|
+
# +script+, and +test+ (recursively). Only filenames with extension
|
33
|
+
# +.builder+, +.rb+, and +.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.
|
@@ -46,16 +46,14 @@ class SourceAnnotationExtractor
|
|
46
46
|
end
|
47
47
|
|
48
48
|
# Returns a hash that maps filenames under +dirs+ (recursively) to arrays
|
49
|
-
# with their annotations.
|
50
|
-
|
51
|
-
# are taken into account.
|
52
|
-
def find(dirs=%w(app lib test))
|
49
|
+
# with their annotations.
|
50
|
+
def find(dirs=%w(app config lib script test))
|
53
51
|
dirs.inject({}) { |h, dir| h.update(find_in(dir)) }
|
54
52
|
end
|
55
53
|
|
56
54
|
# Returns a hash that maps filenames under +dir+ (recursively) to arrays
|
57
55
|
# with their annotations. Only files with annotations are included, and only
|
58
|
-
# those with extension +.builder+, +.rb+, +.
|
56
|
+
# those with extension +.builder+, +.rb+, +.erb+, +.haml+ and +.slim+
|
59
57
|
# are taken into account.
|
60
58
|
def find_in(dir)
|
61
59
|
results = {}
|
@@ -65,10 +63,14 @@ class SourceAnnotationExtractor
|
|
65
63
|
|
66
64
|
if File.directory?(item)
|
67
65
|
results.update(find_in(item))
|
68
|
-
elsif item =~ /\.(builder|
|
66
|
+
elsif item =~ /\.(builder|rb)$/
|
69
67
|
results.update(extract_annotations_from(item, /#\s*(#{tag}):?\s*(.*)$/))
|
70
|
-
elsif item =~ /\.
|
68
|
+
elsif item =~ /\.erb$/
|
71
69
|
results.update(extract_annotations_from(item, /<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/))
|
70
|
+
elsif item =~ /\.haml$/
|
71
|
+
results.update(extract_annotations_from(item, /-\s*#\s*(#{tag}):?\s*(.*)$/))
|
72
|
+
elsif item =~ /\.slim$/
|
73
|
+
results.update(extract_annotations_from(item, /\/\s*\s*(#{tag}):?\s*(.*)$/))
|
72
74
|
end
|
73
75
|
end
|
74
76
|
|
@@ -8,6 +8,8 @@ end
|
|
8
8
|
|
9
9
|
# Monkey-patch to remove redoc'ing and clobber descriptions to cut down on rake -T noise
|
10
10
|
class RDocTaskWithoutDescriptions < RDoc::Task
|
11
|
+
include ::Rake::DSL
|
12
|
+
|
11
13
|
def define
|
12
14
|
task rdoc_task_name
|
13
15
|
|
@@ -61,7 +63,7 @@ namespace :doc do
|
|
61
63
|
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
62
64
|
rdoc.title = "Rails Framework Documentation"
|
63
65
|
rdoc.options << '--line-numbers'
|
64
|
-
rdoc.rdoc_files.include('README
|
66
|
+
rdoc.rdoc_files.include('README')
|
65
67
|
|
66
68
|
gem_path('actionmailer') do |actionmailer|
|
67
69
|
%w(README.rdoc CHANGELOG.md MIT-LICENSE lib/action_mailer/base.rb).each do |file|
|
data/lib/rails/tasks/engine.rake
CHANGED
data/lib/rails/tasks/misc.rake
CHANGED
data/lib/rails/tasks/routes.rake
CHANGED
@@ -3,27 +3,7 @@ task :routes => :environment do
|
|
3
3
|
Rails.application.reload_routes!
|
4
4
|
all_routes = Rails.application.routes.routes
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
routes = all_routes.collect do |route|
|
11
|
-
|
12
|
-
reqs = route.requirements.dup
|
13
|
-
reqs[:to] = route.app unless route.app.class.name.to_s =~ /^ActionDispatch::Routing/
|
14
|
-
reqs = reqs.empty? ? "" : reqs.inspect
|
15
|
-
|
16
|
-
{:name => route.name.to_s, :verb => route.verb.to_s, :path => route.path, :reqs => reqs}
|
17
|
-
end
|
18
|
-
|
19
|
-
# Skip the route if it's internal info route
|
20
|
-
routes.reject! { |r| r[:path] =~ %r{/rails/info/properties|^/assets} }
|
21
|
-
|
22
|
-
name_width = routes.map{ |r| r[:name].length }.max
|
23
|
-
verb_width = routes.map{ |r| r[:verb].length }.max
|
24
|
-
path_width = routes.map{ |r| r[:path].length }.max
|
25
|
-
|
26
|
-
routes.each do |r|
|
27
|
-
puts "#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:path].ljust(path_width)} #{r[:reqs]}"
|
28
|
-
end
|
6
|
+
require 'rails/application/route_inspector'
|
7
|
+
inspector = Rails::Application::RouteInspector.new
|
8
|
+
puts inspector.format(all_routes, ENV['CONTROLLER']).join "\n"
|
29
9
|
end
|