From ab83800c3519595b909b760deb09c6ef46a07274 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Wed, 27 Jan 2010 22:46:59 +0700 Subject: Hide '/rails/info/properties' from 'rake routes' [#3793 state:resolved] Signed-off-by: Pratik Naik --- railties/lib/rails/tasks/routes.rake | 1 + 1 file changed, 1 insertion(+) diff --git a/railties/lib/rails/tasks/routes.rake b/railties/lib/rails/tasks/routes.rake index e8da72db4d..ac0f440896 100644 --- a/railties/lib/rails/tasks/routes.rake +++ b/railties/lib/rails/tasks/routes.rake @@ -7,6 +7,7 @@ task :routes => :environment do reqs = route.requirements.empty? ? "" : route.requirements.inspect {:name => name, :verb => route.verb.to_s, :path => route.path, :reqs => reqs} end + routes.reject!{ |r| r[:path] == "/rails/info/properties" } # skip the route if it's internal info route name_width = routes.collect {|r| r[:name]}.collect {|n| n.length}.max verb_width = routes.collect {|r| r[:verb]}.collect {|v| v.length}.max path_width = routes.collect {|r| r[:path]}.collect {|s| s.length}.max -- cgit v1.2.3 From f16e2ae9c96246ad4eb6b1b26c71150c53e75fbe Mon Sep 17 00:00:00 2001 From: Kieran Pilkington Date: Thu, 28 Jan 2010 13:00:38 +1300 Subject: Updating USAGE information for Mailer generator [#3801 status:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- railties/lib/generators/rails/mailer/USAGE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/lib/generators/rails/mailer/USAGE b/railties/lib/generators/rails/mailer/USAGE index 4b0b8ddc3b..beae79fbf4 100644 --- a/railties/lib/generators/rails/mailer/USAGE +++ b/railties/lib/generators/rails/mailer/USAGE @@ -2,7 +2,7 @@ Description: Stubs out a new mailer and its views. Pass the mailer name, either CamelCased or under_scored, and an optional list of emails as arguments. - This generates a mailer class in app/models and invokes your template + This generates a mailer class in app/mailers and invokes your template engine and test framework generators. Example: -- cgit v1.2.3 From f4e5303bcf36f845ba0808250c44eae26860e366 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Tue, 27 Oct 2009 16:30:24 -0700 Subject: fixed migration logger bug [#3434 status:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- activerecord/lib/active_record/migration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index c059b2d18b..c5630ba2fd 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -488,7 +488,7 @@ module ActiveRecord runnable.pop if down? && !target.nil? runnable.each do |migration| - Base.logger.info "Migrating to #{migration.name} (#{migration.version})" + Base.logger.info "Migrating to #{migration.name} (#{migration.version})" if Base.logger # On our way up, we skip migrating the ones we've already migrated next if up? && migrated.include?(migration.version.to_i) -- cgit v1.2.3 From ea2cbc86f7d73a4884a16530454908cff765c0dc Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Tue, 26 Jan 2010 16:21:12 +0700 Subject: Add test case for unable to run migration if ActiveRecord::Base.logger is nil (#3434) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- activerecord/test/cases/migration_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index 0ef34e440a..dd32eeeff2 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -1350,6 +1350,16 @@ if ActiveRecord::Base.connection.supports_migrations? end end + def test_migration_should_be_run_without_logger + previous_logger = ActiveRecord::Base.logger + ActiveRecord::Base.logger = nil + assert_nothing_raised do + ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/valid") + end + ensure + ActiveRecord::Base.logger = previous_logger + end + protected def with_env_tz(new_tz = 'US/Eastern') old_tz, ENV['TZ'] = ENV['TZ'], new_tz -- cgit v1.2.3 From c01014ac1c98a05fe68e652f978dfa9d43f0fc2b Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Wed, 27 Jan 2010 11:33:25 +0700 Subject: Modify the behavior of `radio_button_tag` to use `sanitize_to_id` for consistency [#1792 status:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- actionpack/lib/action_view/helpers/form_tag_helper.rb | 4 +--- actionpack/test/template/form_tag_helper_test.rb | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index 9b8471c6c6..ba1b0bcc20 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -329,9 +329,7 @@ module ActionView # radio_button_tag 'color', "green", true, :class => "color_input" # # => def radio_button_tag(name, value, checked = false, options = {}) - pretty_tag_value = value.to_s.gsub(/\s/, "_").gsub(/(?!-)\W/, "").downcase - pretty_name = name.to_s.gsub(/\[/, "_").gsub(/\]/, "") - html_options = { "type" => "radio", "name" => name, "id" => "#{pretty_name}_#{pretty_tag_value}", "value" => value }.update(options.stringify_keys) + html_options = { "type" => "radio", "name" => name, "id" => "#{sanitize_to_id(name)}_#{sanitize_to_id(value)}", "value" => value }.update(options.stringify_keys) html_options["checked"] = "checked" if checked tag :input, html_options end diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index 3635c7548e..6ac5df1ea9 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -120,6 +120,10 @@ class FormTagHelperTest < ActionView::TestCase actual = radio_button_tag("person[gender]", "m") expected = %() assert_dom_equal expected, actual + + actual = radio_button_tag('ctrlname', 'apache2.2') + expected = %() + assert_dom_equal expected, actual end def test_select_tag -- cgit v1.2.3 From 17bee0dd2fcce2d040bd6edda3e19cb11c5813d9 Mon Sep 17 00:00:00 2001 From: Szymon Nowak Date: Sat, 30 Jan 2010 17:38:42 +0100 Subject: Change Rails::Generators::Migration protected instance methods to class methods. [#3820 status:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- activerecord/lib/generators/active_record.rb | 17 +++++----- railties/lib/rails/generators/migration.rb | 50 +++++++++++++++------------- 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/activerecord/lib/generators/active_record.rb b/activerecord/lib/generators/active_record.rb index 25b982f296..1ca838b4f2 100644 --- a/activerecord/lib/generators/active_record.rb +++ b/activerecord/lib/generators/active_record.rb @@ -16,16 +16,15 @@ module ActiveRecord end end - protected - # Implement the required interface for Rails::Generators::Migration. - # - def next_migration_number(dirname) #:nodoc: - if ActiveRecord::Base.timestamped_migrations - Time.now.utc.strftime("%Y%m%d%H%M%S") - else - "%.3d" % (current_migration_number(dirname) + 1) - end + # Implement the required interface for Rails::Generators::Migration. + # + def self.next_migration_number(dirname) #:nodoc: + if ActiveRecord::Base.timestamped_migrations + Time.now.utc.strftime("%Y%m%d%H%M%S") + else + "%.3d" % (current_migration_number(dirname) + 1) end + end end end end diff --git a/railties/lib/rails/generators/migration.rb b/railties/lib/rails/generators/migration.rb index 0a9151ecdf..957d695d3a 100644 --- a/railties/lib/rails/generators/migration.rb +++ b/railties/lib/rails/generators/migration.rb @@ -6,11 +6,36 @@ module Rails # module Migration def self.included(base) #:nodoc: + base.extend ClassMethods base.send :attr_reader, :migration_number, :migration_file_name, :migration_class_name end + module ClassMethods + def migration_lookup_at(dirname) #:nodoc: + Dir.glob("#{dirname}/[0-9]*_*.rb") + end + + def migration_exists?(dirname, file_name) #:nodoc: + migration_lookup_at(dirname).grep(/\d+_#{file_name}.rb$/).first + end + + def current_migration_number(dirname) #:nodoc: + migration_lookup_at(dirname).collect do |file| + File.basename(file).split("_").first.to_i + end.max.to_i + end + + def next_migration_number(dirname) #:nodoc: + orm = Rails.configuration.generators.options[:rails][:orm] + require "generators/#{orm}" + "#{orm.to_s.camelize}::Generators::Base".constantize.next_migration_number(dirname) + rescue + raise NotImplementedError + end + end + # Creates a migration template at the given destination. The difference # to the default template method is that the migration number is appended # to the destination file name. @@ -26,11 +51,11 @@ module Rails destination = File.expand_path(destination || source, self.destination_root) migration_dir = File.dirname(destination) - @migration_number = next_migration_number(migration_dir) + @migration_number = self.class.next_migration_number(migration_dir) @migration_file_name = File.basename(destination).sub(/\.rb$/, '') @migration_class_name = @migration_file_name.camelize - destination = migration_exists?(migration_dir, @migration_file_name) + destination = self.class.migration_exists?(migration_dir, @migration_file_name) if behavior == :invoke raise Error, "Another migration is already named #{@migration_file_name}: #{destination}" if destination @@ -39,27 +64,6 @@ module Rails template(source, destination, config) end - - protected - - def migration_lookup_at(dirname) #:nodoc: - Dir.glob("#{dirname}/[0-9]*_*.rb") - end - - def migration_exists?(dirname, file_name) #:nodoc: - migration_lookup_at(dirname).grep(/\d+_#{file_name}.rb$/).first - end - - def current_migration_number(dirname) #:nodoc: - migration_lookup_at(dirname).collect do |file| - File.basename(file).split("_").first.to_i - end.max.to_i - end - - def next_migration_number(dirname) #:nodoc: - raise NotImplementError - end - end end end -- cgit v1.2.3 From 101a8fa5f8cbf0f981ca984a279fb9838c79a751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 2 Feb 2010 10:24:31 +0100 Subject: Ensure that attr_reader methods in generators are protected. --- railties/lib/rails/generators/migration.rb | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/railties/lib/rails/generators/migration.rb b/railties/lib/rails/generators/migration.rb index 957d695d3a..8a8c899cc1 100644 --- a/railties/lib/rails/generators/migration.rb +++ b/railties/lib/rails/generators/migration.rb @@ -6,10 +6,11 @@ module Rails # module Migration def self.included(base) #:nodoc: - base.extend ClassMethods - base.send :attr_reader, :migration_number, - :migration_file_name, - :migration_class_name + base.class_eval do + extend ClassMethods + readers = lambda { attr_reader :migration_number, :migration_file_name, :migration_class_name } + respond_to?(:no_tasks) ? no_tasks(&readers) : readers.call + end end module ClassMethods @@ -28,10 +29,6 @@ module Rails end def next_migration_number(dirname) #:nodoc: - orm = Rails.configuration.generators.options[:rails][:orm] - require "generators/#{orm}" - "#{orm.to_s.camelize}::Generators::Base".constantize.next_migration_number(dirname) - rescue raise NotImplementedError end end -- cgit v1.2.3 From ec4b18ec78618fdd1c4fbfd7fc538ea3fb7ccbc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 2 Feb 2010 10:42:46 +0100 Subject: Get rid of deprecation warnings on config/environments/* --- .../rails/app/templates/config/environments/development.rb.tt | 6 +++--- .../rails/app/templates/config/environments/production.rb.tt | 4 ++-- .../generators/rails/app/templates/config/environments/test.rb.tt | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/railties/lib/generators/rails/app/templates/config/environments/development.rb.tt b/railties/lib/generators/rails/app/templates/config/environments/development.rb.tt index 177ce44d41..f0e917dd96 100644 --- a/railties/lib/generators/rails/app/templates/config/environments/development.rb.tt +++ b/railties/lib/generators/rails/app/templates/config/environments/development.rb.tt @@ -10,9 +10,9 @@ config.whiny_nils = true # Show full error reports and disable caching - config.action_controller.consider_all_requests_local = true - config.action_view.debug_rjs = true - config.action_controller.perform_caching = false + config.consider_all_requests_local = true + config.action_view.debug_rjs = true + config.action_controller.perform_caching = false # Don't care if the mailer can't send config.action_mailer.raise_delivery_errors = false diff --git a/railties/lib/generators/rails/app/templates/config/environments/production.rb.tt b/railties/lib/generators/rails/app/templates/config/environments/production.rb.tt index ee071df63b..917052c3df 100644 --- a/railties/lib/generators/rails/app/templates/config/environments/production.rb.tt +++ b/railties/lib/generators/rails/app/templates/config/environments/production.rb.tt @@ -6,8 +6,8 @@ config.cache_classes = true # Full error reports are disabled and caching is turned on - config.action_controller.consider_all_requests_local = false - config.action_controller.perform_caching = true + config.consider_all_requests_local = false + config.action_controller.perform_caching = true # See everything in the log (default is :info) # config.log_level = :debug diff --git a/railties/lib/generators/rails/app/templates/config/environments/test.rb.tt b/railties/lib/generators/rails/app/templates/config/environments/test.rb.tt index f6c38f3c0d..0b87b241ec 100644 --- a/railties/lib/generators/rails/app/templates/config/environments/test.rb.tt +++ b/railties/lib/generators/rails/app/templates/config/environments/test.rb.tt @@ -11,8 +11,8 @@ config.whiny_nils = true # Show full error reports and disable caching - config.action_controller.consider_all_requests_local = true - config.action_controller.perform_caching = false + config.consider_all_requests_local = true + config.action_controller.perform_caching = false # Disable request forgery protection in test environment config.action_controller.allow_forgery_protection = false -- cgit v1.2.3 From 95eadb39bd2abe986f0981a8e03c317ec9c1bca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 2 Feb 2010 11:32:28 +0100 Subject: Configuration values should be on AV::Base. --- actionpack/lib/action_view/helpers/form_helper.rb | 21 ++++----------------- actionpack/test/template/form_helper_test.rb | 6 +++--- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 76998a6ea1..c2ad7e9f77 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -528,7 +528,7 @@ module ActionView object_name = ActionController::RecordIdentifier.singular_class_name(object) end - builder = options[:builder] || ActionView.default_form_builder + builder = options[:builder] || ActionView::Base.default_form_builder yield builder.new(object_name, object, self, options, block) end @@ -1208,21 +1208,8 @@ module ActionView end end - class << ActionView - attr_accessor :default_form_builder + class Base + cattr_accessor :default_form_builder + @@default_form_builder = ::ActionView::Helpers::FormBuilder end - - self.default_form_builder = ::ActionView::Helpers::FormBuilder - - # 2.3 compatibility - class << Base - def default_form_builder=(builder) - ActionView.default_form_builder = builder - end - - def default_form_builder - ActionView.default_form_builder - end - end - end diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index aafc318b76..f2d524bd1b 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -1195,8 +1195,8 @@ class FormHelperTest < ActionView::TestCase end def test_default_form_builder - old_default_form_builder, ActionView.default_form_builder = - ActionView.default_form_builder, LabelledFormBuilder + old_default_form_builder, ActionView::Base.default_form_builder = + ActionView::Base.default_form_builder, LabelledFormBuilder form_for(:post, @post) do |f| concat f.text_field(:title) @@ -1213,7 +1213,7 @@ class FormHelperTest < ActionView::TestCase assert_dom_equal expected, output_buffer ensure - ActionView.default_form_builder = old_default_form_builder + ActionView::Base.default_form_builder = old_default_form_builder end def test_default_form_builder_with_active_record_helpers -- cgit v1.2.3 From afdf52402ea7cb153be54a342f0e6502a159e327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Pastorino=20and=20Jos=C3=A9=20Ignacio=20Costa?= Date: Mon, 1 Feb 2010 17:00:26 -0200 Subject: Routing Mapper with % interpolation on Ruby 1.9.1 fixed [#3837 status:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- actionpack/lib/action_dispatch/routing/mapper.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 5199984814..8de68b3174 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -207,8 +207,7 @@ module ActionDispatch lambda do |env| req = Request.new(env) - - uri = URI.parse(path_proc.call(req.params.symbolize_keys)) + uri = URI.parse(path_proc.call(req.symbolized_path_parameters)) uri.scheme ||= req.scheme uri.host ||= req.host uri.port ||= req.port unless req.port == 80 -- cgit v1.2.3 From ff2d04a9ec43a8df9d63c69236feb4d82e0f59f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 2 Feb 2010 12:07:41 +0100 Subject: Revert "failing tests in multibyte_chars_test.rb fixed". The bug is in Ruby 1.9.1 p376, not in AS test suite. This reverts commit bf1f70d8776e28f9181faefc4914059b4ad26b99. --- activesupport/test/multibyte_chars_test.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/activesupport/test/multibyte_chars_test.rb b/activesupport/test/multibyte_chars_test.rb index 0f68dcfe23..0e489c10e1 100644 --- a/activesupport/test/multibyte_chars_test.rb +++ b/activesupport/test/multibyte_chars_test.rb @@ -301,10 +301,10 @@ class MultibyteCharsUTF8BehaviourTest < Test::Unit::TestCase assert_equal " #{UNICODE_STRING}", @chars.rjust(5) assert_equal " #{UNICODE_STRING}", @chars.rjust(7) assert_equal "---#{UNICODE_STRING}", @chars.rjust(7, '-') - assert_equal "αα#{UNICODE_STRING}", @chars.rjust(7, 'α') + assert_equal "ααα#{UNICODE_STRING}", @chars.rjust(7, 'α') assert_equal "aba#{UNICODE_STRING}", @chars.rjust(7, 'ab') assert_equal "αηα#{UNICODE_STRING}", @chars.rjust(7, 'αη') - assert_equal "αη#{UNICODE_STRING}", @chars.rjust(8, 'αη') + assert_equal "αηαη#{UNICODE_STRING}", @chars.rjust(8, 'αη') end def test_ljust_should_raise_argument_errors_on_bad_arguments @@ -319,10 +319,10 @@ class MultibyteCharsUTF8BehaviourTest < Test::Unit::TestCase assert_equal "#{UNICODE_STRING} ", @chars.ljust(5) assert_equal "#{UNICODE_STRING} ", @chars.ljust(7) assert_equal "#{UNICODE_STRING}---", @chars.ljust(7, '-') - assert_equal "#{UNICODE_STRING}αα", @chars.ljust(7, 'α') + assert_equal "#{UNICODE_STRING}ααα", @chars.ljust(7, 'α') assert_equal "#{UNICODE_STRING}aba", @chars.ljust(7, 'ab') assert_equal "#{UNICODE_STRING}αηα", @chars.ljust(7, 'αη') - assert_equal "#{UNICODE_STRING}αη", @chars.ljust(8, 'αη') + assert_equal "#{UNICODE_STRING}αηαη", @chars.ljust(8, 'αη') end def test_center_should_raise_argument_errors_on_bad_arguments @@ -339,13 +339,13 @@ class MultibyteCharsUTF8BehaviourTest < Test::Unit::TestCase assert_equal " #{UNICODE_STRING} ", @chars.center(7) assert_equal "--#{UNICODE_STRING}--", @chars.center(8, '-') assert_equal "--#{UNICODE_STRING}---", @chars.center(9, '-') - assert_equal "α#{UNICODE_STRING}α", @chars.center(8, 'α') - assert_equal "α#{UNICODE_STRING}αα", @chars.center(9, 'α') - assert_equal "a#{UNICODE_STRING}", @chars.center(7, 'ab') - assert_equal UNICODE_STRING, @chars.center(8, 'ab') - assert_equal "ab#{UNICODE_STRING}ab", @chars.center(12, 'ab') - assert_equal "α#{UNICODE_STRING}", @chars.center(7, 'αη') - assert_equal UNICODE_STRING, @chars.center(8, 'αη') + assert_equal "αα#{UNICODE_STRING}αα", @chars.center(8, 'α') + assert_equal "αα#{UNICODE_STRING}ααα", @chars.center(9, 'α') + assert_equal "a#{UNICODE_STRING}ab", @chars.center(7, 'ab') + assert_equal "ab#{UNICODE_STRING}ab", @chars.center(8, 'ab') + assert_equal "abab#{UNICODE_STRING}abab", @chars.center(12, 'ab') + assert_equal "α#{UNICODE_STRING}αη", @chars.center(7, 'αη') + assert_equal "αη#{UNICODE_STRING}αη", @chars.center(8, 'αη') end def test_lstrip_strips_whitespace_from_the_left_of_the_string -- cgit v1.2.3 From 2c978160d25ddacdc5bf4fb7a1de40654b318d1d Mon Sep 17 00:00:00 2001 From: Chad Woolley Date: Mon, 1 Feb 2010 18:35:15 -0700 Subject: Fix invocation of system commands in ci script Signed-off-by: Carl Lerche --- ci/ci_build.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ci/ci_build.rb b/ci/ci_build.rb index c8f0f9946b..e571d6d5da 100755 --- a/ci/ci_build.rb +++ b/ci/ci_build.rb @@ -7,7 +7,11 @@ def root_dir end def rake(*tasks) - tasks.each { |task| return false unless system("bundle exec rake", task) } + tasks.each do |task| + cmd = "bundle exec rake #{task}" + puts "Running command: #{cmd}" + return false unless system(cmd) + end true end @@ -105,7 +109,8 @@ puts "[CruiseControl] #{`mysql --version`}" puts "[CruiseControl] #{`pg_config --version`}" puts "[CruiseControl] SQLite3: #{`sqlite3 -version`}" `gem env`.each_line {|line| print "[CruiseControl] #{line}"} -puts "[CruiseControl] Bundled gems:" +# Commented until bundler supports --list again +# puts "[CruiseControl] Bundled gems:" # `gem bundle --list`.each_line {|line| print "[CruiseControl] #{line}"} puts "[CruiseControl] Local gems:" `gem list`.each_line {|line| print "[CruiseControl] #{line}"} -- cgit v1.2.3 From 144f41ed9bf9d32f902531da0d3cf2a12d3a6b2b Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Tue, 2 Feb 2010 10:19:43 -0800 Subject: Use bundler 0.9.0.pre4 when running CI --- ci/ci_build.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/ci_build.rb b/ci/ci_build.rb index e571d6d5da..eb1f784bd7 100755 --- a/ci/ci_build.rb +++ b/ci/ci_build.rb @@ -23,7 +23,7 @@ build_results = {} build_results[:geminstaller] = system "sudo gem install rubygems-update -v 1.3.5 --no-ri --no-rdoc" # Install required version of bundler. -build_results[:geminstaller] = system "sudo gem install bundler -v 0.9.0.pre3 --prerelease --no-ri --no-rdoc" +build_results[:geminstaller] = system "sudo gem install bundler -v 0.9.0.pre4 --prerelease --no-ri --no-rdoc" cd root_dir do puts -- cgit v1.2.3 From d236827881d119fb9ad25c81ce8e7756f1966823 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 2 Feb 2010 15:50:56 -0800 Subject: Removed all the default commands in script/* and replaced them with script/rails and a rails command that'll act the same when run from within the app [DHH] --- railties/CHANGELOG | 6 ++ railties/bin/rails | 47 ++++++++------- .../generators/rails/app/templates/script/about | 3 - .../rails/app/templates/script/console.tt | 5 -- .../rails/app/templates/script/dbconsole.tt | 5 -- .../generators/rails/app/templates/script/destroy | 2 - .../generators/rails/app/templates/script/generate | 2 - .../app/templates/script/performance/benchmarker | 2 - .../app/templates/script/performance/profiler | 2 - .../generators/rails/app/templates/script/plugin | 2 - .../generators/rails/app/templates/script/rails | 6 ++ .../generators/rails/app/templates/script/runner | 3 - .../rails/app/templates/script/server.tt | 5 -- railties/lib/rails/commands/application.rb | 12 ++++ railties/lib/rails/commands/rails.rb | 69 ++++++++++++++++++++++ 15 files changed, 118 insertions(+), 53 deletions(-) delete mode 100755 railties/lib/generators/rails/app/templates/script/about delete mode 100755 railties/lib/generators/rails/app/templates/script/console.tt delete mode 100755 railties/lib/generators/rails/app/templates/script/dbconsole.tt delete mode 100755 railties/lib/generators/rails/app/templates/script/destroy delete mode 100755 railties/lib/generators/rails/app/templates/script/generate delete mode 100755 railties/lib/generators/rails/app/templates/script/performance/benchmarker delete mode 100755 railties/lib/generators/rails/app/templates/script/performance/profiler delete mode 100755 railties/lib/generators/rails/app/templates/script/plugin create mode 100644 railties/lib/generators/rails/app/templates/script/rails delete mode 100755 railties/lib/generators/rails/app/templates/script/runner delete mode 100755 railties/lib/generators/rails/app/templates/script/server.tt create mode 100644 railties/lib/rails/commands/application.rb create mode 100644 railties/lib/rails/commands/rails.rb diff --git a/railties/CHANGELOG b/railties/CHANGELOG index fc9277bd28..4176d7fcad 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,11 @@ *Edge* +* Removed all the default commands in script/* and replaced them with script/rails and a rails command that'll act the same when run from within the app [DHH]. Example: + + ./script/generate scaffold post title:string can now be called as rails g scaffold post title:string + + Run rails --help inside an app for more help. + * Removed config/initializers/new_rails_defaults.rb as all frameworks now follow the settings from it [DHH] * Set config.time_zone to UTC by default [DHH] diff --git a/railties/bin/rails b/railties/bin/rails index afcd9fd0be..44842e2234 100755 --- a/railties/bin/rails +++ b/railties/bin/rails @@ -1,27 +1,30 @@ -begin - require 'rails/ruby_version_check' -rescue LoadError - # If people are not using gems, the load path must still - # be correct. - # TODO: Remove the begin / rescue block somehow - $:.unshift File.expand_path('../../lib', __FILE__) - $:.unshift File.expand_path('../../../activesupport/lib', __FILE__) - $:.unshift File.expand_path('../../../actionpack/lib', __FILE__) - require 'rails/ruby_version_check' -end +if File.exists?(Dir.getwd + '/script/rails') + exec(Dir.getwd + '/script/rails', *ARGV) +else + begin + require 'rails/ruby_version_check' + rescue LoadError + # If people are not using gems, the load path must still + # be correct. + # TODO: Remove the begin / rescue block somehow + $:.unshift File.expand_path('../../lib', __FILE__) + $:.unshift File.expand_path('../../../activesupport/lib', __FILE__) + $:.unshift File.expand_path('../../../actionpack/lib', __FILE__) + require 'rails/ruby_version_check' + end -Signal.trap("INT") { puts; exit } + Signal.trap("INT") { puts; exit } -require 'rails/version' -if %w(--version -v).include? ARGV.first - puts "Rails #{Rails::VERSION::STRING}" - exit(0) -end + require 'rails/version' + if %w(--version -v).include? ARGV.first + puts "Rails #{Rails::VERSION::STRING}" + exit(0) + end -ARGV << "--help" if ARGV.empty? + ARGV << "--help" if ARGV.empty? + require 'rails/generators' + require 'generators/rails/app/app_generator' -require 'rails/generators' -require 'generators/rails/app/app_generator' - -Rails::Generators::AppGenerator.start + Rails::Generators::AppGenerator.start +end \ No newline at end of file diff --git a/railties/lib/generators/rails/app/templates/script/about b/railties/lib/generators/rails/app/templates/script/about deleted file mode 100755 index 93fd007649..0000000000 --- a/railties/lib/generators/rails/app/templates/script/about +++ /dev/null @@ -1,3 +0,0 @@ -require File.expand_path('../../config/environment', __FILE__) -$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" -require 'rails/commands/about' diff --git a/railties/lib/generators/rails/app/templates/script/console.tt b/railties/lib/generators/rails/app/templates/script/console.tt deleted file mode 100755 index 47aa254f9f..0000000000 --- a/railties/lib/generators/rails/app/templates/script/console.tt +++ /dev/null @@ -1,5 +0,0 @@ -require File.expand_path('../../config/boot', __FILE__) -require 'rails/commands/console' -require File.expand_path('../../config/application', __FILE__) - -Rails::Console.start(Rails::Application) diff --git a/railties/lib/generators/rails/app/templates/script/dbconsole.tt b/railties/lib/generators/rails/app/templates/script/dbconsole.tt deleted file mode 100755 index 1e53c1d761..0000000000 --- a/railties/lib/generators/rails/app/templates/script/dbconsole.tt +++ /dev/null @@ -1,5 +0,0 @@ -require File.expand_path('../../config/boot', __FILE__) -require 'rails/commands/dbconsole' -require File.expand_path('../../config/application', __FILE__) - -Rails::DBConsole.start(Rails::Application) diff --git a/railties/lib/generators/rails/app/templates/script/destroy b/railties/lib/generators/rails/app/templates/script/destroy deleted file mode 100755 index adfa8e8426..0000000000 --- a/railties/lib/generators/rails/app/templates/script/destroy +++ /dev/null @@ -1,2 +0,0 @@ -require File.expand_path('../../config/environment', __FILE__) -require 'rails/commands/destroy' diff --git a/railties/lib/generators/rails/app/templates/script/generate b/railties/lib/generators/rails/app/templates/script/generate deleted file mode 100755 index 6fb8ad0395..0000000000 --- a/railties/lib/generators/rails/app/templates/script/generate +++ /dev/null @@ -1,2 +0,0 @@ -require File.expand_path('../../config/environment', __FILE__) -require 'rails/commands/generate' diff --git a/railties/lib/generators/rails/app/templates/script/performance/benchmarker b/railties/lib/generators/rails/app/templates/script/performance/benchmarker deleted file mode 100755 index 9647d8f10a..0000000000 --- a/railties/lib/generators/rails/app/templates/script/performance/benchmarker +++ /dev/null @@ -1,2 +0,0 @@ -require File.expand_path('../../../config/environment', __FILE__) -require 'rails/commands/performance/benchmarker' diff --git a/railties/lib/generators/rails/app/templates/script/performance/profiler b/railties/lib/generators/rails/app/templates/script/performance/profiler deleted file mode 100755 index a5822042d2..0000000000 --- a/railties/lib/generators/rails/app/templates/script/performance/profiler +++ /dev/null @@ -1,2 +0,0 @@ -require File.expand_path('../../../config/environment', __FILE__) -require 'rails/commands/performance/profiler' diff --git a/railties/lib/generators/rails/app/templates/script/plugin b/railties/lib/generators/rails/app/templates/script/plugin deleted file mode 100755 index 1f1af6c880..0000000000 --- a/railties/lib/generators/rails/app/templates/script/plugin +++ /dev/null @@ -1,2 +0,0 @@ -require File.expand_path('../../config/application', __FILE__) -require 'rails/commands/plugin' diff --git a/railties/lib/generators/rails/app/templates/script/rails b/railties/lib/generators/rails/app/templates/script/rails new file mode 100644 index 0000000000..038547598e --- /dev/null +++ b/railties/lib/generators/rails/app/templates/script/rails @@ -0,0 +1,6 @@ +ENV_PATH = File.expand_path('../../config/environment', __FILE__) +BOOT_PATH = File.expand_path('../../config/boot', __FILE__) +APP_PATH = File.expand_path('../../config/application', __FILE__) + +require BOOT_PATH +require 'rails/commands/rails' diff --git a/railties/lib/generators/rails/app/templates/script/runner b/railties/lib/generators/rails/app/templates/script/runner deleted file mode 100755 index 3354ed4a28..0000000000 --- a/railties/lib/generators/rails/app/templates/script/runner +++ /dev/null @@ -1,3 +0,0 @@ -require File.expand_path('../../config/boot', __FILE__) -require 'rails/commands/runner' -require File.expand_path('../../config/environment', __FILE__) diff --git a/railties/lib/generators/rails/app/templates/script/server.tt b/railties/lib/generators/rails/app/templates/script/server.tt deleted file mode 100755 index 4fd0cc7832..0000000000 --- a/railties/lib/generators/rails/app/templates/script/server.tt +++ /dev/null @@ -1,5 +0,0 @@ -require File.expand_path('../../config/boot', __FILE__) -require 'rails/commands/server' - -Dir.chdir(File.expand_path('../..', __FILE__)) -Rails::Server.start diff --git a/railties/lib/rails/commands/application.rb b/railties/lib/rails/commands/application.rb new file mode 100644 index 0000000000..0f09e7eafb --- /dev/null +++ b/railties/lib/rails/commands/application.rb @@ -0,0 +1,12 @@ +require 'rails/version' +if %w(--version -v).include? ARGV.first + puts "Rails #{Rails::VERSION::STRING}" + exit(0) +end + +ARGV << "--help" if ARGV.empty? + +require 'rails/generators' +require 'generators/rails/app/app_generator' + +Rails::Generators::AppGenerator.start \ No newline at end of file diff --git a/railties/lib/rails/commands/rails.rb b/railties/lib/rails/commands/rails.rb new file mode 100644 index 0000000000..a2f86028ec --- /dev/null +++ b/railties/lib/rails/commands/rails.rb @@ -0,0 +1,69 @@ +if ARGV.empty? + ARGV << '--help' +end + +HELP_TEXT = <<-EOT +usage: rails COMMAND [ARGS] + +The most common rails commands are: + generate Generate new code (short-cut alias: "g") + console Start the Rails console (short-cut alias: "c") + server Start the Rails server (short-cut alias: "s") + +In addition to those, there are: + application Generate the Rails application code + dbconsole Start a console for the database specified in config/database.yml + destroy Undo code generated with "generate" + benchmarker See how fast a piece of code runs + profiler Get profile information from a piece of code + plugin Install a plugin + runner Run a piece of code in the application environment + +All commands can be run with -h for more information. +EOT + + +case ARGV.shift +when 'g', 'generate' + require ENV_PATH + require 'rails/commands/generate' +when 'c', 'console' + require BOOT_PATH + require 'rails/commands/console' + require APP_PATH + Rails::Console.start(Rails::Application) +when 's', 'server' + require File.expand_path('../../config/boot', __FILE__) + require 'rails/commands/server' + Dir.chdir(File.expand_path('../..', __FILE__)) + Rails::Server.start + + +when 'dbconsole' + require BOOT_PATH + require 'rails/commands/dbconsole' + require APP_PATH + Rails::DBConsole.start(Rails::Application) +when 'destroy' + require ENV_PATH + require 'rails/commands/destroy' +when 'benchmarker' + require ENV_PATH + require 'rails/commands/performance/benchmarker' +when 'profiler' + require ENV_PATH + require 'rails/commands/performance/profiler' +when 'plugin' + require APP_PATH + require 'rails/commands/plugin' +when 'runner' + require BOOT_PATH + require 'rails/commands/runner' + require ENV_PATH + +when '--help', '-h' + puts HELP_TEXT +else + puts "Error: Command not recognized" + puts HELP_TEXT +end \ No newline at end of file -- cgit v1.2.3 From 08fd9a6491b2be65727199e9fa186fc939a64965 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Tue, 2 Feb 2010 11:10:34 -0800 Subject: Remove the generated gemfile in railties tests since the rails gemfile is used. --- railties/test/isolation/abstract_unit.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index ff4ee6332b..dcadf3f485 100644 --- a/railties/test/isolation/abstract_unit.rb +++ b/railties/test/isolation/abstract_unit.rb @@ -89,6 +89,10 @@ module TestHelpers end end + unless options[:gemfile] + File.delete"#{app_path}/Gemfile" + end + routes = File.read("#{app_path}/config/routes.rb") if routes =~ /(\n\s*end\s*)\Z/ File.open("#{app_path}/config/routes.rb", 'w') do |f| -- cgit v1.2.3 From 9f224061ee2776f3f5e571af361dfef7d3427e2f Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 2 Feb 2010 15:54:09 -0800 Subject: Boot path has already been required, dont need it again --- railties/lib/rails/commands/rails.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/railties/lib/rails/commands/rails.rb b/railties/lib/rails/commands/rails.rb index a2f86028ec..2e7c6931dd 100644 --- a/railties/lib/rails/commands/rails.rb +++ b/railties/lib/rails/commands/rails.rb @@ -28,19 +28,15 @@ when 'g', 'generate' require ENV_PATH require 'rails/commands/generate' when 'c', 'console' - require BOOT_PATH require 'rails/commands/console' require APP_PATH Rails::Console.start(Rails::Application) when 's', 'server' - require File.expand_path('../../config/boot', __FILE__) require 'rails/commands/server' Dir.chdir(File.expand_path('../..', __FILE__)) Rails::Server.start - when 'dbconsole' - require BOOT_PATH require 'rails/commands/dbconsole' require APP_PATH Rails::DBConsole.start(Rails::Application) @@ -57,7 +53,6 @@ when 'plugin' require APP_PATH require 'rails/commands/plugin' when 'runner' - require BOOT_PATH require 'rails/commands/runner' require ENV_PATH -- cgit v1.2.3 From d53749608e89f80325ce21fdc3ac5468d0b05701 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 2 Feb 2010 15:56:16 -0800 Subject: Add a reminder that you should use "rails" not "script/rails" when running normally --- railties/lib/generators/rails/app/templates/script/rails | 2 ++ 1 file changed, 2 insertions(+) diff --git a/railties/lib/generators/rails/app/templates/script/rails b/railties/lib/generators/rails/app/templates/script/rails index 038547598e..1886efc05d 100644 --- a/railties/lib/generators/rails/app/templates/script/rails +++ b/railties/lib/generators/rails/app/templates/script/rails @@ -1,3 +1,5 @@ +# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. + ENV_PATH = File.expand_path('../../config/environment', __FILE__) BOOT_PATH = File.expand_path('../../config/boot', __FILE__) APP_PATH = File.expand_path('../../config/application', __FILE__) -- cgit v1.2.3 From 7840ea29b44c9dcdae72feddd1a5170bb22fb160 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 2 Feb 2010 16:03:47 -0800 Subject: Added "rake about" as a replacement for script/about [DHH] --- railties/CHANGELOG | 2 ++ railties/lib/rails/commands/about.rb | 2 -- railties/lib/rails/tasks/misc.rake | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) delete mode 100644 railties/lib/rails/commands/about.rb diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 4176d7fcad..0b67479742 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *Edge* +* Added "rake about" as a replacement for script/about [DHH] + * Removed all the default commands in script/* and replaced them with script/rails and a rails command that'll act the same when run from within the app [DHH]. Example: ./script/generate scaffold post title:string can now be called as rails g scaffold post title:string diff --git a/railties/lib/rails/commands/about.rb b/railties/lib/rails/commands/about.rb deleted file mode 100644 index d4c30bbeb2..0000000000 --- a/railties/lib/rails/commands/about.rb +++ /dev/null @@ -1,2 +0,0 @@ -require 'rails/info' -puts Rails::Info diff --git a/railties/lib/rails/tasks/misc.rake b/railties/lib/rails/tasks/misc.rake index 4696f02a98..48fce92215 100644 --- a/railties/lib/rails/tasks/misc.rake +++ b/railties/lib/rails/tasks/misc.rake @@ -13,6 +13,13 @@ task :secret do puts ActiveSupport::SecureRandom.hex(64) end +desc 'Explain the current environment' +task :about do + $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" + require 'rails/info' + puts Rails::Info +end + namespace :time do namespace :zones do desc 'Displays names of all time zones recognized by the Rails TimeZone class, grouped by offset. Results can be filtered with optional OFFSET parameter, e.g., OFFSET=-6' -- cgit v1.2.3 From 68ca336195522731b6a20e20b57808115c8318b4 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 2 Feb 2010 16:10:24 -0800 Subject: Fix rails server --- railties/lib/generators/rails/app/templates/script/rails | 1 + railties/lib/rails/commands/rails.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/railties/lib/generators/rails/app/templates/script/rails b/railties/lib/generators/rails/app/templates/script/rails index 1886efc05d..c23d24b30b 100644 --- a/railties/lib/generators/rails/app/templates/script/rails +++ b/railties/lib/generators/rails/app/templates/script/rails @@ -3,6 +3,7 @@ ENV_PATH = File.expand_path('../../config/environment', __FILE__) BOOT_PATH = File.expand_path('../../config/boot', __FILE__) APP_PATH = File.expand_path('../../config/application', __FILE__) +ROOT_PATH = File.expand_path('../..', __FILE__) require BOOT_PATH require 'rails/commands/rails' diff --git a/railties/lib/rails/commands/rails.rb b/railties/lib/rails/commands/rails.rb index 2e7c6931dd..a422d33e67 100644 --- a/railties/lib/rails/commands/rails.rb +++ b/railties/lib/rails/commands/rails.rb @@ -33,7 +33,7 @@ when 'c', 'console' Rails::Console.start(Rails::Application) when 's', 'server' require 'rails/commands/server' - Dir.chdir(File.expand_path('../..', __FILE__)) + Dir.chdir(ROOT_PATH) Rails::Server.start when 'dbconsole' -- cgit v1.2.3 From ea5917715657681c7cb2bbb5f793b9aea29d0609 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 2 Feb 2010 16:11:40 -0800 Subject: Wups, need the application command in there too --- railties/lib/rails/commands/rails.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/railties/lib/rails/commands/rails.rb b/railties/lib/rails/commands/rails.rb index a422d33e67..5f34876f1d 100644 --- a/railties/lib/rails/commands/rails.rb +++ b/railties/lib/rails/commands/rails.rb @@ -36,6 +36,8 @@ when 's', 'server' Dir.chdir(ROOT_PATH) Rails::Server.start +when 'application' + require 'rails/commands/application' when 'dbconsole' require 'rails/commands/dbconsole' require APP_PATH -- cgit v1.2.3 From 9a83bd5006b6f996cbd68045d2d4d7f7dac24de1 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 2 Feb 2010 16:16:26 -0800 Subject: Rename usage path to command to just the command name --- railties/lib/rails/commands/performance/benchmarker.rb | 2 +- railties/lib/rails/commands/performance/profiler.rb | 2 +- railties/lib/rails/commands/plugin.rb | 2 +- railties/lib/rails/commands/runner.rb | 2 +- railties/lib/rails/generators.rb | 3 +-- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/railties/lib/rails/commands/performance/benchmarker.rb b/railties/lib/rails/commands/performance/benchmarker.rb index dfba4bf034..ad84d94dbf 100644 --- a/railties/lib/rails/commands/performance/benchmarker.rb +++ b/railties/lib/rails/commands/performance/benchmarker.rb @@ -1,5 +1,5 @@ if ARGV.empty? - puts "Usage: ./script/performance/benchmarker [times] 'Person.expensive_way' 'Person.another_expensive_way' ..." + puts "Usage: benchmarker [times] 'Person.expensive_way' 'Person.another_expensive_way' ..." exit 1 end diff --git a/railties/lib/rails/commands/performance/profiler.rb b/railties/lib/rails/commands/performance/profiler.rb index aaa075018c..50ae411166 100644 --- a/railties/lib/rails/commands/performance/profiler.rb +++ b/railties/lib/rails/commands/performance/profiler.rb @@ -1,5 +1,5 @@ if ARGV.empty? - $stderr.puts "Usage: ./script/performance/profiler 'Person.expensive_method(10)' [times] [flat|graph|graph_html]" + $stderr.puts "Usage: profiler 'Person.expensive_method(10)' [times] [flat|graph|graph_html]" exit(1) end diff --git a/railties/lib/rails/commands/plugin.rb b/railties/lib/rails/commands/plugin.rb index 159db707e7..af12df1425 100644 --- a/railties/lib/rails/commands/plugin.rb +++ b/railties/lib/rails/commands/plugin.rb @@ -295,7 +295,7 @@ module Commands def options OptionParser.new do |o| o.set_summary_indent(' ') - o.banner = "Usage: #{@script_name} [OPTIONS] command" + o.banner = "Usage: plugin [OPTIONS] command" o.define_head "Rails plugin manager." o.separator "" diff --git a/railties/lib/rails/commands/runner.rb b/railties/lib/rails/commands/runner.rb index 4487d2e7b1..606e04483f 100644 --- a/railties/lib/rails/commands/runner.rb +++ b/railties/lib/rails/commands/runner.rb @@ -5,7 +5,7 @@ code_or_file = nil ARGV.clone.options do |opts| script_name = File.basename($0) - opts.banner = "Usage: #{$0} [options] ('Some.ruby(code)' or a filename)" + opts.banner = "Usage: runner [options] ('Some.ruby(code)' or a filename)" opts.separator "" diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index 8c54014fcb..1f380970d0 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -175,8 +175,7 @@ module Rails groups[base] << namespace end - puts "Usage:" - puts " script/generate GENERATOR [args] [options]" + puts "Usage: generate GENERATOR [args] [options]" puts puts "General options:" puts " -h, [--help] # Print generators options and usage" -- cgit v1.2.3 From 76d5428c3360ae837107ccedb418fc7b0d2aa578 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Wed, 3 Feb 2010 15:42:53 +1100 Subject: Updating index.html to remove script/generate and making railties tests pass again --- .../rails/app/templates/public/index.html | 2 +- railties/test/generators/app_generator_test.rb | 28 ++++------------------ 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/railties/lib/generators/rails/app/templates/public/index.html b/railties/lib/generators/rails/app/templates/public/index.html index b153ae392f..ef916f9c5a 100644 --- a/railties/lib/generators/rails/app/templates/public/index.html +++ b/railties/lib/generators/rails/app/templates/public/index.html @@ -255,7 +255,7 @@
  1. -

    Use script/generate to create your models and controllers

    +

    Use rails generate to create your models and controllers

    To see all available options, run it without parameters.

  2. diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 95a33c50f8..93ef67818d 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -35,7 +35,7 @@ class AppGeneratorTest < Rails::Generators::TestCase public/images public/javascripts public/stylesheets - script/performance + script/rails test/fixtures test/functional test/integration @@ -98,34 +98,14 @@ class AppGeneratorTest < Rails::Generators::TestCase assert_no_file "test" end - def test_shebang_is_added_to_files + def test_shebang_is_added_to_rails_file run_generator [destination_root, "--ruby", "foo/bar/baz"] - - %w( - about - console - dbconsole - destroy - generate - plugin - runner - server - ).each { |path| assert_file "script/#{path}", /#!foo\/bar\/baz/ } + assert_file "script/rails", /#!foo\/bar\/baz/ end def test_shebang_when_is_the_same_as_default_use_env run_generator [destination_root, "--ruby", Thor::Util.ruby_command] - - %w( - about - console - dbconsole - destroy - generate - plugin - runner - server - ).each { |path| assert_file "script/#{path}", /#!\/usr\/bin\/env/ } + assert_file "script/rails", /#!\/usr\/bin\/env/ end def test_template_from_dir_pwd -- cgit v1.2.3 From 80e49354f17853130dd2ae5815d71d192c8ec9d7 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Wed, 3 Feb 2010 15:42:53 +1100 Subject: Updating index.html to remove script/generate and making railties tests pass again --- .../rails/app/templates/public/index.html | 2 +- railties/test/generators/app_generator_test.rb | 28 ++++------------------ 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/railties/lib/generators/rails/app/templates/public/index.html b/railties/lib/generators/rails/app/templates/public/index.html index b153ae392f..ef916f9c5a 100644 --- a/railties/lib/generators/rails/app/templates/public/index.html +++ b/railties/lib/generators/rails/app/templates/public/index.html @@ -255,7 +255,7 @@
    1. -

      Use script/generate to create your models and controllers

      +

      Use rails generate to create your models and controllers

      To see all available options, run it without parameters.

    2. diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 95a33c50f8..93ef67818d 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -35,7 +35,7 @@ class AppGeneratorTest < Rails::Generators::TestCase public/images public/javascripts public/stylesheets - script/performance + script/rails test/fixtures test/functional test/integration @@ -98,34 +98,14 @@ class AppGeneratorTest < Rails::Generators::TestCase assert_no_file "test" end - def test_shebang_is_added_to_files + def test_shebang_is_added_to_rails_file run_generator [destination_root, "--ruby", "foo/bar/baz"] - - %w( - about - console - dbconsole - destroy - generate - plugin - runner - server - ).each { |path| assert_file "script/#{path}", /#!foo\/bar\/baz/ } + assert_file "script/rails", /#!foo\/bar\/baz/ end def test_shebang_when_is_the_same_as_default_use_env run_generator [destination_root, "--ruby", Thor::Util.ruby_command] - - %w( - about - console - dbconsole - destroy - generate - plugin - runner - server - ).each { |path| assert_file "script/#{path}", /#!\/usr\/bin\/env/ } + assert_file "script/rails", /#!\/usr\/bin\/env/ end def test_template_from_dir_pwd -- cgit v1.2.3 From fbdef7aafe753d2375b16c5dcf70a463996b929f Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Wed, 3 Feb 2010 16:39:04 +1100 Subject: Made rake db:create also create the test database if you are in development mode --- activerecord/lib/active_record/railties/databases.rake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index 2ef8676f39..8ca7c394fd 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -26,8 +26,12 @@ namespace :db do end end - desc 'Create the database defined in config/database.yml for the current Rails.env' + desc 'Create the database defined in config/database.yml for the current Rails.env - also makes test database if in development mode' task :create => :load_config do + # Make the test database at the same time as the development one + if Rails.env == 'development' + create_database(ActiveRecord::Base.configurations['test']) + end create_database(ActiveRecord::Base.configurations[Rails.env]) end -- cgit v1.2.3 From 9d653908059523bc2e3e1e646c0bcd4ebe5a80d7 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Wed, 3 Feb 2010 18:06:38 +1100 Subject: Added encoding qery support for SQLite3 to make rake db:charset work on all databases shipping with Rails 3 --- .../lib/active_record/connection_adapters/sqlite3_adapter.rb | 11 +++++++++++ activerecord/lib/active_record/railties/databases.rake | 3 +++ 2 files changed, 14 insertions(+) diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb index d933bc924d..f295af16f0 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb @@ -24,6 +24,17 @@ module ActiveRecord module ConnectionAdapters #:nodoc: class SQLite3Adapter < SQLiteAdapter # :nodoc: + + # Returns the current database encoding format as a string, eg: 'UTF-8' + def encoding + if @connection.respond_to?(:encoding) + @connection.encoding[0]['encoding'] + else + encoding = @connection.send(:get_query_pragma, 'encoding') + encoding[0]['encoding'] + end + end + end end end diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index 8ca7c394fd..4343bef3d4 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -200,6 +200,9 @@ namespace :db do when 'postgresql' ActiveRecord::Base.establish_connection(config) puts ActiveRecord::Base.connection.encoding + when 'sqlite3' + ActiveRecord::Base.establish_connection(config) + puts ActiveRecord::Base.connection.encoding else puts 'sorry, your database adapter is not supported yet, feel free to submit a patch' end -- cgit v1.2.3 From 38d13f9597c4e92643e3b6513e85a7a8475d5b1b Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Wed, 3 Feb 2010 18:31:57 +1100 Subject: Deprecated freeze rake tasks and cleaned up annotations.rake --- railties/lib/rails/tasks/annotations.rake | 2 +- railties/lib/rails/tasks/framework.rake | 75 +++---------------------------- 2 files changed, 8 insertions(+), 69 deletions(-) diff --git a/railties/lib/rails/tasks/annotations.rake b/railties/lib/rails/tasks/annotations.rake index 79973b3145..10a9311b2d 100644 --- a/railties/lib/rails/tasks/annotations.rake +++ b/railties/lib/rails/tasks/annotations.rake @@ -13,7 +13,7 @@ namespace :notes do end end - desc "Enumerate a custom annotation, specify with ANNOTATION=WTFHAX" + desc "Enumerate a custom annotation, specify with ANNOTATION=CUSTOM" task :custom do SourceAnnotationExtractor.enumerate ENV['ANNOTATION'] end diff --git a/railties/lib/rails/tasks/framework.rake b/railties/lib/rails/tasks/framework.rake index 5d7c094d8b..65d3c48f2d 100644 --- a/railties/lib/rails/tasks/framework.rake +++ b/railties/lib/rails/tasks/framework.rake @@ -1,80 +1,19 @@ namespace :rails do namespace :freeze do - desc "Lock this application to the current gems (by unpacking them into vendor/rails)" + desc "The rails:freeze:gems is deprecated, please use bundle install instead" task :gems do - deps = %w(actionpack activerecord actionmailer activesupport activeresource) - require 'rubygems' - require 'rubygems/gem_runner' - - rails = (version = ENV['VERSION']) ? - Gem.cache.find_name('rails', "= #{version}").first : - Gem.cache.find_name('rails').sort_by { |g| g.version }.last - - version ||= rails.version - - unless rails - puts "No rails gem #{version} is installed. Do 'gem list rails' to see what you have available." - exit - end - - puts "Freezing to the gems for Rails #{rails.version}" - rm_rf "vendor/rails" - mkdir_p "vendor/rails" - - begin - chdir("vendor/rails") do - rails.dependencies.select { |g| deps.include? g.name }.each do |g| - Gem::GemRunner.new.run(["unpack", g.name, "--version", g.version_requirements.to_s]) - mv(Dir.glob("#{g.name}*").first, g.name) - end - - Gem::GemRunner.new.run(["unpack", "rails", "--version", "=#{version}"]) - FileUtils.mv(Dir.glob("rails*").first, "railties") - end - rescue Exception - rm_rf "vendor/rails" - raise - end + puts "The rails:freeze:gems is deprecated, please use bundle install instead" end - desc 'Lock to latest Edge Rails, for a specific release use RELEASE=1.2.0' + desc 'The freeze:edge command has been deprecated, specify the path setting in your app Gemfile instead and bundle install' task :edge do - require 'open-uri' - version = ENV["RELEASE"] || "edge" - target = "rails_#{version}.zip" - commits = "http://github.com/api/v1/yaml/rails/rails/commits/master" - url = "http://dev.rubyonrails.org/archives/#{target}" - - chdir 'vendor' do - latest_revision = YAML.load(open(commits))["commits"].first["id"] - - puts "Downloading Rails from #{url}" - File.open('rails.zip', 'wb') do |dst| - open url do |src| - while chunk = src.read(4096) - dst << chunk - end - end - end - - puts 'Unpacking Rails' - rm_rf 'rails' - `unzip rails.zip` - %w(rails.zip rails/Rakefile rails/cleanlogs.sh rails/pushgems.rb rails/release.rb).each do |goner| - rm_f goner - end - - touch "rails/REVISION_#{latest_revision}" - end - - puts 'Updating current scripts, javascripts, and configuration settings' - Rake::Task['rails:update'].invoke + puts 'The freeze:edge command has been deprecated, specify the path setting in your app Gemfile instead and bundle install' end end - desc "Unlock this application from freeze of gems or edge and return to a fluid use of system gems" + desc 'The unfreeze command has been deprecated, please use bundler commands instead' task :unfreeze do - rm_rf "vendor/rails" + puts 'The unfreeze command has been deprecated, please use bundler commands instead' end desc "Update both configs, scripts and public/javascripts from Rails" @@ -112,7 +51,7 @@ namespace :rails do invoke_from_app_generator :create_prototype_files end - desc "Add new scripts to the application script/ directory" + desc "Adds new scripts to the application script/ directory" task :scripts do invoke_from_app_generator :create_script_files end -- cgit v1.2.3 From f390eade5fd70615ba2ee8e089821bcf2d5f7b17 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Wed, 3 Feb 2010 19:50:51 +1100 Subject: Adding 'db' as a shortcut for dbconsole to the rails command --- railties/lib/rails/commands/rails.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/railties/lib/rails/commands/rails.rb b/railties/lib/rails/commands/rails.rb index 5f34876f1d..9597e2e7e6 100644 --- a/railties/lib/rails/commands/rails.rb +++ b/railties/lib/rails/commands/rails.rb @@ -6,13 +6,14 @@ HELP_TEXT = <<-EOT usage: rails COMMAND [ARGS] The most common rails commands are: - generate Generate new code (short-cut alias: "g") - console Start the Rails console (short-cut alias: "c") - server Start the Rails server (short-cut alias: "s") + generate Generate new code (short-cut alias: "g") + console Start the Rails console (short-cut alias: "c") + server Start the Rails server (short-cut alias: "s") + dbconsole Start a console for the database specified in config/database.yml + (short-cut alias: "db") In addition to those, there are: application Generate the Rails application code - dbconsole Start a console for the database specified in config/database.yml destroy Undo code generated with "generate" benchmarker See how fast a piece of code runs profiler Get profile information from a piece of code @@ -35,13 +36,13 @@ when 's', 'server' require 'rails/commands/server' Dir.chdir(ROOT_PATH) Rails::Server.start - -when 'application' - require 'rails/commands/application' -when 'dbconsole' +when 'db', 'dbconsole' require 'rails/commands/dbconsole' require APP_PATH Rails::DBConsole.start(Rails::Application) + +when 'application' + require 'rails/commands/application' when 'destroy' require ENV_PATH require 'rails/commands/destroy' -- cgit v1.2.3 From 836cbe5735eb67a54b20fd051cb0e2ea9c19496c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 3 Feb 2010 17:18:18 +0100 Subject: Add method and path to AC notifications. --- actionpack/lib/action_controller/metal/instrumentation.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/actionpack/lib/action_controller/metal/instrumentation.rb b/actionpack/lib/action_controller/metal/instrumentation.rb index 7f9a7c068b..85035dc09c 100644 --- a/actionpack/lib/action_controller/metal/instrumentation.rb +++ b/actionpack/lib/action_controller/metal/instrumentation.rb @@ -18,7 +18,9 @@ module ActionController :controller => self.class.name, :action => self.action_name, :params => request.filtered_parameters, - :formats => request.formats.map(&:to_sym) + :formats => request.formats.map(&:to_sym), + :method => request.method, + :path => (request.request_uri rescue "unknown") } ActiveSupport::Notifications.instrument("action_controller.start_processing", raw_payload.dup) -- cgit v1.2.3 From 622e3dda849d797fec0d2fcbedd00fe67eb49e8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 3 Feb 2010 17:57:54 +0100 Subject: No more vendored thor. --- railties/lib/rails/generators/base.rb | 2 +- railties/lib/rails/generators/migration.rb | 8 +- .../lib/rails/vendor/thor-0.12.3/CHANGELOG.rdoc | 80 ---- railties/lib/rails/vendor/thor-0.12.3/LICENSE | 20 - railties/lib/rails/vendor/thor-0.12.3/README.rdoc | 234 ---------- railties/lib/rails/vendor/thor-0.12.3/Thorfile | 63 --- railties/lib/rails/vendor/thor-0.12.3/lib/thor.rb | 240 ---------- .../rails/vendor/thor-0.12.3/lib/thor/actions.rb | 274 ----------- .../thor-0.12.3/lib/thor/actions/create_file.rb | 103 ----- .../thor-0.12.3/lib/thor/actions/directory.rb | 91 ---- .../lib/thor/actions/empty_directory.rb | 134 ------ .../lib/thor/actions/file_manipulation.rb | 223 --------- .../lib/thor/actions/inject_into_file.rb | 101 ---- .../lib/rails/vendor/thor-0.12.3/lib/thor/base.rb | 515 --------------------- .../lib/thor/core_ext/file_binary_read.rb | 9 - .../thor/core_ext/hash_with_indifferent_access.rb | 75 --- .../thor-0.12.3/lib/thor/core_ext/ordered_hash.rb | 100 ---- .../lib/rails/vendor/thor-0.12.3/lib/thor/error.rb | 27 -- .../lib/rails/vendor/thor-0.12.3/lib/thor/group.rb | 270 ----------- .../vendor/thor-0.12.3/lib/thor/invocation.rb | 178 ------- .../rails/vendor/thor-0.12.3/lib/thor/parser.rb | 4 - .../vendor/thor-0.12.3/lib/thor/parser/argument.rb | 67 --- .../thor-0.12.3/lib/thor/parser/arguments.rb | 145 ------ .../vendor/thor-0.12.3/lib/thor/parser/option.rb | 132 ------ .../vendor/thor-0.12.3/lib/thor/parser/options.rb | 142 ------ .../vendor/thor-0.12.3/lib/thor/rake_compat.rb | 66 --- .../rails/vendor/thor-0.12.3/lib/thor/runner.rb | 303 ------------ .../lib/rails/vendor/thor-0.12.3/lib/thor/shell.rb | 78 ---- .../vendor/thor-0.12.3/lib/thor/shell/basic.rb | 239 ---------- .../vendor/thor-0.12.3/lib/thor/shell/color.rb | 108 ----- .../lib/rails/vendor/thor-0.12.3/lib/thor/task.rb | 111 ----- .../lib/rails/vendor/thor-0.12.3/lib/thor/util.rb | 233 ---------- .../rails/vendor/thor-0.12.3/lib/thor/version.rb | 3 - railties/railties.gemspec | 5 +- 34 files changed, 7 insertions(+), 4376 deletions(-) delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/CHANGELOG.rdoc delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/LICENSE delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/README.rdoc delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/Thorfile delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor.rb delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions.rb delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions/create_file.rb delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions/directory.rb delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions/empty_directory.rb delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions/file_manipulation.rb delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions/inject_into_file.rb delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor/base.rb delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor/core_ext/file_binary_read.rb delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor/core_ext/hash_with_indifferent_access.rb delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor/core_ext/ordered_hash.rb delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor/error.rb delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor/group.rb delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor/invocation.rb delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor/parser.rb delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor/parser/argument.rb delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor/parser/arguments.rb delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor/parser/option.rb delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor/parser/options.rb delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor/rake_compat.rb delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor/runner.rb delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor/shell.rb delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor/shell/basic.rb delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor/shell/color.rb delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor/task.rb delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor/util.rb delete mode 100644 railties/lib/rails/vendor/thor-0.12.3/lib/thor/version.rb diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb index f4b2bd1ae9..ec0659032f 100644 --- a/railties/lib/rails/generators/base.rb +++ b/railties/lib/rails/generators/base.rb @@ -1,4 +1,4 @@ -require 'thor' +require 'thor/group' require 'rails/generators/actions' module Rails diff --git a/railties/lib/rails/generators/migration.rb b/railties/lib/rails/generators/migration.rb index 8a8c899cc1..7975326c52 100644 --- a/railties/lib/rails/generators/migration.rb +++ b/railties/lib/rails/generators/migration.rb @@ -5,12 +5,10 @@ module Rails # just by implementing the next migration number method. # module Migration + attr_reader :migration_number, :migration_file_name, :migration_class_name + def self.included(base) #:nodoc: - base.class_eval do - extend ClassMethods - readers = lambda { attr_reader :migration_number, :migration_file_name, :migration_class_name } - respond_to?(:no_tasks) ? no_tasks(&readers) : readers.call - end + base.extend ClassMethods end module ClassMethods diff --git a/railties/lib/rails/vendor/thor-0.12.3/CHANGELOG.rdoc b/railties/lib/rails/vendor/thor-0.12.3/CHANGELOG.rdoc deleted file mode 100644 index d02fc43e84..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/CHANGELOG.rdoc +++ /dev/null @@ -1,80 +0,0 @@ -== 0.12, released 2010-01-02 - -* Removed rr in favor to rspec mock framework -* Improved output for thor -T -* [#7] Do not force white color on status -* [#8] Yield a block with the filename on directory - -== 0.11, released 2009-07-01 - -* Added a rake compatibility layer. It allows you to use spec and rdoc tasks on - Thor classes. - -* BACKWARDS INCOMPATIBLE: aliases are not generated automatically anymore - since it wrong behavior to the invocation system. - -* thor help now show information about any class/task. All those calls are - possible: - - thor help describe - thor help describe:amazing - - Or even with default namespaces: - - thor help :spec - -* Thor::Runner now invokes the default task if none is supplied: - - thor describe # invokes the default task, usually help - -* Thor::Runner now works with mappings: - - thor describe -h - -* Added some documentation and code refactoring. - -== 0.9.8, released 2008-10-20 - -* Fixed some tiny issues that were introduced lately. - -== 0.9.7, released 2008-10-13 - -* Setting global method options on the initialize method works as expected: - All other tasks will accept these global options in addition to their own. -* Added 'group' notion to Thor task sets (class Thor); by default all tasks - are in the 'standard' group. Running 'thor -T' will only show the standard - tasks - adding --all will show all tasks. You can also filter on a specific - group using the --group option: thor -T --group advanced - -== 0.9.6, released 2008-09-13 - -* Generic improvements - -== 0.9.5, released 2008-08-27 - -* Improve Windows compatibility -* Update (incorrect) README and task.thor sample file -* Options hash is now frozen (once returned) -* Allow magic predicates on options object. For instance: `options.force?` -* Add support for :numeric type -* BACKWARDS INCOMPATIBLE: Refactor Thor::Options. You cannot access shorthand forms in options hash anymore (for instance, options[:f]) -* Allow specifying optional args with default values: method_options(:user => "mislav") -* Don't write options for nil or false values. This allows, for example, turning color off when running specs. -* Exit with the status of the spec command to help CI stuff out some. - -== 0.9.4, released 2008-08-13 - -* Try to add Windows compatibility. -* BACKWARDS INCOMPATIBLE: options hash is now accessed as a property in your class and is not passed as last argument anymore -* Allow options at the beginning of the argument list as well as the end. -* Make options available with symbol keys in addition to string keys. -* Allow true to be passed to Thor#method_options to denote a boolean option. -* If loading a thor file fails, don't give up, just print a warning and keep going. -* Make sure that we re-raise errors if they happened further down the pipe than we care about. -* Only delete the old file on updating when the installation of the new one is a success -* Make it Ruby 1.8.5 compatible. -* Don't raise an error if a boolean switch is defined multiple times. -* Thor::Options now doesn't parse through things that look like options but aren't. -* Add URI detection to install task, and make sure we don't append ".thor" to URIs -* Add rake2thor to the gem binfiles. -* Make sure local Thorfiles override system-wide ones. diff --git a/railties/lib/rails/vendor/thor-0.12.3/LICENSE b/railties/lib/rails/vendor/thor-0.12.3/LICENSE deleted file mode 100644 index 98722da459..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2008 Yehuda Katz - -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. \ No newline at end of file diff --git a/railties/lib/rails/vendor/thor-0.12.3/README.rdoc b/railties/lib/rails/vendor/thor-0.12.3/README.rdoc deleted file mode 100644 index ee545f3d97..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/README.rdoc +++ /dev/null @@ -1,234 +0,0 @@ -= thor - -Map options to a class. Simply create a class with the appropriate annotations -and have options automatically map to functions and parameters. - -Example: - - class App < Thor # [1] - map "-L" => :list # [2] - - desc "install APP_NAME", "install one of the available apps" # [3] - method_options :force => :boolean, :alias => :string # [4] - def install(name) - user_alias = options[:alias] - if options.force? - # do something - end - # other code - end - - desc "list [SEARCH]", "list all of the available apps, limited by SEARCH" - def list(search="") - # list everything - end - end - -Thor automatically maps commands as such: - - thor app:install myname --force - -That gets converted to: - - App.new.install("myname") - # with {'force' => true} as options hash - -1. Inherit from Thor to turn a class into an option mapper -2. Map additional non-valid identifiers to specific methods. In this case, convert -L to :list -3. Describe the method immediately below. The first parameter is the usage information, and the second parameter is the description -4. Provide any additional options that will be available the instance method options. - -== Types for method_options - -* :boolean - is parsed as --option or --option=true -* :string - is parsed as --option=VALUE -* :numeric - is parsed as --option=N -* :array - is parsed as --option=one two three -* :hash - is parsed as --option=name:string age:integer - -Besides, method_option allows a default value to be given, examples: - - method_options :force => false - #=> Creates a boolean option with default value false - - method_options :alias => "bar" - #=> Creates a string option with default value "bar" - - method_options :threshold => 3.0 - #=> Creates a numeric option with default value 3.0 - -You can also supply :option => :required to mark an option as required. The -type is assumed to be string. If you want a required hash with default values -as option, you can use method_option which uses a more declarative style: - - method_option :attributes, :type => :hash, :default => {}, :required => true - -All arguments can be set to nil (except required arguments), by suppling a no or -skip variant. For example: - - thor app name --no-attributes - -In previous versions, aliases for options were created automatically, but now -they should be explicit. You can supply aliases in both short and declarative -styles: - - method_options %w( force -f ) => :boolean - -Or: - - method_option :force, :type => :boolean, :aliases => "-f" - -You can supply as many aliases as you want. - -NOTE: Type :optional available in Thor 0.9.0 was deprecated. Use :string or :boolean instead. - -== Namespaces - -By default, your Thor tasks are invoked using Ruby namespace. In the example -above, tasks are invoked as: - - thor app:install name --force - -However, you could namespace your class as: - - module Sinatra - class App < Thor - # tasks - end - end - -And then you should invoke your tasks as: - - thor sinatra:app:install name --force - -If desired, you can change the namespace: - - module Sinatra - class App < Thor - namespace :myapp - # tasks - end - end - -And then your tasks hould be invoked as: - - thor myapp:install name --force - -== Invocations - -Thor comes with a invocation-dependency system as well which allows a task to be -invoked only once. For example: - - class Counter < Thor - desc "one", "Prints 1, 2, 3" - def one - puts 1 - invoke :two - invoke :three - end - - desc "two", "Prints 2, 3" - def two - puts 2 - invoke :three - end - - desc "three", "Prints 3" - def three - puts 3 - end - end - -When invoking the task one: - - thor counter:one - -The output is "1 2 3", which means that the three task was invoked only once. -You can even invoke tasks from another class, so be sure to check the -documentation. - -== Thor::Group - -Thor has a special class called Thor::Group. The main difference to Thor class -is that it invokes all tasks at once. The example above could be rewritten in -Thor::Group as this: - - class Counter < Thor::Group - desc "Prints 1, 2, 3" - - def one - puts 1 - end - - def two - puts 2 - end - - def three - puts 3 - end - end - -When invoked: - - thor counter - -It prints "1 2 3" as well. Notice you should describe (using the method desc) -only the class and not each task anymore. Thor::Group is a great tool to create -generators, since you can define several steps which are invoked in the order they -are defined (Thor::Group is the tool use in generators in Rails 3.0). - -Besides, Thor::Group can parse arguments and options as Thor tasks: - - class Counter < Thor::Group - # number will be available as attr_accessor - argument :number, :type => :numeric, :desc => "The number to start counting" - desc "Prints the 'number' given upto 'number+2'" - - def one - puts number + 0 - end - - def two - puts number + 1 - end - - def three - puts number + 2 - end - end - -The counter above expects one parameter and has the folling outputs: - - thor counter 5 - # Prints "5 6 7" - - thor counter 11 - # Prints "11 12 13" - -You can also give options to Thor::Group, but instead of using method_option -and method_options, you should use class_option and class_options. -Both argument and class_options methods are available to Thor class as well. - -== Actions - -Thor comes with several actions which helps with script and generator tasks. You -might be familiar with them since some came from Rails Templates. They are: -say, ask, yes?, no?, add_file, -remove_file, copy_file, template, directory, -inside, run, inject_into_file and a couple more. - -To use them, you just need to include Thor::Actions in your Thor classes: - - class App < Thor - include Thor::Actions - # tasks - end - -Some actions like copy file requires that a class method called source_root is -defined in your class. This is the directory where your templates should be -placed. Be sure to check the documentation. - -== License - -See MIT LICENSE. diff --git a/railties/lib/rails/vendor/thor-0.12.3/Thorfile b/railties/lib/rails/vendor/thor-0.12.3/Thorfile deleted file mode 100644 index ff1cb4498a..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/Thorfile +++ /dev/null @@ -1,63 +0,0 @@ -# enconding: utf-8 - -require File.join(File.dirname(__FILE__), "lib", "thor", "version") -require 'thor/rake_compat' -require 'spec/rake/spectask' -require 'rdoc/task' - -GEM_NAME = 'thor' -EXTRA_RDOC_FILES = ["README.rdoc", "LICENSE", "CHANGELOG.rdoc", "VERSION", "Thorfile"] - -class Default < Thor - include Thor::RakeCompat - - Spec::Rake::SpecTask.new(:spec) do |t| - t.libs << 'lib' - t.spec_opts = ['--options', "spec/spec.opts"] - t.spec_files = FileList['spec/**/*_spec.rb'] - end - - Spec::Rake::SpecTask.new(:rcov) do |t| - t.libs << 'lib' - t.spec_opts = ['--options', "spec/spec.opts"] - t.spec_files = FileList['spec/**/*_spec.rb'] - t.rcov = true - t.rcov_dir = "rcov" - end - - RDoc::Task.new do |rdoc| - rdoc.main = "README.rdoc" - rdoc.rdoc_dir = "rdoc" - rdoc.title = GEM_NAME - rdoc.rdoc_files.include(*EXTRA_RDOC_FILES) - rdoc.rdoc_files.include('lib/**/*.rb') - rdoc.options << '--line-numbers' << '--inline-source' - end - - begin - require 'jeweler' - Jeweler::Tasks.new do |s| - s.name = GEM_NAME - s.version = Thor::VERSION - s.rubyforge_project = "textmate" - s.platform = Gem::Platform::RUBY - s.summary = "A scripting framework that replaces rake, sake and rubigen" - s.email = "ruby-thor@googlegroups.com" - s.homepage = "http://yehudakatz.com" - s.description = "A scripting framework that replaces rake, sake and rubigen" - s.authors = ['Yehuda Katz', 'José Valim'] - s.has_rdoc = true - s.extra_rdoc_files = EXTRA_RDOC_FILES - s.require_path = 'lib' - s.bindir = "bin" - s.executables = %w( thor rake2thor ) - s.files = s.extra_rdoc_files + Dir.glob("{bin,lib}/**/*") - s.files.exclude 'spec/sandbox/**/*' - s.test_files.exclude 'spec/sandbox/**/*' - end - - Jeweler::GemcutterTasks.new - rescue LoadError - puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com" - end -end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor.rb deleted file mode 100644 index d4d8fbd64d..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor.rb +++ /dev/null @@ -1,240 +0,0 @@ -require 'thor/base' -require 'thor/group' -require 'thor/actions' - -class Thor - class << self - # Sets the default task when thor is executed without an explicit task to be called. - # - # ==== Parameters - # meth:: name of the defaut task - # - def default_task(meth=nil) - case meth - when :none - @default_task = 'help' - when nil - @default_task ||= from_superclass(:default_task, 'help') - else - @default_task = meth.to_s - end - end - - # Defines the usage and the description of the next task. - # - # ==== Parameters - # usage - # description - # - def desc(usage, description, options={}) - if options[:for] - task = find_and_refresh_task(options[:for]) - task.usage = usage if usage - task.description = description if description - else - @usage, @desc = usage, description - end - end - - # Maps an input to a task. If you define: - # - # map "-T" => "list" - # - # Running: - # - # thor -T - # - # Will invoke the list task. - # - # ==== Parameters - # Hash[String|Array => Symbol]:: Maps the string or the strings in the array to the given task. - # - def map(mappings=nil) - @map ||= from_superclass(:map, {}) - - if mappings - mappings.each do |key, value| - if key.respond_to?(:each) - key.each {|subkey| @map[subkey] = value} - else - @map[key] = value - end - end - end - - @map - end - - # Declares the options for the next task to be declared. - # - # ==== Parameters - # Hash[Symbol => Object]:: The hash key is the name of the option and the value - # is the type of the option. Can be :string, :array, :hash, :boolean, :numeric - # or :required (string). If you give a value, the type of the value is used. - # - def method_options(options=nil) - @method_options ||= {} - build_options(options, @method_options) if options - @method_options - end - - # Adds an option to the set of method options. If :for is given as option, - # it allows you to change the options from a previous defined task. - # - # def previous_task - # # magic - # end - # - # method_option :foo => :bar, :for => :previous_task - # - # def next_task - # # magic - # end - # - # ==== Parameters - # name:: The name of the argument. - # options:: Described below. - # - # ==== Options - # :desc - Description for the argument. - # :required - If the argument is required or not. - # :default - Default value for this argument. It cannot be required and have default values. - # :aliases - Aliases for this option. - # :type - The type of the argument, can be :string, :hash, :array, :numeric or :boolean. - # :banner - String to show on usage notes. - # - def method_option(name, options={}) - scope = if options[:for] - find_and_refresh_task(options[:for]).options - else - method_options - end - - build_option(name, options, scope) - end - - # Parses the task and options from the given args, instantiate the class - # and invoke the task. This method is used when the arguments must be parsed - # from an array. If you are inside Ruby and want to use a Thor class, you - # can simply initialize it: - # - # script = MyScript.new(args, options, config) - # script.invoke(:task, first_arg, second_arg, third_arg) - # - def start(given_args=ARGV, config={}) - super do - meth = normalize_task_name(given_args.shift) - task = all_tasks[meth] - - if task - args, opts = Thor::Options.split(given_args) - config.merge!(:task_options => task.options) - else - args, opts = given_args, {} - end - - task ||= Thor::Task::Dynamic.new(meth) - trailing = args[Range.new(arguments.size, -1)] - new(args, opts, config).invoke(task, trailing || []) - end - end - - # Prints help information for the given task. - # - # ==== Parameters - # shell - # task_name - # - def task_help(shell, task_name) - task = all_tasks[task_name] - raise UndefinedTaskError, "task '#{task_name}' could not be found in namespace '#{self.namespace}'" unless task - - shell.say "Usage:" - shell.say " #{banner(task)}" - shell.say - class_options_help(shell, nil => task.options.map { |_, o| o }) - shell.say task.description - end - - # Prints help information for this class. - # - # ==== Parameters - # shell - # - def help(shell) - list = printable_tasks - Thor::Util.thor_classes_in(self).each do |klass| - list += klass.printable_tasks(false) - end - list.sort!{ |a,b| a[0] <=> b[0] } - - shell.say "Tasks:" - shell.print_table(list, :ident => 2, :truncate => true) - shell.say - class_options_help(shell) - end - - # Returns tasks ready to be printed. - def printable_tasks(all=true) - (all ? all_tasks : tasks).map do |_, task| - item = [] - item << banner(task) - item << (task.description ? "# #{task.description.gsub(/\s+/m,' ')}" : "") - item - end - end - - protected - - # The banner for this class. You can customize it if you are invoking the - # thor class by another ways which is not the Thor::Runner. It receives - # the task that is going to be invoked and a boolean which indicates if - # the namespace should be displayed as arguments. - # - def banner(task) - "thor " + task.formatted_usage(self) - end - - def baseclass #:nodoc: - Thor - end - - def create_task(meth) #:nodoc: - if @usage && @desc - tasks[meth.to_s] = Thor::Task.new(meth, @desc, @usage, method_options) - @usage, @desc, @method_options = nil - true - elsif self.all_tasks[meth.to_s] || meth.to_sym == :method_missing - true - else - puts "[WARNING] Attempted to create task #{meth.inspect} without usage or description. " << - "Call desc if you want this method to be available as task or declare it inside a " << - "no_tasks{} block. Invoked from #{caller[1].inspect}." - false - end - end - - def initialize_added #:nodoc: - class_options.merge!(method_options) - @method_options = nil - end - - # Receives a task name (can be nil), and try to get a map from it. - # If a map can't be found use the sent name or the default task. - # - def normalize_task_name(meth) #:nodoc: - mapping = map[meth.to_s] - meth = mapping || meth || default_task - meth.to_s.gsub('-','_') # treat foo-bar > foo_bar - end - end - - include Thor::Base - - map HELP_MAPPINGS => :help - - desc "help [TASK]", "Describe available tasks or one specific task" - def help(task=nil) - task ? self.class.task_help(shell, task) : self.class.help(shell) - end -end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions.rb deleted file mode 100644 index da98444bf2..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions.rb +++ /dev/null @@ -1,274 +0,0 @@ -require 'fileutils' -require 'thor/core_ext/file_binary_read' - -Dir[File.join(File.dirname(__FILE__), "actions", "*.rb")].each do |action| - require action -end - -class Thor - module Actions - attr_accessor :behavior - - def self.included(base) #:nodoc: - base.extend ClassMethods - end - - module ClassMethods - # Hold source paths for one Thor instance. source_paths_for_search is the - # method responsible to gather source_paths from this current class, - # inherited paths and the source root. - # - def source_paths - @source_paths ||= [] - end - - # Returns the source paths in the following order: - # - # 1) This class source paths - # 2) Source root - # 3) Parents source paths - # - def source_paths_for_search - paths = [] - paths += self.source_paths - paths << self.source_root if self.respond_to?(:source_root) - paths += from_superclass(:source_paths, []) - paths - end - - # Add runtime options that help actions execution. - # - def add_runtime_options! - class_option :force, :type => :boolean, :aliases => "-f", :group => :runtime, - :desc => "Overwrite files that already exist" - - class_option :pretend, :type => :boolean, :aliases => "-p", :group => :runtime, - :desc => "Run but do not make any changes" - - class_option :quiet, :type => :boolean, :aliases => "-q", :group => :runtime, - :desc => "Supress status output" - - class_option :skip, :type => :boolean, :aliases => "-s", :group => :runtime, - :desc => "Skip files that already exist" - end - end - - # Extends initializer to add more configuration options. - # - # ==== Configuration - # behavior:: The actions default behavior. Can be :invoke or :revoke. - # It also accepts :force, :skip and :pretend to set the behavior - # and the respective option. - # - # destination_root:: The root directory needed for some actions. - # - def initialize(args=[], options={}, config={}) - self.behavior = case config[:behavior].to_s - when "force", "skip" - _cleanup_options_and_set(options, config[:behavior]) - :invoke - when "revoke" - :revoke - else - :invoke - end - - super - self.destination_root = config[:destination_root] - end - - # Wraps an action object and call it accordingly to the thor class behavior. - # - def action(instance) #:nodoc: - if behavior == :revoke - instance.revoke! - else - instance.invoke! - end - end - - # Returns the root for this thor class (also aliased as destination root). - # - def destination_root - @destination_stack.last - end - - # Sets the root for this thor class. Relatives path are added to the - # directory where the script was invoked and expanded. - # - def destination_root=(root) - @destination_stack ||= [] - @destination_stack[0] = File.expand_path(root || '') - end - - # Returns the given path relative to the absolute root (ie, root where - # the script started). - # - def relative_to_original_destination_root(path, remove_dot=true) - path = path.gsub(@destination_stack[0], '.') - remove_dot ? (path[2..-1] || '') : path - end - - # Holds source paths in instance so they can be manipulated. - # - def source_paths - @source_paths ||= self.class.source_paths_for_search - end - - # Receives a file or directory and search for it in the source paths. - # - def find_in_source_paths(file) - relative_root = relative_to_original_destination_root(destination_root, false) - - source_paths.each do |source| - source_file = File.expand_path(file, File.join(source, relative_root)) - return source_file if File.exists?(source_file) - end - - if source_paths.empty? - raise Error, "You don't have any source path defined for class #{self.class.name}. To fix this, " << - "you can define a source_root in your class." - else - raise Error, "Could not find #{file.inspect} in source paths." - end - end - - # Do something in the root or on a provided subfolder. If a relative path - # is given it's referenced from the current root. The full path is yielded - # to the block you provide. The path is set back to the previous path when - # the method exits. - # - # ==== Parameters - # dir:: the directory to move to. - # config:: give :verbose => true to log and use padding. - # - def inside(dir='', config={}, &block) - verbose = config.fetch(:verbose, false) - - say_status :inside, dir, verbose - shell.padding += 1 if verbose - @destination_stack.push File.expand_path(dir, destination_root) - - FileUtils.mkdir_p(destination_root) unless File.exist?(destination_root) - FileUtils.cd(destination_root) { block.arity == 1 ? yield(destination_root) : yield } - - @destination_stack.pop - shell.padding -= 1 if verbose - end - - # Goes to the root and execute the given block. - # - def in_root - inside(@destination_stack.first) { yield } - end - - # Loads an external file and execute it in the instance binding. - # - # ==== Parameters - # path:: The path to the file to execute. Can be a web address or - # a relative path from the source root. - # - # ==== Examples - # - # apply "http://gist.github.com/103208" - # - # apply "recipes/jquery.rb" - # - def apply(path, config={}) - verbose = config.fetch(:verbose, true) - path = find_in_source_paths(path) unless path =~ /^http\:\/\// - - say_status :apply, path, verbose - shell.padding += 1 if verbose - instance_eval(open(path).read) - shell.padding -= 1 if verbose - end - - # Executes a command. - # - # ==== Parameters - # command:: the command to be executed. - # config:: give :verbose => false to not log the status. Specify :with - # to append an executable to command executation. - # - # ==== Example - # - # inside('vendor') do - # run('ln -s ~/edge rails') - # end - # - def run(command, config={}) - return unless behavior == :invoke - - destination = relative_to_original_destination_root(destination_root, false) - desc = "#{command} from #{destination.inspect}" - - if config[:with] - desc = "#{File.basename(config[:with].to_s)} #{desc}" - command = "#{config[:with]} #{command}" - end - - say_status :run, desc, config.fetch(:verbose, true) - system(command) unless options[:pretend] - end - - # Executes a ruby script (taking into account WIN32 platform quirks). - # - # ==== Parameters - # command:: the command to be executed. - # config:: give :verbose => false to not log the status. - # - def run_ruby_script(command, config={}) - return unless behavior == :invoke - run "#{command}", config.merge(:with => Thor::Util.ruby_command) - end - - # Run a thor command. A hash of options can be given and it's converted to - # switches. - # - # ==== Parameters - # task:: the task to be invoked - # args:: arguments to the task - # config:: give :verbose => false to not log the status. Other options - # are given as parameter to Thor. - # - # ==== Examples - # - # thor :install, "http://gist.github.com/103208" - # #=> thor install http://gist.github.com/103208 - # - # thor :list, :all => true, :substring => 'rails' - # #=> thor list --all --substring=rails - # - def thor(task, *args) - config = args.last.is_a?(Hash) ? args.pop : {} - verbose = config.key?(:verbose) ? config.delete(:verbose) : true - - args.unshift task - args.push Thor::Options.to_switches(config) - command = args.join(' ').strip - - run command, :with => :thor, :verbose => verbose - end - - protected - - # Allow current root to be shared between invocations. - # - def _shared_configuration #:nodoc: - super.merge!(:destination_root => self.destination_root) - end - - def _cleanup_options_and_set(options, key) #:nodoc: - case options - when Array - %w(--force -f --skip -s).each { |i| options.delete(i) } - options << "--#{key}" - when Hash - [:force, :skip, "force", "skip"].each { |i| options.delete(i) } - options.merge!(key => true) - end - end - - end -end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions/create_file.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions/create_file.rb deleted file mode 100644 index 6e0eeb43e2..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions/create_file.rb +++ /dev/null @@ -1,103 +0,0 @@ -require 'thor/actions/empty_directory' - -class Thor - module Actions - - # Create a new file relative to the destination root with the given data, - # which is the return value of a block or a data string. - # - # ==== Parameters - # destination:: the relative path to the destination root. - # data:: the data to append to the file. - # config:: give :verbose => false to not log the status. - # - # ==== Examples - # - # create_file "lib/fun_party.rb" do - # hostname = ask("What is the virtual hostname I should use?") - # "vhost.name = #{hostname}" - # end - # - # create_file "config/apach.conf", "your apache config" - # - def create_file(destination, data=nil, config={}, &block) - action CreateFile.new(self, destination, block || data.to_s, config) - end - alias :add_file :create_file - - # AddFile is a subset of Template, which instead of rendering a file with - # ERB, it gets the content from the user. - # - class CreateFile < EmptyDirectory #:nodoc: - attr_reader :data - - def initialize(base, destination, data, config={}) - @data = data - super(base, destination, config) - end - - # Checks if the content of the file at the destination is identical to the rendered result. - # - # ==== Returns - # Boolean:: true if it is identical, false otherwise. - # - def identical? - exists? && File.binread(destination) == render - end - - # Holds the content to be added to the file. - # - def render - @render ||= if data.is_a?(Proc) - data.call - else - data - end - end - - def invoke! - invoke_with_conflict_check do - FileUtils.mkdir_p(File.dirname(destination)) - File.open(destination, 'wb') { |f| f.write render } - end - given_destination - end - - protected - - # Now on conflict we check if the file is identical or not. - # - def on_conflict_behavior(&block) - if identical? - say_status :identical, :blue - else - options = base.options.merge(config) - force_or_skip_or_conflict(options[:force], options[:skip], &block) - end - end - - # If force is true, run the action, otherwise check if it's not being - # skipped. If both are false, show the file_collision menu, if the menu - # returns true, force it, otherwise skip. - # - def force_or_skip_or_conflict(force, skip, &block) - if force - say_status :force, :yellow - block.call unless pretend? - elsif skip - say_status :skip, :yellow - else - say_status :conflict, :red - force_or_skip_or_conflict(force_on_collision?, true, &block) - end - end - - # Shows the file collision menu to the user and gets the result. - # - def force_on_collision? - base.shell.file_collision(destination){ render } - end - - end - end -end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions/directory.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions/directory.rb deleted file mode 100644 index 2e0b459fa3..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions/directory.rb +++ /dev/null @@ -1,91 +0,0 @@ -require 'thor/actions/empty_directory' - -class Thor - module Actions - - # Copies recursively the files from source directory to root directory. - # If any of the files finishes with .tt, it's considered to be a template - # and is placed in the destination without the extension .tt. If any - # empty directory is found, it's copied and all .empty_directory files are - # ignored. Remember that file paths can also be encoded, let's suppose a doc - # directory with the following files: - # - # doc/ - # components/.empty_directory - # README - # rdoc.rb.tt - # %app_name%.rb - # - # When invoked as: - # - # directory "doc" - # - # It will create a doc directory in the destination with the following - # files (assuming that the app_name is "blog"): - # - # doc/ - # components/ - # README - # rdoc.rb - # blog.rb - # - # ==== Parameters - # source:: the relative path to the source root. - # destination:: the relative path to the destination root. - # config:: give :verbose => false to not log the status. - # If :recursive => false, does not look for paths recursively. - # - # ==== Examples - # - # directory "doc" - # directory "doc", "docs", :recursive => false - # - def directory(source, destination=nil, config={}, &block) - action Directory.new(self, source, destination || source, config, &block) - end - - class Directory < EmptyDirectory #:nodoc: - attr_reader :source - - def initialize(base, source, destination=nil, config={}, &block) - @source = File.expand_path(base.find_in_source_paths(source.to_s)) - @block = block - super(base, destination, { :recursive => true }.merge(config)) - end - - def invoke! - base.empty_directory given_destination, config - execute! - end - - def revoke! - execute! - end - - protected - - def execute! - lookup = config[:recursive] ? File.join(source, '**') : source - lookup = File.join(lookup, '{*,.[a-z]*}') - - Dir[lookup].each do |file_source| - next if File.directory?(file_source) - file_destination = File.join(given_destination, file_source.gsub(source, '.')) - file_destination.gsub!('/./', '/') - - case file_source - when /\.empty_directory$/ - dirname = File.dirname(file_destination).gsub(/\/\.$/, '') - next if dirname == given_destination - base.empty_directory(dirname, config) - when /\.tt$/ - destination = base.template(file_source, file_destination[0..-4], config, &@block) - else - destination = base.copy_file(file_source, file_destination, config, &@block) - end - end - end - - end - end -end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions/empty_directory.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions/empty_directory.rb deleted file mode 100644 index 484cb820f8..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions/empty_directory.rb +++ /dev/null @@ -1,134 +0,0 @@ -class Thor - module Actions - - # Creates an empty directory. - # - # ==== Parameters - # destination:: the relative path to the destination root. - # config:: give :verbose => false to not log the status. - # - # ==== Examples - # - # empty_directory "doc" - # - def empty_directory(destination, config={}) - action EmptyDirectory.new(self, destination, config) - end - - # Class which holds create directory logic. This is the base class for - # other actions like create_file and directory. - # - # This implementation is based in Templater actions, created by Jonas Nicklas - # and Michael S. Klishin under MIT LICENSE. - # - class EmptyDirectory #:nodoc: - attr_reader :base, :destination, :given_destination, :relative_destination, :config - - # Initializes given the source and destination. - # - # ==== Parameters - # base:: A Thor::Base instance - # source:: Relative path to the source of this file - # destination:: Relative path to the destination of this file - # config:: give :verbose => false to not log the status. - # - def initialize(base, destination, config={}) - @base, @config = base, { :verbose => true }.merge(config) - self.destination = destination - end - - # Checks if the destination file already exists. - # - # ==== Returns - # Boolean:: true if the file exists, false otherwise. - # - def exists? - ::File.exists?(destination) - end - - def invoke! - invoke_with_conflict_check do - ::FileUtils.mkdir_p(destination) - end - end - - def revoke! - say_status :remove, :red - ::FileUtils.rm_rf(destination) if !pretend? && exists? - given_destination - end - - protected - - # Shortcut for pretend. - # - def pretend? - base.options[:pretend] - end - - # Sets the absolute destination value from a relative destination value. - # It also stores the given and relative destination. Let's suppose our - # script is being executed on "dest", it sets the destination root to - # "dest". The destination, given_destination and relative_destination - # are related in the following way: - # - # inside "bar" do - # empty_directory "baz" - # end - # - # destination #=> dest/bar/baz - # relative_destination #=> bar/baz - # given_destination #=> baz - # - def destination=(destination) - if destination - @given_destination = convert_encoded_instructions(destination.to_s) - @destination = ::File.expand_path(@given_destination, base.destination_root) - @relative_destination = base.relative_to_original_destination_root(@destination) - end - end - - # Filenames in the encoded form are converted. If you have a file: - # - # %class_name%.rb - # - # It gets the class name from the base and replace it: - # - # user.rb - # - def convert_encoded_instructions(filename) - filename.gsub(/%(.*?)%/) do |string| - instruction = $1.strip - base.respond_to?(instruction) ? base.send(instruction) : string - end - end - - # Receives a hash of options and just execute the block if some - # conditions are met. - # - def invoke_with_conflict_check(&block) - if exists? - on_conflict_behavior(&block) - else - say_status :create, :green - block.call unless pretend? - end - - destination - end - - # What to do when the destination file already exists. - # - def on_conflict_behavior(&block) - say_status :exist, :blue - end - - # Shortcut to say_status shell method. - # - def say_status(status, color) - base.shell.say_status status, relative_destination, color if config[:verbose] - end - - end - end -end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions/file_manipulation.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions/file_manipulation.rb deleted file mode 100644 index 44d6836c10..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions/file_manipulation.rb +++ /dev/null @@ -1,223 +0,0 @@ -require 'erb' -require 'open-uri' - -class Thor - module Actions - - # Copies the file from the relative source to the relative destination. If - # the destination is not given it's assumed to be equal to the source. - # - # ==== Parameters - # source:: the relative path to the source root. - # destination:: the relative path to the destination root. - # config:: give :verbose => false to not log the status. - # - # ==== Examples - # - # copy_file "README", "doc/README" - # - # copy_file "doc/README" - # - def copy_file(source, destination=nil, config={}, &block) - destination ||= source - source = File.expand_path(find_in_source_paths(source.to_s)) - - create_file destination, nil, config do - content = File.binread(source) - content = block.call(content) if block - content - end - end - - # Gets the content at the given address and places it at the given relative - # destination. If a block is given instead of destination, the content of - # the url is yielded and used as location. - # - # ==== Parameters - # source:: the address of the given content. - # destination:: the relative path to the destination root. - # config:: give :verbose => false to not log the status. - # - # ==== Examples - # - # get "http://gist.github.com/103208", "doc/README" - # - # get "http://gist.github.com/103208" do |content| - # content.split("\n").first - # end - # - def get(source, destination=nil, config={}, &block) - source = File.expand_path(find_in_source_paths(source.to_s)) unless source =~ /^http\:\/\// - render = File.binread(source) - - destination ||= if block_given? - block.arity == 1 ? block.call(render) : block.call - else - File.basename(source) - end - - create_file destination, render, config - end - - # Gets an ERB template at the relative source, executes it and makes a copy - # at the relative destination. If the destination is not given it's assumed - # to be equal to the source removing .tt from the filename. - # - # ==== Parameters - # source:: the relative path to the source root. - # destination:: the relative path to the destination root. - # config:: give :verbose => false to not log the status. - # - # ==== Examples - # - # template "README", "doc/README" - # - # template "doc/README" - # - def template(source, destination=nil, config={}, &block) - destination ||= source - source = File.expand_path(find_in_source_paths(source.to_s)) - context = instance_eval('binding') - - create_file destination, nil, config do - content = ERB.new(::File.binread(source), nil, '-').result(context) - content = block.call(content) if block - content - end - end - - # Changes the mode of the given file or directory. - # - # ==== Parameters - # mode:: the file mode - # path:: the name of the file to change mode - # config:: give :verbose => false to not log the status. - # - # ==== Example - # - # chmod "script/*", 0755 - # - def chmod(path, mode, config={}) - return unless behavior == :invoke - path = File.expand_path(path, destination_root) - say_status :chmod, relative_to_original_destination_root(path), config.fetch(:verbose, true) - FileUtils.chmod_R(mode, path) unless options[:pretend] - end - - # Prepend text to a file. Since it depends on inject_into_file, it's reversible. - # - # ==== Parameters - # path:: path of the file to be changed - # data:: the data to prepend to the file, can be also given as a block. - # config:: give :verbose => false to not log the status. - # - # ==== Example - # - # prepend_file 'config/environments/test.rb', 'config.gem "rspec"' - # - # prepend_file 'config/environments/test.rb' do - # 'config.gem "rspec"' - # end - # - def prepend_file(path, *args, &block) - config = args.last.is_a?(Hash) ? args.pop : {} - config.merge!(:after => /\A/) - inject_into_file(path, *(args << config), &block) - end - - # Append text to a file. Since it depends on inject_into_file, it's reversible. - # - # ==== Parameters - # path:: path of the file to be changed - # data:: the data to append to the file, can be also given as a block. - # config:: give :verbose => false to not log the status. - # - # ==== Example - # - # append_file 'config/environments/test.rb', 'config.gem "rspec"' - # - # append_file 'config/environments/test.rb' do - # 'config.gem "rspec"' - # end - # - def append_file(path, *args, &block) - config = args.last.is_a?(Hash) ? args.pop : {} - config.merge!(:before => /\z/) - inject_into_file(path, *(args << config), &block) - end - - # Injects text right after the class definition. Since it depends on - # inject_into_file, it's reversible. - # - # ==== Parameters - # path:: path of the file to be changed - # klass:: the class to be manipulated - # data:: the data to append to the class, can be also given as a block. - # config:: give :verbose => false to not log the status. - # - # ==== Examples - # - # inject_into_class "app/controllers/application_controller.rb", " filter_parameter :password\n" - # - # inject_into_class "app/controllers/application_controller.rb", ApplicationController do - # " filter_parameter :password\n" - # end - # - def inject_into_class(path, klass, *args, &block) - config = args.last.is_a?(Hash) ? args.pop : {} - config.merge!(:after => /class #{klass}\n|class #{klass} .*\n/) - inject_into_file(path, *(args << config), &block) - end - - # Run a regular expression replacement on a file. - # - # ==== Parameters - # path:: path of the file to be changed - # flag:: the regexp or string to be replaced - # replacement:: the replacement, can be also given as a block - # config:: give :verbose => false to not log the status. - # - # ==== Example - # - # gsub_file 'app/controllers/application_controller.rb', /#\s*(filter_parameter_logging :password)/, '\1' - # - # gsub_file 'README', /rake/, :green do |match| - # match << " no more. Use thor!" - # end - # - def gsub_file(path, flag, *args, &block) - return unless behavior == :invoke - config = args.last.is_a?(Hash) ? args.pop : {} - - path = File.expand_path(path, destination_root) - say_status :gsub, relative_to_original_destination_root(path), config.fetch(:verbose, true) - - unless options[:pretend] - content = File.binread(path) - content.gsub!(flag, *args, &block) - File.open(path, 'wb') { |file| file.write(content) } - end - end - - # Removes a file at the given location. - # - # ==== Parameters - # path:: path of the file to be changed - # config:: give :verbose => false to not log the status. - # - # ==== Example - # - # remove_file 'README' - # remove_file 'app/controllers/application_controller.rb' - # - def remove_file(path, config={}) - return unless behavior == :invoke - path = File.expand_path(path, destination_root) - - say_status :remove, relative_to_original_destination_root(path), config.fetch(:verbose, true) - ::FileUtils.rm_rf(path) if !options[:pretend] && File.exists?(path) - end - alias :remove_dir :remove_file - - end -end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions/inject_into_file.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions/inject_into_file.rb deleted file mode 100644 index 350ab73862..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions/inject_into_file.rb +++ /dev/null @@ -1,101 +0,0 @@ -require 'thor/actions/empty_directory' - -class Thor - module Actions - - # Injects the given content into a file. Different from gsub_file, this - # method is reversible. - # - # ==== Parameters - # destination:: Relative path to the destination root - # data:: Data to add to the file. Can be given as a block. - # config:: give :verbose => false to not log the status and the flag - # for injection (:after or :before). - # - # ==== Examples - # - # inject_into_file "config/environment.rb", "config.gem :thor", :after => "Rails::Initializer.run do |config|\n" - # - # inject_into_file "config/environment.rb", :after => "Rails::Initializer.run do |config|\n" do - # gems = ask "Which gems would you like to add?" - # gems.split(" ").map{ |gem| " config.gem :#{gem}" }.join("\n") - # end - # - def inject_into_file(destination, *args, &block) - if block_given? - data, config = block, args.shift - else - data, config = args.shift, args.shift - end - action InjectIntoFile.new(self, destination, data, config) - end - - class InjectIntoFile < EmptyDirectory #:nodoc: - attr_reader :replacement, :flag, :behavior - - def initialize(base, destination, data, config) - super(base, destination, { :verbose => true }.merge(config)) - - @behavior, @flag = if @config.key?(:after) - [:after, @config.delete(:after)] - else - [:before, @config.delete(:before)] - end - - @replacement = data.is_a?(Proc) ? data.call : data - @flag = Regexp.escape(@flag) unless @flag.is_a?(Regexp) - end - - def invoke! - say_status :invoke - - content = if @behavior == :after - '\0' + replacement - else - replacement + '\0' - end - - replace!(/#{flag}/, content) - end - - def revoke! - say_status :revoke - - regexp = if @behavior == :after - content = '\1\2' - /(#{flag})(.*)(#{Regexp.escape(replacement)})/m - else - content = '\2\3' - /(#{Regexp.escape(replacement)})(.*)(#{flag})/m - end - - replace!(regexp, content) - end - - protected - - def say_status(behavior) - status = if flag == /\A/ - behavior == :invoke ? :prepend : :unprepend - elsif flag == /\z/ - behavior == :invoke ? :append : :unappend - else - behavior == :invoke ? :inject : :deinject - end - - super(status, config[:verbose]) - end - - # Adds the content to the file. - # - def replace!(regexp, string) - unless base.options[:pretend] - content = File.binread(destination) - content.gsub!(regexp, string) - File.open(destination, 'wb') { |file| file.write(content) } - end - end - - end - end -end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/base.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/base.rb deleted file mode 100644 index aae4cdb89c..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/base.rb +++ /dev/null @@ -1,515 +0,0 @@ -require 'thor/core_ext/hash_with_indifferent_access' -require 'thor/core_ext/ordered_hash' -require 'thor/error' -require 'thor/shell' -require 'thor/invocation' -require 'thor/parser' -require 'thor/task' -require 'thor/util' - -class Thor - # Shortcuts for help. - HELP_MAPPINGS = %w(-h -? --help -D) - - # Thor methods that should not be overwritten by the user. - THOR_RESERVED_WORDS = %w(invoke shell options behavior root destination_root relative_root - action add_file create_file in_root inside run run_ruby_script) - - module Base - attr_accessor :options - - # It receives arguments in an Array and two hashes, one for options and - # other for configuration. - # - # Notice that it does not check if all required arguments were supplied. - # It should be done by the parser. - # - # ==== Parameters - # args:: An array of objects. The objects are applied to their - # respective accessors declared with argument. - # - # options:: An options hash that will be available as self.options. - # The hash given is converted to a hash with indifferent - # access, magic predicates (options.skip?) and then frozen. - # - # config:: Configuration for this Thor class. - # - def initialize(args=[], options={}, config={}) - Thor::Arguments.parse(self.class.arguments, args).each do |key, value| - send("#{key}=", value) - end - - parse_options = self.class.class_options - - if options.is_a?(Array) - task_options = config.delete(:task_options) # hook for start - parse_options = parse_options.merge(task_options) if task_options - array_options, hash_options = options, {} - else - array_options, hash_options = [], options - end - - options = Thor::Options.parse(parse_options, array_options) - self.options = Thor::CoreExt::HashWithIndifferentAccess.new(options).merge!(hash_options) - self.options.freeze - end - - class << self - def included(base) #:nodoc: - base.send :extend, ClassMethods - base.send :include, Invocation - base.send :include, Shell - end - - # Returns the classes that inherits from Thor or Thor::Group. - # - # ==== Returns - # Array[Class] - # - def subclasses - @subclasses ||= [] - end - - # Returns the files where the subclasses are kept. - # - # ==== Returns - # Hash[path => Class] - # - def subclass_files - @subclass_files ||= Hash.new{ |h,k| h[k] = [] } - end - - # Whenever a class inherits from Thor or Thor::Group, we should track the - # class and the file on Thor::Base. This is the method responsable for it. - # - def register_klass_file(klass) #:nodoc: - file = caller[1].match(/(.*):\d+/)[1] - Thor::Base.subclasses << klass unless Thor::Base.subclasses.include?(klass) - - file_subclasses = Thor::Base.subclass_files[File.expand_path(file)] - file_subclasses << klass unless file_subclasses.include?(klass) - end - end - - module ClassMethods - attr_accessor :debugging - - # Adds an argument to the class and creates an attr_accessor for it. - # - # Arguments are different from options in several aspects. The first one - # is how they are parsed from the command line, arguments are retrieved - # from position: - # - # thor task NAME - # - # Instead of: - # - # thor task --name=NAME - # - # Besides, arguments are used inside your code as an accessor (self.argument), - # while options are all kept in a hash (self.options). - # - # Finally, arguments cannot have type :default or :boolean but can be - # optional (supplying :optional => :true or :required => false), although - # you cannot have a required argument after a non-required argument. If you - # try it, an error is raised. - # - # ==== Parameters - # name:: The name of the argument. - # options:: Described below. - # - # ==== Options - # :desc - Description for the argument. - # :required - If the argument is required or not. - # :optional - If the argument is optional or not. - # :type - The type of the argument, can be :string, :hash, :array, :numeric. - # :default - Default value for this argument. It cannot be required and have default values. - # :banner - String to show on usage notes. - # - # ==== Errors - # ArgumentError:: Raised if you supply a required argument after a non required one. - # - def argument(name, options={}) - is_thor_reserved_word?(name, :argument) - no_tasks { attr_accessor name } - - required = if options.key?(:optional) - !options[:optional] - elsif options.key?(:required) - options[:required] - else - options[:default].nil? - end - - remove_argument name - - arguments.each do |argument| - next if argument.required? - raise ArgumentError, "You cannot have #{name.to_s.inspect} as required argument after " << - "the non-required argument #{argument.human_name.inspect}." - end if required - - arguments << Thor::Argument.new(name, options[:desc], required, options[:type], - options[:default], options[:banner]) - end - - # Returns this class arguments, looking up in the ancestors chain. - # - # ==== Returns - # Array[Thor::Argument] - # - def arguments - @arguments ||= from_superclass(:arguments, []) - end - - # Adds a bunch of options to the set of class options. - # - # class_options :foo => false, :bar => :required, :baz => :string - # - # If you prefer more detailed declaration, check class_option. - # - # ==== Parameters - # Hash[Symbol => Object] - # - def class_options(options=nil) - @class_options ||= from_superclass(:class_options, {}) - build_options(options, @class_options) if options - @class_options - end - - # Adds an option to the set of class options - # - # ==== Parameters - # name:: The name of the argument. - # options:: Described below. - # - # ==== Options - # :desc - Description for the argument. - # :required - If the argument is required or not. - # :default - Default value for this argument. - # :group - The group for this options. Use by class options to output options in different levels. - # :aliases - Aliases for this option. - # :type - The type of the argument, can be :string, :hash, :array, :numeric or :boolean. - # :banner - String to show on usage notes. - # - def class_option(name, options={}) - build_option(name, options, class_options) - end - - # Removes a previous defined argument. If :undefine is given, undefine - # accessors as well. - # - # ==== Paremeters - # names:: Arguments to be removed - # - # ==== Examples - # - # remove_argument :foo - # remove_argument :foo, :bar, :baz, :undefine => true - # - def remove_argument(*names) - options = names.last.is_a?(Hash) ? names.pop : {} - - names.each do |name| - arguments.delete_if { |a| a.name == name.to_s } - undef_method name, "#{name}=" if options[:undefine] - end - end - - # Removes a previous defined class option. - # - # ==== Paremeters - # names:: Class options to be removed - # - # ==== Examples - # - # remove_class_option :foo - # remove_class_option :foo, :bar, :baz - # - def remove_class_option(*names) - names.each do |name| - class_options.delete(name) - end - end - - # Defines the group. This is used when thor list is invoked so you can specify - # that only tasks from a pre-defined group will be shown. Defaults to standard. - # - # ==== Parameters - # name - # - def group(name=nil) - case name - when nil - @group ||= from_superclass(:group, 'standard') - else - @group = name.to_s - end - end - - # Returns the tasks for this Thor class. - # - # ==== Returns - # OrderedHash:: An ordered hash with tasks names as keys and Thor::Task - # objects as values. - # - def tasks - @tasks ||= Thor::CoreExt::OrderedHash.new - end - - # Returns the tasks for this Thor class and all subclasses. - # - # ==== Returns - # OrderedHash:: An ordered hash with tasks names as keys and Thor::Task - # objects as values. - # - def all_tasks - @all_tasks ||= from_superclass(:all_tasks, Thor::CoreExt::OrderedHash.new) - @all_tasks.merge(tasks) - end - - # Removes a given task from this Thor class. This is usually done if you - # are inheriting from another class and don't want it to be available - # anymore. - # - # By default it only remove the mapping to the task. But you can supply - # :undefine => true to undefine the method from the class as well. - # - # ==== Parameters - # name:: The name of the task to be removed - # options:: You can give :undefine => true if you want tasks the method - # to be undefined from the class as well. - # - def remove_task(*names) - options = names.last.is_a?(Hash) ? names.pop : {} - - names.each do |name| - tasks.delete(name.to_s) - all_tasks.delete(name.to_s) - undef_method name if options[:undefine] - end - end - - # All methods defined inside the given block are not added as tasks. - # - # So you can do: - # - # class MyScript < Thor - # no_tasks do - # def this_is_not_a_task - # end - # end - # end - # - # You can also add the method and remove it from the task list: - # - # class MyScript < Thor - # def this_is_not_a_task - # end - # remove_task :this_is_not_a_task - # end - # - def no_tasks - @no_tasks = true - yield - @no_tasks = false - end - - # Sets the namespace for the Thor or Thor::Group class. By default the - # namespace is retrieved from the class name. If your Thor class is named - # Scripts::MyScript, the help method, for example, will be called as: - # - # thor scripts:my_script -h - # - # If you change the namespace: - # - # namespace :my_scripts - # - # You change how your tasks are invoked: - # - # thor my_scripts -h - # - # Finally, if you change your namespace to default: - # - # namespace :default - # - # Your tasks can be invoked with a shortcut. Instead of: - # - # thor :my_task - # - def namespace(name=nil) - case name - when nil - @namespace ||= Thor::Util.namespace_from_thor_class(self, false) - else - @namespace = name.to_s - end - end - - # Default way to start generators from the command line. - # - def start(given_args=ARGV, config={}) - self.debugging = given_args.include?("--debug") - config[:shell] ||= Thor::Base.shell.new - yield - rescue Thor::Error => e - if debugging - raise e - else - config[:shell].error e.message - end - exit(1) if exit_on_failure? - end - - protected - - # Prints the class options per group. If an option does not belong to - # any group, it's printed as Class option. - # - def class_options_help(shell, groups={}) #:nodoc: - # Group options by group - class_options.each do |_, value| - groups[value.group] ||= [] - groups[value.group] << value - end - - # Deal with default group - global_options = groups.delete(nil) || [] - print_options(shell, global_options) - - # Print all others - groups.each do |group_name, options| - print_options(shell, options, group_name) - end - end - - # Receives a set of options and print them. - def print_options(shell, options, group_name=nil) - return if options.empty? - - list = [] - padding = options.collect{ |o| o.aliases.size }.max.to_i * 4 - - options.each do |option| - item = [ option.usage(padding) ] - item.push(option.description ? "# #{option.description}" : "") - - list << item - list << [ "", "# Default: #{option.default}" ] if option.show_default? - end - - shell.say(group_name ? "#{group_name} options:" : "Options:") - shell.print_table(list, :ident => 2) - shell.say "" - end - - # Raises an error if the word given is a Thor reserved word. - # - def is_thor_reserved_word?(word, type) #:nodoc: - return false unless THOR_RESERVED_WORDS.include?(word.to_s) - raise "#{word.inspect} is a Thor reserved word and cannot be defined as #{type}" - end - - # Build an option and adds it to the given scope. - # - # ==== Parameters - # name:: The name of the argument. - # options:: Described in both class_option and method_option. - # - def build_option(name, options, scope) #:nodoc: - scope[name] = Thor::Option.new(name, options[:desc], options[:required], - options[:type], options[:default], options[:banner], - options[:group], options[:aliases]) - end - - # Receives a hash of options, parse them and add to the scope. This is a - # fast way to set a bunch of options: - # - # build_options :foo => true, :bar => :required, :baz => :string - # - # ==== Parameters - # Hash[Symbol => Object] - # - def build_options(options, scope) #:nodoc: - options.each do |key, value| - scope[key] = Thor::Option.parse(key, value) - end - end - - # Finds a task with the given name. If the task belongs to the current - # class, just return it, otherwise dup it and add the fresh copy to the - # current task hash. - # - def find_and_refresh_task(name) #:nodoc: - task = if task = tasks[name.to_s] - task - elsif task = all_tasks[name.to_s] - tasks[name.to_s] = task.clone - else - raise ArgumentError, "You supplied :for => #{name.inspect}, but the task #{name.inspect} could not be found." - end - end - - # Everytime someone inherits from a Thor class, register the klass - # and file into baseclass. - # - def inherited(klass) - Thor::Base.register_klass_file(klass) - end - - # Fire this callback whenever a method is added. Added methods are - # tracked as tasks by invoking the create_task method. - # - def method_added(meth) - meth = meth.to_s - - if meth == "initialize" - initialize_added - return - end - - # Return if it's not a public instance method - return unless public_instance_methods.include?(meth) || - public_instance_methods.include?(meth.to_sym) - - return if @no_tasks || !create_task(meth) - - is_thor_reserved_word?(meth, :task) - Thor::Base.register_klass_file(self) - end - - # Retrieves a value from superclass. If it reaches the baseclass, - # returns default. - # - def from_superclass(method, default=nil) - if self == baseclass || !superclass.respond_to?(method, true) - default - else - value = superclass.send(method) - value.dup if value - end - end - - # A flag that makes the process exit with status 1 if any error happens. - # - def exit_on_failure? - false - end - - # SIGNATURE: Sets the baseclass. This is where the superclass lookup - # finishes. - def baseclass #:nodoc: - end - - # SIGNATURE: Creates a new task if valid_task? is true. This method is - # called when a new method is added to the class. - def create_task(meth) #:nodoc: - end - - # SIGNATURE: Defines behavior when the initialize method is added to the - # class. - def initialize_added #:nodoc: - end - end - end -end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/core_ext/file_binary_read.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/core_ext/file_binary_read.rb deleted file mode 100644 index d6af7e44b0..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/core_ext/file_binary_read.rb +++ /dev/null @@ -1,9 +0,0 @@ -class File #:nodoc: - - unless File.respond_to?(:binread) - def self.binread(file) - File.open(file, 'rb') { |f| f.read } - end - end - -end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/core_ext/hash_with_indifferent_access.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/core_ext/hash_with_indifferent_access.rb deleted file mode 100644 index 78bc5cf4bf..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/core_ext/hash_with_indifferent_access.rb +++ /dev/null @@ -1,75 +0,0 @@ -class Thor - module CoreExt #:nodoc: - - # A hash with indifferent access and magic predicates. - # - # hash = Thor::CoreExt::HashWithIndifferentAccess.new 'foo' => 'bar', 'baz' => 'bee', 'force' => true - # - # hash[:foo] #=> 'bar' - # hash['foo'] #=> 'bar' - # hash.foo? #=> true - # - class HashWithIndifferentAccess < ::Hash #:nodoc: - - def initialize(hash={}) - super() - hash.each do |key, value| - self[convert_key(key)] = value - end - end - - def [](key) - super(convert_key(key)) - end - - def []=(key, value) - super(convert_key(key), value) - end - - def delete(key) - super(convert_key(key)) - end - - def values_at(*indices) - indices.collect { |key| self[convert_key(key)] } - end - - def merge(other) - dup.merge!(other) - end - - def merge!(other) - other.each do |key, value| - self[convert_key(key)] = value - end - self - end - - protected - - def convert_key(key) - key.is_a?(Symbol) ? key.to_s : key - end - - # Magic predicates. For instance: - # - # options.force? # => !!options['force'] - # options.shebang # => "/usr/lib/local/ruby" - # options.test_framework?(:rspec) # => options[:test_framework] == :rspec - # - def method_missing(method, *args, &block) - method = method.to_s - if method =~ /^(\w+)\?$/ - if args.empty? - !!self[$1] - else - self[$1] == args.first - end - else - self[method] - end - end - - end - end -end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/core_ext/ordered_hash.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/core_ext/ordered_hash.rb deleted file mode 100644 index 27fea5bb35..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/core_ext/ordered_hash.rb +++ /dev/null @@ -1,100 +0,0 @@ -class Thor - module CoreExt #:nodoc: - - if RUBY_VERSION >= '1.9' - class OrderedHash < ::Hash - end - else - # This class is based on the Ruby 1.9 ordered hashes. - # - # It keeps the semantics and most of the efficiency of normal hashes - # while also keeping track of the order in which elements were set. - # - class OrderedHash #:nodoc: - include Enumerable - - Node = Struct.new(:key, :value, :next, :prev) - - def initialize - @hash = {} - end - - def [](key) - @hash[key] && @hash[key].value - end - - def []=(key, value) - if node = @hash[key] - node.value = value - else - node = Node.new(key, value) - - if @first.nil? - @first = @last = node - else - node.prev = @last - @last.next = node - @last = node - end - end - - @hash[key] = node - value - end - - def delete(key) - if node = @hash[key] - prev_node = node.prev - next_node = node.next - - next_node.prev = prev_node if next_node - prev_node.next = next_node if prev_node - - @first = next_node if @first == node - @last = prev_node if @last == node - - value = node.value - end - - @hash.delete(key) - value - end - - def keys - self.map { |k, v| k } - end - - def values - self.map { |k, v| v } - end - - def each - return unless @first - yield [@first.key, @first.value] - node = @first - yield [node.key, node.value] while node = node.next - self - end - - def merge(other) - hash = self.class.new - - self.each do |key, value| - hash[key] = value - end - - other.each do |key, value| - hash[key] = value - end - - hash - end - - def empty? - @hash.empty? - end - end - end - - end -end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/error.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/error.rb deleted file mode 100644 index f9b31a35d1..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/error.rb +++ /dev/null @@ -1,27 +0,0 @@ -class Thor - # Thor::Error is raised when it's caused by wrong usage of thor classes. Those - # errors have their backtrace supressed and are nicely shown to the user. - # - # Errors that are caused by the developer, like declaring a method which - # overwrites a thor keyword, it SHOULD NOT raise a Thor::Error. This way, we - # ensure that developer errors are shown with full backtrace. - # - class Error < StandardError - end - - # Raised when a task was not found. - # - class UndefinedTaskError < Error - end - - # Raised when a task was found, but not invoked properly. - # - class InvocationError < Error - end - - class RequiredArgumentMissingError < InvocationError - end - - class MalformattedArgumentError < InvocationError - end -end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/group.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/group.rb deleted file mode 100644 index eda3b52c4f..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/group.rb +++ /dev/null @@ -1,270 +0,0 @@ -# Thor has a special class called Thor::Group. The main difference to Thor class -# is that it invokes all tasks at once. It also include some methods that allows -# invocations to be done at the class method, which are not available to Thor -# tasks. -# -class Thor::Group - class << self - # The descrition for this Thor::Group. If none is provided, but a source root - # exists, tries to find the USAGE one folder above it, otherwise searches - # in the superclass. - # - # ==== Parameters - # description:: The description for this Thor::Group. - # - def desc(description=nil) - case description - when nil - @desc ||= from_superclass(:desc, nil) - else - @desc = description - end - end - - # Start works differently in Thor::Group, it simply invokes all tasks - # inside the class. - # - def start(given_args=ARGV, config={}) - super do - if Thor::HELP_MAPPINGS.include?(given_args.first) - help(config[:shell]) - return - end - - args, opts = Thor::Options.split(given_args) - new(args, opts, config).invoke - end - end - - # Prints help information. - # - # ==== Options - # short:: When true, shows only usage. - # - def help(shell) - shell.say "Usage:" - shell.say " #{banner}\n" - shell.say - class_options_help(shell) - shell.say self.desc if self.desc - end - - # Stores invocations for this class merging with superclass values. - # - def invocations #:nodoc: - @invocations ||= from_superclass(:invocations, {}) - end - - # Stores invocation blocks used on invoke_from_option. - # - def invocation_blocks #:nodoc: - @invocation_blocks ||= from_superclass(:invocation_blocks, {}) - end - - # Invoke the given namespace or class given. It adds an instance - # method that will invoke the klass and task. You can give a block to - # configure how it will be invoked. - # - # The namespace/class given will have its options showed on the help - # usage. Check invoke_from_option for more information. - # - def invoke(*names, &block) - options = names.last.is_a?(Hash) ? names.pop : {} - verbose = options.fetch(:verbose, true) - - names.each do |name| - invocations[name] = false - invocation_blocks[name] = block if block_given? - - class_eval <<-METHOD, __FILE__, __LINE__ - def _invoke_#{name.to_s.gsub(/\W/, '_')} - klass, task = self.class.prepare_for_invocation(nil, #{name.inspect}) - - if klass - say_status :invoke, #{name.inspect}, #{verbose.inspect} - block = self.class.invocation_blocks[#{name.inspect}] - _invoke_for_class_method klass, task, &block - else - say_status :error, %(#{name.inspect} [not found]), :red - end - end - METHOD - end - end - - # Invoke a thor class based on the value supplied by the user to the - # given option named "name". A class option must be created before this - # method is invoked for each name given. - # - # ==== Examples - # - # class GemGenerator < Thor::Group - # class_option :test_framework, :type => :string - # invoke_from_option :test_framework - # end - # - # ==== Boolean options - # - # In some cases, you want to invoke a thor class if some option is true or - # false. This is automatically handled by invoke_from_option. Then the - # option name is used to invoke the generator. - # - # ==== Preparing for invocation - # - # In some cases you want to customize how a specified hook is going to be - # invoked. You can do that by overwriting the class method - # prepare_for_invocation. The class method must necessarily return a klass - # and an optional task. - # - # ==== Custom invocations - # - # You can also supply a block to customize how the option is giong to be - # invoked. The block receives two parameters, an instance of the current - # class and the klass to be invoked. - # - def invoke_from_option(*names, &block) - options = names.last.is_a?(Hash) ? names.pop : {} - verbose = options.fetch(:verbose, :white) - - names.each do |name| - unless class_options.key?(name) - raise ArgumentError, "You have to define the option #{name.inspect} " << - "before setting invoke_from_option." - end - - invocations[name] = true - invocation_blocks[name] = block if block_given? - - class_eval <<-METHOD, __FILE__, __LINE__ - def _invoke_from_option_#{name.to_s.gsub(/\W/, '_')} - return unless options[#{name.inspect}] - - value = options[#{name.inspect}] - value = #{name.inspect} if TrueClass === value - klass, task = self.class.prepare_for_invocation(#{name.inspect}, value) - - if klass - say_status :invoke, value, #{verbose.inspect} - block = self.class.invocation_blocks[#{name.inspect}] - _invoke_for_class_method klass, task, &block - else - say_status :error, %(\#{value} [not found]), :red - end - end - METHOD - end - end - - # Remove a previously added invocation. - # - # ==== Examples - # - # remove_invocation :test_framework - # - def remove_invocation(*names) - names.each do |name| - remove_task(name) - remove_class_option(name) - invocations.delete(name) - invocation_blocks.delete(name) - end - end - - # Overwrite class options help to allow invoked generators options to be - # shown recursively when invoking a generator. - # - def class_options_help(shell, groups={}) #:nodoc: - get_options_from_invocations(groups, class_options) do |klass| - klass.send(:get_options_from_invocations, groups, class_options) - end - super(shell, groups) - end - - # Get invocations array and merge options from invocations. Those - # options are added to group_options hash. Options that already exists - # in base_options are not added twice. - # - def get_options_from_invocations(group_options, base_options) #:nodoc: - invocations.each do |name, from_option| - value = if from_option - option = class_options[name] - option.type == :boolean ? name : option.default - else - name - end - next unless value - - klass, task = prepare_for_invocation(name, value) - next unless klass && klass.respond_to?(:class_options) - - value = value.to_s - human_name = value.respond_to?(:classify) ? value.classify : value - - group_options[human_name] ||= [] - group_options[human_name] += klass.class_options.values.select do |option| - base_options[option.name.to_sym].nil? && option.group.nil? && - !group_options.values.flatten.any? { |i| i.name == option.name } - end - - yield klass if block_given? - end - end - - # Returns tasks ready to be printed. - def printable_tasks(*) - item = [] - item << banner - item << (desc ? "# #{desc.gsub(/\s+/m,' ')}" : "") - [item] - end - - protected - - # The banner for this class. You can customize it if you are invoking the - # thor class by another ways which is not the Thor::Runner. - # - def banner - "thor #{self_task.formatted_usage(self, false)}" - end - - # Represents the whole class as a task. - def self_task #:nodoc: - Thor::Task::Dynamic.new(self.namespace, class_options) - end - - def baseclass #:nodoc: - Thor::Group - end - - def create_task(meth) #:nodoc: - tasks[meth.to_s] = Thor::Task.new(meth, nil, nil, nil) - true - end - end - - include Thor::Base - - protected - - # Shortcut to invoke with padding and block handling. Use internally by - # invoke and invoke_from_option class methods. - def _invoke_for_class_method(klass, task=nil, *args, &block) #:nodoc: - shell.padding += 1 - - result = if block_given? - case block.arity - when 3 - block.call(self, klass, task) - when 2 - block.call(self, klass) - when 1 - instance_exec(klass, &block) - end - else - invoke klass, task, *args - end - - shell.padding -= 1 - result - end -end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/invocation.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/invocation.rb deleted file mode 100644 index 32e6a72454..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/invocation.rb +++ /dev/null @@ -1,178 +0,0 @@ -class Thor - module Invocation - def self.included(base) #:nodoc: - base.extend ClassMethods - end - - module ClassMethods - # Prepare for class methods invocations. This method must return a klass to - # have the invoked class options showed in help messages in generators. - # - def prepare_for_invocation(key, name) #:nodoc: - case name - when Symbol, String - Thor::Util.namespace_to_thor_class_and_task(name.to_s, false) - else - name - end - end - end - - # Make initializer aware of invocations and the initializer proc. - # - def initialize(args=[], options={}, config={}, &block) #:nodoc: - @_invocations = config[:invocations] || Hash.new { |h,k| h[k] = [] } - @_initializer = [ args, options, config ] - super - end - - # Receives a name and invokes it. The name can be a string (either "task" or - # "namespace:task"), a Thor::Task, a Class or a Thor instance. If the task - # cannot be guessed by name, it can also be supplied as second argument. - # - # You can also supply the arguments, options and configuration values for - # the task to be invoked, if none is given, the same values used to - # initialize the invoker are used to initialize the invoked. - # - # ==== Examples - # - # class A < Thor - # def foo - # invoke :bar - # invoke "b:hello", ["José"] - # end - # - # def bar - # invoke "b:hello", ["José"] - # end - # end - # - # class B < Thor - # def hello(name) - # puts "hello #{name}" - # end - # end - # - # You can notice that the method "foo" above invokes two tasks: "bar", - # which belongs to the same class and "hello" which belongs to the class B. - # - # By using an invocation system you ensure that a task is invoked only once. - # In the example above, invoking "foo" will invoke "b:hello" just once, even - # if it's invoked later by "bar" method. - # - # When class A invokes class B, all arguments used on A initialization are - # supplied to B. This allows lazy parse of options. Let's suppose you have - # some rspec tasks: - # - # class Rspec < Thor::Group - # class_option :mock_framework, :type => :string, :default => :rr - # - # def invoke_mock_framework - # invoke "rspec:#{options[:mock_framework]}" - # end - # end - # - # As you noticed, it invokes the given mock framework, which might have its - # own options: - # - # class Rspec::RR < Thor::Group - # class_option :style, :type => :string, :default => :mock - # end - # - # Since it's not rspec concern to parse mock framework options, when RR - # is invoked all options are parsed again, so RR can extract only the options - # that it's going to use. - # - # If you want Rspec::RR to be initialized with its own set of options, you - # have to do that explicitely: - # - # invoke "rspec:rr", [], :style => :foo - # - # Besides giving an instance, you can also give a class to invoke: - # - # invoke Rspec::RR, [], :style => :foo - # - def invoke(name=nil, task=nil, args=nil, opts=nil, config=nil) - task, args, opts, config = nil, task, args, opts if task.nil? || task.is_a?(Array) - args, opts, config = nil, args, opts if args.is_a?(Hash) - - object, task = _prepare_for_invocation(name, task) - klass, instance = _initialize_klass_with_initializer(object, args, opts, config) - - method_args = [] - current = @_invocations[klass] - - iterator = proc do |_, task| - unless current.include?(task.name) - current << task.name - task.run(instance, method_args) - end - end - - if task - args ||= [] - method_args = args[Range.new(klass.arguments.size, -1)] || [] - iterator.call(nil, task) - else - klass.all_tasks.map(&iterator) - end - end - - protected - - # Configuration values that are shared between invocations. - # - def _shared_configuration #:nodoc: - { :invocations => @_invocations } - end - - # Prepare for invocation in the instance level. In this case, we have to - # take into account that a just a task name from the current class was - # given or even a Thor::Task object. - # - def _prepare_for_invocation(name, sent_task=nil) #:nodoc: - if name.is_a?(Thor::Task) - task = name - elsif task = self.class.all_tasks[name.to_s] - object = self - else - object, task = self.class.prepare_for_invocation(nil, name) - task ||= sent_task - end - - # If the object was not set, use self and use the name as task. - object, task = self, name unless object - return object, _validate_task(object, task) - end - - # Check if the object given is a Thor class object and get a task object - # for it. - # - def _validate_task(object, task) #:nodoc: - klass = object.is_a?(Class) ? object : object.class - raise "Expected Thor class, got #{klass}" unless klass <= Thor::Base - - task ||= klass.default_task if klass <= Thor - task = klass.all_tasks[task.to_s] || Thor::Task::Dynamic.new(task) if task && !task.is_a?(Thor::Task) - task - end - - # Initialize klass using values stored in the @_initializer. - # - def _initialize_klass_with_initializer(object, args, opts, config) #:nodoc: - if object.is_a?(Class) - klass = object - - stored_args, stored_opts, stored_config = @_initializer - args ||= stored_args.dup - opts ||= stored_opts.dup - - config ||= {} - config = stored_config.merge(_shared_configuration).merge!(config) - [ klass, klass.new(args, opts, config) ] - else - [ object.class, object ] - end - end - end -end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/parser.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/parser.rb deleted file mode 100644 index 57a3f6e1a5..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/parser.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'thor/parser/argument' -require 'thor/parser/arguments' -require 'thor/parser/option' -require 'thor/parser/options' diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/parser/argument.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/parser/argument.rb deleted file mode 100644 index aa8ace4719..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/parser/argument.rb +++ /dev/null @@ -1,67 +0,0 @@ -class Thor - class Argument #:nodoc: - VALID_TYPES = [ :numeric, :hash, :array, :string ] - - attr_reader :name, :description, :required, :type, :default, :banner - alias :human_name :name - - def initialize(name, description=nil, required=true, type=:string, default=nil, banner=nil) - class_name = self.class.name.split("::").last - - raise ArgumentError, "#{class_name} name can't be nil." if name.nil? - raise ArgumentError, "Type :#{type} is not valid for #{class_name.downcase}s." if type && !valid_type?(type) - - @name = name.to_s - @description = description - @required = required || false - @type = (type || :string).to_sym - @default = default - @banner = banner || default_banner - - validate! # Trigger specific validations - end - - def usage - required? ? banner : "[#{banner}]" - end - - def required? - required - end - - def show_default? - case default - when Array, String, Hash - !default.empty? - else - default - end - end - - protected - - def validate! - raise ArgumentError, "An argument cannot be required and have default value." if required? && !default.nil? - end - - def valid_type?(type) - VALID_TYPES.include?(type.to_sym) - end - - def default_banner - case type - when :boolean - nil - when :string, :default - human_name.upcase - when :numeric - "N" - when :hash - "key:value" - when :array - "one two three" - end - end - - end -end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/parser/arguments.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/parser/arguments.rb deleted file mode 100644 index fb5d965e06..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/parser/arguments.rb +++ /dev/null @@ -1,145 +0,0 @@ -class Thor - class Arguments #:nodoc: - NUMERIC = /(\d*\.\d+|\d+)/ - - # Receives an array of args and returns two arrays, one with arguments - # and one with switches. - # - def self.split(args) - arguments = [] - - args.each do |item| - break if item =~ /^-/ - arguments << item - end - - return arguments, args[Range.new(arguments.size, -1)] - end - - def self.parse(base, args) - new(base).parse(args) - end - - # Takes an array of Thor::Argument objects. - # - def initialize(arguments=[]) - @assigns, @non_assigned_required = {}, [] - @switches = arguments - - arguments.each do |argument| - if argument.default - @assigns[argument.human_name] = argument.default - elsif argument.required? - @non_assigned_required << argument - end - end - end - - def parse(args) - @pile = args.dup - - @switches.each do |argument| - break unless peek - @non_assigned_required.delete(argument) - @assigns[argument.human_name] = send(:"parse_#{argument.type}", argument.human_name) - end - - check_requirement! - @assigns - end - - private - - def peek - @pile.first - end - - def shift - @pile.shift - end - - def unshift(arg) - unless arg.kind_of?(Array) - @pile.unshift(arg) - else - @pile = arg + @pile - end - end - - def current_is_value? - peek && peek.to_s !~ /^-/ - end - - # Runs through the argument array getting strings that contains ":" and - # mark it as a hash: - # - # [ "name:string", "age:integer" ] - # - # Becomes: - # - # { "name" => "string", "age" => "integer" } - # - def parse_hash(name) - return shift if peek.is_a?(Hash) - hash = {} - - while current_is_value? && peek.include?(?:) - key, value = shift.split(':') - hash[key] = value - end - hash - end - - # Runs through the argument array getting all strings until no string is - # found or a switch is found. - # - # ["a", "b", "c"] - # - # And returns it as an array: - # - # ["a", "b", "c"] - # - def parse_array(name) - return shift if peek.is_a?(Array) - array = [] - - while current_is_value? - array << shift - end - array - end - - # Check if the peel is numeric ofrmat and return a Float or Integer. - # Otherwise raises an error. - # - def parse_numeric(name) - return shift if peek.is_a?(Numeric) - - unless peek =~ NUMERIC && $& == peek - raise MalformattedArgumentError, "expected numeric value for '#{name}'; got #{peek.inspect}" - end - - $&.index('.') ? shift.to_f : shift.to_i - end - - # Parse string, i.e., just return the current value in the pile. - # - def parse_string(name) - shift - end - - # Raises an error if @non_assigned_required array is not empty. - # - def check_requirement! - unless @non_assigned_required.empty? - names = @non_assigned_required.map do |o| - o.respond_to?(:switch_name) ? o.switch_name : o.human_name - end.join("', '") - - class_name = self.class.name.split('::').last.downcase - raise RequiredArgumentMissingError, "no value provided for required #{class_name} '#{names}'" - end - end - - end -end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/parser/option.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/parser/option.rb deleted file mode 100644 index 9e40ec73fa..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/parser/option.rb +++ /dev/null @@ -1,132 +0,0 @@ -class Thor - class Option < Argument #:nodoc: - attr_reader :aliases, :group - - VALID_TYPES = [:boolean, :numeric, :hash, :array, :string] - - def initialize(name, description=nil, required=nil, type=nil, default=nil, banner=nil, group=nil, aliases=nil) - super(name, description, required, type, default, banner) - @aliases = [*aliases].compact - @group = group.to_s.capitalize if group - end - - # This parse quick options given as method_options. It makes several - # assumptions, but you can be more specific using the option method. - # - # parse :foo => "bar" - # #=> Option foo with default value bar - # - # parse [:foo, :baz] => "bar" - # #=> Option foo with default value bar and alias :baz - # - # parse :foo => :required - # #=> Required option foo without default value - # - # parse :foo => 2 - # #=> Option foo with default value 2 and type numeric - # - # parse :foo => :numeric - # #=> Option foo without default value and type numeric - # - # parse :foo => true - # #=> Option foo with default value true and type boolean - # - # The valid types are :boolean, :numeric, :hash, :array and :string. If none - # is given a default type is assumed. This default type accepts arguments as - # string (--foo=value) or booleans (just --foo). - # - # By default all options are optional, unless :required is given. - # - def self.parse(key, value) - if key.is_a?(Array) - name, *aliases = key - else - name, aliases = key, [] - end - - name = name.to_s - default = value - - type = case value - when Symbol - default = nil - - if VALID_TYPES.include?(value) - value - elsif required = (value == :required) - :string - elsif value == :optional - # TODO Remove this warning in the future. - warn "Optional type is deprecated. Choose :boolean or :string instead. Assumed to be :boolean." - :boolean - end - when TrueClass, FalseClass - :boolean - when Numeric - :numeric - when Hash, Array, String - value.class.name.downcase.to_sym - end - - self.new(name.to_s, nil, required, type, default, nil, nil, aliases) - end - - def switch_name - @switch_name ||= dasherized? ? name : dasherize(name) - end - - def human_name - @human_name ||= dasherized? ? undasherize(name) : name - end - - def usage(padding=0) - sample = if banner && !banner.to_s.empty? - "#{switch_name}=#{banner}" - else - switch_name - end - - sample = "[#{sample}]" unless required? - - if aliases.empty? - (" " * padding) << sample - else - "#{aliases.join(', ')}, #{sample}" - end - end - - # Allow some type predicates as: boolean?, string? and etc. - # - def method_missing(method, *args, &block) - given = method.to_s.sub(/\?$/, '').to_sym - if valid_type?(given) - self.type == given - else - super - end - end - - protected - - def validate! - raise ArgumentError, "An option cannot be boolean and required." if boolean? && required? - end - - def valid_type?(type) - VALID_TYPES.include?(type.to_sym) - end - - def dasherized? - name.index('-') == 0 - end - - def undasherize(str) - str.sub(/^-{1,2}/, '') - end - - def dasherize(str) - (str.length > 1 ? "--" : "-") + str.gsub('_', '-') - end - - end -end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/parser/options.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/parser/options.rb deleted file mode 100644 index 75092308b5..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/parser/options.rb +++ /dev/null @@ -1,142 +0,0 @@ -class Thor - # This is a modified version of Daniel Berger's Getopt::Long class, licensed - # under Ruby's license. - # - class Options < Arguments #:nodoc: - LONG_RE = /^(--\w+[-\w+]*)$/ - SHORT_RE = /^(-[a-z])$/i - EQ_RE = /^(--\w+[-\w+]*|-[a-z])=(.*)$/i - SHORT_SQ_RE = /^-([a-z]{2,})$/i # Allow either -x -v or -xv style for single char args - SHORT_NUM = /^(-[a-z])#{NUMERIC}$/i - - # Receives a hash and makes it switches. - # - def self.to_switches(options) - options.map do |key, value| - case value - when true - "--#{key}" - when Array - "--#{key} #{value.map{ |v| v.inspect }.join(' ')}" - when Hash - "--#{key} #{value.map{ |k,v| "#{k}:#{v}" }.join(' ')}" - when nil, false - "" - else - "--#{key} #{value.inspect}" - end - end.join(" ") - end - - # Takes a hash of Thor::Option objects. - # - def initialize(options={}) - options = options.values - super(options) - @shorts, @switches = {}, {} - - options.each do |option| - @switches[option.switch_name] = option - - option.aliases.each do |short| - @shorts[short.to_s] ||= option.switch_name - end - end - end - - def parse(args) - @pile = args.dup - - while peek - if current_is_switch? - case shift - when SHORT_SQ_RE - unshift($1.split('').map { |f| "-#{f}" }) - next - when EQ_RE, SHORT_NUM - unshift($2) - switch = $1 - when LONG_RE, SHORT_RE - switch = $1 - end - - switch = normalize_switch(switch) - next unless option = switch_option(switch) - - @assigns[option.human_name] = parse_peek(switch, option) - else - shift - end - end - - check_requirement! - @assigns - end - - protected - - # Returns true if the current value in peek is a registered switch. - # - def current_is_switch? - case peek - when LONG_RE, SHORT_RE, EQ_RE, SHORT_NUM - switch?($1) - when SHORT_SQ_RE - $1.split('').any? { |f| switch?("-#{f}") } - end - end - - def switch?(arg) - switch_option(arg) || @shorts.key?(arg) - end - - def switch_option(arg) - if match = no_or_skip?(arg) - @switches[arg] || @switches["--#{match}"] - else - @switches[arg] - end - end - - def no_or_skip?(arg) - arg =~ /^--(no|skip)-([-\w]+)$/ - $2 - end - - # Check if the given argument is actually a shortcut. - # - def normalize_switch(arg) - @shorts.key?(arg) ? @shorts[arg] : arg - end - - # Parse boolean values which can be given as --foo=true, --foo or --no-foo. - # - def parse_boolean(switch) - if current_is_value? - ["true", "TRUE", "t", "T", true].include?(shift) - else - @switches.key?(switch) || !no_or_skip?(switch) - end - end - - # Parse the value at the peek analyzing if it requires an input or not. - # - def parse_peek(switch, option) - unless current_is_value? - if option.boolean? - # No problem for boolean types - elsif no_or_skip?(switch) - return nil # User set value to nil - elsif option.string? && !option.required? - return option.human_name # Return the option name - else - raise MalformattedArgumentError, "no value provided for option '#{switch}'" - end - end - - @non_assigned_required.delete(option) - send(:"parse_#{option.type}", switch) - end - - end -end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/rake_compat.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/rake_compat.rb deleted file mode 100644 index 0d0757fdda..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/rake_compat.rb +++ /dev/null @@ -1,66 +0,0 @@ -require 'rake' - -class Thor - # Adds a compatibility layer to your Thor classes which allows you to use - # rake package tasks. For example, to use rspec rake tasks, one can do: - # - # require 'thor/rake_compat' - # - # class Default < Thor - # include Thor::RakeCompat - # - # Spec::Rake::SpecTask.new(:spec) do |t| - # t.spec_opts = ['--options', "spec/spec.opts"] - # t.spec_files = FileList['spec/**/*_spec.rb'] - # end - # end - # - module RakeCompat - def self.rake_classes - @rake_classes ||= [] - end - - def self.included(base) - # Hack. Make rakefile point to invoker, so rdoc task is generated properly. - rakefile = File.basename(caller[0].match(/(.*):\d+/)[1]) - Rake.application.instance_variable_set(:@rakefile, rakefile) - self.rake_classes << base - end - end -end - -class Object #:nodoc: - alias :rake_task :task - alias :rake_namespace :namespace - - def task(*args, &block) - task = rake_task(*args, &block) - - if klass = Thor::RakeCompat.rake_classes.last - non_namespaced_name = task.name.split(':').last - - description = non_namespaced_name - description << task.arg_names.map{ |n| n.to_s.upcase }.join(' ') - description.strip! - - klass.desc description, task.comment || non_namespaced_name - klass.send :define_method, non_namespaced_name do |*args| - Rake::Task[task.name.to_sym].invoke(*args) - end - end - - task - end - - def namespace(name, &block) - if klass = Thor::RakeCompat.rake_classes.last - const_name = Thor::Util.camel_case(name.to_s).to_sym - klass.const_set(const_name, Class.new(Thor)) - new_klass = klass.const_get(const_name) - Thor::RakeCompat.rake_classes << new_klass - end - - rake_namespace(name, &block) - Thor::RakeCompat.rake_classes.pop - end -end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/runner.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/runner.rb deleted file mode 100644 index f197081e3f..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/runner.rb +++ /dev/null @@ -1,303 +0,0 @@ -require 'fileutils' -require 'open-uri' -require 'yaml' -require 'digest/md5' -require 'pathname' - -class Thor::Runner < Thor #:nodoc: - map "-T" => :list, "-i" => :install, "-u" => :update - - # Override Thor#help so it can give information about any class and any method. - # - def help(meth=nil) - if meth && !self.respond_to?(meth) - initialize_thorfiles(meth) - klass, task = Thor::Util.namespace_to_thor_class_and_task(meth) - # Send mapping -h because it works with Thor::Group too - klass.start(["-h", task].compact, :shell => self.shell) - else - super - end - end - - # If a task is not found on Thor::Runner, method missing is invoked and - # Thor::Runner is then responsable for finding the task in all classes. - # - def method_missing(meth, *args) - meth = meth.to_s - initialize_thorfiles(meth) - klass, task = Thor::Util.namespace_to_thor_class_and_task(meth) - args.unshift(task) if task - klass.start(args, :shell => shell) - end - - desc "install NAME", "Install an optionally named Thor file into your system tasks" - method_options :as => :string, :relative => :boolean - def install(name) - initialize_thorfiles - - # If a directory name is provided as the argument, look for a 'main.thor' - # task in said directory. - begin - if File.directory?(File.expand_path(name)) - base, package = File.join(name, "main.thor"), :directory - contents = open(base).read - else - base, package = name, :file - contents = open(name).read - end - rescue OpenURI::HTTPError - raise Error, "Error opening URI '#{name}'" - rescue Errno::ENOENT - raise Error, "Error opening file '#{name}'" - end - - say "Your Thorfile contains:" - say contents - - return false if no?("Do you wish to continue [y/N]?") - - as = options["as"] || begin - first_line = contents.split("\n")[0] - (match = first_line.match(/\s*#\s*module:\s*([^\n]*)/)) ? match[1].strip : nil - end - - unless as - basename = File.basename(name) - as = ask("Please specify a name for #{name} in the system repository [#{basename}]:") - as = basename if as.empty? - end - - location = if options[:relative] || name =~ /^http:\/\// - name - else - File.expand_path(name) - end - - thor_yaml[as] = { - :filename => Digest::MD5.hexdigest(name + as), - :location => location, - :namespaces => Thor::Util.namespaces_in_content(contents, base) - } - - save_yaml(thor_yaml) - say "Storing thor file in your system repository" - destination = File.join(thor_root, thor_yaml[as][:filename]) - - if package == :file - File.open(destination, "w") { |f| f.puts contents } - else - FileUtils.cp_r(name, destination) - end - - thor_yaml[as][:filename] # Indicate success - end - - desc "uninstall NAME", "Uninstall a named Thor module" - def uninstall(name) - raise Error, "Can't find module '#{name}'" unless thor_yaml[name] - say "Uninstalling #{name}." - FileUtils.rm_rf(File.join(thor_root, "#{thor_yaml[name][:filename]}")) - - thor_yaml.delete(name) - save_yaml(thor_yaml) - - puts "Done." - end - - desc "update NAME", "Update a Thor file from its original location" - def update(name) - raise Error, "Can't find module '#{name}'" if !thor_yaml[name] || !thor_yaml[name][:location] - - say "Updating '#{name}' from #{thor_yaml[name][:location]}" - - old_filename = thor_yaml[name][:filename] - self.options = self.options.merge("as" => name) - filename = install(thor_yaml[name][:location]) - - unless filename == old_filename - File.delete(File.join(thor_root, old_filename)) - end - end - - desc "installed", "List the installed Thor modules and tasks" - method_options :internal => :boolean - def installed - initialize_thorfiles(nil, true) - display_klasses(true, options["internal"]) - end - - desc "list [SEARCH]", "List the available thor tasks (--substring means .*SEARCH)" - method_options :substring => :boolean, :group => :string, :all => :boolean - def list(search="") - initialize_thorfiles - - search = ".*#{search}" if options["substring"] - search = /^#{search}.*/i - group = options[:group] || "standard" - - klasses = Thor::Base.subclasses.select do |k| - (options[:all] || k.group == group) && k.namespace =~ search - end - - display_klasses(false, false, klasses) - end - - private - - def self.banner(task) - "thor " + task.formatted_usage(self, false) - end - - def thor_root - Thor::Util.thor_root - end - - def thor_yaml - @thor_yaml ||= begin - yaml_file = File.join(thor_root, "thor.yml") - yaml = YAML.load_file(yaml_file) if File.exists?(yaml_file) - yaml || {} - end - end - - # Save the yaml file. If none exists in thor root, creates one. - # - def save_yaml(yaml) - yaml_file = File.join(thor_root, "thor.yml") - - unless File.exists?(yaml_file) - FileUtils.mkdir_p(thor_root) - yaml_file = File.join(thor_root, "thor.yml") - FileUtils.touch(yaml_file) - end - - File.open(yaml_file, "w") { |f| f.puts yaml.to_yaml } - end - - def self.exit_on_failure? - true - end - - # Load the thorfiles. If relevant_to is supplied, looks for specific files - # in the thor_root instead of loading them all. - # - # By default, it also traverses the current path until find Thor files, as - # described in thorfiles. This look up can be skipped by suppliying - # skip_lookup true. - # - def initialize_thorfiles(relevant_to=nil, skip_lookup=false) - thorfiles(relevant_to, skip_lookup).each do |f| - Thor::Util.load_thorfile(f) unless Thor::Base.subclass_files.keys.include?(File.expand_path(f)) - end - end - - # Finds Thorfiles by traversing from your current directory down to the root - # directory of your system. If at any time we find a Thor file, we stop. - # - # We also ensure that system-wide Thorfiles are loaded first, so local - # Thorfiles can override them. - # - # ==== Example - # - # If we start at /Users/wycats/dev/thor ... - # - # 1. /Users/wycats/dev/thor - # 2. /Users/wycats/dev - # 3. /Users/wycats <-- we find a Thorfile here, so we stop - # - # Suppose we start at c:\Documents and Settings\james\dev\thor ... - # - # 1. c:\Documents and Settings\james\dev\thor - # 2. c:\Documents and Settings\james\dev - # 3. c:\Documents and Settings\james - # 4. c:\Documents and Settings - # 5. c:\ <-- no Thorfiles found! - # - def thorfiles(relevant_to=nil, skip_lookup=false) - thorfiles = [] - - unless skip_lookup - Pathname.pwd.ascend do |path| - thorfiles = Thor::Util.globs_for(path).map { |g| Dir[g] }.flatten - break unless thorfiles.empty? - end - end - - files = (relevant_to ? thorfiles_relevant_to(relevant_to) : Thor::Util.thor_root_glob) - files += thorfiles - files -= ["#{thor_root}/thor.yml"] - - files.map! do |file| - File.directory?(file) ? File.join(file, "main.thor") : file - end - end - - # Load thorfiles relevant to the given method. If you provide "foo:bar" it - # will load all thor files in the thor.yaml that has "foo" e "foo:bar" - # namespaces registered. - # - def thorfiles_relevant_to(meth) - lookup = [ meth, meth.split(":")[0...-1].join(":") ] - - files = thor_yaml.select do |k, v| - v[:namespaces] && !(v[:namespaces] & lookup).empty? - end - - files.map { |k, v| File.join(thor_root, "#{v[:filename]}") } - end - - # Display information about the given klasses. If with_module is given, - # it shows a table with information extracted from the yaml file. - # - def display_klasses(with_modules=false, show_internal=false, klasses=Thor::Base.subclasses) - klasses -= [Thor, Thor::Runner, Thor::Group] unless show_internal - - raise Error, "No Thor tasks available" if klasses.empty? - show_modules if with_modules && !thor_yaml.empty? - - # Remove subclasses - klasses.dup.each do |klass| - klasses -= Thor::Util.thor_classes_in(klass) - end - - list = Hash.new { |h,k| h[k] = [] } - groups = klasses.select { |k| k.ancestors.include?(Thor::Group) } - - # Get classes which inherit from Thor - (klasses - groups).each { |k| list[k.namespace] += k.printable_tasks(false) } - - # Get classes which inherit from Thor::Base - groups.map! { |k| k.printable_tasks(false).first } - list["root"] = groups - - # Order namespaces with default coming first - list = list.sort{ |a,b| a[0].sub(/^default/, '') <=> b[0].sub(/^default/, '') } - list.each { |n, tasks| display_tasks(n, tasks) unless tasks.empty? } - end - - def display_tasks(namespace, list) #:nodoc: - list.sort!{ |a,b| a[0] <=> b[0] } - - say shell.set_color(namespace, :blue, true) - say "-" * namespace.size - - print_table(list, :truncate => true) - say - end - - def show_modules #:nodoc: - info = [] - labels = ["Modules", "Namespaces"] - - info << labels - info << [ "-" * labels[0].size, "-" * labels[1].size ] - - thor_yaml.each do |name, hash| - info << [ name, hash[:namespaces].join(", ") ] - end - - print_table info - say "" - end -end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/shell.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/shell.rb deleted file mode 100644 index 64a173de83..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/shell.rb +++ /dev/null @@ -1,78 +0,0 @@ -require 'rbconfig' -require 'thor/shell/color' - -class Thor - module Base - # Returns the shell used in all Thor classes. If you are in a Unix platform - # it will use a colored log, otherwise it will use a basic one without color. - # - def self.shell - @shell ||= if Config::CONFIG['host_os'] =~ /mswin|mingw/ - Thor::Shell::Basic - else - Thor::Shell::Color - end - end - - # Sets the shell used in all Thor classes. - # - def self.shell=(klass) - @shell = klass - end - end - - module Shell - SHELL_DELEGATED_METHODS = [:ask, :yes?, :no?, :say, :say_status, :print_table] - - # Add shell to initialize config values. - # - # ==== Configuration - # shell:: An instance of the shell to be used. - # - # ==== Examples - # - # class MyScript < Thor - # argument :first, :type => :numeric - # end - # - # MyScript.new [1.0], { :foo => :bar }, :shell => Thor::Shell::Basic.new - # - def initialize(args=[], options={}, config={}) - super - self.shell = config[:shell] - self.shell.base ||= self if self.shell.respond_to?(:base) - end - - # Holds the shell for the given Thor instance. If no shell is given, - # it gets a default shell from Thor::Base.shell. - # - def shell - @shell ||= Thor::Base.shell.new - end - - # Sets the shell for this thor class. - # - def shell=(shell) - @shell = shell - end - - # Common methods that are delegated to the shell. - # - SHELL_DELEGATED_METHODS.each do |method| - module_eval <<-METHOD, __FILE__, __LINE__ - def #{method}(*args) - shell.#{method}(*args) - end - METHOD - end - - protected - - # Allow shell to be shared between invocations. - # - def _shared_configuration #:nodoc: - super.merge!(:shell => self.shell) - end - - end -end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/shell/basic.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/shell/basic.rb deleted file mode 100644 index a11f45b4e9..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/shell/basic.rb +++ /dev/null @@ -1,239 +0,0 @@ -require 'tempfile' - -class Thor - module Shell - class Basic - attr_accessor :base, :padding - - # Initialize base and padding to nil. - # - def initialize #:nodoc: - @base, @padding = nil, 0 - end - - # Sets the output padding, not allowing less than zero values. - # - def padding=(value) - @padding = [0, value].max - end - - # Ask something to the user and receives a response. - # - # ==== Example - # ask("What is your name?") - # - def ask(statement, color=nil) - say("#{statement} ", color) - $stdin.gets.strip - end - - # Say (print) something to the user. If the sentence ends with a whitespace - # or tab character, a new line is not appended (print + flush). Otherwise - # are passed straight to puts (behavior got from Highline). - # - # ==== Example - # say("I know you knew that.") - # - def say(message="", color=nil, force_new_line=(message.to_s !~ /( |\t)$/)) - message = message.to_s - message = set_color(message, color) if color - - if force_new_line - $stdout.puts(message) - else - $stdout.print(message) - $stdout.flush - end - end - - # Say a status with the given color and appends the message. Since this - # method is used frequently by actions, it allows nil or false to be given - # in log_status, avoiding the message from being shown. If a Symbol is - # given in log_status, it's used as the color. - # - def say_status(status, message, log_status=true) - return if quiet? || log_status == false - spaces = " " * (padding + 1) - color = log_status.is_a?(Symbol) ? log_status : :green - - status = status.to_s.rjust(12) - status = set_color status, color, true if color - say "#{status}#{spaces}#{message}", nil, true - end - - # Make a question the to user and returns true if the user replies "y" or - # "yes". - # - def yes?(statement, color=nil) - ask(statement, color) =~ is?(:yes) - end - - # Make a question the to user and returns true if the user replies "n" or - # "no". - # - def no?(statement, color=nil) - !yes?(statement, color) - end - - # Prints a table. - # - # ==== Parameters - # Array[Array[String, String, ...]] - # - # ==== Options - # ident:: Ident the first column by ident value. - # - def print_table(table, options={}) - return if table.empty? - - formats, ident = [], options[:ident].to_i - options[:truncate] = terminal_width if options[:truncate] == true - - 0.upto(table.first.length - 2) do |i| - maxima = table.max{ |a,b| a[i].size <=> b[i].size }[i].size - formats << "%-#{maxima + 2}s" - end - - formats[0] = formats[0].insert(0, " " * ident) - formats << "%s" - - table.each do |row| - sentence = "" - - row.each_with_index do |column, i| - sentence << formats[i] % column.to_s - end - - sentence = truncate(sentence, options[:truncate]) if options[:truncate] - $stdout.puts sentence - end - end - - # Deals with file collision and returns true if the file should be - # overwriten and false otherwise. If a block is given, it uses the block - # response as the content for the diff. - # - # ==== Parameters - # destination:: the destination file to solve conflicts - # block:: an optional block that returns the value to be used in diff - # - def file_collision(destination) - return true if @always_force - options = block_given? ? "[Ynaqdh]" : "[Ynaqh]" - - while true - answer = ask %[Overwrite #{destination}? (enter "h" for help) #{options}] - - case answer - when is?(:yes), is?(:force), "" - return true - when is?(:no), is?(:skip) - return false - when is?(:always) - return @always_force = true - when is?(:quit) - say 'Aborting...' - raise SystemExit - when is?(:diff) - show_diff(destination, yield) if block_given? - say 'Retrying...' - else - say file_collision_help - end - end - end - - # Called if something goes wrong during the execution. This is used by Thor - # internally and should not be used inside your scripts. If someone went - # wrong, you can always raise an exception. If you raise a Thor::Error, it - # will be rescued and wrapped in the method below. - # - def error(statement) - $stderr.puts statement - end - - # Apply color to the given string with optional bold. Disabled in the - # Thor::Shell::Basic class. - # - def set_color(string, color, bold=false) #:nodoc: - string - end - - protected - - def is?(value) #:nodoc: - value = value.to_s - - if value.size == 1 - /\A#{value}\z/i - else - /\A(#{value}|#{value[0,1]})\z/i - end - end - - def file_collision_help #:nodoc: -</dev/null}.split[1].to_i - end - - def dynamic_width_tput - %x{tput cols 2>/dev/null}.to_i - end - - def unix? - RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i - end - - def truncate(string, width) - if string.length <= width - string - else - ( string[0, width-3] || "" ) + "..." - end - end - - end - end -end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/shell/color.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/shell/color.rb deleted file mode 100644 index b2bc66dfba..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/shell/color.rb +++ /dev/null @@ -1,108 +0,0 @@ -require 'thor/shell/basic' - -class Thor - module Shell - # Inherit from Thor::Shell::Basic and add set_color behavior. Check - # Thor::Shell::Basic to see all available methods. - # - class Color < Basic - # Embed in a String to clear all previous ANSI sequences. - CLEAR = "\e[0m" - # The start of an ANSI bold sequence. - BOLD = "\e[1m" - - # Set the terminal's foreground ANSI color to black. - BLACK = "\e[30m" - # Set the terminal's foreground ANSI color to red. - RED = "\e[31m" - # Set the terminal's foreground ANSI color to green. - GREEN = "\e[32m" - # Set the terminal's foreground ANSI color to yellow. - YELLOW = "\e[33m" - # Set the terminal's foreground ANSI color to blue. - BLUE = "\e[34m" - # Set the terminal's foreground ANSI color to magenta. - MAGENTA = "\e[35m" - # Set the terminal's foreground ANSI color to cyan. - CYAN = "\e[36m" - # Set the terminal's foreground ANSI color to white. - WHITE = "\e[37m" - - # Set the terminal's background ANSI color to black. - ON_BLACK = "\e[40m" - # Set the terminal's background ANSI color to red. - ON_RED = "\e[41m" - # Set the terminal's background ANSI color to green. - ON_GREEN = "\e[42m" - # Set the terminal's background ANSI color to yellow. - ON_YELLOW = "\e[43m" - # Set the terminal's background ANSI color to blue. - ON_BLUE = "\e[44m" - # Set the terminal's background ANSI color to magenta. - ON_MAGENTA = "\e[45m" - # Set the terminal's background ANSI color to cyan. - ON_CYAN = "\e[46m" - # Set the terminal's background ANSI color to white. - ON_WHITE = "\e[47m" - - # Set color by using a string or one of the defined constants. If a third - # option is set to true, it also adds bold to the string. This is based - # on Highline implementation and it automatically appends CLEAR to the end - # of the returned String. - # - def set_color(string, color, bold=false) - color = self.class.const_get(color.to_s.upcase) if color.is_a?(Symbol) - bold = bold ? BOLD : "" - "#{bold}#{color}#{string}#{CLEAR}" - end - - protected - - # Overwrite show_diff to show diff with colors if Diff::LCS is - # available. - # - def show_diff(destination, content) #:nodoc: - if diff_lcs_loaded? && ENV['THOR_DIFF'].nil? && ENV['RAILS_DIFF'].nil? - actual = File.binread(destination).to_s.split("\n") - content = content.to_s.split("\n") - - Diff::LCS.sdiff(actual, content).each do |diff| - output_diff_line(diff) - end - else - super - end - end - - def output_diff_line(diff) #:nodoc: - case diff.action - when '-' - say "- #{diff.old_element.chomp}", :red, true - when '+' - say "+ #{diff.new_element.chomp}", :green, true - when '!' - say "- #{diff.old_element.chomp}", :red, true - say "+ #{diff.new_element.chomp}", :green, true - else - say " #{diff.old_element.chomp}", nil, true - end - end - - # Check if Diff::LCS is loaded. If it is, use it to create pretty output - # for diff. - # - def diff_lcs_loaded? #:nodoc: - return true if defined?(Diff::LCS) - return @diff_lcs_loaded unless @diff_lcs_loaded.nil? - - @diff_lcs_loaded = begin - require 'diff/lcs' - true - rescue LoadError - false - end - end - - end - end -end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/task.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/task.rb deleted file mode 100644 index 5c8877591b..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/task.rb +++ /dev/null @@ -1,111 +0,0 @@ -class Thor - class Task < Struct.new(:name, :description, :usage, :options) - FILE_REGEXP = /^#{Regexp.escape(File.expand_path(__FILE__))}:[\w:]+ `run'$/ - - # A dynamic task that handles method missing scenarios. - class Dynamic < Task - def initialize(name, options=nil) - super(name.to_s, "A dynamically-generated task", name.to_s, options) - end - - def run(instance, args=[]) - unless (instance.methods & [name.to_s, name.to_sym]).empty? - raise Error, "could not find Thor class or task '#{name}'" - end - super - end - end - - def initialize(name, description, usage, options=nil) - super(name.to_s, description, usage, options || {}) - end - - def initialize_copy(other) #:nodoc: - super(other) - self.options = other.options.dup if other.options - end - - # By default, a task invokes a method in the thor class. You can change this - # implementation to create custom tasks. - def run(instance, args=[]) - raise UndefinedTaskError, "the '#{name}' task of #{instance.class} is private" unless public_method?(instance) - instance.send(name, *args) - rescue ArgumentError => e - raise e if instance.class.respond_to?(:debugging) && instance.class.debugging - parse_argument_error(instance, e, caller) - rescue NoMethodError => e - raise e if instance.class.respond_to?(:debugging) && instance.class.debugging - parse_no_method_error(instance, e) - end - - # Returns the formatted usage by injecting given required arguments - # and required options into the given usage. - def formatted_usage(klass, namespace=nil) - namespace = klass.namespace if namespace.nil? - - # Add namespace - formatted = if namespace - "#{namespace.gsub(/^(default|thor:runner:)/,'')}:" - else - "" - end - - # Add usage with required arguments - formatted << if klass && !klass.arguments.empty? - usage.to_s.gsub(/^#{name}/) do |match| - match << " " << klass.arguments.map{ |a| a.usage }.compact.join(' ') - end - else - usage.to_s - end - - # Add required options - formatted << " #{required_options}" - - # Strip and go! - formatted.strip - end - - protected - - def required_options - @required_options ||= options.map{ |_, o| o.usage if o.required? }.compact.sort.join(" ") - end - - # Given a target, checks if this class name is not a private/protected method. - def public_method?(instance) #:nodoc: - collection = instance.private_methods + instance.protected_methods - (collection & [name.to_s, name.to_sym]).empty? - end - - # For Ruby <= 1.8.7, we have to match the method name that we are trying to call. - # In Ruby >= 1.9.1, we have to match the method run in this file. - def backtrace_match?(backtrace) #:nodoc: - method_name = /`#{Regexp.escape(name.split(':').last)}'/ - backtrace =~ method_name || backtrace =~ FILE_REGEXP - end - - def parse_argument_error(instance, e, caller) #:nodoc: - if e.message =~ /wrong number of arguments/ && backtrace_match?(e.backtrace.first.to_s) - if instance.is_a?(Thor::Group) - raise e, "'#{name}' was called incorrectly. Are you sure it has arity equals to 0?" - else - raise InvocationError, "'#{name}' was called incorrectly. Call as " << - "'#{formatted_usage(instance.class)}'" - end - else - raise e - end - end - - def parse_no_method_error(instance, e) #:nodoc: - if e.message =~ /^undefined method `#{name}' for #{Regexp.escape(instance.to_s)}$/ - raise UndefinedTaskError, "The #{instance.class.namespace} namespace " << - "doesn't have a '#{name}' task" - else - raise e - end - end - - end -end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/util.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/util.rb deleted file mode 100644 index c2aed89ccf..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/util.rb +++ /dev/null @@ -1,233 +0,0 @@ -require 'rbconfig' - -class Thor - module Sandbox #:nodoc: - end - - # This module holds several utilities: - # - # 1) Methods to convert thor namespaces to constants and vice-versa. - # - # Thor::Utils.namespace_from_thor_class(Foo::Bar::Baz) #=> "foo:bar:baz" - # - # 2) Loading thor files and sandboxing: - # - # Thor::Utils.load_thorfile("~/.thor/foo") - # - module Util - - # Receives a namespace and search for it in the Thor::Base subclasses. - # - # ==== Parameters - # namespace:: The namespace to search for. - # - def self.find_by_namespace(namespace) - namespace = "default#{namespace}" if namespace.empty? || namespace =~ /^:/ - - Thor::Base.subclasses.find do |klass| - klass.namespace == namespace - end - end - - # Receives a constant and converts it to a Thor namespace. Since Thor tasks - # can be added to a sandbox, this method is also responsable for removing - # the sandbox namespace. - # - # This method should not be used in general because it's used to deal with - # older versions of Thor. On current versions, if you need to get the - # namespace from a class, just call namespace on it. - # - # ==== Parameters - # constant:: The constant to be converted to the thor path. - # - # ==== Returns - # String:: If we receive Foo::Bar::Baz it returns "foo:bar:baz" - # - def self.namespace_from_thor_class(constant, remove_default=true) - constant = constant.to_s.gsub(/^Thor::Sandbox::/, "") - constant = snake_case(constant).squeeze(":") - constant.gsub!(/^default/, '') if remove_default - constant - end - - # Given the contents, evaluate it inside the sandbox and returns the - # namespaces defined in the sandbox. - # - # ==== Parameters - # contents - # - # ==== Returns - # Array[Object] - # - def self.namespaces_in_content(contents, file=__FILE__) - old_constants = Thor::Base.subclasses.dup - Thor::Base.subclasses.clear - - load_thorfile(file, contents) - - new_constants = Thor::Base.subclasses.dup - Thor::Base.subclasses.replace(old_constants) - - new_constants.map!{ |c| c.namespace } - new_constants.compact! - new_constants - end - - # Returns the thor classes declared inside the given class. - # - def self.thor_classes_in(klass) - stringfied_constants = klass.constants.map { |c| c.to_s } - Thor::Base.subclasses.select do |subclass| - next unless subclass.name - stringfied_constants.include?(subclass.name.gsub("#{klass.name}::", '')) - end - end - - # Receives a string and convert it to snake case. SnakeCase returns snake_case. - # - # ==== Parameters - # String - # - # ==== Returns - # String - # - def self.snake_case(str) - return str.downcase if str =~ /^[A-Z_]+$/ - str.gsub(/\B[A-Z]/, '_\&').squeeze('_') =~ /_*(.*)/ - return $+.downcase - end - - # Receives a string and convert it to camel case. camel_case returns CamelCase. - # - # ==== Parameters - # String - # - # ==== Returns - # String - # - def self.camel_case(str) - return str if str !~ /_/ && str =~ /[A-Z]+.*/ - str.split('_').map { |i| i.capitalize }.join - end - - # Receives a namespace and tries to retrieve a Thor or Thor::Group class - # from it. It first searches for a class using the all the given namespace, - # if it's not found, removes the highest entry and searches for the class - # again. If found, returns the highest entry as the class name. - # - # ==== Examples - # - # class Foo::Bar < Thor - # def baz - # end - # end - # - # class Baz::Foo < Thor::Group - # end - # - # Thor::Util.namespace_to_thor_class("foo:bar") #=> Foo::Bar, nil # will invoke default task - # Thor::Util.namespace_to_thor_class("baz:foo") #=> Baz::Foo, nil - # Thor::Util.namespace_to_thor_class("foo:bar:baz") #=> Foo::Bar, "baz" - # - # ==== Parameters - # namespace - # - # ==== Errors - # Thor::Error:: raised if the namespace cannot be found. - # - # Thor::Error:: raised if the namespace evals to a class which does not - # inherit from Thor or Thor::Group. - # - def self.namespace_to_thor_class_and_task(namespace, raise_if_nil=true) - if namespace.include?(?:) - pieces = namespace.split(":") - task = pieces.pop - klass = Thor::Util.find_by_namespace(pieces.join(":")) - end - - unless klass - klass, task = Thor::Util.find_by_namespace(namespace), nil - end - - raise Error, "could not find Thor class or task '#{namespace}'" if raise_if_nil && klass.nil? - return klass, task - end - - # Receives a path and load the thor file in the path. The file is evaluated - # inside the sandbox to avoid namespacing conflicts. - # - def self.load_thorfile(path, content=nil) - content ||= File.binread(path) - - begin - Thor::Sandbox.class_eval(content, path) - rescue Exception => e - $stderr.puts "WARNING: unable to load thorfile #{path.inspect}: #{e.message}" - end - end - - def self.user_home - @@user_home ||= if ENV["HOME"] - ENV["HOME"] - elsif ENV["USERPROFILE"] - ENV["USERPROFILE"] - elsif ENV["HOMEDRIVE"] && ENV["HOMEPATH"] - File.join(ENV["HOMEDRIVE"], ENV["HOMEPATH"]) - elsif ENV["APPDATA"] - ENV["APPDATA"] - else - begin - File.expand_path("~") - rescue - if File::ALT_SEPARATOR - "C:/" - else - "/" - end - end - end - end - - # Returns the root where thor files are located, dependending on the OS. - # - def self.thor_root - File.join(user_home, ".thor").gsub(/\\/, '/') - end - - # Returns the files in the thor root. On Windows thor_root will be something - # like this: - # - # C:\Documents and Settings\james\.thor - # - # If we don't #gsub the \ character, Dir.glob will fail. - # - def self.thor_root_glob - files = Dir["#{thor_root}/*"] - - files.map! do |file| - File.directory?(file) ? File.join(file, "main.thor") : file - end - end - - # Where to look for Thor files. - # - def self.globs_for(path) - ["#{path}/Thorfile", "#{path}/*.thor", "#{path}/tasks/*.thor", "#{path}/lib/tasks/*.thor"] - end - - # Return the path to the ruby interpreter taking into account multiple - # installations and windows extensions. - # - def self.ruby_command - @ruby_command ||= begin - ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']) - ruby << Config::CONFIG['EXEEXT'] - - # escape string in case path to ruby executable contain spaces. - ruby.sub!(/.*\s.*/m, '"\&"') - ruby - end - end - - end -end diff --git a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/version.rb b/railties/lib/rails/vendor/thor-0.12.3/lib/thor/version.rb deleted file mode 100644 index 3c9dd6f808..0000000000 --- a/railties/lib/rails/vendor/thor-0.12.3/lib/thor/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Thor - VERSION = "0.12.3".freeze -end diff --git a/railties/railties.gemspec b/railties/railties.gemspec index a060c3c301..1e6b141a09 100644 --- a/railties/railties.gemspec +++ b/railties/railties.gemspec @@ -9,8 +9,9 @@ Gem::Specification.new do |s| EOF s.add_dependency('rake', '>= 0.8.3') - s.add_dependency('activesupport', '= 3.0.pre') - s.add_dependency('actionpack', '= 3.0.pre') + s.add_dependency('thor', '~> 0.13') + s.add_dependency('activesupport', '= 3.0.pre') + s.add_dependency('actionpack', '= 3.0.pre') s.rdoc_options << '--exclude' << '.' s.has_rdoc = false -- cgit v1.2.3 From 391f2543c96a9b3de4e44f4ea6aeee2f53ad9e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 3 Feb 2010 18:07:22 +0100 Subject: Properly show middlewares on rake about. --- railties/builtin/rails_info/rails/info.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/railties/builtin/rails_info/rails/info.rb b/railties/builtin/rails_info/rails/info.rb index 90c9015fcf..5a496f6536 100644 --- a/railties/builtin/rails_info/rails/info.rb +++ b/railties/builtin/rails_info/rails/info.rb @@ -51,9 +51,12 @@ module Rails def to_s column_width = properties.names.map {|name| name.length}.max - ["About your application's environment", *properties.map do |property| - "%-#{column_width}s %s" % property - end] * "\n" + info = properties.map do |name, value| + value = value.join(", ") if value.is_a?(Array) + "%-#{column_width}s %s" % [name, value] + end + info.unshift "About your application's environment" + info * "\n" end alias inspect to_s -- cgit v1.2.3 From efa850558facf2fbaaf226f1444802da83924b82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 3 Feb 2010 18:49:47 +0100 Subject: Make bin/rails call rails/commands/application, fix generators usage and update .gitignores. --- .gitignore | 5 +- railties/bin/rails | 27 ++------ .../lib/generators/rails/app/templates/gitignore | 1 + .../generators/rails/app/templates/script/rails | 2 +- railties/lib/rails/commands.rb | 79 ++++++++++++++++++---- railties/lib/rails/commands/rails.rb | 67 ------------------ railties/lib/rails/generators.rb | 4 +- railties/lib/rails/generators/base.rb | 2 +- 8 files changed, 76 insertions(+), 111 deletions(-) delete mode 100644 railties/lib/rails/commands/rails.rb diff --git a/.gitignore b/.gitignore index 4082dd9a51..715d0bc4bc 100644 --- a/.gitignore +++ b/.gitignore @@ -14,9 +14,8 @@ railties/test/fixtures/tmp railties/test/initializer/root/log railties/doc/guides/html/images railties/doc/guides/html/stylesheets -benches railties/guides/output -bin -vendor/gems/ railties/tmp +bin +.bundle pkg diff --git a/railties/bin/rails b/railties/bin/rails index 44842e2234..72c47b533f 100755 --- a/railties/bin/rails +++ b/railties/bin/rails @@ -1,30 +1,11 @@ if File.exists?(Dir.getwd + '/script/rails') exec(Dir.getwd + '/script/rails', *ARGV) else - begin - require 'rails/ruby_version_check' - rescue LoadError - # If people are not using gems, the load path must still - # be correct. - # TODO: Remove the begin / rescue block somehow - $:.unshift File.expand_path('../../lib', __FILE__) - $:.unshift File.expand_path('../../../activesupport/lib', __FILE__) - $:.unshift File.expand_path('../../../actionpack/lib', __FILE__) - require 'rails/ruby_version_check' - end + railties_path = File.expand_path('../../lib', __FILE__) + $:.unshift(railties_path) if File.directory?(railties_path) && !$:.include?(railties_path) + require 'rails/ruby_version_check' Signal.trap("INT") { puts; exit } - require 'rails/version' - if %w(--version -v).include? ARGV.first - puts "Rails #{Rails::VERSION::STRING}" - exit(0) - end - - ARGV << "--help" if ARGV.empty? - - require 'rails/generators' - require 'generators/rails/app/app_generator' - - Rails::Generators::AppGenerator.start + require 'rails/commands/application' end \ No newline at end of file diff --git a/railties/lib/generators/rails/app/templates/gitignore b/railties/lib/generators/rails/app/templates/gitignore index a4f05d101d..af64fae5e7 100644 --- a/railties/lib/generators/rails/app/templates/gitignore +++ b/railties/lib/generators/rails/app/templates/gitignore @@ -1,3 +1,4 @@ +.bundle db/*.sqlite3 log/*.log tmp/**/* diff --git a/railties/lib/generators/rails/app/templates/script/rails b/railties/lib/generators/rails/app/templates/script/rails index c23d24b30b..2fcf6d09b5 100644 --- a/railties/lib/generators/rails/app/templates/script/rails +++ b/railties/lib/generators/rails/app/templates/script/rails @@ -6,4 +6,4 @@ APP_PATH = File.expand_path('../../config/application', __FILE__) ROOT_PATH = File.expand_path('../..', __FILE__) require BOOT_PATH -require 'rails/commands/rails' +require 'rails/commands' diff --git a/railties/lib/rails/commands.rb b/railties/lib/rails/commands.rb index 841e98a0dc..f0dcf61d98 100644 --- a/railties/lib/rails/commands.rb +++ b/railties/lib/rails/commands.rb @@ -1,17 +1,70 @@ -commands = Dir["#{File.dirname(__FILE__)}/commands/*.rb"].collect { |file_path| File.basename(file_path).split(".").first } +if ARGV.empty? + ARGV << '--help' +end -if commands.include?(ARGV.first) - require "#{File.dirname(__FILE__)}/commands/#{ARGV.shift}" -else - puts <<-USAGE -The 'run' provides a unified access point for all the default Rails' commands. - -Usage: ./script/run [OPTIONS] +HELP_TEXT = <<-EOT +Usage: rails COMMAND [ARGS] + +The most common rails commands are: + generate Generate new code (short-cut alias: "g") + console Start the Rails console (short-cut alias: "c") + server Start the Rails server (short-cut alias: "s") + dbconsole Start a console for the database specified in config/database.yml + (short-cut alias: "db") + +In addition to those, there are: + application Generate the Rails application code + destroy Undo code generated with "generate" + benchmarker See how fast a piece of code runs + profiler Get profile information from a piece of code + plugin Install a plugin + runner Run a piece of code in the application environment + +All commands can be run with -h for more information. +EOT -Examples: - ./script/run generate controller Admin - ./script/run process reaper -USAGE - puts "Choose: #{commands.join(", ")}" +case ARGV.shift +when 'g', 'generate' + require ENV_PATH + require 'rails/commands/generate' +when 'c', 'console' + require 'rails/commands/console' + require APP_PATH + Rails::Console.start(Rails::Application) +when 's', 'server' + require 'rails/commands/server' + Dir.chdir(ROOT_PATH) + Rails::Server.start +when 'db', 'dbconsole' + require 'rails/commands/dbconsole' + require APP_PATH + Rails::DBConsole.start(Rails::Application) + +when 'application' + require 'rails/commands/application' +when 'destroy' + require ENV_PATH + require 'rails/commands/destroy' +when 'benchmarker' + require ENV_PATH + require 'rails/commands/performance/benchmarker' +when 'profiler' + require ENV_PATH + require 'rails/commands/performance/profiler' +when 'plugin' + require APP_PATH + require 'rails/commands/plugin' +when 'runner' + require 'rails/commands/runner' + require ENV_PATH + +when '--help', '-h' + puts HELP_TEXT +when '--version', '-v' + ARGV.unshift '--version' + require 'rails/commands/application' +else + puts "Error: Command not recognized" + puts HELP_TEXT end \ No newline at end of file diff --git a/railties/lib/rails/commands/rails.rb b/railties/lib/rails/commands/rails.rb deleted file mode 100644 index 9597e2e7e6..0000000000 --- a/railties/lib/rails/commands/rails.rb +++ /dev/null @@ -1,67 +0,0 @@ -if ARGV.empty? - ARGV << '--help' -end - -HELP_TEXT = <<-EOT -usage: rails COMMAND [ARGS] - -The most common rails commands are: - generate Generate new code (short-cut alias: "g") - console Start the Rails console (short-cut alias: "c") - server Start the Rails server (short-cut alias: "s") - dbconsole Start a console for the database specified in config/database.yml - (short-cut alias: "db") - -In addition to those, there are: - application Generate the Rails application code - destroy Undo code generated with "generate" - benchmarker See how fast a piece of code runs - profiler Get profile information from a piece of code - plugin Install a plugin - runner Run a piece of code in the application environment - -All commands can be run with -h for more information. -EOT - - -case ARGV.shift -when 'g', 'generate' - require ENV_PATH - require 'rails/commands/generate' -when 'c', 'console' - require 'rails/commands/console' - require APP_PATH - Rails::Console.start(Rails::Application) -when 's', 'server' - require 'rails/commands/server' - Dir.chdir(ROOT_PATH) - Rails::Server.start -when 'db', 'dbconsole' - require 'rails/commands/dbconsole' - require APP_PATH - Rails::DBConsole.start(Rails::Application) - -when 'application' - require 'rails/commands/application' -when 'destroy' - require ENV_PATH - require 'rails/commands/destroy' -when 'benchmarker' - require ENV_PATH - require 'rails/commands/performance/benchmarker' -when 'profiler' - require ENV_PATH - require 'rails/commands/performance/profiler' -when 'plugin' - require APP_PATH - require 'rails/commands/plugin' -when 'runner' - require 'rails/commands/runner' - require ENV_PATH - -when '--help', '-h' - puts HELP_TEXT -else - puts "Error: Command not recognized" - puts HELP_TEXT -end \ No newline at end of file diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index 1f380970d0..5d95f2fa52 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -9,8 +9,6 @@ require 'active_support/core_ext/hash/deep_merge' require 'active_support/core_ext/module/attribute_accessors' require 'active_support/core_ext/string/inflections' -# TODO: Do not always push on vendored thor -$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/vendor/thor-0.12.3/lib") require 'rails/generators/base' require 'rails/generators/named_base' @@ -175,7 +173,7 @@ module Rails groups[base] << namespace end - puts "Usage: generate GENERATOR [args] [options]" + puts "Usage: rails generate GENERATOR [args] [options]" puts puts "General options:" puts " -h, [--help] # Print generators options and usage" diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb index ec0659032f..dfa0d573c9 100644 --- a/railties/lib/rails/generators/base.rb +++ b/railties/lib/rails/generators/base.rb @@ -261,7 +261,7 @@ module Rails # Use Rails default banner. # def self.banner - "#{$0} #{generator_name} #{self.arguments.map{ |a| a.usage }.join(' ')} [options]" + "rails generate #{generator_name} #{self.arguments.map{ |a| a.usage }.join(' ')} [options]" end # Sets the base_name taking into account the current class namespace. -- cgit v1.2.3 From 77015872be219be8e8121d69ea173cab3a9ce9a0 Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Wed, 3 Feb 2010 16:28:18 -0800 Subject: Removing submodule hacks --- .gitmodules | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index fd4fd34d3e..0000000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "arel"] - path = arel - url = git://github.com/rails/arel.git -- cgit v1.2.3 From f497e7ad1d52fb795784cf6f5b2bc456e46dbd27 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Wed, 3 Feb 2010 16:56:32 -0800 Subject: Update rails to use the latest bundler --- rails.gemspec | 2 +- railties/lib/generators/rails/app/templates/config/boot.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rails.gemspec b/rails.gemspec index b44dc27cb0..acdb1d00fc 100644 --- a/rails.gemspec +++ b/rails.gemspec @@ -14,7 +14,7 @@ Gem::Specification.new do |s| s.add_dependency('activeresource', '= 3.0.pre') s.add_dependency('actionmailer', '= 3.0.pre') s.add_dependency('railties', '= 3.0.pre') - s.add_dependency('bundler', '>= 0.9.0.pre') + s.add_dependency('bundler', '>= 0.9.0.pre5') s.rdoc_options << '--exclude' << '.' s.has_rdoc = false diff --git a/railties/lib/generators/rails/app/templates/config/boot.rb b/railties/lib/generators/rails/app/templates/config/boot.rb index 70bd40bc4c..7407d6143a 100644 --- a/railties/lib/generators/rails/app/templates/config/boot.rb +++ b/railties/lib/generators/rails/app/templates/config/boot.rb @@ -1,6 +1,6 @@ # Use Bundler (preferred) begin - require File.expand_path('../../vendor/environment', __FILE__) + require File.expand_path('../../.bundle/environment', __FILE__) rescue LoadError require 'rubygems' require 'bundler' -- cgit v1.2.3 From 02ef8d20a19f9548800eaefc0ebdf18fbd9a67be Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Thu, 4 Feb 2010 10:59:24 +1100 Subject: Adding guard to make sure test database declarations exist before trying to auto create --- activerecord/lib/active_record/railties/databases.rake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index 4343bef3d4..ed7d2a045e 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -28,8 +28,8 @@ namespace :db do desc 'Create the database defined in config/database.yml for the current Rails.env - also makes test database if in development mode' task :create => :load_config do - # Make the test database at the same time as the development one - if Rails.env == 'development' + # Make the test database at the same time as the development one, if it exists + if Rails.env.development? && ActiveRecord::Base.configurations['test'] create_database(ActiveRecord::Base.configurations['test']) end create_database(ActiveRecord::Base.configurations[Rails.env]) -- cgit v1.2.3 From 1ae543a180095efef5ad59eb9883748ca20cebcf Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Thu, 4 Feb 2010 11:08:46 +1100 Subject: -v and --version params now work on rails script in or our of an app --- railties/lib/rails/commands.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/railties/lib/rails/commands.rb b/railties/lib/rails/commands.rb index f0dcf61d98..4240038673 100644 --- a/railties/lib/rails/commands.rb +++ b/railties/lib/rails/commands.rb @@ -59,6 +59,9 @@ when 'runner' require 'rails/commands/runner' require ENV_PATH + +when '--version', '-v' + puts "Rails #{Rails::VERSION::STRING}" when '--help', '-h' puts HELP_TEXT when '--version', '-v' -- cgit v1.2.3 From 639e044298eed903566086d297ae51a535082e73 Mon Sep 17 00:00:00 2001 From: SubbaRao Pasupuleti Date: Sun, 31 Jan 2010 23:52:05 -0500 Subject: removing , from ,= statement in WrappedDatabaseException constructor [#3830 state:committed] Signed-off-by: Jeremy Kemper --- activerecord/lib/active_record/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 12feef4849..c4e07e8786 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -79,7 +79,7 @@ module ActiveRecord #:nodoc: def initialize(message, original_exception) super(message) - @original_exception, = original_exception + @original_exception = original_exception end end -- cgit v1.2.3 From 36e6daac67b8ece9d05e425e331db8555046bb75 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 3 Feb 2010 17:22:08 -0800 Subject: Copy over latest release notes from docrails --- railties/guides/source/3_0_release_notes.textile | 148 +++++++++++++++++------ 1 file changed, 110 insertions(+), 38 deletions(-) diff --git a/railties/guides/source/3_0_release_notes.textile b/railties/guides/source/3_0_release_notes.textile index afc88af643..5e96f8cf06 100644 --- a/railties/guides/source/3_0_release_notes.textile +++ b/railties/guides/source/3_0_release_notes.textile @@ -1,34 +1,53 @@ -h2. Ruby on Rails 3.0 Release Notes +h2. Rails 3.0: Release Notes -Rails 3.0 is a landmark release as it delivers on the Merb/Rails merge promise made in December 2008. Rails 3.0 provides major upgrades to all of the components of Rails, including a complete overhaul of the router and query APIs. +Rails 3.0 is ponies and rainbows! It's going to cook you dinner and fold your laundry. You're going to wonder how life was ever possible before you it arrived. It's the Best Version of Rails We've Ever Done! -One of the main achievements of this release, is that while there are loads of new features, old APIs have been deprecated with warnings wherever possible, so that you can implement the new features and conventions at your own pace. There is a backwards compatibility layer that will be supported during 3.0.x and removed in 3.1. +But seriously now, it's really good stuff. There are all the good ideas brought over from when the Merb team joined the party and brought a focus on framework agnosticism, slimmer and faster internals, and a handful of tasty APIs. If you're coming to Rails 3.0 from Merb 1.x, you should recognize lots. If you're coming from Rails 2.x, you're going to love it too. -Rails 3.0 adds Active Model ORM abstraction, Abstract Controller generic controller abstraction as well as a consistent Plugin API giving developers full access to all the Rails internals that make Action Mailer, Action Controller, Action View, Active Record and Active Resource work. +Even if you don't give a hoot about any of our internal cleanups, Rails 3.0 is going to delight. We have a bunch of new features and improved APIs. It's never been a better time to be a Rails developer. Some of the highlights are: -These release notes cover the major upgrades, but don't include every little bug fix and change. If you want to see everything, check out the "list of commits":http://github.com/rails/rails/commits/master in the main Rails repository on GitHub. +* Brand new router with an emphasis on RESTful declarations +* New Action Mailer API modelled after Action Controller (now without the agonizing pain of sending multipart messages!) +* New Active Record chainable query language built on top of relational algebra +* Unobtrusive JavaScript helpers with drivers for Prototype, jQuery, and more coming (end of inline JS) +* Explicit dependency management with Bundler + +On top of all that, we've tried our best to deprecate the old APIs with nice warnings. That means that you can move your existing application to Rails 3 without immediately rewriting all your old code to the latest best practices. + +These release notes cover the major upgrades, but don't include every little bug fix and change. Rails 3.0 consists of almost 4,000 commits by more than 250 authors! If you want to see everything, check out the "list of commits":http://github.com/rails/rails/commits/master in the main Rails repository on GitHub. endprologue. -h3. Upgrading from Rails 2.3.5 to Rails 3.0 +WARNING: Rails 3.0 is currently in beta. This means that there are probably bugs and that you should "report them":http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/overview if you see them. You also may not want to run the NORAD nuclear launch application off a beta version. But if you're starting development on a new application and you don't mind getting wind in your hair, please do jump on board! -As always, having a high coverage, passing test suite is your friend when upgrading. You should also first upgrade to Rails 2.3.5 and make sure your application still runs as expected before attempting to update to Rails 3.0. In general, the upgrade from Rails 2.x to 3.0 centers around three big changes: +h3. Upgrading to Rails 3 -h4. New Ruby Version Requirement +If you're upgrading an existing application, it's a great idea to have good test coverage before going in. You should also first upgrade to Rails 2.3.5 and make sure your application still runs as expected before attempting to update to Rails 3. Then take heed of the following changes: -WARNING: Rails only runs on version 1.8.7 of Ruby or later. Support for previous versions of Ruby has been dropped and Rails 3.0 will no longer boot on any of these versions. +h4. Rails 3 requires Ruby 1.8.7+ -h4. The new boot process +Rails 3.0 requires Ruby 1.8.7 or higher. Support for all of the previous Ruby versions has been dropped officially and you should upgrade as early as possible. Rails 3.0 is also compatible with Ruby 1.9.2. -As part of the shift to treating Rails apps as Rack endpoints, you are now required to have a +config/application.rb+ file, which takes over much of the work +config/environment.rb+ used to handle. Along with that comes a lot of internal change to the boot process, but those changes are mostly internal. +h4. Rails Application object -h4. Gems and gems and gems +As part of the groundwork for supporting running multiple Rails applications in the same process, Rails 3 introduces the concept of an Application object. An application object holds all the application specific configurations and is very similar in nature to +config/environment.rb+ from the previous versions of Rails. -The +config.gem+ method is gone and has been replaced by using +bundler+ and a +Gemfile+, see "Vendoring Gems":#vendoring-gems below. +Each Rails application now must have a corresponding application object. The application object is defined in +config/application.rb+. If you're upgrading an existing application to Rails 3, you must add this file and move the appropriate configurations from +config/environment.rb+ to +config/application.rb+. + +h4. script/* replaced by script/rails -h4. New APIs +The new script/rails replaces all the scripts that used to be in the script directory. You do not run script/rails directly though, the +rails+ command detects it is being invoked in the root of a Rails application and runs the script for you. Intended usage is: + + +rails console # => ./script/console +rails g scaffold post title:string # => ./script/generate scaffold post title:string + -Both the router and query interface have seen significant, breaking changes. There is a backwards compatibility layer that is in place and will be supported until the 3.1 release. +Run rails --help for a list of all the options. + +h4. Dependencies and config.gem + +The +config.gem+ method is gone and has been replaced by using +bundler+ and a +Gemfile+, see "Vendoring Gems":#vendoring-gems below. h4. Upgrade Process @@ -37,7 +56,7 @@ To help with the upgrade process, a plugin named "Rails Upgrade":http://github.c Simply install the plugin, then run +rake rails:upgrade:check+ to check your app for pieces that need to be updated (with links to information on how to update them). It also offers a task to generate a +Gemfile+ based on your current +config.gem+ calls and a task to generate a new routes file from your current one. To get the plugin, simply run the following: -script/plugin install git://github.com/rails/rails_upgrade.git +rails plugin install git://github.com/rails/rails_upgrade.git You can see an example of how that works at "Rails Upgrade is now an Official Plugin":http://omgbloglol.com/post/364624593/rails-upgrade-is-now-an-official-plugin @@ -46,30 +65,29 @@ Aside from Rails Upgrade tool, if you need more help, there are people on IRC an More information - "The Path to Rails 3: Approaching the upgrade":http://omgbloglol.com/post/353978923/the-path-to-rails-3-approaching-the-upgrade -h3. Application Creation -As stated above, you must be on Ruby 1.8.7 or later to boot up a Rails application. Rails will no longer boot on Ruby 1.8.6 or earlier. +h3. Creating a Rails 3.0 application -Rails 3.0 is designed to run on 1.8.7 and also support Ruby 1.9. - -There have been a few changes to the +rails+ script that's used to generate Rails applications: - -* The application name, rails my_app, can now optionally be a path instead rails ~/code/my_app, your rails application will be name spaced under the application name you pass the +rails+ command. -* Additionally, any flags you need to generate the application now need to come after the application path, for example: +The new installing rails sequence (for the beta) is: -$ rails myapp --database=mysql +$ gem install rails --prerelease +$ rails myapp +$ cd myapp h4. Vendoring Gems -Rails now uses a +Gemfile+ in the application root to determine the gems you require for your application to start. This +Gemfile+ is then read and acted on by the new "Bundler":http://github.com/wycats/bundler gem, which then vendors all your gems into the vendor directory, making your Rails application isolated from system gems. +Rails now uses a +Gemfile+ in the application root to determine the gems you require for your application to start. This +Gemfile+ is processed by the "Bundler":http://github.com/carlhuda/bundler, which then installs all your dependencies. It can even install all the dependencies locally to your application so that it doesn't depend on the system gems. More information: - "Using bundler":http://yehudakatz.com/2009/11/03/using-the-new-gem-bundler-today/ + h4. Living on the Edge -Due to the use of +Gemfile+, the concept of freezing Rails was dropped, because it's always bundled/frozen inside your application. By default, it uses your system gems when bundling; however, if you want to bundle straight from the Git repository, you can pass the edge flag: ++Bundler+ and +Gemfile+ makes freezing your Rails application easy as pie with the new dedicated bundle command, so rake freeze is no longer relevant and has been dropped. + +If you want to bundle straight from the Git repository, you can pass the edge flag: $ rails myapp --edge @@ -79,56 +97,76 @@ More information: * "Spinning up a new Rails app":http://yehudakatz.com/2009/12/31/spinning-up-a-new-rails-app/ * "Rails 3 and Passenger":http://cakebaker.42dh.com/2010/01/17/rails-3-and-passenger/ + h3. Rails Architectural Changes There are six major changes in the architecture of Rails. + h4. Railties Restrung Railties was updated to provide a consistent plugin API for the entire Rails framework as well as a total rewrite of generators and the Rails bindings, the result is that developers can now hook into any significant stage of the generators and application framework in a consistent, defined manner. + h4. All Rails core components are decoupled With the merge of Merb and Rails, one of the big jobs was to remove the tight coupling between Rails core components. This has now been achieved, and all Rails core components are now using the same API that you can use for developing plugins. This means any plugin you make, or any core component replacement (like DataMapper or Sequel) can access all the functionality that the Rails core components have access to and extend and enhance at will. More information: - "The Great Decoupling":http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/ + h4. Active Model Abstraction Part of decoupling the core components was extracting all ties to Active Record from Action Pack. This has now been completed. All new ORM plugins now just need to implement Active Model interfaces to work seamlessly with Action Pack. More information: - "Make Any Ruby Object Feel Like ActiveRecord":http://yehudakatz.com/2010/01/10/activemodel-make-any-ruby-object-feel-like-activerecord/ + h4. Controller Abstraction Another big part of decoupling the core components was creating a base superclass that is separated from the notions of HTTP in order to handle rendering of views etc. This creation of +AbstractController+ allowed +ActionController+ and +ActionMailer+ to be greatly simplified with common code removed from all these libraries and put into Abstract Controller. More Information: - "Rails Edge Architecture":http://yehudakatz.com/2009/06/11/rails-edge-architecture/ + h4. Arel Integration -"Arel":http://github.com/brynary/arel (or Active Relation) has been taken on as the underpinnings of Active Record and is now required for Rails (it is installed for you when you do a gem bundle). Arel provides an SQL abstraction that simplifies out Active Record and provides the underpinnings for the relation functionality in Active Record. +"Arel":http://github.com/rails/arel (or Active Relation) has been taken on as the underpinnings of Active Record and is now required for Rails. Arel provides an SQL abstraction that simplifies out Active Record and provides the underpinnings for the relation functionality in Active Record. More information: - "Why I wrote Arel":http://magicscalingsprinkles.wordpress.com/2010/01/28/why-i-wrote-arel/. + h4. Mail Extraction Action Mailer ever since its beginnings has had monkey patches, pre parsers and even delivery and receiver agents, all in addition to having TMail vendored in the source tree. Version 3 changes that with all email message related functionality abstracted out to the "Mail":http://github.com/mikel/mail gem. This again reduces code duplication and helps create definable boundaries between Action Mailer and the email parser. More information: - "New Action Mailer API in Rails 3":http://lindsaar.net/2010/1/26/new-actionmailer-api-in-rails-3 + h3. Documentation The documentation in the Rails tree is being updated with all the API changes, additionally, the "Rails Edge guides":http://guides.rails.info/ are being updated one by one to reflect the changes in Rails 3.0. The guides at "guides.rubyonrails.org":http://guides.rubyonrails.org/ however will continue to contain only the stable version of Rails (at this point, version 2.3.5, until 3.0 is released). More Information: - "Rails Documentation Projects":http://weblog.rubyonrails.org/2009/1/15/rails-documentation-projects. + +h3. Internationalization + +A large amount of work has been done with I18n support in Rails 3, including the latest "I18n":http://github.com/svenfuchs/i18n gem supplying many speed improvements. + +* I18n for any object - I18n behavior can be added to any object by including ActiveModel::Translation and ActiveModel::Validations. There is also an errors.messages fallback for translations. +* Attributes can have default translations. +* Form Submit Tags automatically pull the correct status (Create or Update) depending on the object status, and so pull the correct translation. +* Labels with I18n also now work by just passing the attribute name. + +More Information: - "Rails 3 I18n changes":http://blog.plataformatec.com.br/2010/02/rails-3-i18n-changes/ + + h3. Railties With the decoupling of the main Rails frameworks, Railties got a huge overhaul so as to make linking up frameworks, engines or plugins as painless and extensible as possible: * Each application now has it's own name space, application is started with YourAppName.boot for example, makes interacting with other applications a lot easier. -* You now have access to Rails.config which provides huge amount of configuration settings for your application. * Anything under Rails.root/app is now added to the load path, so you can make app/observers/user_observer.rb and Rails will load it without any modifications. * Rails 3.0 now provides a Rails.config object, which provides a central repository of all sorts of Rails wide configuration options. @@ -138,7 +176,7 @@ Railties generators got a huge amount of attention in Rails 3.0, basically: * Generators were completely rewritten and are backwards incompatible. * Rails templates API and generators API were merged (they are the same as the former). -* Generators are no longer loaded from special paths anymore, they are just found in the Ruby load path, so calling script/generate foo will look for generators/foo_generator. +* Generators are no longer loaded from special paths anymore, they are just found in the Ruby load path, so calling rails generate foo will look for generators/foo_generator. * New generators provide hooks, so any template engine, ORM, test framework can easily hook in. * New generators allow you to override the templates by placing a copy at RAILS_ROOT/lib/templates. * Rails::Generators::TestCase is also supplied so you can create your own generators and test them. @@ -149,6 +187,11 @@ Also, the views generated by Railties generators had some overhaul: * Scaffolds generated now make use of _form partials, instead of duplicated code in the edit and new views. * Scaffold forms now use f.submit which returns "Create ModelName" or "Update ModelName" depending on the state of the object passed in. +Finally a couple of enhancements were added to the rake tasks: + +* rake db:forward was added, allowing you to roll forward your migrations individually or in groups. +* rake routes CONTROLLER=x was added allowing you to just view the routes for one controller. + Railties now deprecates: * RAILS_ROOT in favour of Rails.root, @@ -161,10 +204,12 @@ More information: * "Discovering Rails 3 generators":http://blog.plataformatec.com.br/2010/01/discovering-rails-3-generators * "Making Generators for Rails 3 with Thor":http://caffeinedd.com/guides/331-making-generators-for-rails-3-with-thor + h3. Action Pack There have been significant internal and external changes in Action Pack. + h4. Abstract Controller Abstract Controller pulls out the generic parts of Action Controller into a reusable module that any library can use to render templates, render partials, helpers, translations, logging, any part of the request response cycle. This abstraction allowed ActionMailer::Base to now just inherit from +AbstractController+ and just wrap the Rails DSL onto the Mail gem. @@ -175,6 +220,7 @@ Note however that Abstract Controller is not a user facing API, you will not run More Information: - "Rails Edge Architecture":http://yehudakatz.com/2009/06/11/rails-edge-architecture/ + h4. Action Controller * application_controller.rb now has protect_from_forgery on by default. @@ -194,6 +240,7 @@ More Information: * "Render Options in Rails 3":http://www.engineyard.com/blog/2010/render-options-in-rails-3/ * "Three reasons to love ActionController::Responder":http://weblog.rubyonrails.org/2009/8/31/three-reasons-love-responder + h4. Action Dispatch Action Dispatch is new in Rails 3.0 and provides a new, cleaner implementation for routing. @@ -220,9 +267,9 @@ end * Added +scope+ method to the router, allowing you to namespace routes for different languages or different actions, for example: -scope 'es' { resources :projects, - :path_names => { :edit => 'cambiar' }, - :as => 'projeto' } +scope 'es' do + resources :projects, :path_names => { :edit => 'cambiar' }, :as => 'projeto' +end # Gives you the edit action with /es/projeto/1/cambiar @@ -243,6 +290,7 @@ More Information: * "Revamped Routes in Rails 3":http://rizwanreza.com/2009/12/20/revamped-routes-in-rails-3 * "Generic Actions in Rails 3":http://yehudakatz.com/2009/12/20/generic-actions-in-rails-3/ + h4. Action View Major re-write was done in the Action View helpers, implementing Unobtrusive JavaScript (UJS) hooks and removing the old inline AJAX commands. This enables Rails to use any compliant UJS driver to implement the UJS hooks in the helpers. @@ -264,17 +312,23 @@ Produces: * Form label helper now pulls values from I18n with a single value, so f.label :name will pull the :name translation. * I18n select label on should now be :en.helpers.select instead of :en.support.select. * You no longer need to place a minus sign at the end of a ruby interpolation inside an ERb template to remove the trailing carriage return in the HTML output. +* Added +grouped_collection_select+ helper to Action View. +* Action View now will raise exceptions if CSS stylesheets and javascript files listed in the +javascript_include_tag+ and +stylesheet_include_tag+ helpers are missing. +* +content_for?+ has been added allowing you to check for the existence of content in a view before rendering. + h3. Active Model Active Model is new in Rails 3.0. It provides an abstraction layer for any ORM libraries to use to interact with Rails by implementing an Active Model interface. + h4. ORM Abstraction and Action Pack Interface Part of decoupling the core components was extracting all ties to Active Record from Action Pack. This has now been completed. All new ORM plugins now just need to implement Active Model interfaces to work seamlessly with Action Pack. More Information: - "Make Any Ruby Object Feel Like ActiveRecord":http://yehudakatz.com/2010/01/10/activemodel-make-any-ruby-object-feel-like-activerecord/ + h4. Validations Validations have been moved from Active Record into Active Model, providing an interface to validations that works across ORM libraries in Rails 3. @@ -324,8 +378,12 @@ More Information: * "Sexy Validation in Rails 3":http://thelucid.com/2010/01/08/sexy-validation-in-edge-rails-rails-3/ * "Rails 3 Validations Explained":http://lindsaar.net/2010/1/31/validates_rails_3_awesome_is_true + h3. Active Record +Active Record received a lot of attention in Rails 3.0, including abstraction into Active Model, a full update to the Query interface using Arel, validation updates and many enhancements and fixes. All of the Rails 2.x API will be usable through a compatibility layer that will be supported until version 3.1. + + h4. Query Interface Active Record, through the use of Arel, now returns relations on it's core methods. The existing API in Rails 2.3.x is still supported and will not be deprecated until Rails 3.1 and not removed until Rails 3.2, however, the new API provides the following new methods that all return relations allowing them to be chained together: @@ -350,6 +408,13 @@ More Information: * "Active Record Query Interface":http://m.onkey.org/2010/1/22/active-record-query-interface * "Let your SQL Growl in Rails 3":http://hasmanyquestions.wordpress.com/2010/01/17/let-your-sql-growl-in-rails-3/ + +h4. Enhancements + +* Added :destroyed? to Active Record objects. +* Added :inverse_of to Active Record associations allowing you to pull the instance of an already loaded association without hitting the database. + + h4. Patches and Deprecations Additionally, many fixes in the Active Record branch: @@ -357,19 +422,24 @@ Additionally, many fixes in the Active Record branch: * SQLite 2 support has been dropped in favour of SQLite 3. * MySQL support for column order. * PostgreSQL adapter has had it's +TIME ZONE+ support fixed so it no longer inserts incorrect values. +* Support multiple schemas in table names for PostgreSQL. * PostgreSQL support for the XML data type column. * +table_name+ is now cached. +* A large amount of work done on the Oracle adapter as well with many bug fixes. As well as the following deprecations: * +named_scope+ in an Active Record class is deprecated and has been renamed to just +scope+. * In +scope+ methods, you should move to using the relation methods, instead of a :conditions => {} finder method, for example scope :since, lambda {|time| where("created_at > ?", time) }. * save(false) is deprecated, in favour of save(:validate => false). -* I18n error messages for ActiveRecord should be changed from :en.activerecord.errors to :en.errors. +* I18n error messages for ActiveRecord should be changed from :en.activerecord.errors.template to :en.errors.template. * model.errors.on is deprecated in favour of model.errors[] * validates_presence_of => validates... :presence => true * ActiveRecord::Base.colorize_logging and config.active_record.colorize_logging are deprecated in favour of Rails::Subscriber.colorize_logging or config.colorize_logging +NOTE: While an implementation of State Machine has been in Active Record edge for some months now, it has been removed from the Rails 3.0 release. + + h3. Active Resource Active Resource was also extracted out to Active Model allowing you to use Active Resource objects with Action Pack seamlessly. @@ -400,6 +470,7 @@ Deprecations: * save(false) is deprecated, in favour of save(:validate => false). * Ruby 1.9.2: URI.parse and .decode are deprecated and are no longer used in the library. + h3. Active Support A large effort was made in Active Support to make it cherry pickable, that is, you no longer have to require the entire Active Support library to get pieces of it. This allows the various core components of Rails to run slimmer. @@ -438,7 +509,7 @@ The following methods have been removed because they are now available in Ruby 1 * Integer#even? and Integer#odd? * String#each_char -* String#start_with? and String#end_with? (plural aliases still kept) +* String#start_with? and String#end_with? (3rd person aliases still kept) * String#bytesize * Object#tap * Symbol#to_proc @@ -449,8 +520,8 @@ The security patch for REXML remains in Active Support because early patchlevels The following methods have been removed because they are no longer used in the framework: -* Class#subclasses, Class#reachable?, Class#remove_class * Object#remove_subclasses_of, Object#subclasses_of, Object#extend_with_included_modules_from, Object#extended_by +* Class#subclasses, Class#reachable?, Class#remove_class * Regexp#number_of_captures * Regexp.unoptionalize, Regexp.optionalize, Regexp#number_of_captures @@ -481,8 +552,9 @@ More Information: * "New Action Mailer API in Rails 3":http://lindsaar.net/2010/1/26/new-actionmailer-api-in-rails-3 * "New Mail Gem for Ruby":http://lindsaar.net/2010/1/23/mail-gem-version-2-released + h3. Credits -See the "full list of contributors to Rails":http://contributors.rubyonrails.org/, many people have spent many hours making Rails 3 what it is. Kudos to all of them. +See the "full list of contributors to Rails":http://contributors.rubyonrails.org/ for the many people who spent many hours making Rails 3. Kudos to all of them. -Rails 3.0 Release Notes were compiled by "Mikel Lindsaar":http://lindsaar.net, who can be found "feeding":http://feeds.feedburner.com/lindsaar-net and "tweeting":http://twitter.com/raasdnil. \ No newline at end of file +Rails 3.0 Release Notes were compiled by "Mikel Lindsaar":http://lindsaar.net. \ No newline at end of file -- cgit v1.2.3 From ddb512c02b81406d10a932a19a365275d3f54849 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 3 Feb 2010 17:27:06 -0800 Subject: Simplify description --- railties/railties.gemspec | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/railties/railties.gemspec b/railties/railties.gemspec index 1e6b141a09..c01636f1c1 100644 --- a/railties/railties.gemspec +++ b/railties/railties.gemspec @@ -4,8 +4,7 @@ Gem::Specification.new do |s| s.version = '3.0.pre' s.summary = "Controls boot-up, rake tasks and generators for the Rails framework." s.description = <<-EOF - Rails is a framework for building web-application using CGI, FCGI, mod_ruby, or WEBrick - on top of either MySQL, PostgreSQL, SQLite, DB2, SQL Server, or Oracle with eRuby- or Builder-based templates. + Rails is a full-stack, web-application framework. EOF s.add_dependency('rake', '>= 0.8.3') -- cgit v1.2.3 From 79817aa9e7fa7c207868ca56ca8bbd0ee5303d81 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 3 Feb 2010 17:29:51 -0800 Subject: Move to 3.0.0.beta --- Gemfile | 2 +- Rakefile | 1 - actionmailer/actionmailer.gemspec | 4 ++-- actionmailer/lib/action_mailer/version.rb | 2 +- actionpack/actionpack.gemspec | 6 +++--- actionpack/lib/action_pack/version.rb | 2 +- activemodel/activemodel.gemspec | 4 ++-- activemodel/lib/active_model/version.rb | 2 +- activerecord/activerecord.gemspec | 6 +++--- activerecord/lib/active_record/version.rb | 2 +- activeresource/activeresource.gemspec | 6 +++--- activeresource/lib/active_resource/version.rb | 2 +- activesupport/activesupport.gemspec | 2 +- activesupport/lib/active_support/version.rb | 2 +- rails.gemspec | 14 +++++++------- railties/lib/rails/tasks/documentation.rake | 2 +- railties/lib/rails/version.rb | 2 +- railties/railties.gemspec | 6 +++--- 18 files changed, 33 insertions(+), 34 deletions(-) diff --git a/Gemfile b/Gemfile index 051607c0f1..6c2f8a35fe 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ path File.expand_path('..', __FILE__) source :gemcutter -gem "rails", "3.0.pre" +gem "rails", "3.0.0.beta" gem "rake", ">= 0.8.7" gem "mocha", ">= 0.9.8" diff --git a/Rakefile b/Rakefile index a102b38cb7..193e719079 100644 --- a/Rakefile +++ b/Rakefile @@ -38,7 +38,6 @@ Rake::GemPackageTask.new(spec) do |pkg| end task :install => :gem do - system %(cd rack && rake gem VERSION=1.0.2.pre && gem install rack-1.0.2.pre.gem --no-ri --no-rdoc --ignore-dependencies) (PROJECTS - ["railties"]).each do |project| puts "INSTALLING #{project}" system("gem install #{project}/pkg/#{project}-#{ActionPack::VERSION::STRING}.gem --no-ri --no-rdoc") diff --git a/actionmailer/actionmailer.gemspec b/actionmailer/actionmailer.gemspec index abbb542293..1e4a19f736 100644 --- a/actionmailer/actionmailer.gemspec +++ b/actionmailer/actionmailer.gemspec @@ -3,14 +3,14 @@ Gem::Specification.new do |s| s.name = 'actionmailer' s.summary = "Service layer for easy email delivery and testing." s.description = %q{Makes it trivial to test and deliver emails sent from a single service layer.} - s.version = '3.0.pre' + s.version = '3.0.0.beta' s.author = "David Heinemeier Hansson" s.email = "david@loudthinking.com" s.rubyforge_project = "actionmailer" s.homepage = "http://www.rubyonrails.org" - s.add_dependency('actionpack', '= 3.0.pre') + s.add_dependency('actionpack', '= 3.0.0.beta') s.add_dependency('mail', '~> 2.1.2') s.add_dependency('text-format', '~> 1.0.0') diff --git a/actionmailer/lib/action_mailer/version.rb b/actionmailer/lib/action_mailer/version.rb index 0f2b58552b..b11c6ef055 100644 --- a/actionmailer/lib/action_mailer/version.rb +++ b/actionmailer/lib/action_mailer/version.rb @@ -2,7 +2,7 @@ module ActionMailer module VERSION #:nodoc: MAJOR = 3 MINOR = 0 - TINY = "pre" + TINY = "0.beta" STRING = [MAJOR, MINOR, TINY].join('.') end diff --git a/actionpack/actionpack.gemspec b/actionpack/actionpack.gemspec index dc91fba64d..ee1c35f0ae 100644 --- a/actionpack/actionpack.gemspec +++ b/actionpack/actionpack.gemspec @@ -1,7 +1,7 @@ Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = 'actionpack' - s.version = '3.0.pre' + s.version = '3.0.0.beta' s.summary = "Web-flow and rendering framework putting the VC in MVC." s.description = %q{Eases web-request routing, handling, and response as a half-way front, half-way page controller. Implemented with specific emphasis on enabling easy unit/integration testing that doesn't require a browser.} #' @@ -14,8 +14,8 @@ Gem::Specification.new do |s| s.has_rdoc = true s.requirements << 'none' - s.add_dependency('activesupport', '= 3.0.pre') - s.add_dependency('activemodel', '= 3.0.pre') + s.add_dependency('activesupport', '= 3.0.0.beta') + s.add_dependency('activemodel', '= 3.0.0.beta') s.add_dependency('rack', '~> 1.1.0') s.add_dependency('rack-test', '~> 0.5.0') s.add_dependency('rack-mount', '~> 0.4.0') diff --git a/actionpack/lib/action_pack/version.rb b/actionpack/lib/action_pack/version.rb index ed0cdf38ee..4dde21dd40 100644 --- a/actionpack/lib/action_pack/version.rb +++ b/actionpack/lib/action_pack/version.rb @@ -2,7 +2,7 @@ module ActionPack #:nodoc: module VERSION #:nodoc: MAJOR = 3 MINOR = 0 - TINY = "pre" + TINY = "0.beta" STRING = [MAJOR, MINOR, TINY].join('.') end diff --git a/activemodel/activemodel.gemspec b/activemodel/activemodel.gemspec index c3ff624419..64ae6e0760 100644 --- a/activemodel/activemodel.gemspec +++ b/activemodel/activemodel.gemspec @@ -1,7 +1,7 @@ Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = 'activemodel' - s.version = '3.0.pre' + s.version = '3.0.0.beta' s.summary = "A toolkit for building other modeling frameworks like ActiveRecord" s.description = %q{Extracts common modeling concerns from ActiveRecord to share between similar frameworks like ActiveResource.} @@ -12,7 +12,7 @@ Gem::Specification.new do |s| s.has_rdoc = true - s.add_dependency('activesupport', '= 3.0.pre') + s.add_dependency('activesupport', '= 3.0.0.beta') s.require_path = 'lib' s.files = Dir["CHANGELOG", "MIT-LICENSE", "README", "lib/**/*"] diff --git a/activemodel/lib/active_model/version.rb b/activemodel/lib/active_model/version.rb index 0c233b7b4f..f569447bc8 100644 --- a/activemodel/lib/active_model/version.rb +++ b/activemodel/lib/active_model/version.rb @@ -2,7 +2,7 @@ module ActiveModel module VERSION #:nodoc: MAJOR = 3 MINOR = 0 - TINY = "pre" + TINY = "0.beta" STRING = [MAJOR, MINOR, TINY].join('.') end diff --git a/activerecord/activerecord.gemspec b/activerecord/activerecord.gemspec index 4fd1a0213c..a8c990e3cb 100644 --- a/activerecord/activerecord.gemspec +++ b/activerecord/activerecord.gemspec @@ -1,14 +1,14 @@ Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = 'activerecord' - s.version = '3.0.pre' + s.version = '3.0.0.beta' s.summary = "Implements the ActiveRecord pattern for ORM." s.description = %q{Implements the ActiveRecord pattern (Fowler, PoEAA) for ORM. It ties database tables and classes together for business objects, like Customer or Subscription, that can find, save, and destroy themselves without resorting to manual SQL.} s.files = Dir['CHANGELOG', 'README', 'examples/**/*', 'lib/**/*'] - s.add_dependency('activesupport', '= 3.0.pre') - s.add_dependency('activemodel', '= 3.0.pre') + s.add_dependency('activesupport', '= 3.0.0.beta') + s.add_dependency('activemodel', '= 3.0.0.beta') s.add_dependency('arel', '~> 0.2.0') s.require_path = 'lib' diff --git a/activerecord/lib/active_record/version.rb b/activerecord/lib/active_record/version.rb index 10ef9d7594..d55b14f082 100644 --- a/activerecord/lib/active_record/version.rb +++ b/activerecord/lib/active_record/version.rb @@ -2,7 +2,7 @@ module ActiveRecord module VERSION #:nodoc: MAJOR = 3 MINOR = 0 - TINY = "pre" + TINY = "0.beta" STRING = [MAJOR, MINOR, TINY].join('.') end diff --git a/activeresource/activeresource.gemspec b/activeresource/activeresource.gemspec index ad2031c9e7..b7555228cd 100644 --- a/activeresource/activeresource.gemspec +++ b/activeresource/activeresource.gemspec @@ -1,14 +1,14 @@ Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = 'activeresource' - s.version = '3.0.pre' + s.version = '3.0.0.beta' s.summary = "Think Active Record for web resources." s.description = %q{Wraps web resources in model classes that can be manipulated through XML over REST.} s.files = Dir['CHANGELOG', 'README', 'examples/**/*', 'lib/**/*'] - s.add_dependency('activesupport', '= 3.0.pre') - s.add_dependency('activemodel', '= 3.0.pre') + s.add_dependency('activesupport', '= 3.0.0.beta') + s.add_dependency('activemodel', '= 3.0.0.beta') s.require_path = 'lib' s.autorequire = 'active_resource' diff --git a/activeresource/lib/active_resource/version.rb b/activeresource/lib/active_resource/version.rb index 0f312eac39..952a0d3b5f 100644 --- a/activeresource/lib/active_resource/version.rb +++ b/activeresource/lib/active_resource/version.rb @@ -2,7 +2,7 @@ module ActiveResource module VERSION #:nodoc: MAJOR = 3 MINOR = 0 - TINY = "pre" + TINY = "0.beta" STRING = [MAJOR, MINOR, TINY].join('.') end diff --git a/activesupport/activesupport.gemspec b/activesupport/activesupport.gemspec index 19cdbaa41a..9e0b48278c 100644 --- a/activesupport/activesupport.gemspec +++ b/activesupport/activesupport.gemspec @@ -1,7 +1,7 @@ Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = "activesupport" - s.version = "3.0.pre" + s.version = "3.0.0.beta" s.date = "2009-09-01" s.summary = "Support and utility classes used by the Rails framework." s.description = %q{Utility library which carries commonly used classes and goodies from the Rails framework} diff --git a/activesupport/lib/active_support/version.rb b/activesupport/lib/active_support/version.rb index 3ae6150f2d..b92e469a08 100644 --- a/activesupport/lib/active_support/version.rb +++ b/activesupport/lib/active_support/version.rb @@ -2,7 +2,7 @@ module ActiveSupport module VERSION #:nodoc: MAJOR = 3 MINOR = 0 - TINY = "pre" + TINY = "0.beta" STRING = [MAJOR, MINOR, TINY].join('.') end diff --git a/rails.gemspec b/rails.gemspec index b44dc27cb0..89681cb0aa 100644 --- a/rails.gemspec +++ b/rails.gemspec @@ -1,19 +1,19 @@ Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = 'rails' - s.version = '3.0.pre' + s.version = '3.0.0.beta' s.summary = "Web-application framework with template engine, control-flow layer, and ORM." s.description = <<-EOF Rails is a framework for building web-application using CGI, FCGI, mod_ruby, or WEBrick on top of either MySQL, PostgreSQL, SQLite, DB2, SQL Server, or Oracle with eRuby- or Builder-based templates. EOF - s.add_dependency('activesupport', '= 3.0.pre') - s.add_dependency('actionpack', '= 3.0.pre') - s.add_dependency('activerecord', '= 3.0.pre') - s.add_dependency('activeresource', '= 3.0.pre') - s.add_dependency('actionmailer', '= 3.0.pre') - s.add_dependency('railties', '= 3.0.pre') + s.add_dependency('activesupport', '= 3.0.0.beta') + s.add_dependency('actionpack', '= 3.0.0.beta') + s.add_dependency('activerecord', '= 3.0.0.beta') + s.add_dependency('activeresource', '= 3.0.0.beta') + s.add_dependency('actionmailer', '= 3.0.0.beta') + s.add_dependency('railties', '= 3.0.0.beta') s.add_dependency('bundler', '>= 0.9.0.pre') s.rdoc_options << '--exclude' << '.' diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake index 3f49a9a720..7095046f21 100644 --- a/railties/lib/rails/tasks/documentation.rake +++ b/railties/lib/rails/tasks/documentation.rake @@ -14,7 +14,7 @@ namespace :doc do desc 'Generate documentation for the Rails framework. Specify path with PATH="/path/to/rails"' Rake::RDocTask.new("rails") { |rdoc| path = ENV['RAILS_PATH'] || 'vendor/gems/gems' - version = '-3.0.pre' unless ENV['RAILS_PATH'] + version = '-3.0.0.beta' unless ENV['RAILS_PATH'] rdoc.rdoc_dir = 'doc/api' rdoc.template = "#{ENV['template']}.rb" if ENV['template'] rdoc.title = "Rails Framework Documentation" diff --git a/railties/lib/rails/version.rb b/railties/lib/rails/version.rb index 9a65096061..c327d4545a 100644 --- a/railties/lib/rails/version.rb +++ b/railties/lib/rails/version.rb @@ -2,7 +2,7 @@ module Rails module VERSION #:nodoc: MAJOR = 3 MINOR = 0 - TINY = "pre" + TINY = "0.beta" STRING = [MAJOR, MINOR, TINY].join('.') end diff --git a/railties/railties.gemspec b/railties/railties.gemspec index c01636f1c1..62cfc1bbed 100644 --- a/railties/railties.gemspec +++ b/railties/railties.gemspec @@ -1,7 +1,7 @@ Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = 'railties' - s.version = '3.0.pre' + s.version = '3.0.0.beta' s.summary = "Controls boot-up, rake tasks and generators for the Rails framework." s.description = <<-EOF Rails is a full-stack, web-application framework. @@ -9,8 +9,8 @@ Gem::Specification.new do |s| s.add_dependency('rake', '>= 0.8.3') s.add_dependency('thor', '~> 0.13') - s.add_dependency('activesupport', '= 3.0.pre') - s.add_dependency('actionpack', '= 3.0.pre') + s.add_dependency('activesupport', '= 3.0.0.beta') + s.add_dependency('actionpack', '= 3.0.0.beta') s.rdoc_options << '--exclude' << '.' s.has_rdoc = false -- cgit v1.2.3 From e71825d40d4427ad1bf8b819adea5987fbf59fc5 Mon Sep 17 00:00:00 2001 From: Chad Woolley Date: Wed, 3 Feb 2010 18:54:46 -0700 Subject: remove arel directory, breaks 'git submodule init', which breaks ci builds Signed-off-by: Yehuda Katz --- arel | 1 - 1 file changed, 1 deletion(-) delete mode 160000 arel diff --git a/arel b/arel deleted file mode 160000 index 0faeb50474..0000000000 --- a/arel +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0faeb5047407348533db952d9cf93ea59d2526dc -- cgit v1.2.3 From 031139bb717d37f29bc3daf3a6d40ab2a9d7d3fc Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 3 Feb 2010 17:59:39 -0800 Subject: Homogenize gemspecs and remove the deprecated autorequire --- actionmailer/actionmailer.gemspec | 32 ++++++++++++++-------------- actionpack/actionpack.gemspec | 27 ++++++++++++----------- activerecord/activerecord.gemspec | 30 ++++++++++++-------------- activeresource/activeresource.gemspec | 28 ++++++++++++------------ activesupport/activesupport.gemspec | 30 +++++++++++++------------- rails.gemspec | 29 ++++++++++++------------- railties/railties.gemspec | 40 +++++++++++++++++------------------ 7 files changed, 103 insertions(+), 113 deletions(-) diff --git a/actionmailer/actionmailer.gemspec b/actionmailer/actionmailer.gemspec index 1e4a19f736..c3b1c96832 100644 --- a/actionmailer/actionmailer.gemspec +++ b/actionmailer/actionmailer.gemspec @@ -1,22 +1,22 @@ Gem::Specification.new do |s| - s.platform = Gem::Platform::RUBY - s.name = 'actionmailer' - s.summary = "Service layer for easy email delivery and testing." - s.description = %q{Makes it trivial to test and deliver emails sent from a single service layer.} - s.version = '3.0.0.beta' + s.platform = Gem::Platform::RUBY + s.name = 'actionmailer' + s.version = '3.0.0.beta' + s.summary = 'Email composition, delivery, and recieval framework (part of Rails).' + s.description = 'Email composition, delivery, and recieval framework (part of Rails).' - s.author = "David Heinemeier Hansson" - s.email = "david@loudthinking.com" - s.rubyforge_project = "actionmailer" - s.homepage = "http://www.rubyonrails.org" + s.author = 'David Heinemeier Hansson' + s.email = 'david@loudthinking.com' + s.homepage = 'http://www.rubyonrails.org' + s.rubyforge_project = 'actionmailer' - s.add_dependency('actionpack', '= 3.0.0.beta') - s.add_dependency('mail', '~> 2.1.2') - s.add_dependency('text-format', '~> 1.0.0') + s.files = Dir['CHANGELOG', 'README', 'MIT-LICENSE', 'lib/**/*'] + s.require_path = 'lib' + s.requirements << 'none' - s.files = Dir['CHANGELOG', 'README', 'MIT-LICENSE', 'lib/**/*'] s.has_rdoc = true - s.requirements << 'none' - s.require_path = 'lib' - s.autorequire = 'action_mailer' + + s.add_dependency('actionpack', '= 3.0.0.beta') + s.add_dependency('mail', '~> 2.1.2') + s.add_dependency('text-format', '~> 1.0.0') end diff --git a/actionpack/actionpack.gemspec b/actionpack/actionpack.gemspec index ee1c35f0ae..2017776661 100644 --- a/actionpack/actionpack.gemspec +++ b/actionpack/actionpack.gemspec @@ -1,26 +1,25 @@ Gem::Specification.new do |s| - s.platform = Gem::Platform::RUBY - s.name = 'actionpack' - s.version = '3.0.0.beta' - s.summary = "Web-flow and rendering framework putting the VC in MVC." - s.description = %q{Eases web-request routing, handling, and response as a half-way front, half-way page controller. Implemented with specific emphasis on enabling easy unit/integration testing that doesn't require a browser.} #' + s.platform = Gem::Platform::RUBY + s.name = 'actionpack' + s.version = '3.0.0.beta' + s.summary = 'Web-flow and rendering framework putting the VC in MVC (part of Rails).' + s.description = 'Web-flow and rendering framework putting the VC in MVC (part of Rails).' - s.author = "David Heinemeier Hansson" - s.email = "david@loudthinking.com" - s.rubyforge_project = "actionpack" - s.homepage = "http://www.rubyonrails.org" + s.author = 'David Heinemeier Hansson' + s.email = 'david@loudthinking.com' + s.homepage = 'http://www.rubyonrails.org' + s.rubyforge_project = 'actionpack' - s.files = Dir['CHANGELOG', 'README', 'MIT-LICENSE', 'lib/**/*'] - s.has_rdoc = true + s.files = Dir['CHANGELOG', 'README', 'MIT-LICENSE', 'lib/**/*'] + s.require_path = 'lib' s.requirements << 'none' + s.has_rdoc = true + s.add_dependency('activesupport', '= 3.0.0.beta') s.add_dependency('activemodel', '= 3.0.0.beta') s.add_dependency('rack', '~> 1.1.0') s.add_dependency('rack-test', '~> 0.5.0') s.add_dependency('rack-mount', '~> 0.4.0') s.add_dependency('erubis', '~> 2.6.5') - - s.require_path = 'lib' - s.autorequire = 'action_controller' end diff --git a/activerecord/activerecord.gemspec b/activerecord/activerecord.gemspec index a8c990e3cb..f7ed77ca4b 100644 --- a/activerecord/activerecord.gemspec +++ b/activerecord/activerecord.gemspec @@ -1,25 +1,23 @@ Gem::Specification.new do |s| - s.platform = Gem::Platform::RUBY - s.name = 'activerecord' - s.version = '3.0.0.beta' - s.summary = "Implements the ActiveRecord pattern for ORM." - s.description = %q{Implements the ActiveRecord pattern (Fowler, PoEAA) for ORM. It ties database tables and classes together for business objects, like Customer or Subscription, that can find, save, and destroy themselves without resorting to manual SQL.} + s.platform = Gem::Platform::RUBY + s.name = 'activerecord' + s.version = '3.0.0.beta' + s.summary = 'Object-relational mapper framework (part of Rails).' + s.description = 'Object-relational mapper framework (part of Rails).' - s.files = Dir['CHANGELOG', 'README', 'examples/**/*', 'lib/**/*'] - - s.add_dependency('activesupport', '= 3.0.0.beta') - s.add_dependency('activemodel', '= 3.0.0.beta') - s.add_dependency('arel', '~> 0.2.0') + s.author = 'David Heinemeier Hansson' + s.email = 'david@loudthinking.com' + s.homepage = 'http://www.rubyonrails.org' + s.rubyforge_project = 'activerecord' + s.files = Dir['CHANGELOG', 'README', 'examples/**/*', 'lib/**/*'] s.require_path = 'lib' - s.autorequire = 'active_record' - s.has_rdoc = true + s.has_rdoc = true s.extra_rdoc_files = %w( README ) s.rdoc_options.concat ['--main', 'README'] - s.author = "David Heinemeier Hansson" - s.email = "david@loudthinking.com" - s.homepage = "http://www.rubyonrails.org" - s.rubyforge_project = "activerecord" + s.add_dependency('activesupport', '= 3.0.0.beta') + s.add_dependency('activemodel', '= 3.0.0.beta') + s.add_dependency('arel', '~> 0.2.0') end diff --git a/activeresource/activeresource.gemspec b/activeresource/activeresource.gemspec index b7555228cd..8668761977 100644 --- a/activeresource/activeresource.gemspec +++ b/activeresource/activeresource.gemspec @@ -1,24 +1,22 @@ Gem::Specification.new do |s| - s.platform = Gem::Platform::RUBY - s.name = 'activeresource' - s.version = '3.0.0.beta' - s.summary = "Think Active Record for web resources." - s.description = %q{Wraps web resources in model classes that can be manipulated through XML over REST.} + s.platform = Gem::Platform::RUBY + s.name = 'activeresource' + s.version = '3.0.0.beta' + s.summary = 'REST-model framework (part of Rails).' + s.description = 'REST-model framework (part of Rails).' - s.files = Dir['CHANGELOG', 'README', 'examples/**/*', 'lib/**/*'] - - s.add_dependency('activesupport', '= 3.0.0.beta') - s.add_dependency('activemodel', '= 3.0.0.beta') + s.author = 'David Heinemeier Hansson' + s.email = 'david@loudthinking.com' + s.homepage = 'http://www.rubyonrails.org' + s.rubyforge_project = 'activeresource' + s.files = Dir['CHANGELOG', 'README', 'examples/**/*', 'lib/**/*'] s.require_path = 'lib' - s.autorequire = 'active_resource' - s.has_rdoc = true + s.has_rdoc = true s.extra_rdoc_files = %w( README ) s.rdoc_options.concat ['--main', 'README'] - s.author = "David Heinemeier Hansson" - s.email = "david@loudthinking.com" - s.homepage = "http://www.rubyonrails.org" - s.rubyforge_project = "activeresource" + s.add_dependency('activesupport', '= 3.0.0.beta') + s.add_dependency('activemodel', '= 3.0.0.beta') end diff --git a/activesupport/activesupport.gemspec b/activesupport/activesupport.gemspec index 9e0b48278c..c366ccfa8e 100644 --- a/activesupport/activesupport.gemspec +++ b/activesupport/activesupport.gemspec @@ -1,22 +1,22 @@ Gem::Specification.new do |s| - s.platform = Gem::Platform::RUBY - s.name = "activesupport" - s.version = "3.0.0.beta" - s.date = "2009-09-01" - s.summary = "Support and utility classes used by the Rails framework." - s.description = %q{Utility library which carries commonly used classes and goodies from the Rails framework} + s.platform = Gem::Platform::RUBY + s.name = 'activesupport' + s.version = '3.0.0.beta' + s.summary = 'Support and utility classes used by the Rails framework.' + s.description = 'Support and utility classes used by the Rails framework.' - s.add_dependency('i18n', '~> 0.3.0') - s.add_dependency('tzinfo', '~> 0.3.16') - s.add_dependency('builder', '~> 2.1.2') - s.add_dependency('memcache-client', '~> 1.7.5') + s.author = 'David Heinemeier Hansson' + s.email = 'david@loudthinking.com' + s.homepage = 'http://www.rubyonrails.org' + s.rubyforge_project = 'activesupport' - s.files = Dir['CHANGELOG', 'README', 'lib/**/*'] + s.files = Dir['CHANGELOG', 'README', 'lib/**/*'] s.require_path = 'lib' + s.has_rdoc = true - s.author = "David Heinemeier Hansson" - s.email = "david@loudthinking.com" - s.homepage = "http://www.rubyonrails.org" - s.rubyforge_project = "activesupport" + s.add_dependency('i18n', '~> 0.3.0') + s.add_dependency('tzinfo', '~> 0.3.16') + s.add_dependency('builder', '~> 2.1.2') + s.add_dependency('memcache-client', '~> 1.7.5') end diff --git a/rails.gemspec b/rails.gemspec index 80443c6f6f..37a9636ad7 100644 --- a/rails.gemspec +++ b/rails.gemspec @@ -1,12 +1,17 @@ Gem::Specification.new do |s| - s.platform = Gem::Platform::RUBY - s.name = 'rails' - s.version = '3.0.0.beta' - s.summary = "Web-application framework with template engine, control-flow layer, and ORM." - s.description = <<-EOF - Rails is a framework for building web-application using CGI, FCGI, mod_ruby, or WEBrick - on top of either MySQL, PostgreSQL, SQLite, DB2, SQL Server, or Oracle with eRuby- or Builder-based templates. - EOF + s.platform = Gem::Platform::RUBY + s.name = 'rails' + s.version = '3.0.0.beta' + s.summary = 'Full-stack web-application framework.' + s.description = 'Full-stack web-application framework.' + + s.author = 'David Heinemeier Hansson' + s.email = 'david@loudthinking.com' + s.homepage = 'http://www.rubyonrails.org' + s.rubyforge_project = 'rails' + + s.rdoc_options << '--exclude' << '.' + s.has_rdoc = false s.add_dependency('activesupport', '= 3.0.0.beta') s.add_dependency('actionpack', '= 3.0.0.beta') @@ -15,12 +20,4 @@ Gem::Specification.new do |s| s.add_dependency('actionmailer', '= 3.0.0.beta') s.add_dependency('railties', '= 3.0.0.beta') s.add_dependency('bundler', '>= 0.9.0.pre5') - - s.rdoc_options << '--exclude' << '.' - s.has_rdoc = false - - s.author = "David Heinemeier Hansson" - s.email = "david@loudthinking.com" - s.homepage = "http://www.rubyonrails.org" - s.rubyforge_project = "rails" end diff --git a/railties/railties.gemspec b/railties/railties.gemspec index 62cfc1bbed..e91bd0e1b5 100644 --- a/railties/railties.gemspec +++ b/railties/railties.gemspec @@ -1,28 +1,26 @@ Gem::Specification.new do |s| - s.platform = Gem::Platform::RUBY - s.name = 'railties' - s.version = '3.0.0.beta' - s.summary = "Controls boot-up, rake tasks and generators for the Rails framework." - s.description = <<-EOF - Rails is a full-stack, web-application framework. - EOF + s.platform = Gem::Platform::RUBY + s.name = 'railties' + s.version = '3.0.0.beta' + s.summary = 'Controls boot-up, rake tasks and generators for the Rails framework.' + s.description = 'Controls boot-up, rake tasks and generators for the Rails framework.' - s.add_dependency('rake', '>= 0.8.3') - s.add_dependency('thor', '~> 0.13') - s.add_dependency('activesupport', '= 3.0.0.beta') - s.add_dependency('actionpack', '= 3.0.0.beta') + s.author = 'David Heinemeier Hansson' + s.email = 'david@loudthinking.com' + s.homepage = 'http://www.rubyonrails.org' + s.rubyforge_project = 'rails' + + s.files = Dir['CHANGELOG', 'README', 'bin/**/*', 'builtin/**/*', 'guides/**/*', 'lib/**/{*,.[a-z]*}'] + s.require_path = 'lib' + s.bindir = 'bin' + s.executables = ['rails'] + s.default_executable = 'rails' s.rdoc_options << '--exclude' << '.' s.has_rdoc = false - s.files = Dir['CHANGELOG', 'README', 'bin/**/*', 'builtin/**/*', 'guides/**/*', 'lib/**/{*,.[a-z]*}'] - s.require_path = 'lib' - s.bindir = "bin" - s.executables = ["rails"] - s.default_executable = "rails" - - s.author = "David Heinemeier Hansson" - s.email = "david@loudthinking.com" - s.homepage = "http://www.rubyonrails.org" - s.rubyforge_project = "rails" + s.add_dependency('rake', '>= 0.8.3') + s.add_dependency('thor', '~> 0.13') + s.add_dependency('activesupport', '= 3.0.0.beta') + s.add_dependency('actionpack', '= 3.0.0.beta') end -- cgit v1.2.3 From db15e49ddf64afd982ddb52e7d0487314f7dcf97 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 3 Feb 2010 22:08:48 -0800 Subject: Autorequire bundled libraries by default --- railties/lib/generators/rails/app/templates/config/boot.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/railties/lib/generators/rails/app/templates/config/boot.rb b/railties/lib/generators/rails/app/templates/config/boot.rb index 7407d6143a..03396113e8 100644 --- a/railties/lib/generators/rails/app/templates/config/boot.rb +++ b/railties/lib/generators/rails/app/templates/config/boot.rb @@ -16,6 +16,9 @@ rescue LoadError # require 'rubygems' end +# Auto-require all bundled libraries. +Bundler.require + <% unless options[:skip_activerecord] -%> require 'rails/all' @@ -40,4 +43,4 @@ require "action_view/railtie" require "action_mailer/railtie" require "active_resource/railtie" require "rails/test_unit/railtie" -<% end -%> \ No newline at end of file +<% end -%> -- cgit v1.2.3 From b63643004c1b44cfd3686cde180cd06bdc0617ca Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 4 Feb 2010 00:19:07 -0800 Subject: Bump bundler dep to 0.9.1.pre1 --- ci/ci_build.rb | 2 +- rails.gemspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/ci_build.rb b/ci/ci_build.rb index eb1f784bd7..522d1209c9 100755 --- a/ci/ci_build.rb +++ b/ci/ci_build.rb @@ -23,7 +23,7 @@ build_results = {} build_results[:geminstaller] = system "sudo gem install rubygems-update -v 1.3.5 --no-ri --no-rdoc" # Install required version of bundler. -build_results[:geminstaller] = system "sudo gem install bundler -v 0.9.0.pre4 --prerelease --no-ri --no-rdoc" +build_results[:geminstaller] = system "sudo gem install bundler -v 0.9.1.pre1 --prerelease --no-ri --no-rdoc" cd root_dir do puts diff --git a/rails.gemspec b/rails.gemspec index 37a9636ad7..fb69baebf4 100644 --- a/rails.gemspec +++ b/rails.gemspec @@ -19,5 +19,5 @@ Gem::Specification.new do |s| s.add_dependency('activeresource', '= 3.0.0.beta') s.add_dependency('actionmailer', '= 3.0.0.beta') s.add_dependency('railties', '= 3.0.0.beta') - s.add_dependency('bundler', '>= 0.9.0.pre5') + s.add_dependency('bundler', '>= 0.9.1.pre1') end -- cgit v1.2.3 From c9ec28b2b643de7a315276cc285d7a4506b9d568 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 4 Feb 2010 00:21:47 -0800 Subject: Use a normal gem source url instead of a magic symbol --- railties/lib/generators/rails/app/templates/Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/lib/generators/rails/app/templates/Gemfile b/railties/lib/generators/rails/app/templates/Gemfile index ce495177eb..2ad3041ab9 100644 --- a/railties/lib/generators/rails/app/templates/Gemfile +++ b/railties/lib/generators/rails/app/templates/Gemfile @@ -1,5 +1,5 @@ # Edit this Gemfile to bundle your application's dependencies. -source :gemcutter +source 'http://gemcutter.org' <% if !dev_or_edge? %> gem "rails", "<%= Rails::VERSION::STRING %>" -- cgit v1.2.3 From 31248fe3698c8d6c54465dfdf463ea49749e1c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 4 Feb 2010 10:39:55 +0100 Subject: Remove instrument! and require thread from AS::Notifications. --- activesupport/lib/active_support/notifications.rb | 2 +- .../lib/active_support/notifications/fanout.rb | 4 +--- .../lib/active_support/notifications/instrumenter.rb | 9 --------- activesupport/test/notifications_test.rb | 18 +----------------- 4 files changed, 3 insertions(+), 30 deletions(-) diff --git a/activesupport/lib/active_support/notifications.rb b/activesupport/lib/active_support/notifications.rb index a1383bb478..3e96decb8c 100644 --- a/activesupport/lib/active_support/notifications.rb +++ b/activesupport/lib/active_support/notifications.rb @@ -45,7 +45,7 @@ module ActiveSupport class << self attr_writer :notifier delegate :publish, :subscribe, :to => :notifier - delegate :instrument, :instrument!, :to => :instrumenter + delegate :instrument, :to => :instrumenter def notifier @notifier ||= Notifier.new diff --git a/activesupport/lib/active_support/notifications/fanout.rb b/activesupport/lib/active_support/notifications/fanout.rb index ac482a2ec8..0ec23da073 100644 --- a/activesupport/lib/active_support/notifications/fanout.rb +++ b/activesupport/lib/active_support/notifications/fanout.rb @@ -1,5 +1,3 @@ -require 'thread' - module ActiveSupport module Notifications # This is a default queue implementation that ships with Notifications. It @@ -21,8 +19,8 @@ module ActiveSupport @subscribers.each { |s| s.publish(*args) } end + # This is a sync queue, so there is not waiting. def wait - sleep(0.05) until @subscribers.all?(&:drained?) end # Used for internal implementation only. diff --git a/activesupport/lib/active_support/notifications/instrumenter.rb b/activesupport/lib/active_support/notifications/instrumenter.rb index 7c5b118ee3..f3d877efe7 100644 --- a/activesupport/lib/active_support/notifications/instrumenter.rb +++ b/activesupport/lib/active_support/notifications/instrumenter.rb @@ -20,15 +20,6 @@ module ActiveSupport result end - # The same as instrument, but sends the notification even if the yielded - # block raises an error. - def instrument!(name, payload={}) - time = Time.now - yield(payload) if block_given? - ensure - @notifier.publish(name, time, Time.now, @id, payload) - end - private def unique_id SecureRandom.hex(10) diff --git a/activesupport/test/notifications_test.rb b/activesupport/test/notifications_test.rb index 0b78b53c73..545811a376 100644 --- a/activesupport/test/notifications_test.rb +++ b/activesupport/test/notifications_test.rb @@ -67,29 +67,13 @@ module Notifications end class InstrumentationTest < TestCase - delegate :instrument, :instrument!, :to => ActiveSupport::Notifications + delegate :instrument, :to => ActiveSupport::Notifications def test_instrument_returns_block_result assert_equal 2, instrument(:awesome) { 1 + 1 } drain end - def test_instrument_with_bang_returns_result_even_on_failure - begin - instrument!(:awesome, :payload => "notifications") do - raise "FAIL" - end - flunk - rescue - end - - drain - - assert_equal 1, @events.size - assert_equal :awesome, @events.last.name - assert_equal Hash[:payload => "notifications"], @events.last.payload - end - def test_instrument_yields_the_paylod_for_further_modification assert_equal 2, instrument(:awesome) { |p| p[:result] = 1 + 1 } drain -- cgit v1.2.3 From 79376e3c9d0838ff1562e0a46239c6b0337058b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 4 Feb 2010 13:53:37 +0100 Subject: Update Gemfile to use latest bundler config. --- railties/lib/generators/rails/app/app_generator.rb | 36 +++++++++++++--------- .../lib/generators/rails/app/templates/Gemfile | 10 +++--- railties/test/generators/app_generator_test.rb | 7 +++++ 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/railties/lib/generators/rails/app/app_generator.rb b/railties/lib/generators/rails/app/app_generator.rb index dcb8af208f..c439ed89f5 100644 --- a/railties/lib/generators/rails/app/app_generator.rb +++ b/railties/lib/generators/rails/app/app_generator.rb @@ -9,6 +9,8 @@ module Rails::Generators class AppGenerator < Base DATABASES = %w( mysql oracle postgresql sqlite3 frontbase ibm_db ) + + attr_accessor :rails_template add_shebang_option! argument :app_path, :type => :string @@ -90,18 +92,6 @@ module Rails::Generators template "config/boot.rb" end - def gem_for_database - # %w( mysql oracle postgresql sqlite3 frontbase ibm_db ) - case options[:database] - when "mysql" then "mysql" - when "oracle" then "ruby-oci8" - when "postgresql" then "pg" - when "sqlite3" then "sqlite3-ruby" - when "frontbase" then "ruby-frontbase" - when "ibm_db" then "ibm_db" - end - end - def create_activerecord_files return if options[:skip_activerecord] template "config/databases/#{options[:database]}.yml", "config/database.yml" @@ -185,7 +175,10 @@ module Rails::Generators end protected - attr_accessor :rails_template + + def self.banner + "rails #{self.arguments.map(&:usage).join(' ')} [options]" + end def set_default_accessors! self.rails_template = case options[:template] @@ -230,8 +223,21 @@ module Rails::Generators options.dev? || options.edge? end - def self.banner - "#{$0} #{self.arguments.map(&:usage).join(' ')} [options]" + def gem_for_database + # %w( mysql oracle postgresql sqlite3 frontbase ibm_db ) + case options[:database] + when "oracle" then "ruby-oci8" + when "postgresql" then "pg" + when "sqlite3" then "sqlite3-ruby" + when "frontbase" then "ruby-frontbase" + else options[:database] + end + end + + def require_for_database + case options[:database] + when "sqlite3" then "sqlite3" + end end def mysql_socket diff --git a/railties/lib/generators/rails/app/templates/Gemfile b/railties/lib/generators/rails/app/templates/Gemfile index 2ad3041ab9..f51edc4d2f 100644 --- a/railties/lib/generators/rails/app/templates/Gemfile +++ b/railties/lib/generators/rails/app/templates/Gemfile @@ -18,17 +18,17 @@ gem "rails", "<%= Rails::VERSION::STRING %>" # ActiveRecord requires a database adapter. By default, # Rails has selected sqlite3. <% end -%> -gem "<%= gem_for_database %>" +gem "<%= gem_for_database %>"<% if require_for_database %>, :require => "<%= require_for_database %>"<% end %> <% end -%> ## Bundle the gems you use: # gem "bj" # gem "hpricot", "0.6" -# gem "sqlite3-ruby", :require_as => "sqlite3" -# gem "aws-s3", :require_as => "aws/s3" +# gem "sqlite3-ruby", :require => "sqlite3" +# gem "aws-s3", :require => "aws/s3" ## Bundle gems used only in certain environments: -# gem "rspec", :only => :test -# only :test do +# gem "rspec", :group => :test +# group :test do # gem "webrat" # end diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 93ef67818d..76579adb26 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -74,6 +74,13 @@ class AppGeneratorTest < Rails::Generators::TestCase def test_config_database_is_added_by_default run_generator assert_file "config/database.yml", /sqlite3/ + assert_file "Gemfile", /^gem "sqlite3-ruby", :require => "sqlite3"$/ + end + + def test_config_another_database + run_generator([destination_root, "-d", "mysql"]) + assert_file "config/database.yml", /mysql/ + assert_file "Gemfile", /^gem "mysql"$/ end def test_config_database_is_not_added_if_skip_activerecord_is_given -- cgit v1.2.3 From d0f98420ea0fd71d09d11017762d863efe6f0b11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 4 Feb 2010 14:05:13 +0100 Subject: Automatically require rubygems when --dev flag is given. --- railties/lib/rails/commands/application.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/railties/lib/rails/commands/application.rb b/railties/lib/rails/commands/application.rb index 0f09e7eafb..fe2f89ee98 100644 --- a/railties/lib/rails/commands/application.rb +++ b/railties/lib/rails/commands/application.rb @@ -4,7 +4,8 @@ if %w(--version -v).include? ARGV.first exit(0) end -ARGV << "--help" if ARGV.empty? +ARGV << "--help" if ARGV.empty? +require 'rubygems' if ARGV.include?("--dev") require 'rails/generators' require 'generators/rails/app/app_generator' -- cgit v1.2.3 From 6d6e6105c074eb9f266619e77a0873635af94124 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Pastorino=20and=20Jos=C3=A9=20Ignacio=20Costa?= Date: Wed, 3 Feb 2010 18:30:08 -0200 Subject: require 'action_controller' added on a test that uses it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- actionmailer/test/old_base/asset_host_test.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/actionmailer/test/old_base/asset_host_test.rb b/actionmailer/test/old_base/asset_host_test.rb index 124032f1d9..aa9cfd88dd 100644 --- a/actionmailer/test/old_base/asset_host_test.rb +++ b/actionmailer/test/old_base/asset_host_test.rb @@ -1,4 +1,5 @@ require 'abstract_unit' +require 'action_controller' class AssetHostMailer < ActionMailer::Base def email_with_asset -- cgit v1.2.3