From 7ab12f944d10560cfed4894dc289c49fb0b0c120 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Sun, 15 Sep 2019 11:09:58 +0900 Subject: [PATCH 1/3] resolve takes keyword arguments --- test/test_resolve.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_resolve.rb b/test/test_resolve.rb index 1144e7ba7..eb6b6f8b2 100644 --- a/test/test_resolve.rb +++ b/test/test_resolve.rb @@ -262,8 +262,8 @@ def setup assert_match(/#{ random_path }/, error.message) end - def resolve(path, options = {}) - uri, _ = @env.resolve(path, options) + def resolve(path, **options) + uri, _ = @env.resolve(path, **options) uri end end From f71f0741f3805881919059c743656101e91b1ada Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Sun, 15 Sep 2019 11:10:52 +0900 Subject: [PATCH 2/3] resolve! takes keyword arguments --- test/test_resolve.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_resolve.rb b/test/test_resolve.rb index eb6b6f8b2..7f98f37c9 100644 --- a/test/test_resolve.rb +++ b/test/test_resolve.rb @@ -255,7 +255,7 @@ def setup @env.append_path(random_path) error = assert_raises(Sprockets::FileNotFound) do - uri, _ = @env.resolve!("thisfiledoesnotexistandshouldraiseerrors", {}) + uri, _ = @env.resolve!("thisfiledoesnotexistandshouldraiseerrors", **{}) uri end From 013c681cd783dae48d0d92b3215ce70193e6474e Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Sun, 15 Sep 2019 11:11:13 +0900 Subject: [PATCH 3/3] 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