diff options
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails.rb | 14 | ||||
-rw-r--r-- | railties/lib/rails/commands.rb | 10 | ||||
-rw-r--r-- | railties/lib/rails/generators/actions.rb | 19 | ||||
-rw-r--r-- | railties/lib/rails/generators/base.rb | 10 | ||||
-rw-r--r-- | railties/lib/rails/generators/named_base.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/public/404.html | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/public/422.html | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/public/500.html | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/public/index.html | 4 | ||||
-rw-r--r-- | railties/lib/rails/generators/resource_helpers.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/railtie.rb | 2 | ||||
-rw-r--r-- | railties/test/application/asset_debugging_test.rb | 8 | ||||
-rw-r--r-- | railties/test/application/assets_test.rb | 8 | ||||
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 10 | ||||
-rw-r--r-- | railties/test/rails_info_test.rb | 2 |
15 files changed, 55 insertions, 42 deletions
diff --git a/railties/lib/rails.rb b/railties/lib/rails.rb index 6b431d3ee3..945063e55c 100644 --- a/railties/lib/rails.rb +++ b/railties/lib/rails.rb @@ -25,11 +25,11 @@ module Rails class << self def application - @@application ||= nil + @application ||= nil end def application=(application) - @@application = application + @application = application end # The Configuration instance used to configure the Rails environment @@ -46,15 +46,15 @@ module Rails end def logger - @@logger ||= nil + @logger ||= nil end def logger=(logger) - @@logger = logger + @logger = logger end def backtrace_cleaner - @@backtrace_cleaner ||= begin + @backtrace_cleaner ||= begin # Relies on Active Support, so we have to lazy load to postpone definition until AS has been loaded require 'rails/backtrace_cleaner' Rails::BacktraceCleaner.new @@ -74,11 +74,11 @@ module Rails end def cache - @@cache ||= nil + @cache ||= nil end def cache=(cache) - @@cache = cache + @cache = cache end # Returns all rails groups for loading based on: diff --git a/railties/lib/rails/commands.rb b/railties/lib/rails/commands.rb index 71fe604e69..82cdd6053b 100644 --- a/railties/lib/rails/commands.rb +++ b/railties/lib/rails/commands.rb @@ -64,9 +64,13 @@ when 'application', 'runner' require "rails/commands/#{command}" when 'new' - puts "Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first.\n" - puts "Type 'rails' for help." - exit(1) + if ARGV.first.in?(['-h', '--help']) + require 'rails/commands/application' + else + puts "Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first.\n" + puts "Type 'rails' for help." + exit(1) + end when '--version', '-v' ARGV.unshift '--version' diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index 32793b1a70..9b0649e456 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -69,6 +69,7 @@ module Rails # ==== Example # # add_source "http://gems.github.com/" + # def add_source(source, options={}) log :source, source @@ -82,6 +83,16 @@ module Rails # If options :env is specified, the line is appended to the corresponding # file in config/environments. # + # ==== Examples + # + # environment do + # "config.autoload_paths += %W(#{config.root}/extras)" + # end + # + # environment(nil, :env => "development") do + # "config.active_record.observers = :cacher" + # end + # def environment(data=nil, options={}, &block) sentinel = /class [a-z_:]+ < Rails::Application/i env_file_sentinel = /::Application\.configure do/ @@ -160,13 +171,13 @@ module Rails # <<-TASK # namespace :#{project} do # task :bootstrap do - # puts "i like boots!" + # puts "I like boots!" # end # end # TASK # end # - # rakefile("seed.rake", "puts 'im plantin ur seedz'") + # rakefile('seed.rake', 'puts "Planting seeds"') # def rakefile(filename, data=nil, &block) log :rakefile, filename @@ -239,7 +250,7 @@ module Rails # # === Example # - # route "root :to => 'welcome'" + # route "root :to => 'welcome#index'" # def route(routing_code) log :route, routing_code @@ -265,7 +276,6 @@ module Rails # Define log for backwards compatibility. If just one argument is sent, # invoke say, otherwise invoke say_status. Differently from say and # similarly to say_status, this method respects the quiet? option given. - # def log(*args) if args.size == 1 say args.first.to_s unless options.quiet? @@ -276,7 +286,6 @@ module Rails end # Add an extension to the given name based on the platform. - # def extify(name) if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ "#{name}.bat" diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb index ffc2d6e081..1648b9674a 100644 --- a/railties/lib/rails/generators/base.rb +++ b/railties/lib/rails/generators/base.rb @@ -248,7 +248,6 @@ module Rails # Check whether the given class names are already taken by user # application or Ruby on Rails. - # def class_collisions(*class_names) #:nodoc: return unless behavior == :invoke @@ -275,13 +274,11 @@ module Rails end # Use Rails default banner. - # def self.banner "rails generate #{namespace.sub(/^rails:/,'')} #{self.arguments.map{ |a| a.usage }.join(' ')} [options]".gsub(/\s+/, ' ') end # Sets the base_name taking into account the current class namespace. - # def self.base_name @base_name ||= begin if base = name.to_s.split('::').first @@ -292,7 +289,6 @@ module Rails # Removes the namespaces and get the generator name. For example, # Rails::Generators::ModelGenerator will return "model" as generator name. - # def self.generator_name @generator_name ||= begin if generator = name.to_s.split('::').last @@ -304,20 +300,17 @@ module Rails # Return the default value for the option name given doing a lookup in # Rails::Generators.options. - # def self.default_value_for_option(name, options) default_for_option(Rails::Generators.options, name, options, options[:default]) end # Return default aliases for the option name given doing a lookup in # Rails::Generators.aliases. - # def self.default_aliases_for_option(name, options) default_for_option(Rails::Generators.aliases, name, options, options[:aliases]) end # Return default for the option name given doing a lookup in config. - # def self.default_for_option(config, name, options, default) if generator_name and c = config[generator_name.to_sym] and c.key?(name) c[name] @@ -331,14 +324,12 @@ module Rails end # Keep hooks configuration that are used on prepare_for_invocation. - # def self.hooks #:nodoc: @hooks ||= from_superclass(:hooks, {}) end # Prepare class invocation to search on Rails namespace if a previous # added hook is being used. - # def self.prepare_for_invocation(name, value) #:nodoc: return super unless value.is_a?(String) || value.is_a?(Symbol) @@ -354,7 +345,6 @@ module Rails # Small macro to add ruby as an option to the generator with proper # default value plus an instance helper method called shebang. - # def self.add_shebang_option! class_option :ruby, :type => :string, :aliases => "-r", :default => Thor::Util.ruby_command, :desc => "Path to the Ruby binary of your choice", :banner => "PATH" diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb index 862fd9e88d..c457b5fbbc 100644 --- a/railties/lib/rails/generators/named_base.rb +++ b/railties/lib/rails/generators/named_base.rb @@ -99,7 +99,7 @@ module Rails end def i18n_scope - @i18n_scope ||= file_path.gsub('/', '.') + @i18n_scope ||= file_path.tr('/', '.') end def table_name diff --git a/railties/lib/rails/generators/rails/app/templates/public/404.html b/railties/lib/rails/generators/rails/app/templates/public/404.html index 9a48320a5f..276c8c1c6a 100644 --- a/railties/lib/rails/generators/rails/app/templates/public/404.html +++ b/railties/lib/rails/generators/rails/app/templates/public/404.html @@ -2,7 +2,7 @@ <html> <head> <title>The page you were looking for doesn't exist (404)</title> - <style type="text/css"> + <style> body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; } div.dialog { width: 25em; diff --git a/railties/lib/rails/generators/rails/app/templates/public/422.html b/railties/lib/rails/generators/rails/app/templates/public/422.html index 83660ab187..3f1bfb3417 100644 --- a/railties/lib/rails/generators/rails/app/templates/public/422.html +++ b/railties/lib/rails/generators/rails/app/templates/public/422.html @@ -2,7 +2,7 @@ <html> <head> <title>The change you wanted was rejected (422)</title> - <style type="text/css"> + <style> body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; } div.dialog { width: 25em; diff --git a/railties/lib/rails/generators/rails/app/templates/public/500.html b/railties/lib/rails/generators/rails/app/templates/public/500.html index f3648a0dbc..dfdb7d0b05 100644 --- a/railties/lib/rails/generators/rails/app/templates/public/500.html +++ b/railties/lib/rails/generators/rails/app/templates/public/500.html @@ -2,7 +2,7 @@ <html> <head> <title>We're sorry, but something went wrong (500)</title> - <style type="text/css"> + <style> body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; } div.dialog { width: 25em; diff --git a/railties/lib/rails/generators/rails/app/templates/public/index.html b/railties/lib/rails/generators/rails/app/templates/public/index.html index a1d50995c5..dd09a96de9 100644 --- a/railties/lib/rails/generators/rails/app/templates/public/index.html +++ b/railties/lib/rails/generators/rails/app/templates/public/index.html @@ -2,7 +2,7 @@ <html> <head> <title>Ruby on Rails: Welcome aboard</title> - <style type="text/css" media="screen"> + <style media="screen"> body { margin: 0; margin-bottom: 25px; @@ -171,7 +171,7 @@ font-style: italic; } </style> - <script type="text/javascript"> + <script> function about() { info = document.getElementById('about-content'); if (window.XMLHttpRequest) diff --git a/railties/lib/rails/generators/resource_helpers.rb b/railties/lib/rails/generators/resource_helpers.rb index 3c5b39fa16..48833869e5 100644 --- a/railties/lib/rails/generators/resource_helpers.rb +++ b/railties/lib/rails/generators/resource_helpers.rb @@ -50,7 +50,7 @@ module Rails end def controller_i18n_scope - @controller_i18n_scope ||= controller_file_path.gsub('/', '.') + @controller_i18n_scope ||= controller_file_path.tr('/', '.') end # Loads the ORM::Generators::ActiveModel class. This class is responsible diff --git a/railties/lib/rails/railtie.rb b/railties/lib/rails/railtie.rb index e8563f4daf..dc5de4084e 100644 --- a/railties/lib/rails/railtie.rb +++ b/railties/lib/rails/railtie.rb @@ -162,7 +162,7 @@ module Rails protected def generate_railtie_name(class_or_module) - ActiveSupport::Inflector.underscore(class_or_module).gsub("/", "_") + ActiveSupport::Inflector.underscore(class_or_module).tr("/", "_") end end diff --git a/railties/test/application/asset_debugging_test.rb b/railties/test/application/asset_debugging_test.rb index a2a7f184b8..1ac349a560 100644 --- a/railties/test/application/asset_debugging_test.rb +++ b/railties/test/application/asset_debugging_test.rb @@ -45,8 +45,8 @@ module ApplicationTests # the debug_assets params isn't used if compile is off get '/posts?debug_assets=true' - assert_match(/<script src="\/assets\/application-([0-z]+)\.js" type="text\/javascript"><\/script>/, last_response.body) - assert_no_match(/<script src="\/assets\/xmlhr-([0-z]+)\.js" type="text\/javascript"><\/script>/, last_response.body) + assert_match(/<script src="\/assets\/application-([0-z]+)\.js"><\/script>/, last_response.body) + assert_no_match(/<script src="\/assets\/xmlhr-([0-z]+)\.js"><\/script>/, last_response.body) end test "assets aren't concatened when compile is true is on and debug_assets params is true" do @@ -58,8 +58,8 @@ module ApplicationTests class ::PostsController < ActionController::Base ; end get '/posts?debug_assets=true' - assert_match(/<script src="\/assets\/application-([0-z]+)\.js\?body=1" type="text\/javascript"><\/script>/, last_response.body) - assert_match(/<script src="\/assets\/xmlhr-([0-z]+)\.js\?body=1" type="text\/javascript"><\/script>/, last_response.body) + assert_match(/<script src="\/assets\/application-([0-z]+)\.js\?body=1"><\/script>/, last_response.body) + assert_match(/<script src="\/assets\/xmlhr-([0-z]+)\.js\?body=1"><\/script>/, last_response.body) end end end diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb index 1469c9af4d..37981917e3 100644 --- a/railties/test/application/assets_test.rb +++ b/railties/test/application/assets_test.rb @@ -382,8 +382,8 @@ module ApplicationTests # the debug_assets params isn't used if compile is off get '/posts?debug_assets=true' - assert_match(/<script src="\/assets\/application-([0-z]+)\.js" type="text\/javascript"><\/script>/, last_response.body) - assert_no_match(/<script src="\/assets\/xmlhr-([0-z]+)\.js" type="text\/javascript"><\/script>/, last_response.body) + assert_match(/<script src="\/assets\/application-([0-z]+)\.js"><\/script>/, last_response.body) + assert_no_match(/<script src="\/assets\/xmlhr-([0-z]+)\.js"><\/script>/, last_response.body) end test "assets aren't concatened when compile is true is on and debug_assets params is true" do @@ -397,8 +397,8 @@ module ApplicationTests class ::PostsController < ActionController::Base ; end get '/posts?debug_assets=true' - assert_match(/<script src="\/assets\/application-([0-z]+)\.js\?body=1" type="text\/javascript"><\/script>/, last_response.body) - assert_match(/<script src="\/assets\/xmlhr-([0-z]+)\.js\?body=1" type="text\/javascript"><\/script>/, last_response.body) + assert_match(/<script src="\/assets\/application-([0-z]+)\.js\?body=1"><\/script>/, last_response.body) + assert_match(/<script src="\/assets\/xmlhr-([0-z]+)\.js\?body=1"><\/script>/, last_response.body) end test "assets can access model information when precompiling" do diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 128854e4ad..40cb876b34 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -83,6 +83,16 @@ class AppGeneratorTest < Rails::Generators::TestCase assert_equal false, $?.success? end + def test_application_new_show_help_message_inside_existing_rails_directory + app_root = File.join(destination_root, 'myfirstapp') + run_generator [app_root] + output = Dir.chdir(app_root) do + `rails new --help` + end + assert_match /rails new APP_PATH \[options\]/, output + assert_equal true, $?.success? + end + def test_application_name_is_detected_if_it_exists_and_app_folder_renamed app_root = File.join(destination_root, "myapp") app_moved_root = File.join(destination_root, "myapp_moved") diff --git a/railties/test/rails_info_test.rb b/railties/test/rails_info_test.rb index 1da66062aa..b9fb071d23 100644 --- a/railties/test/rails_info_test.rb +++ b/railties/test/rails_info_test.rb @@ -43,7 +43,7 @@ class InfoTest < ActiveSupport::TestCase def test_frameworks_exist Rails::Info.frameworks.each do |framework| - dir = File.dirname(__FILE__) + "/../../" + framework.gsub('_', '') + dir = File.dirname(__FILE__) + "/../../" + framework.delete('_') assert File.directory?(dir), "#{framework.classify} does not exist" end end |