diff options
Diffstat (limited to 'railties/lib')
50 files changed, 184 insertions, 338 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 1e4d25f18c..953233d774 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -50,7 +50,9 @@ module Rails end end - attr_accessor :assets + attr_accessor :assets, :sandbox + alias_method :sandbox?, :sandbox + delegate :default_url_options, :default_url_options=, :to => :routes # This method is called just after an application inherits from Rails::Application, @@ -96,24 +98,25 @@ module Rails self end - def load_tasks + def load_tasks(app=self) initialize_tasks - railties.all { |r| r.load_tasks } + railties.all { |r| r.load_tasks(app) } super self end - def load_generators + def load_generators(app=self) initialize_generators - railties.all { |r| r.load_generators } + railties.all { |r| r.load_generators(app) } + Rails::Generators.configure!(app.config.generators) super self end - def load_console(sandbox=false) - initialize_console(sandbox) - railties.all { |r| r.load_console(sandbox) } - super() + def load_console(app=self) + initialize_console + railties.all { |r| r.load_console(app) } + super self end @@ -183,10 +186,12 @@ module Rails end def initialize_tasks - require "rails/tasks" - task :environment do - $rails_rake_task = true - require_environment! + self.class.rake_tasks do + require "rails/tasks" + task :environment do + $rails_rake_task = true + require_environment! + end end end @@ -194,7 +199,8 @@ module Rails require "rails/generators" end - def initialize_console(sandbox=false) + def initialize_console + require "pp" require "rails/console/app" require "rails/console/helpers" end diff --git a/railties/lib/rails/code_statistics.rb b/railties/lib/rails/code_statistics.rb index 40416dd83a..770c23ae41 100644 --- a/railties/lib/rails/code_statistics.rb +++ b/railties/lib/rails/code_statistics.rb @@ -104,4 +104,4 @@ class CodeStatistics #:nodoc: puts " Code LOC: #{code} Test LOC: #{tests} Code to Test Ratio: 1:#{sprintf("%.1f", tests.to_f/code)}" puts "" end - end +end diff --git a/railties/lib/rails/commands.rb b/railties/lib/rails/commands.rb index 4a082aedb8..39627a3094 100644 --- a/railties/lib/rails/commands.rb +++ b/railties/lib/rails/commands.rb @@ -15,6 +15,8 @@ command = aliases[command] || command case command when 'generate', 'destroy', 'plugin' + require 'rails/generators' + if command == 'plugin' && ARGV.first == 'new' require "rails/commands/plugin_new" else @@ -22,7 +24,9 @@ when 'generate', 'destroy', 'plugin' Rails.application.require_environment! if defined?(ENGINE_PATH) && engine = Rails::Engine.find(ENGINE_PATH) - Rails.application = engine + Rails.application.load_generators(engine) + else + Rails.application.load_generators end require "rails/commands/#{command}" diff --git a/railties/lib/rails/commands/application.rb b/railties/lib/rails/commands/application.rb index f3fa1fd54d..1cf23a8b92 100644 --- a/railties/lib/rails/commands/application.rb +++ b/railties/lib/rails/commands/application.rb @@ -12,7 +12,6 @@ else end require 'rubygems' if ARGV.include?("--dev") - require 'rails/generators' require 'rails/generators/rails/app/app_generator' diff --git a/railties/lib/rails/commands/console.rb b/railties/lib/rails/commands/console.rb index 66dbb5d11e..32e361d421 100644 --- a/railties/lib/rails/commands/console.rb +++ b/railties/lib/rails/commands/console.rb @@ -23,7 +23,8 @@ module Rails opt.parse!(ARGV) end - @app.load_console(options[:sandbox]) + @app.sandbox = options[:sandbox] + @app.load_console if options[:debugger] begin diff --git a/railties/lib/rails/commands/destroy.rb b/railties/lib/rails/commands/destroy.rb index 2a84e2a6df..ae354eca97 100644 --- a/railties/lib/rails/commands/destroy.rb +++ b/railties/lib/rails/commands/destroy.rb @@ -1,8 +1,6 @@ require 'rails/generators' require 'active_support/core_ext/object/inclusion' -Rails::Generators.configure! - if ARGV.first.in?([nil, "-h", "--help"]) Rails::Generators.help 'destroy' exit diff --git a/railties/lib/rails/commands/generate.rb b/railties/lib/rails/commands/generate.rb index 28c1c56352..b6f9a003d1 100644 --- a/railties/lib/rails/commands/generate.rb +++ b/railties/lib/rails/commands/generate.rb @@ -1,8 +1,6 @@ require 'rails/generators' require 'active_support/core_ext/object/inclusion' -Rails::Generators.configure! - if ARGV.first.in?([nil, "-h", "--help"]) Rails::Generators.help 'generate' exit diff --git a/railties/lib/rails/commands/plugin_new.rb b/railties/lib/rails/commands/plugin_new.rb index 8baa8ebfd4..0287ba0638 100644 --- a/railties/lib/rails/commands/plugin_new.rb +++ b/railties/lib/rails/commands/plugin_new.rb @@ -1,3 +1,5 @@ +require 'rubygems' if ARGV.include?("--dev") + if ARGV.first != "new" ARGV[0] = "--help" else @@ -6,5 +8,4 @@ end require 'rails/generators' require 'rails/generators/rails/plugin_new/plugin_new_generator' - -Rails::Generators::PluginNewGenerator.start +Rails::Generators::PluginNewGenerator.start
\ No newline at end of file diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb index 505a4ca2bd..91c87514cf 100644 --- a/railties/lib/rails/commands/server.rb +++ b/railties/lib/rails/commands/server.rb @@ -78,6 +78,7 @@ module Rails middlewares = [] middlewares << [Rails::Rack::LogTailer, log_path] unless options[:daemonize] middlewares << [Rails::Rack::Debugger] if options[:debugger] + middlewares << [Rails::Rack::ContentLength] Hash.new(middlewares) end diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index 66fab0a760..f8ad17773a 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -43,6 +43,7 @@ module Rails class Generators #:nodoc: attr_accessor :aliases, :options, :templates, :fallbacks, :colorize_logging + attr_reader :hidden_namespaces def initialize @aliases = Hash.new { |h,k| h[k] = {} } @@ -50,6 +51,7 @@ module Rails @fallbacks = {} @templates = [] @colorize_logging = true + @hidden_namespaces = [] end def initialize_copy(source) @@ -59,6 +61,10 @@ module Rails @templates = @templates.dup end + def hide_namespace(namespace) + @hidden_namespaces << namespace + end + def method_missing(method, *args) method = method.to_s.sub(/=$/, '').to_sym diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index de004700ab..383be1802f 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -387,7 +387,7 @@ module Rails delegate :middleware, :root, :paths, :to => :config delegate :engine_name, :isolated?, :to => "self.class" - def load_tasks + def load_tasks(*) super paths["lib/tasks"].existent.sort.each { |ext| load(ext) } end @@ -522,9 +522,15 @@ module Rails end initializer :append_assets_path do |app| - app.config.assets.paths.unshift(*paths["vendor/assets"].existent) - app.config.assets.paths.unshift(*paths["lib/assets"].existent) - app.config.assets.paths.unshift(*paths["app/assets"].existent) + if app.config.assets.respond_to?(:prepend_path) + app.config.assets.prepend_path(*paths["vendor/assets"].existent) + app.config.assets.prepend_path(*paths["lib/assets"].existent) + app.config.assets.prepend_path(*paths["app/assets"].existent) + else + app.config.assets.paths.unshift(*paths["vendor/assets"].existent) + app.config.assets.paths.unshift(*paths["lib/assets"].existent) + app.config.assets.paths.unshift(*paths["app/assets"].existent) + end end initializer :prepend_helpers_path do |app| diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index 85c67af19a..09e505a75b 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -57,7 +57,7 @@ module Rails :resource_controller => :controller, :scaffold_controller => :scaffold_controller, :stylesheets => true, - :stylesheet_engine => nil, + :stylesheet_engine => :css, :test_framework => false, :template_engine => :erb }, @@ -68,13 +68,14 @@ module Rails } } - def self.configure!(config = Rails.application.config.generators) #:nodoc: + def self.configure!(config) #:nodoc: no_color! unless config.colorize_logging aliases.deep_merge! config.aliases options.deep_merge! config.options fallbacks.merge! config.fallbacks templates_path.concat config.templates templates_path.uniq! + hide_namespaces *config.hidden_namespaces end def self.templates_path @@ -175,6 +176,7 @@ module Rails orm = options[:rails][:orm] test = options[:rails][:test_framework] template = options[:rails][:template_engine] + css = options[:rails][:stylesheet_engine] [ "rails", @@ -194,7 +196,11 @@ module Rails "#{test}:plugin", "#{template}:controller", "#{template}:scaffold", - "#{template}:mailer" + "#{template}:mailer", + "#{css}:scaffold", + "#{css}:assets", + "css:assets", + "css:scaffold" ] end end @@ -280,7 +286,6 @@ module Rails # Receives namespaces in an array and tries to find matching generators # in the load path. def self.lookup(namespaces) #:nodoc: - load_generators_from_railties! paths = namespaces_to_paths(namespaces) paths.each do |raw_path| @@ -304,8 +309,6 @@ module Rails # This will try to load any generator in the load path to show in help. def self.lookup! #:nodoc: - load_generators_from_railties! - $LOAD_PATH.each do |base| Dir[File.join(base, "{rails/generators,generators}", "**", "*_generator.rb")].each do |path| begin @@ -318,13 +321,6 @@ module Rails end end - # Allow generators to be loaded from custom paths. - def self.load_generators_from_railties! #:nodoc: - return if defined?(@generators_from_railties) || Rails.application.nil? - @generators_from_railties = true - Rails.application.load_generators - end - # Convert namespaces to paths by replacing ":" for "/" and adding # an extra lookup. For example, "rails:model" should be searched # in both: "rails/model/model_generator" and "rails/model_generator". diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 8512b1ca4a..caa9c1016c 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -1,5 +1,5 @@ require 'digest/md5' -require 'active_support/secure_random' +require 'securerandom' require 'active_support/core_ext/string/strip' require 'rails/version' unless defined?(Rails::VERSION) require 'rbconfig' diff --git a/railties/lib/rails/generators/css/assets/assets_generator.rb b/railties/lib/rails/generators/css/assets/assets_generator.rb new file mode 100644 index 0000000000..492177ca2e --- /dev/null +++ b/railties/lib/rails/generators/css/assets/assets_generator.rb @@ -0,0 +1,13 @@ +require "rails/generators/named_base" + +module Css + module Generators + class AssetsGenerator < Rails::Generators::NamedBase + source_root File.expand_path("../templates", __FILE__) + + def copy_stylesheet + copy_file "stylesheet.css", File.join('app/assets/stylesheets', class_path, "#{file_name}.css") + end + end + end +end diff --git a/railties/lib/rails/generators/rails/assets/templates/stylesheet.css.scss b/railties/lib/rails/generators/css/assets/templates/stylesheet.css index ba95e217cc..afad32db02 100644 --- a/railties/lib/rails/generators/rails/assets/templates/stylesheet.css.scss +++ b/railties/lib/rails/generators/css/assets/templates/stylesheet.css @@ -1,5 +1,4 @@ -/* +/* Place all the styles related to the matching controller here. They will automatically be included in application.css. - You can use Sass (SCSS) here: http://sass-lang.com/ */ diff --git a/railties/lib/rails/generators/css/scaffold/scaffold_generator.rb b/railties/lib/rails/generators/css/scaffold/scaffold_generator.rb new file mode 100644 index 0000000000..1d7fe9fac0 --- /dev/null +++ b/railties/lib/rails/generators/css/scaffold/scaffold_generator.rb @@ -0,0 +1,16 @@ +require "rails/generators/named_base" + +module Css + module Generators + class ScaffoldGenerator < Rails::Generators::NamedBase + # In order to allow the Sass generators to pick up the default Rails CSS and + # transform it, we leave it in a standard location for the CSS stylesheet + # generators to handle. For the simple, default case, just copy it over. + def copy_stylesheet + dir = Rails::Generators::ScaffoldGenerator.source_root + file = File.join(dir, "scaffold.css") + create_file "app/assets/stylesheets/scaffold.css", File.read(file) + end + end + end +end diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index 5f9fb9685c..242677cc65 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -272,7 +272,7 @@ module Rails end def app_secret - ActiveSupport::SecureRandom.hex(64) + SecureRandom.hex(64) end def mysql_socket diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile index 20bd9db624..ebe38bf8e6 100644 --- a/railties/lib/rails/generators/rails/app/templates/Gemfile +++ b/railties/lib/rails/generators/rails/app/templates/Gemfile @@ -4,12 +4,12 @@ source 'http://rubygems.org' <%= database_gemfile_entry -%> -<%= "gem 'jruby-openssl'\n" if defined?(JRUBY_VERSION) && JRUBY_VERSION < "1.6" -%> +<%= "gem 'jruby-openssl'\n" if defined?(JRUBY_VERSION) -%> # Asset template engines <%= "gem 'json'\n" if RUBY_VERSION < "1.9.2" -%> -gem 'sass' +gem 'sass-rails' gem 'coffee-script' -# gem 'uglifier' +gem 'uglifier' <%= gem_for_javascript %> diff --git a/railties/lib/rails/generators/rails/app/templates/config/application.rb b/railties/lib/rails/generators/rails/app/templates/config/application.rb index 8ff80c6fd3..a097c77391 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/application.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb @@ -39,17 +39,6 @@ module <%= app_const_base %> # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de - # Please note that JavaScript expansions are *ignored altogether* if the asset - # pipeline is enabled (see config.assets.enabled below). Put your defaults in - # app/assets/javascripts/application.js in that case. - # - # JavaScript files you want as :defaults (application.js is always included). -<% if options[:skip_javascript] -%> - # config.action_view.javascript_expansions[:defaults] = %w() -<% else -%> - # config.action_view.javascript_expansions[:defaults] = %w(prototype prototype_ujs) -<% end -%> - # Configure the default encoding used in templates for Ruby 1.9. config.encoding = "utf-8" diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt index ca2d339e4b..ffd9058238 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt @@ -21,4 +21,7 @@ # Only use best-standards-support built into browsers config.action_dispatch.best_standards_support = :builtin + + # Do not compress assets + config.assets.compress = false end diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt index 1c3dc1117f..60e26755fe 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt @@ -11,9 +11,11 @@ # Disable Rails's static asset server (Apache or nginx will already do this) config.serve_static_assets = false - # Compress both stylesheets and JavaScripts + # Compress JavaScripts and CSS + config.assets.compress = true + + # Specify the default JavaScript compressor config.assets.js_compressor = :uglifier - config.assets.css_compressor = :scss # Specifies the header that your server uses for sending files # (comment out if your front-end server doesn't support this) diff --git a/railties/lib/rails/generators/rails/assets/assets_generator.rb b/railties/lib/rails/generators/rails/assets/assets_generator.rb index 2d52da77eb..db3422fe83 100644 --- a/railties/lib/rails/generators/rails/assets/assets_generator.rb +++ b/railties/lib/rails/generators/rails/assets/assets_generator.rb @@ -13,12 +13,6 @@ module Rails File.join('app/assets/javascripts', class_path, "#{asset_name}.#{javascript_extension}") end - def create_stylesheet_files - return unless options.stylesheets? - copy_file "stylesheet.#{stylesheet_extension}", - File.join('app/assets/stylesheets', class_path, "#{asset_name}.#{stylesheet_extension}") - end - protected def asset_name @@ -30,9 +24,8 @@ module Rails "js.#{options.javascript_engine}" : "js" end - def stylesheet_extension - options.stylesheet_engine.present? ? - "css.#{options.stylesheet_engine}" : "css" + hook_for :stylesheet_engine do |stylesheet_engine| + invoke stylesheet_engine, [name] if options[:stylesheets] end end end diff --git a/railties/lib/rails/generators/rails/plugin/USAGE b/railties/lib/rails/generators/rails/plugin/USAGE deleted file mode 100644 index 1bcfcf190d..0000000000 --- a/railties/lib/rails/generators/rails/plugin/USAGE +++ /dev/null @@ -1,13 +0,0 @@ -Description: - Stubs out a new plugin at vendor/plugins. Pass the plugin name, either - CamelCased or under_scored, as an argument. - -Example: - `rails generate plugin BrowserFilters` - - creates a standard browser_filters plugin: - vendor/plugins/browser_filters/README - vendor/plugins/browser_filters/init.rb - vendor/plugins/browser_filters/install.rb - vendor/plugins/browser_filters/lib/browser_filters.rb - vendor/plugins/browser_filters/test/browser_filters_test.rb diff --git a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb deleted file mode 100644 index 97f681d826..0000000000 --- a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb +++ /dev/null @@ -1,54 +0,0 @@ - -require 'rails/generators/rails/generator/generator_generator' - -module Rails - module Generators - class PluginGenerator < NamedBase - class_option :tasks, :desc => "When supplied creates tasks base files." - - def show_deprecation - return unless behavior == :invoke - message = "Plugin generator is deprecated, please use 'rails plugin new' command to generate plugin structure." - ActiveSupport::Deprecation.warn message - end - - check_class_collision - - def create_root_files - directory '.', plugin_dir, :recursive => false - end - - def create_lib_files - directory 'lib', plugin_dir('lib'), :recursive => false - end - - def create_tasks_files - return unless options[:tasks] - directory 'lib/tasks', plugin_dir('lib/tasks') - end - - hook_for :generator do |generator| - inside plugin_dir, :verbose => true do - invoke generator, [ name ], :namespace => false - end - end - - hook_for :test_framework do |test_framework| - inside plugin_dir, :verbose => true do - invoke test_framework - end - end - - protected - - def plugin_dir(join=nil) - if join - File.join(plugin_dir, join) - else - "vendor/plugins/#{file_name}" - end - end - - end - end -end diff --git a/railties/lib/rails/generators/rails/plugin/templates/MIT-LICENSE.tt b/railties/lib/rails/generators/rails/plugin/templates/MIT-LICENSE.tt deleted file mode 100644 index 8717df053d..0000000000 --- a/railties/lib/rails/generators/rails/plugin/templates/MIT-LICENSE.tt +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) <%= Date.today.year %> [name of plugin creator] - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/railties/lib/rails/generators/rails/plugin/templates/README.tt b/railties/lib/rails/generators/rails/plugin/templates/README.tt deleted file mode 100644 index 702db07cb1..0000000000 --- a/railties/lib/rails/generators/rails/plugin/templates/README.tt +++ /dev/null @@ -1,13 +0,0 @@ -<%= class_name %> -<%= "=" * class_name.size %> - -Introduction goes here. - - -Example -======= - -Example goes here. - - -Copyright (c) <%= Date.today.year %> [name of plugin creator], released under the MIT license diff --git a/railties/lib/rails/generators/rails/plugin/templates/Rakefile.tt b/railties/lib/rails/generators/rails/plugin/templates/Rakefile.tt deleted file mode 100644 index 77149ae351..0000000000 --- a/railties/lib/rails/generators/rails/plugin/templates/Rakefile.tt +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env rake -require 'rake/testtask' -require 'rake/rdoctask' - -desc 'Default: run unit tests.' -task :default => :test - -desc 'Test the <%= file_name %> plugin.' -Rake::TestTask.new(:test) do |t| - t.libs << 'lib' - t.libs << 'test' - t.pattern = 'test/**/*_test.rb' - t.verbose = true -end - -desc 'Generate documentation for the <%= file_name %> plugin.' -Rake::RDocTask.new(:rdoc) do |rdoc| - rdoc.rdoc_dir = 'rdoc' - rdoc.title = '<%= class_name %>' - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.rdoc_files.include('README') - rdoc.rdoc_files.include('lib/**/*.rb') -end
\ No newline at end of file diff --git a/railties/lib/rails/generators/rails/plugin/templates/init.rb b/railties/lib/rails/generators/rails/plugin/templates/init.rb deleted file mode 100644 index 3c19a743c9..0000000000 --- a/railties/lib/rails/generators/rails/plugin/templates/init.rb +++ /dev/null @@ -1 +0,0 @@ -# Include hook code here diff --git a/railties/lib/rails/generators/rails/plugin/templates/install.rb b/railties/lib/rails/generators/rails/plugin/templates/install.rb deleted file mode 100644 index f7732d3796..0000000000 --- a/railties/lib/rails/generators/rails/plugin/templates/install.rb +++ /dev/null @@ -1 +0,0 @@ -# Install hook code here diff --git a/railties/lib/rails/generators/rails/plugin/templates/lib/%file_name%.rb.tt b/railties/lib/rails/generators/rails/plugin/templates/lib/%file_name%.rb.tt deleted file mode 100644 index d8d908a959..0000000000 --- a/railties/lib/rails/generators/rails/plugin/templates/lib/%file_name%.rb.tt +++ /dev/null @@ -1 +0,0 @@ -# <%= class_name %> diff --git a/railties/lib/rails/generators/rails/plugin/templates/lib/tasks/%file_name%_tasks.rake.tt b/railties/lib/rails/generators/rails/plugin/templates/lib/tasks/%file_name%_tasks.rake.tt deleted file mode 100644 index 72920a9d3a..0000000000 --- a/railties/lib/rails/generators/rails/plugin/templates/lib/tasks/%file_name%_tasks.rake.tt +++ /dev/null @@ -1,4 +0,0 @@ -# desc "Explaining what the task does" -# task :<%= file_name %> do -# # Task goes here -# end diff --git a/railties/lib/rails/generators/rails/plugin/templates/uninstall.rb b/railties/lib/rails/generators/rails/plugin/templates/uninstall.rb deleted file mode 100644 index 9738333463..0000000000 --- a/railties/lib/rails/generators/rails/plugin/templates/uninstall.rb +++ /dev/null @@ -1 +0,0 @@ -# Uninstall hook code here diff --git a/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb b/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb index 9ddb3cae33..4967d1793c 100644 --- a/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +++ b/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb @@ -202,7 +202,7 @@ task :default => :test end def create_test_dummy_files - return if options[:skip_test_unit] + return if options[:skip_test_unit] && options[:dummy_path] == 'test/dummy' create_dummy_app end diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec b/railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec index 3d9bfb22c7..56b06829d8 100644 --- a/railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec +++ b/railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec @@ -4,6 +4,9 @@ Gem::Specification.new do |s| s.name = "<%= name %>" s.summary = "Insert <%= camelized %> summary." s.description = "Insert <%= camelized %> description." - s.files = Dir["lib/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"] + s.files = Dir["{app,config,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"] +<% unless options.skip_test_unit? -%> + s.test_files = Dir["test/**/*"] +<% end -%> s.version = "0.0.1" end diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile b/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile index 5704e75a29..b28a842731 100755 --- a/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile +++ b/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile @@ -4,10 +4,15 @@ begin rescue LoadError puts 'You must `gem install bundler` and `bundle install` to run rake tasks' end +begin + require 'rdoc/task' +rescue LoadError + require 'rdoc/rdoc' + require 'rake/rdoctask' + RDoc::Task = Rake::RDocTask +end -require 'rake/rdoctask' - -Rake::RDocTask.new(:rdoc) do |rdoc| +RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_dir = 'rdoc' rdoc.title = '<%= camelized %>' rdoc.options << '--line-numbers' << '--inline-source' diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/script/rails.tt b/railties/lib/rails/generators/rails/plugin_new/templates/script/rails.tt index ebd5a77dd5..65d82abf6d 100644 --- a/railties/lib/rails/generators/rails/plugin_new/templates/script/rails.tt +++ b/railties/lib/rails/generators/rails/plugin_new/templates/script/rails.tt @@ -1,4 +1,3 @@ -#!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. ENGINE_PATH = File.expand_path('../..', __FILE__) diff --git a/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb b/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb index aa9b45c5a5..03a61a035e 100644 --- a/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb +++ b/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb @@ -11,21 +11,12 @@ module Rails hook_for :scaffold_controller, :required => true - def copy_stylesheets_file - if behavior == :invoke && options.stylesheets? - template "scaffold.#{stylesheet_extension}", "app/assets/stylesheets/scaffold.#{stylesheet_extension}" - end - end - hook_for :assets do |assets| invoke assets, [controller_name] end - private - - def stylesheet_extension - options.stylesheet_engine.present? ? - "css.#{options.stylesheet_engine}" : "css" + hook_for :stylesheet_engine do |stylesheet_engine| + invoke stylesheet_engine, [controller_name] if options[:stylesheets] && behavior == :invoke end end end diff --git a/railties/lib/rails/generators/rails/scaffold/templates/scaffold.css.scss b/railties/lib/rails/generators/rails/scaffold/templates/scaffold.css.scss deleted file mode 100644 index 45116b53f6..0000000000 --- a/railties/lib/rails/generators/rails/scaffold/templates/scaffold.css.scss +++ /dev/null @@ -1,58 +0,0 @@ -body { background-color: #fff; color: #333; } - -body, p, ol, ul, td { - font-family: verdana, arial, helvetica, sans-serif; - font-size: 13px; - line-height: 18px; -} - -pre { - background-color: #eee; - padding: 10px; - font-size: 11px; -} - -a { - color: #000; - &:visited { color: #666; } - &:hover { color: #fff; background-color:#000; } -} - -div.field, div.actions { - margin-bottom: 10px; -} - -#notice { - color: green; -} - -.field_with_errors { - padding: 2px; - background-color: red; - display: table; -} - -#error_explanation { - width: 450px; - border: 2px solid red; - padding: 7px; - padding-bottom: 0; - margin-bottom: 20px; - background-color: #f0f0f0; - - h2 { - text-align: left; - font-weight: bold; - padding: 5px 5px 5px 15px; - font-size: 12px; - margin: -7px; - margin-bottom: 0px; - background-color: #c00; - color: #fff; - } - - ul li { - font-size: 12px; - list-style: square; - } -}
\ No newline at end of file diff --git a/railties/lib/rails/paths.rb b/railties/lib/rails/paths.rb index 5d217dcb10..09ff0ef378 100644 --- a/railties/lib/rails/paths.rb +++ b/railties/lib/rails/paths.rb @@ -2,29 +2,11 @@ require 'set' module Rails module Paths - module PathParent #:nodoc: - def method_missing(id, *args) - match = id.to_s.match(/^(.*)=$/) - full = [@current, $1 || id].compact.join("/") - - ActiveSupport::Deprecation.warn 'config.paths.app.controller API is deprecated in ' << - 'favor of config.paths["app/controller"] API.' - - if match || args.any? - @root[full] = Path.new(@root, full, *args) - elsif path = @root[full] - path - else - super - end - end - end - # This object is an extended hash that behaves as root of the Rails::Paths system. # It allows you to collect information about how you want to structure your application # paths by a Hash like API. It requires you to give a physical path on initialization. # - # root = Root.new + # root = Root.new "/rails" # root.add "app/controllers", :eager_load => true # # The command above creates a new root object and add "app/controllers" as a path. @@ -54,8 +36,7 @@ module Rails # # Finally, the Path object also provides a few helpers: # - # root = Root.new - # root.path = "/rails" + # root = Root.new "/rails" # root.add "app/controllers" # # root["app/controllers"].expanded # => ["/rails/app/controllers"] @@ -63,11 +44,10 @@ module Rails # # Check the Path documentation for more information. class Root < ::Hash - include PathParent attr_accessor :path def initialize(path) - raise if path.is_a?(Array) + raise "Argument should be a String of the physical root path" if path.is_a?(Array) @current = nil @path = path @root = self @@ -121,8 +101,6 @@ module Rails end class Path < Array - include PathParent - attr_reader :path attr_accessor :glob @@ -194,11 +172,6 @@ module Rails expanded.select { |f| File.exists?(f) } end - def paths - ActiveSupport::Deprecation.warn "paths is deprecated. Please call expand instead." - expanded - end - alias to_a expanded end end diff --git a/railties/lib/rails/rack.rb b/railties/lib/rails/rack.rb index 1f20ceae44..d4a41b217e 100644 --- a/railties/lib/rails/rack.rb +++ b/railties/lib/rails/rack.rb @@ -1,8 +1,8 @@ module Rails module Rack - autoload :Debugger, "rails/rack/debugger" - autoload :Logger, "rails/rack/logger" - autoload :LogTailer, "rails/rack/log_tailer" - autoload :Static, "rails/rack/static" + autoload :ContentLength, "rails/rack/content_length" + autoload :Debugger, "rails/rack/debugger" + autoload :Logger, "rails/rack/logger" + autoload :LogTailer, "rails/rack/log_tailer" end end diff --git a/railties/lib/rails/rack/content_length.rb b/railties/lib/rails/rack/content_length.rb new file mode 100644 index 0000000000..6839af4152 --- /dev/null +++ b/railties/lib/rails/rack/content_length.rb @@ -0,0 +1,38 @@ +require 'action_dispatch' +require 'rack/utils' + +module Rails + module Rack + # Sets the Content-Length header on responses with fixed-length bodies. + class ContentLength + include ::Rack::Utils + + def initialize(app, sendfile=nil) + @app = app + @sendfile = sendfile + end + + def call(env) + status, headers, body = @app.call(env) + headers = HeaderHash.new(headers) + + if !STATUS_WITH_NO_ENTITY_BODY.include?(status.to_i) && + !headers['Content-Length'] && + !headers['Transfer-Encoding'] && + !(@sendfile && headers[@sendfile]) + + old_body = body + body, length = [], 0 + old_body.each do |part| + body << part + length += bytesize(part) + end + old_body.close if old_body.respond_to?(:close) + headers['Content-Length'] = length.to_s + end + + [status, headers, body] + end + end + end +end
\ No newline at end of file diff --git a/railties/lib/rails/rack/debugger.rb b/railties/lib/rails/rack/debugger.rb index 06e23db5f1..831188eeee 100644 --- a/railties/lib/rails/rack/debugger.rb +++ b/railties/lib/rails/rack/debugger.rb @@ -1,5 +1,3 @@ -require 'active_support/core_ext/kernel/requires' - module Rails module Rack class Debugger @@ -8,11 +6,12 @@ module Rails ARGV.clear # clear ARGV so that rails server options aren't passed to IRB - require_library_or_gem 'ruby-debug' + require 'ruby-debug' + ::Debugger.start ::Debugger.settings[:autoeval] = true if ::Debugger.respond_to?(:settings) puts "=> Debugger enabled" - rescue Exception + rescue LoadError puts "You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'" exit end diff --git a/railties/lib/rails/rack/static.rb b/railties/lib/rails/rack/static.rb deleted file mode 100644 index ebe8b9e103..0000000000 --- a/railties/lib/rails/rack/static.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'action_dispatch' - -module Rails::Rack - Static = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('Rails::Rack::Static', ActionDispatch::Static) -end diff --git a/railties/lib/rails/railtie.rb b/railties/lib/rails/railtie.rb index b183eb8ddd..65c567d72f 100644 --- a/railties/lib/rails/railtie.rb +++ b/railties/lib/rails/railtie.rb @@ -173,23 +173,24 @@ module Rails def eager_load! end - def load_console(sandbox=false) - self.class.console.each { |block| block.call(sandbox) } + def load_console(app) + self.class.console.each { |block| block.call(app) } end - def load_tasks - self.class.rake_tasks.each(&:call) + def load_tasks(app) + extend Rake::DSL if defined? Rake::DSL + self.class.rake_tasks.each { |block| block.call(app) } # load also tasks from all superclasses klass = self.class.superclass while klass.respond_to?(:rake_tasks) - klass.rake_tasks.each { |t| self.instance_exec(&t) } + klass.rake_tasks.each { |t| self.instance_exec(app, &t) } klass = klass.superclass end end - def load_generators - self.class.generators.each(&:call) + def load_generators(app) + self.class.generators.each { |block| block.call(app) } end end end diff --git a/railties/lib/rails/railtie/configuration.rb b/railties/lib/rails/railtie/configuration.rb index bfd2a73aeb..f888684117 100644 --- a/railties/lib/rails/railtie/configuration.rb +++ b/railties/lib/rails/railtie/configuration.rb @@ -26,11 +26,6 @@ module Rails @@app_generators end - def generators(&block) #:nodoc - ActiveSupport::Deprecation.warn "config.generators in Rails::Railtie is deprecated. Please use config.app_generators instead." - app_generators(&block) - end - # First configurable block to run. Called before any initializers are run. def before_configuration(&block) ActiveSupport.on_load(:before_configuration, :yield => true, &block) diff --git a/railties/lib/rails/tasks/assets.rake b/railties/lib/rails/tasks/assets.rake index 158df31749..5d2f02af13 100644 --- a/railties/lib/rails/tasks/assets.rake +++ b/railties/lib/rails/tasks/assets.rake @@ -2,7 +2,7 @@ namespace :assets do desc "Compile all the assets named in config.assets.precompile" task :precompile => :environment do # Give assets access to asset_path - ActionView::Helpers::SprocketsHelper + Sprockets::Helpers::RailsHelper assets = Rails.application.config.assets.precompile Rails.application.assets.precompile(*assets) diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake index edd716d7d0..79255d1f56 100644 --- a/railties/lib/rails/tasks/documentation.rake +++ b/railties/lib/rails/tasks/documentation.rake @@ -1,7 +1,13 @@ -require 'rake/rdoctask' +begin + require 'rdoc/task' +rescue LoadError + require 'rdoc/rdoc' + require 'rake/rdoctask' + RDoc::Task = Rake::RDocTask +end # Monkey-patch to remove redoc'ing and clobber descriptions to cut down on rake -T noise -class RDocTaskWithoutDescriptions < Rake::RDocTask +class RDocTaskWithoutDescriptions < RDoc::Task def define task rdoc_task_name diff --git a/railties/lib/rails/tasks/misc.rake b/railties/lib/rails/tasks/misc.rake index e505b8c338..833fcb6f72 100644 --- a/railties/lib/rails/tasks/misc.rake +++ b/railties/lib/rails/tasks/misc.rake @@ -9,8 +9,8 @@ end desc 'Generate a cryptographically secure secret key (this is typically used to generate a secret for cookie sessions).' task :secret do - require 'active_support/secure_random' - puts ActiveSupport::SecureRandom.hex(64) + require 'securerandom' + puts SecureRandom.hex(64) end desc 'List versions of all Rails frameworks and the environment' diff --git a/railties/lib/rails/test_help.rb b/railties/lib/rails/test_help.rb index 41485c8bac..68f566274d 100644 --- a/railties/lib/rails/test_help.rb +++ b/railties/lib/rails/test_help.rb @@ -3,7 +3,6 @@ abort("Abort testing: Your Rails environment is running in production mode!") if Rails.env.production? require 'test/unit' -require 'active_support/core_ext/kernel/requires' require 'active_support/test_case' require 'action_controller/test_case' require 'action_dispatch/testing/integration' diff --git a/railties/lib/rails/version.rb b/railties/lib/rails/version.rb index fc6c0a0204..3d6ecb9d30 100644 --- a/railties/lib/rails/version.rb +++ b/railties/lib/rails/version.rb @@ -3,7 +3,7 @@ module Rails MAJOR = 3 MINOR = 1 TINY = 0 - PRE = "beta1" + PRE = "rc1" STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.') end |