diff options
-rw-r--r-- | actionmailer/Rakefile | 7 | ||||
-rw-r--r-- | actionpack/Rakefile | 7 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/http/request.rb | 10 | ||||
-rw-r--r-- | actionpack/test/dispatch/request_test.rb | 1 | ||||
-rw-r--r-- | actionview/Rakefile | 7 | ||||
-rw-r--r-- | activejob/Rakefile | 7 | ||||
-rw-r--r-- | activemodel/Rakefile | 7 | ||||
-rw-r--r-- | activerecord/Rakefile | 9 | ||||
-rw-r--r-- | activesupport/CHANGELOG.md | 17 | ||||
-rw-r--r-- | activesupport/Rakefile | 7 | ||||
-rw-r--r-- | activesupport/lib/active_support/multibyte/chars.rb | 6 | ||||
-rw-r--r-- | activesupport/lib/active_support/ordered_options.rb | 8 | ||||
-rw-r--r-- | activesupport/test/ordered_options_test.rb | 15 | ||||
-rw-r--r-- | guides/source/action_mailer_basics.md | 2 | ||||
-rw-r--r-- | guides/source/initialization.md | 5 | ||||
-rw-r--r-- | railties/Rakefile | 9 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/Gemfile | 6 |
17 files changed, 60 insertions, 70 deletions
diff --git a/actionmailer/Rakefile b/actionmailer/Rakefile index 8f4de8fafa..33ccbf8ce1 100644 --- a/actionmailer/Rakefile +++ b/actionmailer/Rakefile @@ -26,10 +26,3 @@ spec = eval(File.read('actionmailer.gemspec')) Gem::PackageTask.new(spec) do |p| p.gem_spec = spec end - -desc "Release to rubygems" -task release: :package do - require 'rake/gemcutter' - Rake::Gemcutter::Tasks.new(spec).define - Rake::Task['gem:push'].invoke -end diff --git a/actionpack/Rakefile b/actionpack/Rakefile index 3bd27f8d64..70f9763764 100644 --- a/actionpack/Rakefile +++ b/actionpack/Rakefile @@ -30,13 +30,6 @@ Gem::PackageTask.new(spec) do |p| p.gem_spec = spec end -desc "Release to rubygems" -task :release => :package do - require 'rake/gemcutter' - Rake::Gemcutter::Tasks.new(spec).define - Rake::Task['gem:push'].invoke -end - task :lines do load File.expand_path('..', File.dirname(__FILE__)) + '/tools/line_statistics' files = FileList["lib/**/*.rb"] diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb index 0f5c5a8eb1..f3de19db0b 100644 --- a/actionpack/lib/action_dispatch/http/request.rb +++ b/actionpack/lib/action_dispatch/http/request.rb @@ -235,11 +235,13 @@ module ActionDispatch end alias :xhr? :xml_http_request? + # Returns the IP address of client as a +String+. def ip @ip ||= super end - # Originating IP address, usually set by the RemoteIp middleware. + # Returns the IP address of client as a +String+, + # usually set by the RemoteIp middleware. def remote_ip @remote_ip ||= (@env["action_dispatch.remote_ip"] || ip).to_s end @@ -256,13 +258,13 @@ module ActionDispatch env[ACTION_DISPATCH_REQUEST_ID] end - def request_id=(id) + def request_id=(id) # :nodoc: env[ACTION_DISPATCH_REQUEST_ID] = id end alias_method :uuid, :request_id - def x_request_id + def x_request_id # :nodoc @env[HTTP_X_REQUEST_ID] end @@ -293,6 +295,8 @@ module ActionDispatch end end + # returns true if request content mime type is + # +application/x-www-form-urlencoded+ or +multipart/form-data+. def form_data? FORM_DATA_MEDIA_TYPES.include?(content_mime_type.to_s) end diff --git a/actionpack/test/dispatch/request_test.rb b/actionpack/test/dispatch/request_test.rb index f208cfda89..27ee8603e4 100644 --- a/actionpack/test/dispatch/request_test.rb +++ b/actionpack/test/dispatch/request_test.rb @@ -663,6 +663,7 @@ class RequestMethod < BaseRequestTest assert_equal 'GET', request.request_method assert_equal 'GET', request.env["REQUEST_METHOD"] + assert request.get? end test "invalid http method raises exception" do diff --git a/actionview/Rakefile b/actionview/Rakefile index 2b752b83df..4ecc9c6c6c 100644 --- a/actionview/Rakefile +++ b/actionview/Rakefile @@ -51,13 +51,6 @@ Gem::PackageTask.new(spec) do |p| p.gem_spec = spec end -desc "Release to rubygems" -task :release => :package do - require 'rake/gemcutter' - Rake::Gemcutter::Tasks.new(spec).define - Rake::Task['gem:push'].invoke -end - task :lines do lines, codelines, total_lines, total_codelines = 0, 0, 0, 0 diff --git a/activejob/Rakefile b/activejob/Rakefile index 0e36bb81b3..ab35170e3c 100644 --- a/activejob/Rakefile +++ b/activejob/Rakefile @@ -81,10 +81,3 @@ spec = eval(File.read('activejob.gemspec')) Gem::PackageTask.new(spec) do |p| p.gem_spec = spec end - -desc 'Release to rubygems' -task release: :package do - require 'rake/gemcutter' - Rake::Gemcutter::Tasks.new(spec).define - Rake::Task['gem:push'].invoke -end diff --git a/activemodel/Rakefile b/activemodel/Rakefile index 7256285a41..4a7098a97d 100644 --- a/activemodel/Rakefile +++ b/activemodel/Rakefile @@ -27,10 +27,3 @@ spec = eval(File.read("#{dir}/activemodel.gemspec")) Gem::PackageTask.new(spec) do |p| p.gem_spec = spec end - -desc "Release to rubygems" -task :release => :package do - require 'rake/gemcutter' - Rake::Gemcutter::Tasks.new(spec).define - Rake::Task['gem:push'].invoke -end diff --git a/activerecord/Rakefile b/activerecord/Rakefile index fa53926eb2..407f92952d 100644 --- a/activerecord/Rakefile +++ b/activerecord/Rakefile @@ -157,12 +157,3 @@ spec = eval(File.read('activerecord.gemspec')) Gem::PackageTask.new(spec) do |p| p.gem_spec = spec end - -# Publishing ------------------------------------------------------ - -desc "Release to rubygems" -task :release => :package do - require 'rake/gemcutter' - Rake::Gemcutter::Tasks.new(spec).define - Rake::Task['gem:push'].invoke -end diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index 36be5fe936..2fac308d2e 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -1,3 +1,20 @@ +* Add a bang version to `ActiveSupport::OrderedOptions` get methods which will raise + an `KeyError` if the value is `.blank?` + + Before: + + if (slack_url = Rails.application.secrets.slack_url).present?) + # Do something worthwhile + else + # Raise as important secret password is not specified + end + + After: + + slack_url = Rails.application.secrets.slack_url! + + *Aditya Sanghi*, *Gaurish Sharma* + * Remove deprecated `Class#superclass_delegating_accessor`. Use `Class#class_attribute` instead. diff --git a/activesupport/Rakefile b/activesupport/Rakefile index 7c40df8dc8..22f0c90d30 100644 --- a/activesupport/Rakefile +++ b/activesupport/Rakefile @@ -23,10 +23,3 @@ spec = eval(File.read('activesupport.gemspec')) Gem::PackageTask.new(spec) do |p| p.gem_spec = spec end - -desc "Release to rubygems" -task :release => :package do - require 'rake/gemcutter' - Rake::Gemcutter::Tasks.new(spec).define - Rake::Task['gem:push'].invoke -end diff --git a/activesupport/lib/active_support/multibyte/chars.rb b/activesupport/lib/active_support/multibyte/chars.rb index 9b3cfd18e2..45cf6fc1ef 100644 --- a/activesupport/lib/active_support/multibyte/chars.rb +++ b/activesupport/lib/active_support/multibyte/chars.rb @@ -88,6 +88,12 @@ module ActiveSupport #:nodoc: # Works like <tt>String#slice!</tt>, but returns an instance of # Chars, or nil if the string was not modified. + # + # string = 'Welcome' + # string.mb_chars.slice!(3) # => #<ActiveSupport::Multibyte::Chars:0x000000038109b8 @wrapped_string="c"> + # string # => 'Welome' + # string.mb_chars.slice!(0..3) # => #<ActiveSupport::Multibyte::Chars:0x00000002eb80a0 @wrapped_string="Welo"> + # string # => 'me' def slice!(*args) chars(@wrapped_string.slice!(*args)) end diff --git a/activesupport/lib/active_support/ordered_options.rb b/activesupport/lib/active_support/ordered_options.rb index a33e2c58a9..bc0326473d 100644 --- a/activesupport/lib/active_support/ordered_options.rb +++ b/activesupport/lib/active_support/ordered_options.rb @@ -31,7 +31,13 @@ module ActiveSupport if name_string.chomp!('=') self[name_string] = args.first else - self[name] + bangs = name_string.chomp!('!') + + if bangs + fetch(name_string.to_sym).presence || raise(KeyError.new("#{name_string} is blank.")) + else + self[name_string] + end end end diff --git a/activesupport/test/ordered_options_test.rb b/activesupport/test/ordered_options_test.rb index fdc745b23b..18767a3536 100644 --- a/activesupport/test/ordered_options_test.rb +++ b/activesupport/test/ordered_options_test.rb @@ -85,4 +85,19 @@ class OrderedOptionsTest < ActiveSupport::TestCase assert_equal 42, a.method(:blah=).call(42) assert_equal 42, a.method(:blah).call end + + def test_raises_with_bang + a = ActiveSupport::OrderedOptions.new + a[:foo] = :bar + assert a.respond_to?(:foo!) + + assert_nothing_raised { a.foo! } + assert_equal a.foo, a.foo! + + assert_raises(KeyError) do + a.foo = nil + a.foo! + end + assert_raises(KeyError) { a.non_existing_key! } + end end diff --git a/guides/source/action_mailer_basics.md b/guides/source/action_mailer_basics.md index 92a4081233..bf3bf5d19e 100644 --- a/guides/source/action_mailer_basics.md +++ b/guides/source/action_mailer_basics.md @@ -344,7 +344,7 @@ The same format can be used to set carbon copy (Cc:) and blind carbon copy Sometimes you wish to show the name of the person instead of just their email address when they receive the email. The trick to doing that is to format the -email address in the format `"Full Name <email>"`. +email address in the format `"Full Name" <email>`. ```ruby def welcome_email(user) diff --git a/guides/source/initialization.md b/guides/source/initialization.md index fb499e7b6d..0e9881e5dc 100644 --- a/guides/source/initialization.md +++ b/guides/source/initialization.md @@ -557,9 +557,8 @@ I18n and Rails configuration are all being defined here. The rest of `config/application.rb` defines the configuration for the `Rails::Application` which will be used once the application is fully initialized. When `config/application.rb` has finished loading Rails and defined -the application namespace, we go back to `config/environment.rb`, -where the application is initialized. For example, if the application was called -`Blog`, here we would find `Rails.application.initialize!`, which is +the application namespace, we go back to `config/environment.rb`. Here, the +application is initialized with `Rails.application.initialize!`, which is defined in `rails/application.rb`. ### `railties/lib/rails/application.rb` diff --git a/railties/Rakefile b/railties/Rakefile index 9a377ce4ee..7e2cda6102 100644 --- a/railties/Rakefile +++ b/railties/Rakefile @@ -39,12 +39,3 @@ spec = eval(File.read('railties.gemspec')) Gem::PackageTask.new(spec) do |pkg| pkg.gem_spec = spec end - -# Publishing ------------------------------------------------------- - -desc "Release to rubygems" -task :release => :package do - require 'rake/gemcutter' - Rake::Gemcutter::Tasks.new(spec).define - Rake::Task['gem:push'].invoke -end diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile index c11bb58bfa..29203b9c37 100644 --- a/railties/lib/rails/generators/rails/app/templates/Gemfile +++ b/railties/lib/rails/generators/rails/app/templates/Gemfile @@ -21,11 +21,13 @@ source 'https://rubygems.org' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development -group :development, :test do <% if RUBY_ENGINE == 'ruby' -%> +group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug' +end +group :development do # Access an IRB console on exception pages or by using <%%= console %> in views <%- if options.dev? || options.edge? -%> gem 'web-console', github: "rails/web-console" @@ -36,8 +38,8 @@ group :development, :test do # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' <% end -%> -<% end -%> end +<% end -%> <% if RUBY_PLATFORM.match(/bccwin|cygwin|emx|mingw|mswin|wince|java/) -%> # Windows does not include zoneinfo files, so bundle the tzinfo-data gem |