Skip to content

Commit

Permalink
Merge pull request #625 from amatsuda/kwargs
Browse files Browse the repository at this point in the history
Fixes for Ruby 2.7 keyword arguments warnings
  • Loading branch information
schneems authored Sep 17, 2019
2 parents cbf3b82 + 013c681 commit d9e7037
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/sprockets/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/sprockets/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions test/test_asset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/test_resolve.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,15 @@ def setup
@env.append_path(random_path)

error = assert_raises(Sprockets::FileNotFound) do
uri, _ = @env.resolve!("thisfiledoesnotexistandshouldraiseerrors", {})
uri, _ = @env.resolve!("thisfiledoesnotexistandshouldraiseerrors", **{})
uri
end

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

0 comments on commit d9e7037

Please sign in to comment.