Skip to content

Commit

Permalink
Remove deprecated API of positional arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
stoivo committed Jun 18, 2024
1 parent 090091b commit 6ce174a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 25 deletions.
30 changes: 6 additions & 24 deletions lib/css_parser/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -410,17 +410,11 @@ def compact! # :nodoc:
# See add_block! for options.
#
# Deprecated: originally accepted three params: `uri`, `base_uri` and `media_types`
def load_uri!(uri, options = {}, deprecated = nil)
def load_uri!(uri, options = {})
uri = Addressable::URI.parse(uri) unless uri.respond_to? :scheme

opts = {base_uri: nil, media_types: :all}

if options.is_a? Hash
opts.merge!(options)
else
opts[:base_uri] = options if options.is_a? String
opts[:media_types] = deprecated if deprecated
end
opts.merge!(options)

if uri.scheme == 'file' or uri.scheme.nil?
uri.path = File.expand_path(uri.path)
Expand All @@ -438,15 +432,9 @@ def load_uri!(uri, options = {}, deprecated = nil)
end

# Load a local CSS file.
def load_file!(file_name, options = {}, deprecated = nil)
def load_file!(file_name, options = {})
opts = {base_dir: nil, media_types: :all}

if options.is_a? Hash
opts.merge!(options)
else
opts[:base_dir] = options if options.is_a? String
opts[:media_types] = deprecated if deprecated
end
opts.merge!(options)

file_path = @options[:file_resource]
.find_file(file_name, base_dir: opts[:base_dir])
Expand All @@ -462,15 +450,9 @@ def load_file!(file_name, options = {}, deprecated = nil)
end

# Load a local CSS string.
def load_string!(src, options = {}, deprecated = nil)
def load_string!(src, options = {})
opts = {base_dir: nil, media_types: :all}

if options.is_a? Hash
opts.merge!(options)
else
opts[:base_dir] = options if options.is_a? String
opts[:media_types] = deprecated if deprecated
end
opts.merge!(options)

add_block!(src, opts)
end
Expand Down
2 changes: 1 addition & 1 deletion test/test_css_parser_loading.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def test_loading_a_string

def test_following_at_import_rules_local
base_dir = File.expand_path('fixtures', __dir__)
@cp.load_file!('import1.css', base_dir)
@cp.load_file!('import1.css', base_dir: base_dir)

# from '/import1.css'
assert_equal 'color: lime;', @cp.find_by_selector('div').join(' ')
Expand Down

0 comments on commit 6ce174a

Please sign in to comment.