From 63fff600accb41b56a3e6ac403d9b1732de3086d Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sat, 6 Aug 2016 19:36:34 +0200 Subject: modernizes hash syntax in actionview --- actionview/lib/action_view/base.rb | 6 +- .../lib/action_view/helpers/asset_tag_helper.rb | 10 +-- .../lib/action_view/helpers/asset_url_helper.rb | 2 +- .../lib/action_view/helpers/atom_feed_helper.rb | 8 +-- .../lib/action_view/helpers/controller_helper.rb | 2 +- actionview/lib/action_view/helpers/csrf_helper.rb | 4 +- actionview/lib/action_view/helpers/date_helper.rb | 76 +++++++++++----------- actionview/lib/action_view/helpers/debug_helper.rb | 4 +- .../action_view/helpers/output_safety_helper.rb | 6 +- .../lib/action_view/helpers/rendering_helper.rb | 4 +- actionview/lib/action_view/helpers/tags/base.rb | 6 +- .../action_view/helpers/tags/collection_select.rb | 4 +- .../helpers/tags/grouped_collection_select.rb | 4 +- .../lib/action_view/helpers/tags/password_field.rb | 2 +- actionview/lib/action_view/helpers/tags/select.rb | 4 +- actionview/lib/action_view/layouts.rb | 2 +- .../lib/action_view/renderer/abstract_renderer.rb | 2 +- .../renderer/streaming_template_renderer.rb | 2 +- .../lib/action_view/renderer/template_renderer.rb | 6 +- .../lib/action_view/tasks/cache_digests.rake | 4 +- .../lib/action_view/template/handlers/erb.rb | 4 +- actionview/lib/action_view/template/resolver.rb | 12 ++-- actionview/lib/action_view/test_case.rb | 2 +- actionview/lib/action_view/testing/resolvers.rb | 10 +-- actionview/lib/action_view/view_paths.rb | 2 +- 25 files changed, 94 insertions(+), 94 deletions(-) (limited to 'actionview/lib') diff --git a/actionview/lib/action_view/base.rb b/actionview/lib/action_view/base.rb index c614302657..d9a9d3d8ce 100644 --- a/actionview/lib/action_view/base.rb +++ b/actionview/lib/action_view/base.rb @@ -169,7 +169,7 @@ module ActionView #:nodoc: class_attribute :logger class << self - delegate :erb_trim_mode=, :to => "ActionView::Template::Handlers::ERB" + delegate :erb_trim_mode=, to: "ActionView::Template::Handlers::ERB" def cache_template_loading ActionView::Resolver.caching? @@ -187,8 +187,8 @@ module ActionView #:nodoc: attr_accessor :view_renderer attr_internal :config, :assigns - delegate :lookup_context, :to => :view_renderer - delegate :formats, :formats=, :locale, :locale=, :view_paths, :view_paths=, :to => :lookup_context + delegate :lookup_context, to: :view_renderer + delegate :formats, :formats=, :locale, :locale=, :view_paths, :view_paths=, to: :lookup_context def assign(new_assigns) # :nodoc: @_assigns = new_assigns.each { |key, value| instance_variable_set("@#{key}", value) } diff --git a/actionview/lib/action_view/helpers/asset_tag_helper.rb b/actionview/lib/action_view/helpers/asset_tag_helper.rb index a3064046e4..6cac4bc0ad 100644 --- a/actionview/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionview/lib/action_view/helpers/asset_tag_helper.rb @@ -139,7 +139,7 @@ module ActionView "rel" => tag_options[:rel] || "alternate", "type" => tag_options[:type] || Template::Types[type].to_s, "title" => tag_options[:title] || type.to_s.upcase, - "href" => url_options.is_a?(Hash) ? url_for(url_options.merge(:only_path => false)) : url_options + "href" => url_options.is_a?(Hash) ? url_for(url_options.merge(only_path: false)) : url_options ) end @@ -172,9 +172,9 @@ module ActionView # # => def favicon_link_tag(source="favicon.ico", options={}) tag("link", { - :rel => "shortcut icon", - :type => "image/x-icon", - :href => path_to_image(source) + rel: "shortcut icon", + type: "image/x-icon", + href: path_to_image(source) }.merge!(options.symbolize_keys)) end @@ -313,7 +313,7 @@ module ActionView if sources.size > 1 content_tag(type, options) do - safe_join sources.map { |source| tag("source", :src => send("path_to_#{type}", source)) } + safe_join sources.map { |source| tag("source", src: send("path_to_#{type}", source)) } end else options[:src] = send("path_to_#{type}", sources.first) diff --git a/actionview/lib/action_view/helpers/asset_url_helper.rb b/actionview/lib/action_view/helpers/asset_url_helper.rb index ca9846b90d..7bd3027880 100644 --- a/actionview/lib/action_view/helpers/asset_url_helper.rb +++ b/actionview/lib/action_view/helpers/asset_url_helper.rb @@ -169,7 +169,7 @@ module ActionView # asset_url "application.js", host: "http://cdn.example.com" # => http://cdn.example.com/assets/application.js # def asset_url(source, options = {}) - path_to_asset(source, options.merge(:protocol => :request)) + path_to_asset(source, options.merge(protocol: :request)) end alias_method :url_to_asset, :asset_url # aliased to avoid conflicts with an asset_url named route diff --git a/actionview/lib/action_view/helpers/atom_feed_helper.rb b/actionview/lib/action_view/helpers/atom_feed_helper.rb index 9a713d573e..46e4172e5d 100644 --- a/actionview/lib/action_view/helpers/atom_feed_helper.rb +++ b/actionview/lib/action_view/helpers/atom_feed_helper.rb @@ -117,8 +117,8 @@ module ActionView xml.feed(feed_opts) do xml.id(options[:id] || "tag:#{request.host},#{options[:schema_date]}:#{request.fullpath.split(".")[0]}") - xml.link(:rel => "alternate", :type => "text/html", :href => options[:root_url] || (request.protocol + request.host_with_port)) - xml.link(:rel => "self", :type => "application/atom+xml", :href => options[:url] || request.url) + xml.link(rel: "alternate", type: "text/html", href: options[:root_url] || (request.protocol + request.host_with_port)) + xml.link(rel: "self", type: "application/atom+xml", href: options[:url] || request.url) yield AtomFeedBuilder.new(xml, self, options) end @@ -138,7 +138,7 @@ module ActionView def method_missing(method, *arguments, &block) if xhtml_block?(method, arguments) @xml.__send__(method, *arguments) do - @xml.div(:xmlns => "http://www.w3.org/1999/xhtml") do |xhtml| + @xml.div(xmlns: "http://www.w3.org/1999/xhtml") do |xhtml| block.call(xhtml) end end @@ -192,7 +192,7 @@ module ActionView type = options.fetch(:type, "text/html") url = options.fetch(:url) { @view.polymorphic_url(record) } - @xml.link(:rel => "alternate", :type => type, :href => url) if url + @xml.link(rel: "alternate", type: type, href: url) if url yield AtomBuilder.new(@xml) end diff --git a/actionview/lib/action_view/helpers/controller_helper.rb b/actionview/lib/action_view/helpers/controller_helper.rb index 645c30c2ea..e86cdca4e4 100644 --- a/actionview/lib/action_view/helpers/controller_helper.rb +++ b/actionview/lib/action_view/helpers/controller_helper.rb @@ -8,7 +8,7 @@ module ActionView attr_internal :controller, :request delegate :request_forgery_protection_token, :params, :session, :cookies, :response, :headers, - :flash, :action_name, :controller_name, :controller_path, :to => :controller + :flash, :action_name, :controller_name, :controller_path, to: :controller def assign_controller(controller) if @_controller = controller diff --git a/actionview/lib/action_view/helpers/csrf_helper.rb b/actionview/lib/action_view/helpers/csrf_helper.rb index ba3693b413..d07115a5ee 100644 --- a/actionview/lib/action_view/helpers/csrf_helper.rb +++ b/actionview/lib/action_view/helpers/csrf_helper.rb @@ -20,8 +20,8 @@ module ActionView def csrf_meta_tags if protect_against_forgery? [ - tag("meta", :name => "csrf-param", :content => request_forgery_protection_token), - tag("meta", :name => "csrf-token", :content => form_authenticity_token) + tag("meta", name: "csrf-param", content: request_forgery_protection_token), + tag("meta", name: "csrf-token", content: form_authenticity_token) ].join("\n").html_safe end end diff --git a/actionview/lib/action_view/helpers/date_helper.rb b/actionview/lib/action_view/helpers/date_helper.rb index a6740b3eec..f2ef714e8e 100644 --- a/actionview/lib/action_view/helpers/date_helper.rb +++ b/actionview/lib/action_view/helpers/date_helper.rb @@ -101,34 +101,34 @@ module ActionView distance_in_minutes = ((to_time - from_time)/60.0).round distance_in_seconds = (to_time - from_time).round - I18n.with_options :locale => options[:locale], :scope => options[:scope] do |locale| + I18n.with_options locale: options[:locale], scope: options[:scope] do |locale| case distance_in_minutes when 0..1 return distance_in_minutes == 0 ? - locale.t(:less_than_x_minutes, :count => 1) : - locale.t(:x_minutes, :count => distance_in_minutes) unless options[:include_seconds] + locale.t(:less_than_x_minutes, count: 1) : + locale.t(:x_minutes, count: distance_in_minutes) unless options[:include_seconds] case distance_in_seconds - when 0..4 then locale.t :less_than_x_seconds, :count => 5 - when 5..9 then locale.t :less_than_x_seconds, :count => 10 - when 10..19 then locale.t :less_than_x_seconds, :count => 20 + when 0..4 then locale.t :less_than_x_seconds, count: 5 + when 5..9 then locale.t :less_than_x_seconds, count: 10 + when 10..19 then locale.t :less_than_x_seconds, count: 20 when 20..39 then locale.t :half_a_minute - when 40..59 then locale.t :less_than_x_minutes, :count => 1 - else locale.t :x_minutes, :count => 1 + when 40..59 then locale.t :less_than_x_minutes, count: 1 + else locale.t :x_minutes, count: 1 end - when 2...45 then locale.t :x_minutes, :count => distance_in_minutes - when 45...90 then locale.t :about_x_hours, :count => 1 + when 2...45 then locale.t :x_minutes, count: distance_in_minutes + when 45...90 then locale.t :about_x_hours, count: 1 # 90 mins up to 24 hours - when 90...1440 then locale.t :about_x_hours, :count => (distance_in_minutes.to_f / 60.0).round + when 90...1440 then locale.t :about_x_hours, count: (distance_in_minutes.to_f / 60.0).round # 24 hours up to 42 hours - when 1440...2520 then locale.t :x_days, :count => 1 + when 1440...2520 then locale.t :x_days, count: 1 # 42 hours up to 30 days - when 2520...43200 then locale.t :x_days, :count => (distance_in_minutes.to_f / 1440.0).round + when 2520...43200 then locale.t :x_days, count: (distance_in_minutes.to_f / 1440.0).round # 30 days up to 60 days - when 43200...86400 then locale.t :about_x_months, :count => (distance_in_minutes.to_f / 43200.0).round + when 43200...86400 then locale.t :about_x_months, count: (distance_in_minutes.to_f / 43200.0).round # 60 days up to 365 days - when 86400...525600 then locale.t :x_months, :count => (distance_in_minutes.to_f / 43200.0).round + when 86400...525600 then locale.t :x_months, count: (distance_in_minutes.to_f / 43200.0).round else if from_time.acts_like?(:time) && to_time.acts_like?(:time) fyear = from_time.year @@ -149,11 +149,11 @@ module ActionView remainder = (minutes_with_offset % MINUTES_IN_YEAR) distance_in_years = (minutes_with_offset.div MINUTES_IN_YEAR) if remainder < MINUTES_IN_QUARTER_YEAR - locale.t(:about_x_years, :count => distance_in_years) + locale.t(:about_x_years, count: distance_in_years) elsif remainder < MINUTES_IN_THREE_QUARTERS_YEAR - locale.t(:over_x_years, :count => distance_in_years) + locale.t(:over_x_years, count: distance_in_years) else - locale.t(:almost_x_years, :count => distance_in_years + 1) + locale.t(:almost_x_years, count: distance_in_years + 1) end end end @@ -682,10 +682,10 @@ module ActionView def time_tag(date_or_time, *args, &block) options = args.extract_options! format = options.delete(:format) || :long - content = args.first || I18n.l(date_or_time, :format => format) + content = args.first || I18n.l(date_or_time, format: format) datetime = date_or_time.acts_like?(:time) ? date_or_time.xmlschema : date_or_time.iso8601 - content_tag("time".freeze, content, options.reverse_merge(:datetime => datetime), &block) + content_tag("time".freeze, content, options.reverse_merge(datetime: datetime), &block) end end @@ -694,7 +694,7 @@ module ActionView DEFAULT_PREFIX = "date".freeze POSITION = { - :year => 1, :month => 2, :day => 3, :hour => 4, :minute => 5, :second => 6 + year: 1, month: 2, day: 3, hour: 4, minute: 5, second: 6 }.freeze AMPM_TRANSLATION = Hash[ @@ -781,7 +781,7 @@ module ActionView if @options[:use_hidden] || @options[:discard_minute] build_hidden(:minute, min) else - build_options_and_select(:minute, min, :step => @options[:minute_step]) + build_options_and_select(:minute, min, step: @options[:minute_step]) end end @@ -801,7 +801,7 @@ module ActionView if @options[:use_hidden] || @options[:discard_day] build_hidden(:day, day || 1) else - build_options_and_select(:day, day, :start => 1, :end => 31, :leading_zeros => false, :use_two_digit_numbers => @options[:use_two_digit_numbers]) + build_options_and_select(:day, day, start: 1, end: 31, leading_zeros: false, use_two_digit_numbers: @options[:use_two_digit_numbers]) end end @@ -811,7 +811,7 @@ module ActionView else month_options = [] 1.upto(12) do |month_number| - options = { :value => month_number } + options = { value: month_number } options[:selected] = "selected" if month == month_number month_options << content_tag("option".freeze, month_name(month_number), options) + "\n" end @@ -861,7 +861,7 @@ module ActionView # valid. Otherwise, February 31st or February 29th, 2011 can be selected, which are invalid. def set_day_if_discarded if @datetime && @options[:discard_day] - @datetime = @datetime.change(:day => 1) + @datetime = @datetime.change(day: 1) end end @@ -886,7 +886,7 @@ module ActionView # "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] def translated_month_names key = @options[:use_short_month] ? :'date.abbr_month_names' : :'date.month_names' - I18n.translate(key, :locale => @options[:locale]) + I18n.translate(key, locale: @options[:locale]) end # Looks up month names by number (1-based): @@ -929,7 +929,7 @@ module ActionView end def translated_date_order - date_order = I18n.translate(:'date.order', :locale => @options[:locale], :default => []) + date_order = I18n.translate(:'date.order', locale: @options[:locale], default: []) date_order = date_order.map(&:to_sym) forbidden_elements = date_order - [:year, :month, :day] @@ -976,7 +976,7 @@ module ActionView select_options = [] start.step(stop, step) do |i| value = leading_zeros ? sprintf("%02d", i) : i - tag_options = { :value => value } + tag_options = { value: value } tag_options[:selected] = "selected" if selected == i text = options[:use_two_digit_numbers] ? sprintf("%02d", i) : value text = options[:ampm] ? AMPM_TRANSLATION[i] : text @@ -993,14 +993,14 @@ module ActionView # " def build_select(type, select_options_as_html) select_options = { - :id => input_id_from_type(type), - :name => input_name_from_type(type) + id: input_id_from_type(type), + name: input_name_from_type(type) }.merge!(@html_options) select_options[:disabled] = "disabled" if @options[:disabled] select_options[:class] = css_class_attribute(type, select_options[:class], @options[:with_css_classes]) if @options[:with_css_classes] select_html = "\n" - select_html << content_tag("option".freeze, "", :value => "") + "\n" if @options[:include_blank] + select_html << content_tag("option".freeze, "", value: "") + "\n" if @options[:include_blank] select_html << prompt_option_tag(type, @options[:prompt]) + "\n" if @options[:prompt] select_html << select_options_as_html @@ -1027,15 +1027,15 @@ module ActionView def prompt_option_tag(type, options) prompt = case options when Hash - default_options = {:year => false, :month => false, :day => false, :hour => false, :minute => false, :second => false} + default_options = {year: false, month: false, day: false, hour: false, minute: false, second: false} default_options.merge!(options)[type.to_sym] when String options else - I18n.translate(:"datetime.prompts.#{type}", :locale => @options[:locale]) + I18n.translate(:"datetime.prompts.#{type}", locale: @options[:locale]) end - prompt ? content_tag("option".freeze, prompt, :value => "") : "" + prompt ? content_tag("option".freeze, prompt, value: "") : "" end # Builds hidden input tag for date part and value. @@ -1043,10 +1043,10 @@ module ActionView # => "" def build_hidden(type, value) select_options = { - :type => "hidden", - :id => input_id_from_type(type), - :name => input_name_from_type(type), - :value => value + type: "hidden", + id: input_id_from_type(type), + name: input_name_from_type(type), + value: value }.merge!(@html_options.slice(:disabled)) select_options[:disabled] = "disabled" if @options[:disabled] diff --git a/actionview/lib/action_view/helpers/debug_helper.rb b/actionview/lib/action_view/helpers/debug_helper.rb index e9dccbad1c..468a798d93 100644 --- a/actionview/lib/action_view/helpers/debug_helper.rb +++ b/actionview/lib/action_view/helpers/debug_helper.rb @@ -25,10 +25,10 @@ module ActionView def debug(object) Marshal::dump(object) object = ERB::Util.html_escape(object.to_yaml) - content_tag(:pre, object, :class => "debug_dump") + content_tag(:pre, object, class: "debug_dump") rescue # errors from Marshal or YAML # Object couldn't be dumped, perhaps because of singleton methods -- this is the fallback - content_tag(:code, object.inspect, :class => "debug_dump") + content_tag(:code, object.inspect, class: "debug_dump") end end end diff --git a/actionview/lib/action_view/helpers/output_safety_helper.rb b/actionview/lib/action_view/helpers/output_safety_helper.rb index f84bff7d06..8e63e59fac 100644 --- a/actionview/lib/action_view/helpers/output_safety_helper.rb +++ b/actionview/lib/action_view/helpers/output_safety_helper.rb @@ -42,9 +42,9 @@ module ActionView #:nodoc: options.assert_valid_keys(:words_connector, :two_words_connector, :last_word_connector, :locale) default_connectors = { - :words_connector => ", ", - :two_words_connector => " and ", - :last_word_connector => ", and " + words_connector: ", ", + two_words_connector: " and ", + last_word_connector: ", and " } if defined?(I18n) i18n_connectors = I18n.translate(:'support.array', locale: options[:locale], default: {}) diff --git a/actionview/lib/action_view/helpers/rendering_helper.rb b/actionview/lib/action_view/helpers/rendering_helper.rb index c98f2d74a8..7d7f2393ff 100644 --- a/actionview/lib/action_view/helpers/rendering_helper.rb +++ b/actionview/lib/action_view/helpers/rendering_helper.rb @@ -27,12 +27,12 @@ module ActionView case options when Hash if block_given? - view_renderer.render_partial(self, options.merge(:partial => options[:layout]), &block) + view_renderer.render_partial(self, options.merge(partial: options[:layout]), &block) else view_renderer.render(self, options) end else - view_renderer.render_partial(self, :partial => options, :locals => locals, &block) + view_renderer.render_partial(self, partial: options, locals: locals, &block) end end diff --git a/actionview/lib/action_view/helpers/tags/base.rb b/actionview/lib/action_view/helpers/tags/base.rb index 0c4b9570e3..a86600aeb9 100644 --- a/actionview/lib/action_view/helpers/tags/base.rb +++ b/actionview/lib/action_view/helpers/tags/base.rb @@ -130,7 +130,7 @@ module ActionView select = content_tag("select", add_options(option_tags, options, value), html_options) if html_options["multiple"] && options.fetch(:include_hidden, true) - tag("input", :disabled => html_options["disabled"], :name => html_options["name"], :type => "hidden", :value => "") + select + tag("input", disabled: html_options["disabled"], name: html_options["name"], type: "hidden", value: "") + select else select end @@ -143,10 +143,10 @@ module ActionView def add_options(option_tags, options, value = nil) if options[:include_blank] - option_tags = tag_builder.content_tag_string("option", options[:include_blank].kind_of?(String) ? options[:include_blank] : nil, :value => "") + "\n" + option_tags + option_tags = tag_builder.content_tag_string("option", options[:include_blank].kind_of?(String) ? options[:include_blank] : nil, value: "") + "\n" + option_tags end if value.blank? && options[:prompt] - option_tags = tag_builder.content_tag_string("option", prompt_text(options[:prompt]), :value => "") + "\n" + option_tags + option_tags = tag_builder.content_tag_string("option", prompt_text(options[:prompt]), value: "") + "\n" + option_tags end option_tags end diff --git a/actionview/lib/action_view/helpers/tags/collection_select.rb b/actionview/lib/action_view/helpers/tags/collection_select.rb index 6cb2b2e0d3..4365c714eb 100644 --- a/actionview/lib/action_view/helpers/tags/collection_select.rb +++ b/actionview/lib/action_view/helpers/tags/collection_select.rb @@ -13,8 +13,8 @@ module ActionView def render option_tags_options = { - :selected => @options.fetch(:selected) { value(@object) }, - :disabled => @options[:disabled] + selected: @options.fetch(:selected) { value(@object) }, + disabled: @options[:disabled] } select_content_tag( diff --git a/actionview/lib/action_view/helpers/tags/grouped_collection_select.rb b/actionview/lib/action_view/helpers/tags/grouped_collection_select.rb index 2ed4712dac..20e312dd0f 100644 --- a/actionview/lib/action_view/helpers/tags/grouped_collection_select.rb +++ b/actionview/lib/action_view/helpers/tags/grouped_collection_select.rb @@ -15,8 +15,8 @@ module ActionView def render option_tags_options = { - :selected => @options.fetch(:selected) { value(@object) }, - :disabled => @options[:disabled] + selected: @options.fetch(:selected) { value(@object) }, + disabled: @options[:disabled] } select_content_tag( diff --git a/actionview/lib/action_view/helpers/tags/password_field.rb b/actionview/lib/action_view/helpers/tags/password_field.rb index 6099fa6f19..274c27df82 100644 --- a/actionview/lib/action_view/helpers/tags/password_field.rb +++ b/actionview/lib/action_view/helpers/tags/password_field.rb @@ -3,7 +3,7 @@ module ActionView module Tags # :nodoc: class PasswordField < TextField # :nodoc: def render - @options = {:value => nil}.merge!(@options) + @options = {value: nil}.merge!(@options) super end end diff --git a/actionview/lib/action_view/helpers/tags/select.rb b/actionview/lib/action_view/helpers/tags/select.rb index 180900cc8d..dcfe8ae757 100644 --- a/actionview/lib/action_view/helpers/tags/select.rb +++ b/actionview/lib/action_view/helpers/tags/select.rb @@ -13,8 +13,8 @@ module ActionView def render option_tags_options = { - :selected => @options.fetch(:selected) { value(@object) }, - :disabled => @options[:disabled] + selected: @options.fetch(:selected) { value(@object) }, + disabled: @options[:disabled] } option_tags = if grouped_choices? diff --git a/actionview/lib/action_view/layouts.rb b/actionview/lib/action_view/layouts.rb index b6015c62cf..f1730a5aae 100644 --- a/actionview/lib/action_view/layouts.rb +++ b/actionview/lib/action_view/layouts.rb @@ -205,7 +205,7 @@ module ActionView include ActionView::Rendering included do - class_attribute :_layout, :_layout_conditions, :instance_accessor => false + class_attribute :_layout, :_layout_conditions, instance_accessor: false self._layout = nil self._layout_conditions = {} _write_layout_method diff --git a/actionview/lib/action_view/renderer/abstract_renderer.rb b/actionview/lib/action_view/renderer/abstract_renderer.rb index 1dddf53df0..baff791987 100644 --- a/actionview/lib/action_view/renderer/abstract_renderer.rb +++ b/actionview/lib/action_view/renderer/abstract_renderer.rb @@ -15,7 +15,7 @@ module ActionView # that new object is called in turn. This abstracts the setup and rendering # into a separate classes for partials and templates. class AbstractRenderer #:nodoc: - delegate :find_template, :find_file, :template_exists?, :any_templates?, :with_fallbacks, :with_layout_format, :formats, :to => :@lookup_context + delegate :find_template, :find_file, :template_exists?, :any_templates?, :with_fallbacks, :with_layout_format, :formats, to: :@lookup_context def initialize(lookup_context) @lookup_context = lookup_context diff --git a/actionview/lib/action_view/renderer/streaming_template_renderer.rb b/actionview/lib/action_view/renderer/streaming_template_renderer.rb index 5587d59834..f49cf589f8 100644 --- a/actionview/lib/action_view/renderer/streaming_template_renderer.rb +++ b/actionview/lib/action_view/renderer/streaming_template_renderer.rb @@ -64,7 +64,7 @@ module ActionView output = ActionView::StreamingBuffer.new(buffer) yielder = lambda { |*name| view._layout_for(*name) } - instrument(:template, :identifier => template.identifier, :layout => layout.try(:virtual_path)) do + instrument(:template, identifier: template.identifier, layout: layout.try(:virtual_path)) do fiber = Fiber.new do if layout layout.render(view, locals, output, &yielder) diff --git a/actionview/lib/action_view/renderer/template_renderer.rb b/actionview/lib/action_view/renderer/template_renderer.rb index fcc8ff3d6a..333413c4a1 100644 --- a/actionview/lib/action_view/renderer/template_renderer.rb +++ b/actionview/lib/action_view/renderer/template_renderer.rb @@ -32,7 +32,7 @@ module ActionView with_fallbacks { find_file(options[:file], nil, false, keys, @details) } elsif options.key?(:inline) handler = Template.handler_for_extension(options[:type] || "erb") - Template.new(options[:inline], "inline template", handler, :locals => keys) + Template.new(options[:inline], "inline template", handler, locals: keys) elsif options.key?(:template) if options[:template].respond_to?(:render) options[:template] @@ -50,7 +50,7 @@ module ActionView view, locals = @view, locals || {} render_with_layout(layout_name, locals) do |layout| - instrument(:template, :identifier => template.identifier, :layout => layout.try(:virtual_path)) do + instrument(:template, identifier: template.identifier, layout: layout.try(:virtual_path)) do template.render(view, locals) { |*name| view._layout_for(*name) } end end @@ -89,7 +89,7 @@ module ActionView find_template(layout, nil, false, [], details) end rescue ActionView::MissingTemplate - all_details = @details.merge(:formats => @lookup_context.default_formats) + all_details = @details.merge(formats: @lookup_context.default_formats) raise unless template_exists?(layout, nil, false, [], all_details) end when Proc diff --git a/actionview/lib/action_view/tasks/cache_digests.rake b/actionview/lib/action_view/tasks/cache_digests.rake index ad7c6851b1..d30b3f7797 100644 --- a/actionview/lib/action_view/tasks/cache_digests.rake +++ b/actionview/lib/action_view/tasks/cache_digests.rake @@ -1,12 +1,12 @@ namespace :cache_digests do desc "Lookup nested dependencies for TEMPLATE (like messages/show or comments/_comment.html)" - task :nested_dependencies => :environment do + task nested_dependencies: :environment do abort "You must provide TEMPLATE for the task to run" unless ENV["TEMPLATE"].present? puts JSON.pretty_generate ActionView::Digestor.tree(CacheDigests.template_name, CacheDigests.finder).children.map(&:to_dep_map) end desc "Lookup first-level dependencies for TEMPLATE (like messages/show or comments/_comment.html)" - task :dependencies => :environment do + task dependencies: :environment do abort "You must provide TEMPLATE for the task to run" unless ENV["TEMPLATE"].present? puts JSON.pretty_generate ActionView::Digestor.tree(CacheDigests.template_name, CacheDigests.finder).children.map(&:name) end diff --git a/actionview/lib/action_view/template/handlers/erb.rb b/actionview/lib/action_view/template/handlers/erb.rb index 375153e4fc..6f07de1813 100644 --- a/actionview/lib/action_view/template/handlers/erb.rb +++ b/actionview/lib/action_view/template/handlers/erb.rb @@ -119,8 +119,8 @@ module ActionView self.class.erb_implementation.new( erb, - :escape => (self.class.escape_whitelist.include? template.type), - :trim => (self.class.erb_trim_mode == "-") + escape: (self.class.escape_whitelist.include? template.type), + trim: (self.class.erb_trim_mode == "-") ).src end diff --git a/actionview/lib/action_view/template/resolver.rb b/actionview/lib/action_view/template/resolver.rb index aa107f9923..6a7baf4fbc 100644 --- a/actionview/lib/action_view/template/resolver.rb +++ b/actionview/lib/action_view/template/resolver.rb @@ -37,7 +37,7 @@ module ActionView class Cache #:nodoc: class SmallCache < Concurrent::Map def initialize(options = {}) - super(options.merge(:initial_capacity => 2)) + super(options.merge(initial_capacity: 2)) end end @@ -204,7 +204,7 @@ module ActionView # An abstract class that implements a Resolver with path semantics. class PathResolver < Resolver #:nodoc: - EXTENSIONS = { :locale => ".", :formats => ".", :variants => "+", :handlers => "." } + EXTENSIONS = { locale: ".", formats: ".", variants: "+", handlers: "." } DEFAULT_PATTERN = ":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}" def initialize(pattern=nil) @@ -230,10 +230,10 @@ module ActionView contents = File.binread(template) Template.new(contents, File.expand_path(template), handler, - :virtual_path => path.virtual, - :format => format, - :variant => variant, - :updated_at => mtime(template) + virtual_path: path.virtual, + format: format, + variant: variant, + updated_at: mtime(template) ) end end diff --git a/actionview/lib/action_view/test_case.rb b/actionview/lib/action_view/test_case.rb index 88a7c99e49..29be7dc7a8 100644 --- a/actionview/lib/action_view/test_case.rb +++ b/actionview/lib/action_view/test_case.rb @@ -49,7 +49,7 @@ module ActionView include ActiveSupport::Testing::ConstantLookup - delegate :lookup_context, :to => :controller + delegate :lookup_context, to: :controller attr_accessor :controller, :output_buffer, :rendered module ClassMethods diff --git a/actionview/lib/action_view/testing/resolvers.rb b/actionview/lib/action_view/testing/resolvers.rb index 27ad6ca70e..1a92dd71b1 100644 --- a/actionview/lib/action_view/testing/resolvers.rb +++ b/actionview/lib/action_view/testing/resolvers.rb @@ -33,10 +33,10 @@ module ActionView #:nodoc: next unless query.match?(_path) handler, format, variant = extract_handler_and_format_and_variant(_path, formats) templates << Template.new(source, _path, handler, - :virtual_path => path.virtual, - :format => format, - :variant => variant, - :updated_at => updated_at + virtual_path: path.virtual, + format: format, + variant: variant, + updated_at: updated_at ) end @@ -47,7 +47,7 @@ module ActionView #:nodoc: class NullResolver < PathResolver def query(path, exts, formats, _) handler, format, variant = extract_handler_and_format_and_variant(path, formats) - [ActionView::Template.new("Template generated by Null Resolver", path.virtual, handler, :virtual_path => path.virtual, :format => format, :variant => variant)] + [ActionView::Template.new("Template generated by Null Resolver", path.virtual, handler, virtual_path: path.virtual, format: format, variant: variant)] end end end diff --git a/actionview/lib/action_view/view_paths.rb b/actionview/lib/action_view/view_paths.rb index 717d6866c5..b07940195d 100644 --- a/actionview/lib/action_view/view_paths.rb +++ b/actionview/lib/action_view/view_paths.rb @@ -9,7 +9,7 @@ module ActionView end delegate :template_exists?, :any_templates?, :view_paths, :formats, :formats=, - :locale, :locale=, :to => :lookup_context + :locale, :locale=, to: :lookup_context module ClassMethods def _prefixes # :nodoc: -- cgit v1.2.3