Skip to content

Commit

Permalink
Fix Ruby 2.7 deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
inukshuk committed Jan 7, 2020
1 parent 9c35c4a commit e5b47bb
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/anystyle/feature/position.rb
Expand Up @@ -4,7 +4,7 @@ class Position < Feature
attr_reader :idx, :seq

def initialize(idx: :idx, seq: :seq, **opts)
super(opts)
super(**opts)
@idx, @seq = idx, seq
end

Expand Down
8 changes: 4 additions & 4 deletions lib/anystyle/parser.rb
Expand Up @@ -87,12 +87,12 @@ def prepare(input, **opts)
expand Wapiti::Dataset.new([input])
when String
if !input.tainted? && input.length < 1024 && File.exists?(input)
expand Wapiti::Dataset.open(input, opts)
expand Wapiti::Dataset.open(input, **opts)
else
expand Wapiti::Dataset.parse(input, opts)
expand Wapiti::Dataset.parse(input, **opts)
end
else
expand Wapiti::Dataset.parse(input, opts)
expand Wapiti::Dataset.parse(input, **opts)
end
end
end
Expand Down Expand Up @@ -207,7 +207,7 @@ def prepare(input, **opts)
opts[:separator] ||= options[:separator]
opts[:delimiter] ||= options[:delimiter]
input = input.join("\n") if input.is_a?(Array) && input[0].is_a?(String)
super(input, opts)
super(input, **opts)
end
end
end
1 change: 1 addition & 0 deletions spec/anystyle/dictionary/gdbm_spec.rb
Expand Up @@ -2,6 +2,7 @@

begin
require 'gdbm'
require 'tmpdir'

module AnyStyle
describe "GDBM Dictionary Adapter" do
Expand Down
2 changes: 1 addition & 1 deletion spec/anystyle/normalizer/arxiv_spec.rb
Expand Up @@ -7,7 +7,7 @@ module AnyStyle
'Preprint, arXiv:1402.7034,' => { arxiv: ['1402.7034'] },
'[arXiv:hepph/9905221].' => { arxiv: ['hepph/9905221'] }
}).each do |(a, b)|
expect(n.normalize(note: [a])).to include(b)
expect(n.normalize({ note: [a] })).to include(b)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/anystyle/normalizer/locator_spec.rb
Expand Up @@ -10,7 +10,7 @@ module AnyStyle
'doi:10.1002/mpr.33.' => { doi: ['10.1002/mpr.33.'] },
'https://doi.org/10.1000/182' => { doi: ['10.1000/182'] }
}).each do |(a, b)|
expect(n.normalize(doi: [a])).to include(b)
expect(n.normalize({ doi: [a] })).to include(b)
end
end

Expand All @@ -19,7 +19,7 @@ module AnyStyle
'https://doi.org/10/aabbe' => { doi: ['10/aabbe'] },
'https://doi.org/10.1000/182' => { doi: ['10.1000/182'] }
}).each do |(a, b)|
expect(n.normalize(url: [a])).to include(b)
expect(n.normalize({ url: [a] })).to include(b)
end
end
end
Expand Down
22 changes: 14 additions & 8 deletions spec/anystyle/normalizer/volume_spec.rb
Expand Up @@ -48,20 +48,22 @@ module AnyStyle
'22. Jg. Heft 3,' => { volume: ['22'], issue: ['3'] },
'19.Jg. H.3,' => { volume: ['19'], issue: ['3'] },
'Jg. 37:' => { volume: ['37'] }

# 47ème année, n°1,
# Isuue 140,
# 40 (4), art. no. 5446343,
# 129, 4, Pt. 2:

}).each do |(a, b)|
expect(n.normalize(volume: [a])).to include(b),
-> { "'#{a}' should normalise to #{b}, got: " + n.normalize(volume: [a]).to_s }
expect(n.normalize({ volume: [a] }))
.to include(b), -> {
"'#{a}' should normalise to #{b}, got: " + n.normalize(volume: [a]).to_s
}
end
end

it "extracts number of volumes" do
expect(n.normalize(volume: ['8 vols.'])).to include(volume: ['8'])
expect(n.normalize({ volume: ['8 vols.'] })).to include(volume: ['8'])
end

it "extracts page numbers" do
Expand All @@ -71,8 +73,10 @@ module AnyStyle
# '22(3):pp.87-106' => { volume: ['22'], issue: ['3'], pages: ['87-106'] },
# '35:S42-S45' => { volume: ['35'], pages: ['42-45'] }
}).each do |(a, b)|
expect(n.normalize(volume: [a])).to include(b),
->{ "'#{a}' should normalise to #{b}, got: " + n.normalize(volume: [a]).to_s }
expect(n.normalize({ volume: [a] }))
.to include(b), -> {
"'#{a}' should normalise to #{b}, got: " + n.normalize(volume: [a]).to_s
}
end
end

Expand All @@ -87,8 +91,10 @@ module AnyStyle
'19 Jg., Heft 2/2011,' => { volume: ['19'], issue: ['2'], date: ['2011'] },
'Jg. 51, Heft 3/2000,' => { volume: ['51'], issue: ['3'], date: ['2000'] }
}).each do |(a, b)|
expect(n.normalize(volume: [a])).to include(b),
->{ "'#{a}' should normalise to #{b}, got: " + n.normalize(volume: [a]).to_s }
expect(n.normalize({ volume: [a] }))
.to include(b), -> {
"'#{a}' should normalise to #{b}, got: " + n.normalize(volume: [a]).to_s
}
end
end
end
Expand Down

0 comments on commit e5b47bb

Please sign in to comment.