diff options
Diffstat (limited to 'actionview/lib')
-rw-r--r-- | actionview/lib/action_view/base.rb | 2 | ||||
-rw-r--r-- | actionview/lib/action_view/helpers/asset_url_helper.rb | 24 | ||||
-rw-r--r-- | actionview/lib/action_view/helpers/atom_feed_helper.rb | 4 | ||||
-rw-r--r-- | actionview/lib/action_view/helpers/date_helper.rb | 6 | ||||
-rw-r--r-- | actionview/lib/action_view/helpers/javascript_helper.rb | 2 | ||||
-rw-r--r-- | actionview/lib/action_view/helpers/tag_helper.rb | 4 | ||||
-rw-r--r-- | actionview/lib/action_view/helpers/tags/base.rb | 4 | ||||
-rw-r--r-- | actionview/lib/action_view/helpers/tags/password_field.rb | 2 | ||||
-rw-r--r-- | actionview/lib/action_view/helpers/url_helper.rb | 2 | ||||
-rw-r--r-- | actionview/lib/action_view/layouts.rb | 2 | ||||
-rw-r--r-- | actionview/lib/action_view/renderer/partial_renderer.rb | 2 | ||||
-rw-r--r-- | actionview/lib/action_view/renderer/template_renderer.rb | 2 | ||||
-rw-r--r-- | actionview/lib/action_view/template/resolver.rb | 8 | ||||
-rw-r--r-- | actionview/lib/action_view/test_case.rb | 2 | ||||
-rw-r--r-- | actionview/lib/action_view/testing/resolvers.rb | 4 | ||||
-rw-r--r-- | actionview/lib/action_view/view_paths.rb | 2 |
16 files changed, 36 insertions, 36 deletions
diff --git a/actionview/lib/action_view/base.rb b/actionview/lib/action_view/base.rb index d9a9d3d8ce..b7c05fdb88 100644 --- a/actionview/lib/action_view/base.rb +++ b/actionview/lib/action_view/base.rb @@ -141,7 +141,7 @@ module ActionView #:nodoc: # Specify the proc used to decorate input tags that refer to attributes with errors. cattr_accessor :field_error_proc - @@field_error_proc = Proc.new{ |html_tag, instance| "<div class=\"field_with_errors\">#{html_tag}</div>".html_safe } + @@field_error_proc = Proc.new { |html_tag, instance| "<div class=\"field_with_errors\">#{html_tag}</div>".html_safe } # How to complete the streaming when an exception occurs. # This is our best guess: first try to close the attribute, then the tag. diff --git a/actionview/lib/action_view/helpers/asset_url_helper.rb b/actionview/lib/action_view/helpers/asset_url_helper.rb index 7bd3027880..76a4893f2e 100644 --- a/actionview/lib/action_view/helpers/asset_url_helper.rb +++ b/actionview/lib/action_view/helpers/asset_url_helper.rb @@ -254,7 +254,7 @@ module ActionView # javascript_path "http://www.example.com/js/xmlhr" # => http://www.example.com/js/xmlhr # javascript_path "http://www.example.com/js/xmlhr.js" # => http://www.example.com/js/xmlhr.js def javascript_path(source, options = {}) - path_to_asset(source, {type: :javascript}.merge!(options)) + path_to_asset(source, { type: :javascript }.merge!(options)) end alias_method :path_to_javascript, :javascript_path # aliased to avoid conflicts with a javascript_path named route @@ -266,7 +266,7 @@ module ActionView # javascript_url "js/xmlhr.js", host: "http://stage.example.com" # => http://stage.example.com/assets/dir/xmlhr.js # def javascript_url(source, options = {}) - url_to_asset(source, {type: :javascript}.merge!(options)) + url_to_asset(source, { type: :javascript }.merge!(options)) end alias_method :url_to_javascript, :javascript_url # aliased to avoid conflicts with a javascript_url named route @@ -281,7 +281,7 @@ module ActionView # stylesheet_path "http://www.example.com/css/style" # => http://www.example.com/css/style # stylesheet_path "http://www.example.com/css/style.css" # => http://www.example.com/css/style.css def stylesheet_path(source, options = {}) - path_to_asset(source, {type: :stylesheet}.merge!(options)) + path_to_asset(source, { type: :stylesheet }.merge!(options)) end alias_method :path_to_stylesheet, :stylesheet_path # aliased to avoid conflicts with a stylesheet_path named route @@ -293,7 +293,7 @@ module ActionView # stylesheet_url "css/style.css", host: "http://stage.example.com" # => http://stage.example.com/css/style.css # def stylesheet_url(source, options = {}) - url_to_asset(source, {type: :stylesheet}.merge!(options)) + url_to_asset(source, { type: :stylesheet }.merge!(options)) end alias_method :url_to_stylesheet, :stylesheet_url # aliased to avoid conflicts with a stylesheet_url named route @@ -311,7 +311,7 @@ module ActionView # The alias +path_to_image+ is provided to avoid that. Rails uses the alias internally, and # plugin authors are encouraged to do so. def image_path(source, options = {}) - path_to_asset(source, {type: :image}.merge!(options)) + path_to_asset(source, { type: :image }.merge!(options)) end alias_method :path_to_image, :image_path # aliased to avoid conflicts with an image_path named route @@ -323,7 +323,7 @@ module ActionView # image_url "edit.png", host: "http://stage.example.com" # => http://stage.example.com/edit.png # def image_url(source, options = {}) - url_to_asset(source, {type: :image}.merge!(options)) + url_to_asset(source, { type: :image }.merge!(options)) end alias_method :url_to_image, :image_url # aliased to avoid conflicts with an image_url named route @@ -337,7 +337,7 @@ module ActionView # video_path("/trailers/hd.avi") # => /trailers/hd.avi # video_path("http://www.example.com/vid/hd.avi") # => http://www.example.com/vid/hd.avi def video_path(source, options = {}) - path_to_asset(source, {type: :video}.merge!(options)) + path_to_asset(source, { type: :video }.merge!(options)) end alias_method :path_to_video, :video_path # aliased to avoid conflicts with a video_path named route @@ -349,7 +349,7 @@ module ActionView # video_url "hd.avi", host: "http://stage.example.com" # => http://stage.example.com/hd.avi # def video_url(source, options = {}) - url_to_asset(source, {type: :video}.merge!(options)) + url_to_asset(source, { type: :video }.merge!(options)) end alias_method :url_to_video, :video_url # aliased to avoid conflicts with an video_url named route @@ -363,7 +363,7 @@ module ActionView # audio_path("/sounds/horse.wav") # => /sounds/horse.wav # audio_path("http://www.example.com/sounds/horse.wav") # => http://www.example.com/sounds/horse.wav def audio_path(source, options = {}) - path_to_asset(source, {type: :audio}.merge!(options)) + path_to_asset(source, { type: :audio }.merge!(options)) end alias_method :path_to_audio, :audio_path # aliased to avoid conflicts with an audio_path named route @@ -375,7 +375,7 @@ module ActionView # audio_url "horse.wav", host: "http://stage.example.com" # => http://stage.example.com/horse.wav # def audio_url(source, options = {}) - url_to_asset(source, {type: :audio}.merge!(options)) + url_to_asset(source, { type: :audio }.merge!(options)) end alias_method :url_to_audio, :audio_url # aliased to avoid conflicts with an audio_url named route @@ -388,7 +388,7 @@ module ActionView # font_path("/dir/font.ttf") # => /dir/font.ttf # font_path("http://www.example.com/dir/font.ttf") # => http://www.example.com/dir/font.ttf def font_path(source, options = {}) - path_to_asset(source, {type: :font}.merge!(options)) + path_to_asset(source, { type: :font }.merge!(options)) end alias_method :path_to_font, :font_path # aliased to avoid conflicts with an font_path named route @@ -400,7 +400,7 @@ module ActionView # font_url "font.ttf", host: "http://stage.example.com" # => http://stage.example.com/font.ttf # def font_url(source, options = {}) - url_to_asset(source, {type: :font}.merge!(options)) + url_to_asset(source, { type: :font }.merge!(options)) end alias_method :url_to_font, :font_url # aliased to avoid conflicts with an font_url named route end diff --git a/actionview/lib/action_view/helpers/atom_feed_helper.rb b/actionview/lib/action_view/helpers/atom_feed_helper.rb index e5d063e03c..09d243c46d 100644 --- a/actionview/lib/action_view/helpers/atom_feed_helper.rb +++ b/actionview/lib/action_view/helpers/atom_feed_helper.rb @@ -112,8 +112,8 @@ module ActionView end end - feed_opts = {"xml:lang" => options[:language] || "en-US", "xmlns" => "http://www.w3.org/2005/Atom"} - feed_opts.merge!(options).reject!{|k,v| !k.to_s.match(/^xml/)} + feed_opts = { "xml:lang" => options[:language] || "en-US", "xmlns" => "http://www.w3.org/2005/Atom" } + feed_opts.merge!(options).reject! { |k,v| !k.to_s.match(/^xml/) } xml.feed(feed_opts) do xml.id(options[:id] || "tag:#{request.host},#{options[:schema_date]}:#{request.fullpath.split(".")[0]}") diff --git a/actionview/lib/action_view/helpers/date_helper.rb b/actionview/lib/action_view/helpers/date_helper.rb index 99db209d63..74c6f0ab1c 100644 --- a/actionview/lib/action_view/helpers/date_helper.rb +++ b/actionview/lib/action_view/helpers/date_helper.rb @@ -135,7 +135,7 @@ module ActionView fyear += 1 if from_time.month >= 3 tyear = to_time.year tyear -= 1 if to_time.month < 3 - leap_years = (fyear > tyear) ? 0 : (fyear..tyear).count{|x| Date.leap?(x)} + leap_years = (fyear > tyear) ? 0 : (fyear..tyear).count { |x| Date.leap?(x) } minute_offset_for_leap_year = leap_years * 1440 # Discount the leap year days when calculating year distance. # e.g. if there are 20 leap year days between 2 dates having the same day @@ -918,7 +918,7 @@ module ActionView elsif @options[:add_month_numbers] "#{number} - #{month_names[number]}" elsif format_string = @options[:month_format_string] - format_string % {number: number, name: month_names[number]} + format_string % { number: number, name: month_names[number] } else month_names[number] end @@ -1027,7 +1027,7 @@ 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 diff --git a/actionview/lib/action_view/helpers/javascript_helper.rb b/actionview/lib/action_view/helpers/javascript_helper.rb index 8f7be4905d..22e1e74ad6 100644 --- a/actionview/lib/action_view/helpers/javascript_helper.rb +++ b/actionview/lib/action_view/helpers/javascript_helper.rb @@ -24,7 +24,7 @@ module ActionView # $('some_element').replaceWith('<%= j render 'some/element_template' %>'); def escape_javascript(javascript) if javascript - result = javascript.gsub(/(\\|<\/|\r\n|\342\200\250|\342\200\251|[\n\r"'])/u) {|match| JS_ESCAPE_MAP[match] } + result = javascript.gsub(/(\\|<\/|\r\n|\342\200\250|\342\200\251|[\n\r"'])/u) { |match| JS_ESCAPE_MAP[match] } javascript.html_safe? ? result.html_safe : result else "" diff --git a/actionview/lib/action_view/helpers/tag_helper.rb b/actionview/lib/action_view/helpers/tag_helper.rb index 030d07845b..4950f272a4 100644 --- a/actionview/lib/action_view/helpers/tag_helper.rb +++ b/actionview/lib/action_view/helpers/tag_helper.rb @@ -88,9 +88,9 @@ module ActionView if value.is_a?(Array) value = escape ? safe_join(value, " ") : value.join(" ") else - value = escape ? ERB::Util.unwrapped_html_escape(value) : value + value = escape ? ERB::Util.unwrapped_html_escape(value) : value.to_s end - %(#{key}="#{value}") + %(#{key}="#{value.gsub(/"/, '"'.freeze)}") end private diff --git a/actionview/lib/action_view/helpers/tags/base.rb b/actionview/lib/action_view/helpers/tags/base.rb index 43335023ce..e3e3c8b109 100644 --- a/actionview/lib/action_view/helpers/tags/base.rb +++ b/actionview/lib/action_view/helpers/tags/base.rb @@ -80,8 +80,8 @@ module ActionView def add_default_name_and_id(options) index = name_and_id_index(options) - options["name"] = options.fetch("name"){ tag_name(options["multiple"], index) } - options["id"] = options.fetch("id"){ tag_id(index) } + options["name"] = options.fetch("name") { tag_name(options["multiple"], index) } + options["id"] = options.fetch("id") { tag_id(index) } if namespace = options.delete("namespace") options["id"] = options["id"] ? "#{namespace}_#{options['id']}" : namespace end diff --git a/actionview/lib/action_view/helpers/tags/password_field.rb b/actionview/lib/action_view/helpers/tags/password_field.rb index 274c27df82..444ef65074 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/url_helper.rb b/actionview/lib/action_view/helpers/url_helper.rb index 82aeeedad9..dad0e9dac3 100644 --- a/actionview/lib/action_view/helpers/url_helper.rb +++ b/actionview/lib/action_view/helpers/url_helper.rb @@ -570,7 +570,7 @@ module ActionView html_options else - link_to_remote_options?(options) ? {"data-remote" => "true".freeze} : {} + link_to_remote_options?(options) ? { "data-remote" => "true".freeze } : {} end end diff --git a/actionview/lib/action_view/layouts.rb b/actionview/lib/action_view/layouts.rb index b2fcd823d2..b6bf6b9374 100644 --- a/actionview/lib/action_view/layouts.rb +++ b/actionview/lib/action_view/layouts.rb @@ -266,7 +266,7 @@ module ActionView def layout(layout, conditions = {}) include LayoutConditions unless conditions.empty? - conditions.each {|k, v| conditions[k] = Array(v).map(&:to_s) } + conditions.each { |k, v| conditions[k] = Array(v).map(&:to_s) } self._layout_conditions = conditions self._layout = layout diff --git a/actionview/lib/action_view/renderer/partial_renderer.rb b/actionview/lib/action_view/renderer/partial_renderer.rb index 92bd0ccf91..4314e1ff71 100644 --- a/actionview/lib/action_view/renderer/partial_renderer.rb +++ b/actionview/lib/action_view/renderer/partial_renderer.rb @@ -346,7 +346,7 @@ module ActionView view._layout_for(*name, &block) end - content = layout.render(view, locals){ content } if layout + content = layout.render(view, locals) { content } if layout content end end diff --git a/actionview/lib/action_view/renderer/template_renderer.rb b/actionview/lib/action_view/renderer/template_renderer.rb index 0151653b73..331a5ea228 100644 --- a/actionview/lib/action_view/renderer/template_renderer.rb +++ b/actionview/lib/action_view/renderer/template_renderer.rb @@ -63,7 +63,7 @@ module ActionView if layout view = @view view.view_flow.set(:layout, content) - layout.render(view, locals){ |*name| view._layout_for(*name) } + layout.render(view, locals) { |*name| view._layout_for(*name) } else content end diff --git a/actionview/lib/action_view/template/resolver.rb b/actionview/lib/action_view/template/resolver.rb index 33d60be144..20c2d5c782 100644 --- a/actionview/lib/action_view/template/resolver.rb +++ b/actionview/lib/action_view/template/resolver.rb @@ -42,10 +42,10 @@ module ActionView end # preallocate all the default blocks for performance/memory consumption reasons - PARTIAL_BLOCK = lambda {|cache, partial| cache[partial] = SmallCache.new} - PREFIX_BLOCK = lambda {|cache, prefix| cache[prefix] = SmallCache.new(&PARTIAL_BLOCK)} - NAME_BLOCK = lambda {|cache, name| cache[name] = SmallCache.new(&PREFIX_BLOCK)} - KEY_BLOCK = lambda {|cache, key| cache[key] = SmallCache.new(&NAME_BLOCK)} + PARTIAL_BLOCK = lambda { |cache, partial| cache[partial] = SmallCache.new } + PREFIX_BLOCK = lambda { |cache, prefix| cache[prefix] = SmallCache.new(&PARTIAL_BLOCK) } + NAME_BLOCK = lambda { |cache, name| cache[name] = SmallCache.new(&PREFIX_BLOCK) } + KEY_BLOCK = lambda { |cache, key| cache[key] = SmallCache.new(&NAME_BLOCK) } # usually a majority of template look ups return nothing, use this canonical preallocated array to save memory NO_TEMPLATES = [].freeze diff --git a/actionview/lib/action_view/test_case.rb b/actionview/lib/action_view/test_case.rb index 2945aceb3e..2805cfe612 100644 --- a/actionview/lib/action_view/test_case.rb +++ b/actionview/lib/action_view/test_case.rb @@ -145,7 +145,7 @@ module ActionView def view_rendered?(view, expected_locals) locals_for(view).any? do |actual_locals| - expected_locals.all? {|key, value| value == actual_locals[key] } + expected_locals.all? { |key, value| value == actual_locals[key] } end end end diff --git a/actionview/lib/action_view/testing/resolvers.rb b/actionview/lib/action_view/testing/resolvers.rb index 1a92dd71b1..5cb9f66529 100644 --- a/actionview/lib/action_view/testing/resolvers.rb +++ b/actionview/lib/action_view/testing/resolvers.rb @@ -23,7 +23,7 @@ module ActionView #:nodoc: def query(path, exts, formats, _) query = "" EXTENSIONS.each_key do |ext| - query << "(" << exts[ext].map {|e| e && Regexp.escape(".#{e}") }.join("|") << "|)" + query << "(" << exts[ext].map { |e| e && Regexp.escape(".#{e}") }.join("|") << "|)" end query = /^(#{Regexp.escape(path)})#{query}$/ @@ -40,7 +40,7 @@ module ActionView #:nodoc: ) end - templates.sort_by {|t| -t.identifier.match(/^#{query}$/).captures.reject(&:blank?).size } + templates.sort_by { |t| -t.identifier.match(/^#{query}$/).captures.reject(&:blank?).size } end end diff --git a/actionview/lib/action_view/view_paths.rb b/actionview/lib/action_view/view_paths.rb index 6b6cbcf06a..2ed62ca88f 100644 --- a/actionview/lib/action_view/view_paths.rb +++ b/actionview/lib/action_view/view_paths.rb @@ -43,7 +43,7 @@ module ActionView end def details_for_lookup - { } + {} end def append_view_path(path) |