Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for Ruby 2.7 keyword arguments warnings #625

Merged
merged 3 commits into from
Sep 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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