diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2016-10-29 01:05:58 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2016-10-29 01:17:49 -0200 |
commit | fe1f4b2ad56f010a4e9b93d547d63a15953d9dc2 (patch) | |
tree | 49257bdeadca12d5b167800a25d58dd50c0d6ddb /actionview/lib/action_view | |
parent | f81a5ffbdec6c1d748aaef02ba10a6e0d86cbf3f (diff) | |
download | rails-fe1f4b2ad56f010a4e9b93d547d63a15953d9dc2.tar.gz rails-fe1f4b2ad56f010a4e9b93d547d63a15953d9dc2.tar.bz2 rails-fe1f4b2ad56f010a4e9b93d547d63a15953d9dc2.zip |
Add more rubocop rules about whitespaces
Diffstat (limited to 'actionview/lib/action_view')
21 files changed, 33 insertions, 33 deletions
diff --git a/actionview/lib/action_view/context.rb b/actionview/lib/action_view/context.rb index ee263df484..31aa73a0cf 100644 --- a/actionview/lib/action_view/context.rb +++ b/actionview/lib/action_view/context.rb @@ -28,7 +28,7 @@ module ActionView # returns the correct buffer on +yield+. This is usually # overwritten by helpers to add more behavior. # :api: plugin - def _layout_for(name=nil) + def _layout_for(name = nil) name ||= :layout view_flow.get(name).html_safe end diff --git a/actionview/lib/action_view/flows.rb b/actionview/lib/action_view/flows.rb index 16874c1194..6d5f57a570 100644 --- a/actionview/lib/action_view/flows.rb +++ b/actionview/lib/action_view/flows.rb @@ -5,7 +5,7 @@ module ActionView attr_reader :content def initialize - @content = Hash.new { |h,k| h[k] = ActiveSupport::SafeBuffer.new } + @content = Hash.new { |h, k| h[k] = ActiveSupport::SafeBuffer.new } end # Called by _layout_for to read stored values. diff --git a/actionview/lib/action_view/helpers/asset_tag_helper.rb b/actionview/lib/action_view/helpers/asset_tag_helper.rb index 39fa11ccfd..4e4f4823e6 100644 --- a/actionview/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionview/lib/action_view/helpers/asset_tag_helper.rb @@ -168,7 +168,7 @@ module ActionView # # favicon_link_tag 'mb-icon.png', rel: 'apple-touch-icon', type: 'image/png' # # => <link href="/assets/mb-icon.png" rel="apple-touch-icon" type="image/png" /> - def favicon_link_tag(source="favicon.ico", options={}) + def favicon_link_tag(source = "favicon.ico", options = {}) tag("link", { rel: "shortcut icon", type: "image/x-icon", @@ -206,7 +206,7 @@ module ActionView # # => <img alt="Icon" class="menu_icon" src="/icons/icon.gif" /> # image_tag("/icons/icon.gif", data: { title: 'Rails Application' }) # # => <img data-title="Rails Application" src="/icons/icon.gif" /> - def image_tag(source, options={}) + def image_tag(source, options = {}) options = options.symbolize_keys check_for_image_tag_errors(options) diff --git a/actionview/lib/action_view/helpers/atom_feed_helper.rb b/actionview/lib/action_view/helpers/atom_feed_helper.rb index 09d243c46d..cef8098f67 100644 --- a/actionview/lib/action_view/helpers/atom_feed_helper.rb +++ b/actionview/lib/action_view/helpers/atom_feed_helper.rb @@ -103,7 +103,7 @@ module ActionView xml = options.delete(:xml) || eval("xml", block.binding) xml.instruct! if options[:instruct] - options[:instruct].each do |target,attrs| + options[:instruct].each do |target, attrs| if attrs.respond_to?(:keys) xml.instruct!(target, attrs) elsif attrs.respond_to?(:each) @@ -113,7 +113,7 @@ module ActionView 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.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/cache_helper.rb b/actionview/lib/action_view/helpers/cache_helper.rb index 5258a01144..87d341d862 100644 --- a/actionview/lib/action_view/helpers/cache_helper.rb +++ b/actionview/lib/action_view/helpers/cache_helper.rb @@ -218,7 +218,7 @@ module ActionView def fragment_name_with_digest(name, virtual_path) #:nodoc: virtual_path ||= @virtual_path if virtual_path - name = controller.url_for(name).split("://").last if name.is_a?(Hash) + name = controller.url_for(name).split("://").last if name.is_a?(Hash) digest = Digestor.digest name: virtual_path, finder: lookup_context, dependencies: view_cache_dependencies [ name, digest ] else diff --git a/actionview/lib/action_view/helpers/date_helper.rb b/actionview/lib/action_view/helpers/date_helper.rb index ea7259a25d..8ec351b360 100644 --- a/actionview/lib/action_view/helpers/date_helper.rb +++ b/actionview/lib/action_view/helpers/date_helper.rb @@ -98,7 +98,7 @@ module ActionView from_time = from_time.to_time if from_time.respond_to?(:to_time) to_time = to_time.to_time if to_time.respond_to?(:to_time) from_time, to_time = to_time, from_time if from_time > to_time - distance_in_minutes = ((to_time - from_time)/60.0).round + 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| diff --git a/actionview/lib/action_view/helpers/form_helper.rb b/actionview/lib/action_view/helpers/form_helper.rb index 124a14f1d9..9bffe860db 100644 --- a/actionview/lib/action_view/helpers/form_helper.rb +++ b/actionview/lib/action_view/helpers/form_helper.rb @@ -1569,7 +1569,7 @@ module ActionView index = if options.has_key?(:index) options[:index] elsif defined?(@auto_index) - self.object_name = @object_name.to_s.sub(/\[\]$/,"") + self.object_name = @object_name.to_s.sub(/\[\]$/, "") @auto_index end @@ -1809,7 +1809,7 @@ module ActionView # post: # create: "Add %{model}" # - def submit(value=nil, options={}) + def submit(value = nil, options = {}) value, options = nil, value if value.is_a?(Hash) value ||= submit_default_value @template.submit_tag(value, options) diff --git a/actionview/lib/action_view/helpers/output_safety_helper.rb b/actionview/lib/action_view/helpers/output_safety_helper.rb index 8e63e59fac..9f1a890f6a 100644 --- a/actionview/lib/action_view/helpers/output_safety_helper.rb +++ b/actionview/lib/action_view/helpers/output_safety_helper.rb @@ -28,7 +28,7 @@ module ActionView #:nodoc: # safe_join([raw("<p>foo</p>"), raw("<p>bar</p>")], raw("<br />") # # => "<p>foo</p><br /><p>bar</p>" # - def safe_join(array, sep=$,) + def safe_join(array, sep = $,) sep = ERB::Util.unwrapped_html_escape(sep) array.flatten.map! { |i| ERB::Util.unwrapped_html_escape(i) }.join(sep).html_safe diff --git a/actionview/lib/action_view/helpers/tags/base.rb b/actionview/lib/action_view/helpers/tags/base.rb index e3e3c8b109..cf8a6d6028 100644 --- a/actionview/lib/action_view/helpers/tags/base.rb +++ b/actionview/lib/action_view/helpers/tags/base.rb @@ -11,7 +11,7 @@ module ActionView @object_name, @method_name = object_name.to_s.dup, method_name.to_s.dup @template_object = template_object - @object_name.sub!(/\[\]$/,"") || @object_name.sub!(/\[\]\]$/,"]") + @object_name.sub!(/\[\]$/, "") || @object_name.sub!(/\[\]\]$/, "]") @object = retrieve_object(options.delete(:object)) @options = options @auto_index = Regexp.last_match ? retrieve_autoindex(Regexp.last_match.pre_match) : nil @@ -110,7 +110,7 @@ module ActionView end def sanitized_method_name - @sanitized_method_name ||= @method_name.sub(/\?$/,"") + @sanitized_method_name ||= @method_name.sub(/\?$/, "") end def sanitized_value(value) @@ -152,7 +152,7 @@ module ActionView end def name_and_id_index(options) - options.key?("index") ? options.delete("index") || "" : @auto_index + options.key?("index") ? options.delete("index") || "" : @auto_index end end end diff --git a/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb b/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb index 2a6bf49567..0359d4e65d 100644 --- a/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb +++ b/actionview/lib/action_view/helpers/tags/collection_check_boxes.rb @@ -7,7 +7,7 @@ module ActionView include CollectionHelpers class CheckBoxBuilder < Builder # :nodoc: - def check_box(extra_html_options={}) + def check_box(extra_html_options = {}) html_options = extra_html_options.merge(@input_html_options) html_options[:multiple] = true @template_object.check_box(@object_name, @method_name, html_options, @value, nil) diff --git a/actionview/lib/action_view/helpers/tags/collection_helpers.rb b/actionview/lib/action_view/helpers/tags/collection_helpers.rb index 36575b2fd0..c8be392865 100644 --- a/actionview/lib/action_view/helpers/tags/collection_helpers.rb +++ b/actionview/lib/action_view/helpers/tags/collection_helpers.rb @@ -17,7 +17,7 @@ module ActionView @input_html_options = input_html_options end - def label(label_html_options={}, &block) + def label(label_html_options = {}, &block) html_options = @input_html_options.slice(:index, :namespace).merge(label_html_options) html_options[:for] ||= @input_html_options[:id] if @input_html_options[:id] diff --git a/actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb b/actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb index eed7941cd6..a5f72af9ff 100644 --- a/actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb +++ b/actionview/lib/action_view/helpers/tags/collection_radio_buttons.rb @@ -7,7 +7,7 @@ module ActionView include CollectionHelpers class RadioButtonBuilder < Builder # :nodoc: - def radio_button(extra_html_options={}) + def radio_button(extra_html_options = {}) html_options = extra_html_options.merge(@input_html_options) @template_object.radio_button(@object_name, @method_name, @value, html_options) end diff --git a/actionview/lib/action_view/helpers/url_helper.rb b/actionview/lib/action_view/helpers/url_helper.rb index 36b7515173..1277126995 100644 --- a/actionview/lib/action_view/helpers/url_helper.rb +++ b/actionview/lib/action_view/helpers/url_helper.rb @@ -563,7 +563,7 @@ module ActionView html_options = html_options.stringify_keys html_options["data-remote"] = "true".freeze if link_to_remote_options?(options) || link_to_remote_options?(html_options) - method = html_options.delete("method".freeze) + method = html_options.delete("method".freeze) add_method_to_attributes!(html_options, method) if method @@ -586,7 +586,7 @@ module ActionView html_options["data-method".freeze] = method end - def token_tag(token=nil, form_options: {}) + def token_tag(token = nil, form_options: {}) if token != false && protect_against_forgery? token ||= form_authenticity_token(form_options: form_options) tag(:input, type: "hidden", name: request_forgery_protection_token.to_s, value: token) diff --git a/actionview/lib/action_view/lookup_context.rb b/actionview/lib/action_view/lookup_context.rb index 9d6c762cc4..50faf1b8dd 100644 --- a/actionview/lib/action_view/lookup_context.rb +++ b/actionview/lib/action_view/lookup_context.rb @@ -204,7 +204,7 @@ module ActionView prefixes = prefixes.presence parts = name.to_s.split("/".freeze) parts.shift if parts.first.empty? - name = parts.pop + name = parts.pop return name, prefixes || [""] if parts.empty? diff --git a/actionview/lib/action_view/railtie.rb b/actionview/lib/action_view/railtie.rb index 42795ca2c7..68205cb720 100644 --- a/actionview/lib/action_view/railtie.rb +++ b/actionview/lib/action_view/railtie.rb @@ -23,7 +23,7 @@ module ActionView initializer "action_view.set_configs" do |app| ActiveSupport.on_load(:action_view) do - app.config.action_view.each do |k,v| + app.config.action_view.each do |k, v| send "#{k}=", v end end diff --git a/actionview/lib/action_view/renderer/partial_renderer.rb b/actionview/lib/action_view/renderer/partial_renderer.rb index c900da3277..bf338ec910 100644 --- a/actionview/lib/action_view/renderer/partial_renderer.rb +++ b/actionview/lib/action_view/renderer/partial_renderer.rb @@ -357,7 +357,7 @@ module ActionView # set to that string. Otherwise, the +options[:partial]+ object must # respond to +to_partial_path+ in order to setup the path. def setup(context, options, block) - @view = context + @view = context @options = options @block = block diff --git a/actionview/lib/action_view/rendering.rb b/actionview/lib/action_view/rendering.rb index 3ca7f9d220..b70e7239fc 100644 --- a/actionview/lib/action_view/rendering.rb +++ b/actionview/lib/action_view/rendering.rb @@ -113,7 +113,7 @@ module ActionView # Normalize args by converting render "foo" to render :action => "foo" and # render "foo/bar" to render :template => "foo/bar". # :api: private - def _normalize_args(action=nil, options={}) + def _normalize_args(action = nil, options = {}) options = super(action, options) case action when NilClass diff --git a/actionview/lib/action_view/template.rb b/actionview/lib/action_view/template.rb index 98571cf55e..2dcd6324db 100644 --- a/actionview/lib/action_view/template.rb +++ b/actionview/lib/action_view/template.rb @@ -151,7 +151,7 @@ module ActionView # This method is instrumented as "!render_template.action_view". Notice that # we use a bang in this instrumentation because you don't want to # consume this in production. This is only slow if it's being listened to. - def render(view, locals, buffer=nil, &block) + def render(view, locals, buffer = nil, &block) instrument_render_template do compile!(view) view.send(method_name, locals, buffer, &block) diff --git a/actionview/lib/action_view/template/resolver.rb b/actionview/lib/action_view/template/resolver.rb index 5a2948d5a9..ed93ebc027 100644 --- a/actionview/lib/action_view/template/resolver.rb +++ b/actionview/lib/action_view/template/resolver.rb @@ -141,13 +141,13 @@ module ActionView end # Normalizes the arguments and passes it on to find_templates. - def find_all(name, prefix=nil, partial=false, details={}, key=nil, locals=[]) + def find_all(name, prefix = nil, partial = false, details = {}, key = nil, locals = []) cached(key, [name, prefix, partial], details, locals) do find_templates(name, prefix, partial, details) end end - def find_all_anywhere(name, prefix, partial=false, details={}, key=nil, locals=[]) + def find_all_anywhere(name, prefix, partial = false, details = {}, key = nil, locals = []) cached(key, [name, prefix, partial], details, locals) do find_templates(name, prefix, partial, details, true) end @@ -207,7 +207,7 @@ module ActionView EXTENSIONS = { locale: ".", formats: ".", variants: "+", handlers: "." } DEFAULT_PATTERN = ":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}" - def initialize(pattern=nil) + def initialize(pattern = nil) @pattern = pattern || DEFAULT_PATTERN super() end @@ -297,7 +297,7 @@ module ActionView handler = Template.handler_for_extension(extension) format, variant = pieces.last.split(EXTENSIONS[:variants], 2) if pieces.last - format &&= Template::Types[format] + format &&= Template::Types[format] [handler, format, variant] end @@ -342,7 +342,7 @@ module ActionView # * <tt>:handlers</tt> - possible handlers (for example erb, haml, builder...) # class FileSystemResolver < PathResolver - def initialize(path, pattern=nil) + def initialize(path, pattern = nil) raise ArgumentError, "path already is a Resolver class" if path.is_a?(Resolver) super(pattern) @path = File.expand_path(path) diff --git a/actionview/lib/action_view/test_case.rb b/actionview/lib/action_view/test_case.rb index 3eb1ac0826..5fb7bb54b5 100644 --- a/actionview/lib/action_view/test_case.rb +++ b/actionview/lib/action_view/test_case.rb @@ -18,7 +18,7 @@ module ActionView end def controller_path=(path) - self.class.controller_path=(path) + self.class.controller_path = (path) end def initialize @@ -270,8 +270,8 @@ module ActionView end if routes && - ( routes.named_routes.route_defined?(selector) || - routes.mounted_helpers.method_defined?(selector) ) + (routes.named_routes.route_defined?(selector) || + routes.mounted_helpers.method_defined?(selector)) @controller.__send__(selector, *args) else super diff --git a/actionview/lib/action_view/testing/resolvers.rb b/actionview/lib/action_view/testing/resolvers.rb index f072664535..f4a7a9138c 100644 --- a/actionview/lib/action_view/testing/resolvers.rb +++ b/actionview/lib/action_view/testing/resolvers.rb @@ -8,7 +8,7 @@ module ActionView #:nodoc: class FixtureResolver < PathResolver attr_reader :hash - def initialize(hash = {}, pattern=nil) + def initialize(hash = {}, pattern = nil) super(pattern) @hash = hash end |