From bcf5fea5e5a22edd5c7b27c29a53de0a4bedbc27 Mon Sep 17 00:00:00 2001 From: Adrian Sanchez Date: Wed, 5 May 2010 01:39:59 -0500 Subject: Bundler deprecated options in Gemfile with application template using method "gem" [#4534 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- railties/lib/rails/generators/actions.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index a31932906d..7af329bbf0 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -54,7 +54,8 @@ module Rails name, version = args # Deal with deprecated options - { :env => :only, :lib => :require_as }.each do |old, new| + { :env => :group, :only => :group, + :lib => :require, :require_as => :require }.each do |old, new| next unless options[old] options[new] = options.delete(old) ActiveSupport::Deprecation.warn "#{old.inspect} option in gem is deprecated, use #{new.inspect} instead" -- cgit v1.2.3 From 80fc6536bda191731e3963f1539c84a7b0c4e764 Mon Sep 17 00:00:00 2001 From: Jeroen van Dijk + Rodrigo Urubatan Date: Fri, 14 May 2010 23:54:13 +0200 Subject: Added Rake task rails:templates:copy to copy templates for customization [#4574 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- railties/lib/rails/tasks/framework.rake | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/tasks/framework.rake b/railties/lib/rails/tasks/framework.rake index 738f7f5301..063a393bfc 100644 --- a/railties/lib/rails/tasks/framework.rake +++ b/railties/lib/rails/tasks/framework.rake @@ -30,6 +30,28 @@ namespace :rails do generator.apply template, :verbose => false end + namespace :templates do + desc "Copy all the templates from rails to the application directory for customization. Already existing local copies will be overwritten" + task :copy do + generators_lib = File.expand_path("../../generators", __FILE__) + project_templates = "#{Rails.root}/lib/templates" + + default_templates = { "erb" => %w{controller mailer scaffold}, + "rails" => %w{controller helper metal scaffold_controller stylesheets} } + + default_templates.each do |type, names| + local_template_type_dir = File.join(project_templates, type) + FileUtils.mkdir_p local_template_type_dir + + names.each do |name| + dst_name = File.join(local_template_type_dir, name) + src_name = File.join(generators_lib, type, name, "templates") + FileUtils.cp_r src_name, dst_name + end + end + end + end + namespace :update do def invoke_from_app_generator(method) app_generator.invoke(method) -- cgit v1.2.3 From 9cfeefb637b603ce41d3019c8baa95ea984620d7 Mon Sep 17 00:00:00 2001 From: wycats Date: Sat, 15 May 2010 06:08:55 -0700 Subject: Reorganized initializers a bit to enable better hooks for common cases without the need for Railtie. Specifically, the following hooks were added: * before_configuration: this hook is run immediately after the Application class comes into existence, but before the user has added any configuration. This is the appropriate place to set configuration for your plugin * before_initialize: This is run after all of the user's configuration has completed, but before any initializers have begun (in other words, it runs right after config/environments/{development,production,test}.rb) * after_initialize: This is run after all of the initializers have run. It is an appropriate place for forking in a preforking setup Each of these hooks may be used via ActiveSupport.on_load(name) { }. In all these cases, the context inside the block will be the Application object. This means that for simple cases, you can use these hooks without needing to create a Railtie. --- railties/lib/rails/application.rb | 10 +++--- railties/lib/rails/application/bootstrap.rb | 8 ++--- railties/lib/rails/application/configuration.rb | 2 +- railties/lib/rails/application/finisher.rb | 6 ++-- railties/lib/rails/engine.rb | 15 +++++--- railties/lib/rails/railtie/configuration.rb | 48 +++++++++++++++++++++---- 6 files changed, 65 insertions(+), 24 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index d39f9a2ae9..9e18dccf69 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -12,7 +12,7 @@ module Rails # points to it. # # In other words, Rails::Application is Singleton and whenever you are accessing - # Rails::Application.config or YourApplication::Application.config, you are actually + # Rails::Application.config or YourApplication::Application.config, you are actually # accessing YourApplication::Application.instance.config. # # == Initialization @@ -40,7 +40,7 @@ module Rails # # The Application is also responsible for building the middleware stack and setting up # both application and engines metals. - # + # class Application < Engine autoload :Bootstrap, 'rails/application/bootstrap' autoload :Configurable, 'rails/application/configurable' @@ -69,6 +69,8 @@ module Rails raise "You cannot have more than one Rails::Application" if Rails.application super Rails.application = base.instance + + ActiveSupport.run_load_hooks(:before_configuration, base.instance) end def respond_to?(*args) @@ -82,7 +84,7 @@ module Rails end end - delegate :metal_loader, :to => :config + delegate :middleware, :metal_loader, :to => :config def require_environment! environment = paths.config.environment.to_a.first @@ -125,7 +127,7 @@ module Rails end def app - @app ||= middleware.build(routes) + @app ||= config.middleware.build(routes) end def call(env) diff --git a/railties/lib/rails/application/bootstrap.rb b/railties/lib/rails/application/bootstrap.rb index 022e1a91d8..e62eed8a87 100644 --- a/railties/lib/rails/application/bootstrap.rb +++ b/railties/lib/rails/application/bootstrap.rb @@ -10,7 +10,8 @@ module Rails require environment if environment end - initializer :load_all_active_support do + initializer :load_active_support do + require 'active_support/dependencies' require "active_support/all" unless config.active_support.bare end @@ -18,7 +19,6 @@ module Rails # Used by Passenger to ensure everything's loaded before forking and # to avoid autoload race conditions in JRuby. initializer :preload_frameworks do - require 'active_support/dependencies' ActiveSupport::Autoload.eager_autoload! if config.preload_frameworks end @@ -66,8 +66,8 @@ module Rails ActiveSupport::Dependencies.mechanism = config.cache_classes ? :require : :load end - initializer :bootstrap_load_path do - # This is just an initializer used as hook so all load paths are loaded together + initializer :bootstrap_hook do |app| + ActiveSupport.run_load_hooks(:before_initialize, app) end end end diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 1ad77fdfec..cd77f1adaf 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -33,7 +33,7 @@ module Rails end def middleware - @middleware ||= default_middleware_stack + @middleware ||= app_middleware.merge_into(default_middleware_stack) end def metal_loader diff --git a/railties/lib/rails/application/finisher.rb b/railties/lib/rails/application/finisher.rb index 94507bb387..03bc270c81 100644 --- a/railties/lib/rails/application/finisher.rb +++ b/railties/lib/rails/application/finisher.rb @@ -35,10 +35,8 @@ module Rails app end - initializer :after_initialize do - config.after_initialize_blocks.each do |block| - block.call(self) - end + initializer :finisher_hook do |app| + ActiveSupport.run_load_hooks(:after_initialize, app) end # Disable dependency loading during request cycle diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index ab0ead65a9..652bd40ee4 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -45,7 +45,7 @@ module Rails # app.middleware.use MyEngine::Middleware # end # end - # + # # == Paths # # Since Rails 3.0, both your Application and Engines do not have hardcoded paths. @@ -125,7 +125,7 @@ module Rails end end - delegate :middleware, :paths, :root, :to => :config + delegate :paths, :root, :to => :config def load_tasks super @@ -133,7 +133,7 @@ module Rails end # Add configured load paths to ruby load paths and remove duplicates. - initializer :set_load_path, :before => :bootstrap_load_path do + initializer :set_load_path, :before => :bootstrap_hook do config.load_paths.reverse_each do |path| $LOAD_PATH.unshift(path) if File.directory?(path) end @@ -142,7 +142,10 @@ module Rails # Set the paths from which Rails will automatically load source files, # and the load_once paths. - initializer :set_autoload_paths, :before => :bootstrap_load_path do |app| + # + # This needs to be an initializer, since it needs to run once + # per engine and get the engine as a block parameter + initializer :set_autoload_paths, :before => :bootstrap_hook do |app| ActiveSupport::Dependencies.load_paths.unshift(*config.load_paths) if reloadable?(app) @@ -200,7 +203,9 @@ module Rails end end - initializer :load_app_classes do |app| + # This needs to be an initializer, since it needs to run once + # per engine and get the engine as a block parameter + initializer :load_app_classes, :before => :finisher_hook do |app| next if $rails_rake_task if app.config.cache_classes diff --git a/railties/lib/rails/railtie/configuration.rb b/railties/lib/rails/railtie/configuration.rb index 16eccaccc4..f57d82a3d8 100644 --- a/railties/lib/rails/railtie/configuration.rb +++ b/railties/lib/rails/railtie/configuration.rb @@ -3,10 +3,50 @@ require 'rails/configuration' module Rails class Railtie class Configuration + class MiddlewareStackProxy + def initialize + @operations = [] + end + + def insert_before(*args, &block) + @operations << [:insert_before, args, block] + end + + alias insert insert_before + + def insert_after(*args, &block) + @operations << [:insert_after, args, block] + end + + def swap(*args, &block) + @operations << [:swap, args, block] + end + + def use(*args, &block) + @operations << [:use, args, block] + end + + def merge_into(other) + @operations.each do |operation, args, block| + other.send(operation, *args, &block) + end + other + end + end + def initialize @@options ||= {} end + # This allows you to modify the application's middlewares from Engines. + # + # All operations you run on the app_middleware will be replayed on the + # application once it is defined and the default_middlewares are + # created + def app_middleware + @@app_middleware ||= MiddlewareStackProxy.new + end + # Holds generators configuration: # # config.generators do |g| @@ -28,12 +68,8 @@ module Rails end end - def after_initialize_blocks - @@after_initialize_blocks ||= [] - end - - def after_initialize(&blk) - after_initialize_blocks << blk if blk + def after_initialize(&block) + ActiveSupport.on_load(:after_initialize, :yield => true, &block) end def to_prepare_blocks -- cgit v1.2.3 From 351816fab6dbe564b7bddbd877648edb06a2bfb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sat, 15 May 2010 23:48:56 +0200 Subject: Ensure that eager_load actually takes place just after the middleware stack is built by using another pattern. Also create a engine_blank_point initializer to ensure any :before or :after hooks defined inside engines won't move the configuration initializers to other places. --- railties/lib/rails/application/finisher.rb | 10 ++++++++-- railties/lib/rails/engine.rb | 25 ++++++++++++------------- railties/lib/rails/railtie.rb | 3 +++ 3 files changed, 23 insertions(+), 15 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/application/finisher.rb b/railties/lib/rails/application/finisher.rb index 03bc270c81..9d04f1ce38 100644 --- a/railties/lib/rails/application/finisher.rb +++ b/railties/lib/rails/application/finisher.rb @@ -35,8 +35,14 @@ module Rails app end - initializer :finisher_hook do |app| - ActiveSupport.run_load_hooks(:after_initialize, app) + initializer :eager_load! do + if config.cache_classes && !$rails_rake_task + railties.all(&:eager_load!) + end + end + + initializer :finisher_hook do + ActiveSupport.run_load_hooks(:after_initialize, self) end # Disable dependency loading during request cycle diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 652bd40ee4..b44755820c 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -132,6 +132,15 @@ module Rails config.paths.lib.tasks.to_a.sort.each { |ext| load(ext) } end + def eager_load! + config.eager_load_paths.each do |load_path| + matcher = /\A#{Regexp.escape(load_path)}\/(.*)\.rb\Z/ + Dir.glob("#{load_path}/**/*.rb").sort.each do |file| + require_dependency file.sub(matcher, '\1') + end + end + end + # Add configured load paths to ruby load paths and remove duplicates. initializer :set_load_path, :before => :bootstrap_hook do config.load_paths.reverse_each do |path| @@ -203,19 +212,9 @@ module Rails end end - # This needs to be an initializer, since it needs to run once - # per engine and get the engine as a block parameter - initializer :load_app_classes, :before => :finisher_hook do |app| - next if $rails_rake_task - - if app.config.cache_classes - config.eager_load_paths.each do |load_path| - matcher = /\A#{Regexp.escape(load_path)}\/(.*)\.rb\Z/ - Dir.glob("#{load_path}/**/*.rb").sort.each do |file| - require_dependency file.sub(matcher, '\1') - end - end - end + initializer :engines_blank_point do + # We need this initializer so all extra initializers added in engines are + # consistently executed after all the initializers above across all engines. end protected diff --git a/railties/lib/rails/railtie.rb b/railties/lib/rails/railtie.rb index b6b57bc5b5..1dba6e1538 100644 --- a/railties/lib/rails/railtie.rb +++ b/railties/lib/rails/railtie.rb @@ -197,6 +197,9 @@ module Rails end end + def eager_load! + end + def rake_tasks self.class.rake_tasks end -- cgit v1.2.3 From 3afdfc35e8aec7e6379e093dd1278cb3de54f21b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 16 May 2010 00:34:54 +0200 Subject: Expose remaining hooks to minimize the need for a Railtie based on feedback from plugin developers. --- railties/lib/rails/application.rb | 1 - railties/lib/rails/application/finisher.rb | 1 + railties/lib/rails/railtie/configuration.rb | 12 ++++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 9e18dccf69..a3b3a56bc8 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -69,7 +69,6 @@ module Rails raise "You cannot have more than one Rails::Application" if Rails.application super Rails.application = base.instance - ActiveSupport.run_load_hooks(:before_configuration, base.instance) end diff --git a/railties/lib/rails/application/finisher.rb b/railties/lib/rails/application/finisher.rb index 9d04f1ce38..fbab4d5515 100644 --- a/railties/lib/rails/application/finisher.rb +++ b/railties/lib/rails/application/finisher.rb @@ -37,6 +37,7 @@ module Rails initializer :eager_load! do if config.cache_classes && !$rails_rake_task + ActiveSupport.run_load_hooks(:before_eager_load, self) railties.all(&:eager_load!) end end diff --git a/railties/lib/rails/railtie/configuration.rb b/railties/lib/rails/railtie/configuration.rb index f57d82a3d8..c4a315708b 100644 --- a/railties/lib/rails/railtie/configuration.rb +++ b/railties/lib/rails/railtie/configuration.rb @@ -68,6 +68,18 @@ module Rails end end + def before_configuration(&block) + ActiveSupport.on_load(:before_configuration, :yield => true, &block) + end + + def before_eager_load(&block) + ActiveSupport.on_load(:before_eager_load, :yield => true, &block) + end + + def before_initialize(&block) + ActiveSupport.on_load(:before_initialize, :yield => true, &block) + end + def after_initialize(&block) ActiveSupport.on_load(:after_initialize, :yield => true, &block) end -- cgit v1.2.3 From 4750e61bfecd210e5c4d96546d638b5cd23bb09e Mon Sep 17 00:00:00 2001 From: Jeff Kreeftmeijer Date: Fri, 14 May 2010 22:14:49 +0200 Subject: using :time_select when the attribute type is :time in the scaffold generator. [#2377 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- railties/lib/rails/generators/generated_attribute.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/generators/generated_attribute.rb b/railties/lib/rails/generators/generated_attribute.rb index e962308585..f01934f946 100644 --- a/railties/lib/rails/generators/generated_attribute.rb +++ b/railties/lib/rails/generators/generated_attribute.rb @@ -9,12 +9,13 @@ module Rails def field_type @field_type ||= case type - when :integer, :float, :decimal then :text_field - when :datetime, :timestamp, :time then :datetime_select - when :date then :date_select - when :string then :text_field - when :text then :text_area - when :boolean then :check_box + when :integer, :float, :decimal then :text_field + when :time then :time_select + when :datetime, :timestamp then :datetime_select + when :date then :date_select + when :string then :text_field + when :text then :text_area + when :boolean then :check_box else :text_field end -- cgit v1.2.3 From 99b38f371a17eb3965f794227279e89fb6c694a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 16 May 2010 12:03:11 +0200 Subject: Move AD::Cascade to the bottom of the middleware stack. --- railties/lib/rails/application/configuration.rb | 4 +-- railties/lib/rails/configuration.rb | 31 +++++++++++++++++++++++ railties/lib/rails/railtie/configuration.rb | 33 +------------------------ 3 files changed, 34 insertions(+), 34 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index cd77f1adaf..9353fbefef 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -150,10 +150,10 @@ module Rails middleware.use('::ActionDispatch::Cookies') middleware.use(lambda { session_store }, lambda { session_options }) middleware.use('::ActionDispatch::Flash', :if => lambda { session_store }) - middleware.use(lambda { metal_loader.build_middleware(metals) }, :if => lambda { metal_loader.metals.any? }) - middleware.use('ActionDispatch::ParamsParser') + middleware.use('::ActionDispatch::ParamsParser') middleware.use('::Rack::MethodOverride') middleware.use('::ActionDispatch::Head') + middleware.use(lambda { metal_loader.build_middleware(metals) }, :if => lambda { metal_loader.metals.any? }) end end end diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index bd404f4a14..ee0fca6592 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -5,6 +5,37 @@ require 'rails/rack' module Rails module Configuration + class MiddlewareStackProxy #:nodoc: + def initialize + @operations = [] + end + + def insert_before(*args, &block) + @operations << [:insert_before, args, block] + end + + alias :insert :insert_before + + def insert_after(*args, &block) + @operations << [:insert_after, args, block] + end + + def swap(*args, &block) + @operations << [:swap, args, block] + end + + def use(*args, &block) + @operations << [:use, args, block] + end + + def merge_into(other) + @operations.each do |operation, args, block| + other.send(operation, *args, &block) + end + other + end + end + class Generators #:nodoc: attr_accessor :aliases, :options, :templates, :fallbacks, :colorize_logging diff --git a/railties/lib/rails/railtie/configuration.rb b/railties/lib/rails/railtie/configuration.rb index c4a315708b..4e6f94c534 100644 --- a/railties/lib/rails/railtie/configuration.rb +++ b/railties/lib/rails/railtie/configuration.rb @@ -3,37 +3,6 @@ require 'rails/configuration' module Rails class Railtie class Configuration - class MiddlewareStackProxy - def initialize - @operations = [] - end - - def insert_before(*args, &block) - @operations << [:insert_before, args, block] - end - - alias insert insert_before - - def insert_after(*args, &block) - @operations << [:insert_after, args, block] - end - - def swap(*args, &block) - @operations << [:swap, args, block] - end - - def use(*args, &block) - @operations << [:use, args, block] - end - - def merge_into(other) - @operations.each do |operation, args, block| - other.send(operation, *args, &block) - end - other - end - end - def initialize @@options ||= {} end @@ -44,7 +13,7 @@ module Rails # application once it is defined and the default_middlewares are # created def app_middleware - @@app_middleware ||= MiddlewareStackProxy.new + @@app_middleware ||= Rails::Configuration::MiddlewareStackProxy.new end # Holds generators configuration: -- cgit v1.2.3 From 5ff6de0982c165bb9038258d867398c73c142084 Mon Sep 17 00:00:00 2001 From: Jeff Kreeftmeijer Date: Sun, 16 May 2010 11:20:11 +0200 Subject: Added assert_attribute_type to clean up GeneratedAttributeTest [#2377 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- railties/lib/rails/generators/test_case.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/generators/test_case.rb b/railties/lib/rails/generators/test_case.rb index 6b97c69d8d..24b57aabf9 100644 --- a/railties/lib/rails/generators/test_case.rb +++ b/railties/lib/rails/generators/test_case.rb @@ -189,6 +189,18 @@ module Rails end alias :assert_method :assert_instance_method + # Asserts the given field name gets translated to an attribute type + # properly. + # + # assert_attribute_type 'date', :date_select + # + def assert_attribute_type(name, attribute_type) + assert_equal( + Rails::Generators::GeneratedAttribute.new('test', name).field_type, + attribute_type + ) + end + # Runs the generator configured for this class. The first argument is an array like # command line arguments: # -- cgit v1.2.3 From 1a2d556de7935588e04c541e6c0804b5533db6b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 16 May 2010 12:07:44 +0200 Subject: Rename assert_attribute_type to asser_field_type. --- railties/lib/rails/generators/test_case.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/generators/test_case.rb b/railties/lib/rails/generators/test_case.rb index 24b57aabf9..952400e049 100644 --- a/railties/lib/rails/generators/test_case.rb +++ b/railties/lib/rails/generators/test_case.rb @@ -192,11 +192,11 @@ module Rails # Asserts the given field name gets translated to an attribute type # properly. # - # assert_attribute_type 'date', :date_select + # assert_field_type :date, :date_select # - def assert_attribute_type(name, attribute_type) + def assert_field_type(name, attribute_type) assert_equal( - Rails::Generators::GeneratedAttribute.new('test', name).field_type, + Rails::Generators::GeneratedAttribute.new('test', name.to_s).field_type, attribute_type ) end -- cgit v1.2.3 From 3e84ea014e9f4d0f8d302c9bf8ad04240eec2804 Mon Sep 17 00:00:00 2001 From: Aleksandr Koss Date: Sat, 15 May 2010 20:15:23 +0700 Subject: Fix Hash#index deprecated warning in 1.9.x [#4600 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- railties/lib/rails/tasks/routes.rake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/tasks/routes.rake b/railties/lib/rails/tasks/routes.rake index 42e01d5e51..4bb94d39ea 100644 --- a/railties/lib/rails/tasks/routes.rake +++ b/railties/lib/rails/tasks/routes.rake @@ -3,7 +3,8 @@ task :routes => :environment do Rails::Application.reload_routes! all_routes = ENV['CONTROLLER'] ? Rails.application.routes.routes.select { |route| route.defaults[:controller] == ENV['CONTROLLER'] } : Rails.application.routes.routes routes = all_routes.collect do |route| - name = Rails.application.routes.named_routes.routes.index(route).to_s + key_method = Hash.method_defined?('key') ? 'key' : 'index' + name = Rails.application.routes.named_routes.routes.send(key_method, route).to_s reqs = route.requirements.empty? ? "" : route.requirements.inspect {:name => name, :verb => route.verb.to_s, :path => route.path, :reqs => reqs} end -- cgit v1.2.3 From 6cabc9a61fd78a7cbc06d083a59cb252794e5a97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 16 May 2010 14:34:36 +0200 Subject: Add some comments related to Hash method check. --- railties/lib/rails/tasks/routes.rake | 3 +++ 1 file changed, 3 insertions(+) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/tasks/routes.rake b/railties/lib/rails/tasks/routes.rake index 4bb94d39ea..41619bc1f8 100644 --- a/railties/lib/rails/tasks/routes.rake +++ b/railties/lib/rails/tasks/routes.rake @@ -3,6 +3,9 @@ task :routes => :environment do Rails::Application.reload_routes! all_routes = ENV['CONTROLLER'] ? Rails.application.routes.routes.select { |route| route.defaults[:controller] == ENV['CONTROLLER'] } : Rails.application.routes.routes routes = all_routes.collect do |route| + # TODO: The :index method is deprecated in 1.9 in favor of :key + # but we don't have :key in 1.8.7. We can remove this check when + # stop supporting 1.8.x key_method = Hash.method_defined?('key') ? 'key' : 'index' name = Rails.application.routes.named_routes.routes.send(key_method, route).to_s reqs = route.requirements.empty? ? "" : route.requirements.inspect -- cgit v1.2.3 From 6c69221985268ada25b4c32360fa4f2403f2156b Mon Sep 17 00:00:00 2001 From: Rizwan Reza Date: Sun, 16 May 2010 19:45:30 +0430 Subject: Takes out stale methods relating to edge_rails_version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- railties/lib/rails/info.rb | 33 --------------------------------- 1 file changed, 33 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/info.rb b/railties/lib/rails/info.rb index 5a496f6536..e9c3ebe685 100644 --- a/railties/lib/rails/info.rb +++ b/railties/lib/rails/info.rb @@ -35,20 +35,6 @@ module Rails end end - def edge_rails_revision(info = git_info) - info[/commit ([a-z0-9-]+)/, 1] || freeze_edge_version - end - - def freeze_edge_version - if File.exist?(rails_vendor_root) - begin - Dir[File.join(rails_vendor_root, 'REVISION_*')].first.scan(/_(\d+)$/).first.first - rescue - Dir[File.join(rails_vendor_root, 'TAG_*')].first.scan(/_(.+)$/).first.first rescue 'unknown' - end - end - end - def to_s column_width = properties.names.map {|name| name.length}.max info = properties.map do |name, value| @@ -75,20 +61,6 @@ module Rails table << '' end end - - protected - def rails_vendor_root - @rails_vendor_root ||= "#{Rails.root}/vendor/rails" - end - - def git_info - env_lang, ENV['LC_ALL'] = ENV['LC_ALL'], 'C' - Dir.chdir(rails_vendor_root) do - silence_stderr { `git log -n 1` } - end - ensure - ENV['LC_ALL'] = env_lang - end end # The Ruby version and platform, e.g. "1.8.2 (powerpc-darwin8.2.0)". @@ -120,11 +92,6 @@ module Rails Rails.configuration.middleware.active.map(&:inspect) end - # The Rails Git revision, if it's checked out into vendor/rails. - property 'Edge Rails revision' do - edge_rails_revision - end - # The application's location on the filesystem. property 'Application root' do File.expand_path(Rails.root) -- cgit v1.2.3 From b7bdacf1abb71ec2b46ea54893fb881dea36cca8 Mon Sep 17 00:00:00 2001 From: Aleksandr Koss Date: Sun, 16 May 2010 17:52:25 +0100 Subject: Added rails command aliases (s g c db) to reserved words in app generator [#4602 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- railties/lib/rails/generators/rails/app/app_generator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index 0a0b033738..ee44acc2fa 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -149,7 +149,7 @@ module Rails # can change in Ruby 1.8.7 when we FileUtils.cd. RAILS_DEV_PATH = File.expand_path("../../../../../..", File.dirname(__FILE__)) - RESERVED_NAMES = %w[generate console server dbconsole + RESERVED_NAMES = %w[generate g console c server s dbconsole db application destroy benchmarker profiler plugin runner test] -- cgit v1.2.3 From 64d109e3539ad600f58536d3ecabd2f87b67fd1c Mon Sep 17 00:00:00 2001 From: wycats Date: Sun, 16 May 2010 10:25:55 +0400 Subject: Significantly improved internal encoding heuristics and support. * Default Encoding.default_internal to UTF-8 * Eliminated the use of file-wide magic comments to coerce code evaluated inside the file * Read templates as BINARY, use default_external or template-wide magic comments inside the Template to set the initial encoding * This means that template handlers in Ruby 1.9 will receive Strings encoded in default_internal (UTF-8 by default) * Create a better Exception for encoding issues, and use it when the template source has bytes that are not compatible with the specified encoding * Allow template handlers to opt-into handling BINARY. If they do so, they need to do some of their own manual encoding work * Added a "Configuration Gotchas" section to the intro Rails Guide instructing users to use UTF-8 for everything * Use config.encoding= in Ruby 1.8, and raise if a value that is an invalid $KCODE value is used Also: * Fixed a few tests that were assert() rather than assert_equal() and were caught by Minitest requiring a String for the message * Fixed a test where an assert_select was misformed, also caught by Minitest being more restrictive * Fixed a test where a Rack response was returning a String rather than an Enumerable --- railties/lib/rails/application/configuration.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 9353fbefef..8afe423973 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -1,4 +1,5 @@ require 'active_support/deprecation' +require 'active_support/core_ext/string/encoding' require 'rails/engine/configuration' module Rails @@ -27,8 +28,15 @@ module Rails def encoding=(value) @encoding = value - if defined?(Encoding) && Encoding.respond_to?(:default_external=) + if "ruby".encoding_aware? Encoding.default_external = value + Encoding.default_internal = value + else + $KCODE = value + if $KCODE == "NONE" + raise "The value you specified for config.encoding is " \ + "invalid. The possible values are UTF8, SJIS, or EUC" + end end end -- cgit v1.2.3 From ade756fe42423033bae8e5aea8f58782f7a6c517 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sun, 16 May 2010 13:52:51 -0700 Subject: Moved encoding work in progress to a feature branch. This reverts commits af0d1a88157942c6e6398dbf73891cff1e152405 and 64d109e3539ad600f58536d3ecabd2f87b67fd1c. --- railties/lib/rails/application/configuration.rb | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 8afe423973..9353fbefef 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -1,5 +1,4 @@ require 'active_support/deprecation' -require 'active_support/core_ext/string/encoding' require 'rails/engine/configuration' module Rails @@ -28,15 +27,8 @@ module Rails def encoding=(value) @encoding = value - if "ruby".encoding_aware? + if defined?(Encoding) && Encoding.respond_to?(:default_external=) Encoding.default_external = value - Encoding.default_internal = value - else - $KCODE = value - if $KCODE == "NONE" - raise "The value you specified for config.encoding is " \ - "invalid. The possible values are UTF8, SJIS, or EUC" - end end end -- cgit v1.2.3