diff options
author | Xavier Noria <fxn@hashref.com> | 2014-10-28 16:17:33 -0700 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2014-10-28 16:35:24 -0700 |
commit | b3bfa361c503e107aff4dee5edf79bd7fd3d3725 (patch) | |
tree | 4a9725f90708b45ff85e68b01335bbf94ee35f17 /actionpack/lib/action_dispatch | |
parent | 777142d3a7b9ea36fcc8562613749299ac6dc243 (diff) | |
download | rails-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/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/http/response.rb | 8 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 25 |
2 files changed, 21 insertions, 12 deletions
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 |