From 013c681cd783dae48d0d92b3215ce70193e6474e Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Sun, 15 Sep 2019 11:11:13 +0900 Subject: [PATCH] Unify find_asset method signature to take keyword arguments --- lib/sprockets/base.rb | 4 ++-- lib/sprockets/environment.rb | 4 ++-- test/test_asset.rb | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/sprockets/base.rb b/lib/sprockets/base.rb index 719d6f51e..2060eb364 100644 --- a/lib/sprockets/base.rb +++ b/lib/sprockets/base.rb @@ -75,8 +75,8 @@ def file_digest(path) end # Find asset by logical path or expanded path. - def find_asset(*args) - uri, _ = resolve(*args) + def find_asset(*args, **options) + uri, _ = resolve(*args, **options) if uri load(uri) end diff --git a/lib/sprockets/environment.rb b/lib/sprockets/environment.rb index 11840dcff..5d73ae5aa 100644 --- a/lib/sprockets/environment.rb +++ b/lib/sprockets/environment.rb @@ -27,8 +27,8 @@ def cached end alias_method :index, :cached - def find_asset(*args) - cached.find_asset(*args) + def find_asset(*args, **options) + cached.find_asset(*args, **options) end def find_asset!(*args) diff --git a/test/test_asset.rb b/test/test_asset.rb index c70b0ed91..8e5c3ac82 100644 --- a/test/test_asset.rb +++ b/test/test_asset.rb @@ -332,7 +332,7 @@ def setup end def asset(logical_path, options = {}) - @env.find_asset(logical_path, {pipeline: @pipeline}.merge(options)) + @env.find_asset(logical_path, **{pipeline: @pipeline}.merge(options)) end end @@ -403,7 +403,7 @@ def setup end def asset(logical_path, options = {}) - @env.find_asset(logical_path, {pipeline: @pipeline}.merge(options)) + @env.find_asset(logical_path, **{pipeline: @pipeline}.merge(options)) end end @@ -1110,7 +1110,7 @@ def setup end def asset(logical_path, options = {}) - @env.find_asset(logical_path, {pipeline: @pipeline}.merge(options)) + @env.find_asset(logical_path, **{pipeline: @pipeline}.merge(options)) end def read(logical_path) @@ -1245,7 +1245,7 @@ def logical_path(path, options = {}) filename = fixture_path("paths/#{path}") assert File.exist?(filename), "#{filename} does not exist" silence_warnings do - assert asset = @env.find_asset(filename, options), "couldn't find asset: #{filename}" + assert asset = @env.find_asset(filename, **options), "couldn't find asset: #{filename}" asset.logical_path end end @@ -1308,7 +1308,7 @@ def content_type(path, options = {}) filename = fixture_path("paths/#{path}") assert File.exist?(filename), "#{filename} does not exist" silence_warnings do - assert asset = @env.find_asset(filename, options), "couldn't find asset: #{filename}" + assert asset = @env.find_asset(filename, **options), "couldn't find asset: #{filename}" asset.content_type end end