Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge remote branch 'mainstream/master'

Conflicts:
	railties/guides/source/3_0_release_notes.textile
  • Loading branch information...
commit 8260f0b40f8954f1822a0f856f7c0706afbba0bd 2 parents 6241d4e + 6d6e610
@lifo lifo authored
Showing with 418 additions and 4,822 deletions.
  1. +2 −3 .gitignore
  2. +0 −3  .gitmodules
  3. +1 −1  Gemfile
  4. +0 −1  Rakefile
  5. +16 −16 actionmailer/actionmailer.gemspec
  6. +1 −1  actionmailer/lib/action_mailer/version.rb
  7. +1 −0  actionmailer/test/old_base/asset_host_test.rb
  8. +15 −16 actionpack/actionpack.gemspec
  9. +3 −1 actionpack/lib/action_controller/metal/instrumentation.rb
  10. +1 −2  actionpack/lib/action_dispatch/routing/mapper.rb
  11. +1 −1  actionpack/lib/action_pack/version.rb
  12. +4 −17 actionpack/lib/action_view/helpers/form_helper.rb
  13. +1 −3 actionpack/lib/action_view/helpers/form_tag_helper.rb
  14. +3 −3 actionpack/test/template/form_helper_test.rb
  15. +4 −0 actionpack/test/template/form_tag_helper_test.rb
  16. +2 −2 activemodel/activemodel.gemspec
  17. +1 −1  activemodel/lib/active_model/version.rb
  18. +14 −16 activerecord/activerecord.gemspec
  19. +1 −1  activerecord/lib/active_record/base.rb
  20. +11 −0 activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
  21. +1 −1  activerecord/lib/active_record/migration.rb
  22. +8 −1 activerecord/lib/active_record/railties/databases.rake
  23. +1 −1  activerecord/lib/active_record/version.rb
  24. +8 −9 activerecord/lib/generators/active_record.rb
  25. +10 −0 activerecord/test/cases/migration_test.rb
  26. +13 −15 activeresource/activeresource.gemspec
  27. +1 −1  activeresource/lib/active_resource/version.rb
  28. +15 −15 activesupport/activesupport.gemspec
  29. +1 −1  activesupport/lib/active_support/notifications.rb
  30. +1 −3 activesupport/lib/active_support/notifications/fanout.rb
  31. +0 −9 activesupport/lib/active_support/notifications/instrumenter.rb
  32. +1 −1  activesupport/lib/active_support/version.rb
  33. +11 −11 activesupport/test/multibyte_chars_test.rb
  34. +1 −17 activesupport/test/notifications_test.rb
  35. +0 −1  arel
  36. +8 −3 ci/ci_build.rb
  37. +16 −19 rails.gemspec
  38. +8 −0 railties/CHANGELOG
  39. +9 −25 railties/bin/rails
  40. +6 −3 railties/builtin/rails_info/rails/info.rb
  41. +21 −15 railties/lib/generators/rails/app/app_generator.rb
  42. +6 −6 railties/lib/generators/rails/app/templates/Gemfile
  43. +5 −2 railties/lib/generators/rails/app/templates/config/boot.rb
  44. +3 −3 railties/lib/generators/rails/app/templates/config/environments/development.rb.tt
  45. +2 −2 railties/lib/generators/rails/app/templates/config/environments/production.rb.tt
  46. +2 −2 railties/lib/generators/rails/app/templates/config/environments/test.rb.tt
  47. +1 −0  railties/lib/generators/rails/app/templates/gitignore
  48. +1 −1  railties/lib/generators/rails/app/templates/public/index.html
  49. +0 −3  railties/lib/generators/rails/app/templates/script/about
  50. +0 −5 railties/lib/generators/rails/app/templates/script/console.tt
  51. +0 −5 railties/lib/generators/rails/app/templates/script/dbconsole.tt
  52. +0 −2  railties/lib/generators/rails/app/templates/script/destroy
  53. +0 −2  railties/lib/generators/rails/app/templates/script/generate
  54. +0 −2  railties/lib/generators/rails/app/templates/script/performance/benchmarker
  55. +0 −2  railties/lib/generators/rails/app/templates/script/performance/profiler
  56. +0 −2  railties/lib/generators/rails/app/templates/script/plugin
  57. +9 −0 railties/lib/generators/rails/app/templates/script/rails
  58. +0 −3  railties/lib/generators/rails/app/templates/script/runner
  59. +0 −5 railties/lib/generators/rails/app/templates/script/server.tt
  60. +1 −1  railties/lib/generators/rails/mailer/USAGE
  61. +69 −13 railties/lib/rails/commands.rb
  62. +0 −2  railties/lib/rails/commands/about.rb
  63. +13 −0 railties/lib/rails/commands/application.rb
  64. +1 −1  railties/lib/rails/commands/performance/benchmarker.rb
  65. +1 −1  railties/lib/rails/commands/performance/profiler.rb
  66. +1 −1  railties/lib/rails/commands/plugin.rb
  67. +1 −1  railties/lib/rails/commands/runner.rb
  68. +1 −4 railties/lib/rails/generators.rb
  69. +2 −2 railties/lib/rails/generators/base.rb
  70. +25 −26 railties/lib/rails/generators/migration.rb
  71. +1 −1  railties/lib/rails/tasks/annotations.rake
  72. +1 −1  railties/lib/rails/tasks/documentation.rake
  73. +7 −68 railties/lib/rails/tasks/framework.rake
  74. +7 −0 railties/lib/rails/tasks/misc.rake
  75. +1 −0  railties/lib/rails/tasks/routes.rake
  76. +0 −80 railties/lib/rails/vendor/thor-0.12.3/CHANGELOG.rdoc
  77. +0 −20 railties/lib/rails/vendor/thor-0.12.3/LICENSE
  78. +0 −234 railties/lib/rails/vendor/thor-0.12.3/README.rdoc
  79. +0 −63 railties/lib/rails/vendor/thor-0.12.3/Thorfile
  80. +0 −240 railties/lib/rails/vendor/thor-0.12.3/lib/thor.rb
  81. +0 −274 railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions.rb
  82. +0 −103 railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions/create_file.rb
  83. +0 −91 railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions/directory.rb
  84. +0 −134 railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions/empty_directory.rb
  85. +0 −223 railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions/file_manipulation.rb
  86. +0 −101 railties/lib/rails/vendor/thor-0.12.3/lib/thor/actions/inject_into_file.rb
  87. +0 −515 railties/lib/rails/vendor/thor-0.12.3/lib/thor/base.rb
  88. +0 −9 railties/lib/rails/vendor/thor-0.12.3/lib/thor/core_ext/file_binary_read.rb
  89. +0 −75 railties/lib/rails/vendor/thor-0.12.3/lib/thor/core_ext/hash_with_indifferent_access.rb
  90. +0 −100 railties/lib/rails/vendor/thor-0.12.3/lib/thor/core_ext/ordered_hash.rb
  91. +0 −27 railties/lib/rails/vendor/thor-0.12.3/lib/thor/error.rb
  92. +0 −270 railties/lib/rails/vendor/thor-0.12.3/lib/thor/group.rb
  93. +0 −178 railties/lib/rails/vendor/thor-0.12.3/lib/thor/invocation.rb
  94. +0 −4 railties/lib/rails/vendor/thor-0.12.3/lib/thor/parser.rb
  95. +0 −67 railties/lib/rails/vendor/thor-0.12.3/lib/thor/parser/argument.rb
  96. +0 −145 railties/lib/rails/vendor/thor-0.12.3/lib/thor/parser/arguments.rb
  97. +0 −132 railties/lib/rails/vendor/thor-0.12.3/lib/thor/parser/option.rb
  98. +0 −142 railties/lib/rails/vendor/thor-0.12.3/lib/thor/parser/options.rb
  99. +0 −66 railties/lib/rails/vendor/thor-0.12.3/lib/thor/rake_compat.rb
  100. +0 −303 railties/lib/rails/vendor/thor-0.12.3/lib/thor/runner.rb
  101. +0 −78 railties/lib/rails/vendor/thor-0.12.3/lib/thor/shell.rb
  102. +0 −239 railties/lib/rails/vendor/thor-0.12.3/lib/thor/shell/basic.rb
  103. +0 −108 railties/lib/rails/vendor/thor-0.12.3/lib/thor/shell/color.rb
  104. +0 −111 railties/lib/rails/vendor/thor-0.12.3/lib/thor/task.rb
  105. +0 −233 railties/lib/rails/vendor/thor-0.12.3/lib/thor/util.rb
  106. +0 −3  railties/lib/rails/vendor/thor-0.12.3/lib/thor/version.rb
  107. +1 −1  railties/lib/rails/version.rb
  108. +19 −21 railties/railties.gemspec
  109. +11 −24 railties/test/generators/app_generator_test.rb
  110. +4 −0 railties/test/isolation/abstract_unit.rb
View
5 .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
View
3  .gitmodules
@@ -1,3 +0,0 @@
-[submodule "arel"]
- path = arel
- url = git://github.com/rails/arel.git
View
2  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"
View
1  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")
View
32 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.pre'
+ 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.pre')
- 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
View
2  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
View
1  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
View
31 actionpack/actionpack.gemspec
@@ -1,26 +1,25 @@
Gem::Specification.new do |s|
- s.platform = Gem::Platform::RUBY
- s.name = 'actionpack'
- s.version = '3.0.pre'
- 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.add_dependency('activesupport', '= 3.0.pre')
- s.add_dependency('activemodel', '= 3.0.pre')
+ 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
View
4 actionpack/lib/action_controller/metal/instrumentation.rb
@@ -18,7 +18,9 @@ def process_action(action, *args)
: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)
View
3  actionpack/lib/action_dispatch/routing/mapper.rb
@@ -207,8 +207,7 @@ def redirect(*args, &block)
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
View
2  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
View
21 actionpack/lib/action_view/helpers/form_helper.rb
@@ -528,7 +528,7 @@ def fields_for(record_or_name_or_array, *args, &block)
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 @@ def nested_child_index(name)
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
View
4 actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -329,9 +329,7 @@ def check_box_tag(name, value = "1", checked = false, options = {})
# radio_button_tag 'color', "green", true, :class => "color_input"
# # => <input checked="checked" class="color_input" id="color_green" name="color" type="radio" value="green" />
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
View
6 actionpack/test/template/form_helper_test.rb
@@ -1195,8 +1195,8 @@ def test_form_for_with_labelled_builder
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 @@ def test_default_form_builder
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
View
4 actionpack/test/template/form_tag_helper_test.rb
@@ -120,6 +120,10 @@ def test_radio_button_tag
actual = radio_button_tag("person[gender]", "m")
expected = %(<input id="person_gender_m" name="person[gender]" type="radio" value="m" />)
assert_dom_equal expected, actual
+
+ actual = radio_button_tag('ctrlname', 'apache2.2')
+ expected = %(<input id="ctrlname_apache2.2" name="ctrlname" type="radio" value="apache2.2" />)
+ assert_dom_equal expected, actual
end
def test_select_tag
View
4 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/**/*"]
View
2  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
View
30 activerecord/activerecord.gemspec
@@ -1,25 +1,23 @@
Gem::Specification.new do |s|
- s.platform = Gem::Platform::RUBY
- s.name = 'activerecord'
- s.version = '3.0.pre'
- 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.pre')
- s.add_dependency('activemodel', '= 3.0.pre')
- 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
View
2  activerecord/lib/active_record/base.rb
@@ -79,7 +79,7 @@ class WrappedDatabaseException < StatementInvalid
def initialize(message, original_exception)
super(message)
- @original_exception, = original_exception
+ @original_exception = original_exception
end
end
View
11 activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
@@ -24,6 +24,17 @@ def self.sqlite3_connection(config) # :nodoc:
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
View
2  activerecord/lib/active_record/migration.rb
@@ -488,7 +488,7 @@ def migrate
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)
View
9 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 it exists
+ if Rails.env.development? && ActiveRecord::Base.configurations['test']
+ create_database(ActiveRecord::Base.configurations['test'])
+ end
create_database(ActiveRecord::Base.configurations[Rails.env])
end
@@ -196,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
View
2  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
View
17 activerecord/lib/generators/active_record.rb
@@ -16,16 +16,15 @@ def self.source_root
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
View
10 activerecord/test/cases/migration_test.rb
@@ -1350,6 +1350,16 @@ def test_create_table_with_custom_sequence_name
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
View
28 activeresource/activeresource.gemspec
@@ -1,24 +1,22 @@
Gem::Specification.new do |s|
- s.platform = Gem::Platform::RUBY
- s.name = 'activeresource'
- s.version = '3.0.pre'
- 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.pre')
- s.add_dependency('activemodel', '= 3.0.pre')
+ 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
View
2  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
View
30 activesupport/activesupport.gemspec
@@ -1,22 +1,22 @@
Gem::Specification.new do |s|
- s.platform = Gem::Platform::RUBY
- s.name = "activesupport"
- s.version = "3.0.pre"
- 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
View
2  activesupport/lib/active_support/notifications.rb
@@ -45,7 +45,7 @@ module Notifications
class << self
attr_writer :notifier
delegate :publish, :subscribe, :to => :notifier
- delegate :instrument, :instrument!, :to => :instrumenter
+ delegate :instrument, :to => :instrumenter
def notifier
@notifier ||= Notifier.new
View
4 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 @@ def publish(*args)
@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.
View
9 activesupport/lib/active_support/notifications/instrumenter.rb
@@ -20,15 +20,6 @@ def instrument(name, payload={})
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)
View
2  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
View
22 activesupport/test/multibyte_chars_test.rb
@@ -301,10 +301,10 @@ def test_rjust_should_count_characters_instead_of_bytes
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 @@ def test_ljust_should_count_characters_instead_of_bytes
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 @@ def test_center_should_count_charactes_instead_of_bytes
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
View
18 activesupport/test/notifications_test.rb
@@ -67,29 +67,13 @@ def event(*args)
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
1  arel
@@ -1 +0,0 @@
-Subproject commit 0faeb5047407348533db952d9cf93ea59d2526dc
View
11 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
@@ -19,7 +23,7 @@ def rake(*tasks)
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.1.pre1 --prerelease --no-ri --no-rdoc"
cd root_dir do
puts
@@ -105,7 +109,8 @@ def rake(*tasks)
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}"}
View
35 rails.gemspec
@@ -1,26 +1,23 @@
Gem::Specification.new do |s|
- s.platform = Gem::Platform::RUBY
- s.name = 'rails'
- s.version = '3.0.pre'
- 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.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('bundler', '>= 0.9.0.pre')
+ 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.author = "David Heinemeier Hansson"
- s.email = "david@loudthinking.com"
- s.homepage = "http://www.rubyonrails.org"
- s.rubyforge_project = "rails"
+ 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.1.pre1')
end
View
8 railties/CHANGELOG
@@ -1,5 +1,13 @@
*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
+
+ 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]
View
34 railties/bin/rails
@@ -1,27 +1,11 @@
-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 }
-
-require 'rails/version'
-if %w(--version -v).include? ARGV.first
- puts "Rails #{Rails::VERSION::STRING}"
- exit(0)
-end
+if File.exists?(Dir.getwd + '/script/rails')
+ exec(Dir.getwd + '/script/rails', *ARGV)
+else
+ railties_path = File.expand_path('../../lib', __FILE__)
+ $:.unshift(railties_path) if File.directory?(railties_path) && !$:.include?(railties_path)
-ARGV << "--help" if ARGV.empty?
-
-
-require 'rails/generators'
-require 'generators/rails/app/app_generator'
+ require 'rails/ruby_version_check'
+ Signal.trap("INT") { puts; exit }
-Rails::Generators::AppGenerator.start
+ require 'rails/commands/application'
+end
View
9 railties/builtin/rails_info/rails/info.rb
@@ -51,9 +51,12 @@ def freeze_edge_version
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
View
36 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 @@ def create_boot_file
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 @@ def bundle_if_dev_or_edge
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 @@ def dev_or_edge?
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
View
12 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 %>"
@@ -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
View
7 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'
@@ -16,6 +16,9 @@
# require 'rubygems'
end
+# Auto-require all bundled libraries.
+Bundler.require
+
<% unless options[:skip_activerecord] -%>
require 'rails/all'
@@ -40,4 +43,4 @@
require "action_mailer/railtie"
require "active_resource/railtie"
require "rails/test_unit/railtie"
-<% end -%>
+<% end -%>
View
6 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
View
4 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
View
4 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
View
1  railties/lib/generators/rails/app/templates/gitignore
@@ -1,3 +1,4 @@
+.bundle
db/*.sqlite3
log/*.log
tmp/**/*
View
2  railties/lib/generators/rails/app/templates/public/index.html
@@ -255,7 +255,7 @@
<ol>
<li>
- <h2>Use <code>script/generate</code> to create your models and controllers</h2>
+ <h2>Use <code>rails generate</code> to create your models and controllers</h2>
<p>To see all available options, run it without parameters.</p>
</li>
View
3  railties/lib/generators/rails/app/templates/script/about
@@ -1,3 +0,0 @@
-require File.expand_path('../../config/environment', __FILE__)
-$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
-require 'rails/commands/about'
View
5 railties/lib/generators/rails/app/templates/script/console.tt
@@ -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)
View
5 railties/lib/generators/rails/app/templates/script/dbconsole.tt
@@ -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)
View
2  railties/lib/generators/rails/app/templates/script/destroy
@@ -1,2 +0,0 @@
-require File.expand_path('../../config/environment', __FILE__)
-require 'rails/commands/destroy'
View
2  railties/lib/generators/rails/app/templates/script/generate
@@ -1,2 +0,0 @@
-require File.expand_path('../../config/environment', __FILE__)
-require 'rails/commands/generate'
View
2  railties/lib/generators/rails/app/templates/script/performance/benchmarker
@@ -1,2 +0,0 @@
-require File.expand_path('../../../config/environment', __FILE__)
-require 'rails/commands/performance/benchmarker'
View
2  railties/lib/generators/rails/app/templates/script/performance/profiler
@@ -1,2 +0,0 @@
-require File.expand_path('../../../config/environment', __FILE__)
-require 'rails/commands/performance/profiler'
View
2  railties/lib/generators/rails/app/templates/script/plugin
@@ -1,2 +0,0 @@
-require File.expand_path('../../config/application', __FILE__)
-require 'rails/commands/plugin'
View
9 railties/lib/generators/rails/app/templates/script/rails
@@ -0,0 +1,9 @@
+# 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__)
+ROOT_PATH = File.expand_path('../..', __FILE__)
+
+require BOOT_PATH
+require 'rails/commands'
View
3  railties/lib/generators/rails/app/templates/script/runner
@@ -1,3 +0,0 @@
-require File.expand_path('../../config/boot', __FILE__)
-require 'rails/commands/runner'
-require File.expand_path('../../config/environment', __FILE__)
View
5 railties/lib/generators/rails/app/templates/script/server.tt
@@ -1,5 +0,0 @@
-require File.expand_path('../../config/boot', __FILE__)
-require 'rails/commands/server'
-
-Dir.chdir(File.expand_path('../..', __FILE__))
-Rails::Server.start
View
2  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:
View
82 railties/lib/rails/commands.rb
@@ -1,17 +1,73 @@
-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 <command> [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 '--version', '-v'
+ puts "Rails #{Rails::VERSION::STRING}"
+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
View
2  railties/lib/rails/commands/about.rb
@@ -1,2 +0,0 @@
-require 'rails/info'
-puts Rails::Info
View
13 railties/lib/rails/commands/application.rb
@@ -0,0 +1,13 @@
+require 'rails/version'
+if %w(--version -v).include? ARGV.first
+ puts "Rails #{Rails::VERSION::STRING}"
+ exit(0)
+end
+
+ARGV << "--help" if ARGV.empty?
+require 'rubygems' if ARGV.include?("--dev")
+
+require 'rails/generators'
+require 'generators/rails/app/app_generator'
+
+Rails::Generators::AppGenerator.start
View
2  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
View
2  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
View
2  railties/lib/rails/commands/plugin.rb
@@ -295,7 +295,7 @@ def environment=(value)
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 ""
View
2  railties/lib/rails/commands/runner.rb
@@ -5,7 +5,7 @@
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 ""
View
5 railties/lib/rails/generators.rb
@@ -9,8 +9,6 @@
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,8 +173,7 @@ def self.help
groups[base] << namespace
end
- puts "Usage:"
- puts " script/generate GENERATOR [args] [options]"
+ puts "Usage: rails generate GENERATOR [args] [options]"
puts
puts "General options:"
puts " -h, [--help] # Print generators options and usage"
View
4 railties/lib/rails/generators/base.rb
@@ -1,4 +1,4 @@
-require 'thor'
+require 'thor/group'
require 'rails/generators/actions'
module Rails
@@ -261,7 +261,7 @@ def class_collisions(*class_names) #:nodoc:
# 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.
View
51 railties/lib/rails/generators/migration.rb
@@ -5,10 +5,30 @@ module Generators
# 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.send :attr_reader, :migration_number,
- :migration_file_name,
- :migration_class_name
+ base.extend ClassMethods
+ 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:
+ raise NotImplementedError
+ end
end
# Creates a migration template at the given destination. The difference
@@ -26,11 +46,11 @@ def migration_template(source, destination=nil, config={})
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 +59,6 @@ def migration_template(source, destination=nil, config={})
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
View
2  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
View
2  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"
View
75 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
View
7 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'
View
1  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
View
80 railties/lib/rails/vendor/thor-0.12.3/CHANGELOG.rdoc
@@ -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.
View
20 railties/lib/rails/vendor/thor-0.12.3/LICENSE
@@ -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.
View
234 railties/lib/rails/vendor/thor-0.12.3/README.rdoc
@@ -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 <tt>method_options</tt>
-
-* :boolean - is parsed as <tt>--option</tt> or <tt>--option=true</tt>
-* :string - is parsed as <tt>--option=VALUE</tt>
-* :numeric - is parsed as <tt>--option=N</tt>
-* :array - is parsed as <tt>--option=one two three</tt>
-* :hash - is parsed as <tt>--option=name:string age:integer</tt>
-
-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 <tt>:option => :required</tt> 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 <tt>method_option</tt> 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 <tt>desc</tt>)
-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 <tt>method_option</tt>
-and <tt>method_options</tt>, you should use <tt>class_option</tt> and <tt>class_options</tt>.
-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:
-<tt>say</tt>, <tt>ask</tt>, <tt>yes?</tt>, <tt>no?</tt>, <tt>add_file</tt>,
-<tt>remove_file</tt>, <tt>copy_file</tt>, <tt>template</tt>, <tt>directory</tt>,
-<tt>inside</tt>, <tt>run</tt>, <tt>inject_into_file</tt> 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.
View
63 railties/lib/rails/vendor/thor-0.12.3/Thorfile
@@ -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
View
240 railties/lib/rails/vendor/thor-0.12.3/lib/thor.rb
@@ -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<Symbol>:: 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<String>
- # description<String>
- #
- 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