From 3ee9d0061fa042a9fcffa864ffa1492a00d0d179 Mon Sep 17 00:00:00 2001 From: schneems Date: Tue, 30 Aug 2016 10:26:13 -0500 Subject: [PATCH] Address comment via @dhh, better option naming --- .../action_view/helpers/asset_tag_helper.rb | 16 +++++++------- .../action_view/helpers/asset_url_helper.rb | 22 +++++++++---------- .../test/application/asset_debugging_test.rb | 8 +++---- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/actionview/lib/action_view/helpers/asset_tag_helper.rb b/actionview/lib/action_view/helpers/asset_tag_helper.rb index 8dc879611c..9c22fb0bde 100644 --- a/actionview/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionview/lib/action_view/helpers/asset_tag_helper.rb @@ -56,7 +56,7 @@ module ActionView # # => def javascript_include_tag(*sources) options = sources.extract_options!.stringify_keys - path_options = options.extract!("protocol", "extname", "host", "public_folder").symbolize_keys + path_options = options.extract!("protocol", "extname", "host", "skip_pipeline").symbolize_keys sources.uniq.map { |source| tag_options = { "src" => path_to_javascript(source, path_options) @@ -92,7 +92,7 @@ module ActionView # # def stylesheet_link_tag(*sources) options = sources.extract_options!.stringify_keys - path_options = options.extract!("protocol", "host", "public_folder").symbolize_keys + path_options = options.extract!("protocol", "host", "skip_pipeline").symbolize_keys sources.uniq.map { |source| tag_options = { "rel" => "stylesheet", @@ -173,7 +173,7 @@ module ActionView tag("link", { rel: "shortcut icon", type: "image/x-icon", - href: path_to_image(source, public_folder: options.delete(:public_folder)) + href: path_to_image(source, skip_pipeline: options.delete(:skip_pipeline)) }.merge!(options.symbolize_keys)) end @@ -211,7 +211,7 @@ module ActionView options = options.symbolize_keys check_for_image_tag_errors(options) - src = options[:src] = path_to_image(source, public_folder: options.delete(:public_folder)) + src = options[:src] = path_to_image(source, skip_pipeline: options.delete(:skip_pipeline)) unless src.start_with?("cid:") || src.start_with?("data:") || src.blank? options[:alt] = options.fetch(:alt) { image_alt(src) } @@ -289,7 +289,7 @@ module ActionView public_poster_folder = options.delete(:public_poster_folder) sources << options multiple_sources_tag_builder("video", sources) do |options| - options[:poster] = path_to_image(options[:poster], public_folder: public_poster_folder) if options[:poster] + options[:poster] = path_to_image(options[:poster], skip_pipeline: public_poster_folder) if options[:poster] options[:width], options[:height] = extract_dimensions(options.delete(:size)) if options[:size] end end @@ -313,17 +313,17 @@ module ActionView private def multiple_sources_tag_builder(type, sources) options = sources.extract_options!.symbolize_keys - public_folder = options.delete(:public_folder) + skip_pipeline = options.delete(:skip_pipeline) sources.flatten! yield options if block_given? if sources.size > 1 content_tag(type, options) do - safe_join sources.map { |source| tag("source", src: send("path_to_#{type}", source, public_folder: public_folder)) } + safe_join sources.map { |source| tag("source", src: send("path_to_#{type}", source, skip_pipeline: skip_pipeline)) } end else - options[:src] = send("path_to_#{type}", sources.first, public_folder: public_folder) + options[:src] = send("path_to_#{type}", sources.first, skip_pipeline: skip_pipeline) content_tag(type, nil, options) end end diff --git a/actionview/lib/action_view/helpers/asset_url_helper.rb b/actionview/lib/action_view/helpers/asset_url_helper.rb index dc46cad410..d1f85d3319 100644 --- a/actionview/lib/action_view/helpers/asset_url_helper.rb +++ b/actionview/lib/action_view/helpers/asset_url_helper.rb @@ -121,7 +121,7 @@ module ActionView # This is the entry point for all assets. # When using the asset pipeline (i.e. sprockets and sprockets-rails), the # behavior is "enhanced". You can bypass the asset pipeline by passing in - # public_folder: true to the options. + # skip_pipeline: true to the options. # # All other asset *_path helpers delegate through this method. # @@ -132,16 +132,16 @@ module ActionView # # asset_path("application.js") # => "/assets/application-60aa4fdc5cea14baf5400fba1abf4f2a46a5166bad4772b1effe341570f07de9.js" # - # === Without the asset pipeline (public_folder: true) + # === Without the asset pipeline (skip_pipeline: true) # # Accepts a type option that can specify the asset's extension. No error # checking is done to verify the source passed into +asset_path+ is valid # and that the file exists on disk. # - # asset_path("application.js", public_folder: true) # => "application.js" - # asset_path("filedoesnotexist.png", public_folder: true) # => "filedoesnotexist.png" - # asset_path("application", type: :javascript, public_folder: true) # => "/javascripts/application.js" - # asset_path("application", type: :stylesheet, public_folder: true) # => "/stylesheets/application.css" + # asset_path("application.js", skip_pipeline: true) # => "application.js" + # asset_path("filedoesnotexist.png", skip_pipeline: true) # => "filedoesnotexist.png" + # asset_path("application", type: :javascript, skip_pipeline: true) # => "/javascripts/application.js" + # asset_path("application", type: :stylesheet, skip_pipeline: true) # => "/stylesheets/application.css" # # === Options applying to all assets # @@ -167,18 +167,18 @@ module ActionView # root prepended. # # Rails.application.config.relative_url_root = "bar" - # asset_path("foo.js", public_folder: true) # => "bar/foo.js" + # asset_path("foo.js", skip_pipeline: true) # => "bar/foo.js" # # - A different asset host can be specified via config.action_controller.asset_host # this is commonly used in conjunction with a CDN. # # Rails.application.config.action_controller.asset_host = "assets.example.com" - # asset_path("foo.js", public_folder: true) # => "http://assets.example.com/foo.js" + # asset_path("foo.js", skip_pipeline: true) # => "http://assets.example.com/foo.js" # # - An extension name can be specified manually with extname. # - # asset_path("foo", public_folder: true, extname: ".js") # => "/foo.js" - # asset_path("foo.css", public_folder: true, extname: ".js") # => "/foo.css.js" + # asset_path("foo", skip_pipeline: true, extname: ".js") # => "/foo.js" + # asset_path("foo.css", skip_pipeline: true, extname: ".js") # => "/foo.css.js" def asset_path(source, options = {}) raise ArgumentError, "nil is not a valid asset source" if source.nil? @@ -193,7 +193,7 @@ module ActionView end if source[0] != ?/ - if options[:public_folder] + if options[:skip_pipeline] source = public_compute_asset_path(source, options) else source = compute_asset_path(source, options) diff --git a/railties/test/application/asset_debugging_test.rb b/railties/test/application/asset_debugging_test.rb index ac42cbcec9..06d170fa4a 100644 --- a/railties/test/application/asset_debugging_test.rb +++ b/railties/test/application/asset_debugging_test.rb @@ -88,7 +88,7 @@ module ApplicationTests } cases.each do |(view_method, tag_match)| - app_file "app/views/posts/index.html.erb", "<%= #{ view_method } '#{contents}', public_folder: true %>" + app_file "app/views/posts/index.html.erb", "<%= #{ view_method } '#{contents}', skip_pipeline: true %>" app "development" @@ -114,7 +114,7 @@ module ApplicationTests } cases.each do |(view_method, tag_match)| - app_file "app/views/posts/index.html.erb", "<%= #{ view_method } '#{contents}', public_folder: true %>" + app_file "app/views/posts/index.html.erb", "<%= #{ view_method } '#{contents}', skip_pipeline: true %>" app "development" @@ -127,10 +127,10 @@ module ApplicationTests end end - test "{ public_folder: true } does not use the asset pipeline" do + test "{ skip_pipeline: true } does not use the asset pipeline" do cases = { /\/assets\/application-.*.\.js/ => {}, - /application.js/ => { public_folder: true }, + /application.js/ => { skip_pipeline: true }, } cases.each do |(tag_match, options_hash)| app_file "app/views/posts/index.html.erb", "<%= asset_path('application.js', #{ options_hash }) %>"