aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2014-10-28 16:17:33 -0700
committerXavier Noria <fxn@hashref.com>2014-10-28 16:35:24 -0700
commitb3bfa361c503e107aff4dee5edf79bd7fd3d3725 (patch)
tree4a9725f90708b45ff85e68b01335bbf94ee35f17 /actionpack/lib
parent777142d3a7b9ea36fcc8562613749299ac6dc243 (diff)
downloadrails-b3bfa361c503e107aff4dee5edf79bd7fd3d3725.tar.gz
rails-b3bfa361c503e107aff4dee5edf79bd7fd3d3725.tar.bz2
rails-b3bfa361c503e107aff4dee5edf79bd7fd3d3725.zip
let's warn with heredocs
The current style for warning messages without newlines uses concatenation of string literals with manual trailing spaces where needed. Heredocs have better readability, and with `squish` we can still produce a single line. This is a similar use case to the one that motivated defining `strip_heredoc`, heredocs are super clean.
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/metal/strong_parameters.rb11
-rw-r--r--actionpack/lib/action_dispatch/http/response.rb8
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb25
3 files changed, 28 insertions, 16 deletions
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb
index 7038f0997f..a5ee1e2159 100644
--- a/actionpack/lib/action_controller/metal/strong_parameters.rb
+++ b/actionpack/lib/action_controller/metal/strong_parameters.rb
@@ -1,5 +1,6 @@
require 'active_support/core_ext/hash/indifferent_access'
require 'active_support/core_ext/array/wrap'
+require 'active_support/core_ext/string/filters'
require 'active_support/deprecation'
require 'active_support/rescuable'
require 'action_dispatch/http/upload'
@@ -114,10 +115,12 @@ module ActionController
def self.const_missing(const_name)
super unless const_name == :NEVER_UNPERMITTED_PARAMS
- ActiveSupport::Deprecation.warn "`ActionController::Parameters::NEVER_UNPERMITTED_PARAMS`"\
- " has been deprecated. Use "\
- "`ActionController::Parameters.always_permitted_parameters` instead."
- self.always_permitted_parameters
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
+ `ActionController::Parameters::NEVER_UNPERMITTED_PARAMS` has been deprecated.
+ Use `ActionController::Parameters.always_permitted_parameters` instead.
+ MSG
+
+ always_permitted_parameters
end
# Returns a new instance of <tt>ActionController::Parameters</tt>.
diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb
index 99d46af953..2918a98796 100644
--- a/actionpack/lib/action_dispatch/http/response.rb
+++ b/actionpack/lib/action_dispatch/http/response.rb
@@ -1,4 +1,5 @@
require 'active_support/core_ext/module/attribute_accessors'
+require 'active_support/core_ext/string/filters'
require 'active_support/deprecation'
require 'action_dispatch/http/filter_redirect'
require 'monitor'
@@ -288,7 +289,12 @@ module ActionDispatch # :nodoc:
# as arrays work, and "flattening" responses, cascading to the rack body!
# Not sensible behavior.
def to_ary
- ActiveSupport::Deprecation.warn 'ActionDispatch::Response#to_ary no longer performs implicit conversion to an Array. Please use response.to_a instead, or a splat like `status, headers, body = *response`'
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
+ 'ActionDispatch::Response#to_ary no longer performs implicit conversion
+ to an Array. Please use response.to_a instead, or a splat like `status,
+ headers, body = *response`
+ MSG
+
to_a
end
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index 6acee80513..746742a85f 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -6,6 +6,7 @@ require 'active_support/core_ext/object/to_query'
require 'active_support/core_ext/hash/slice'
require 'active_support/core_ext/module/remove_method'
require 'active_support/core_ext/array/extract_options'
+require 'active_support/core_ext/string/filters'
require 'action_controller/metal/exceptions'
require 'action_dispatch/http/request'
require 'action_dispatch/routing/endpoint'
@@ -325,20 +326,22 @@ module ActionDispatch
LEGACY = ->(options) {
if options.key?(:only_path)
if options[:only_path]
- ActiveSupport::Deprecation.warn \
- "You are calling a `*_path` helper with the `only_path` option " \
- "explicitly set to `true`. This option will stop working on " \
- "path helpers in Rails 5. Simply remove the `only_path: true` " \
- "argument from your call as it is redundant when applied to a " \
- "path helper."
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
+ You are calling a `*_path` helper with the `only_path` option
+ explicitly set to `true`. This option will stop working on
+ path helpers in Rails 5. Simply remove the `only_path: true`
+ argument from your call as it is redundant when applied to a
+ path helper.
+ MSG
PATH.call(options)
else
- ActiveSupport::Deprecation.warn \
- "You are calling a `*_path` helper with the `only_path` option " \
- "explicitly set to `false`. This option will stop working on " \
- "path helpers in Rails 5. Use the corresponding `*_url` helper " \
- "instead."
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
+ You are calling a `*_path` helper with the `only_path` option
+ explicitly set to `false`. This option will stop working on
+ path helpers in Rails 5. Use the corresponding `*_url` helper
+ instead.
+ MSG
FULL.call(options)
end