Skip to content

Commit

Permalink
return to original method signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
dimus committed Jan 20, 2021
1 parent c4a1ccb commit 592f6c0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lib/biodiversity/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ module Parser
%i[pointer int string int], :strptr)
attach_function(:free_mem, :FreeMemory, %i[pointer], :void)

def self.parse(name, simple: false, details: false)
def self.parse(name, simple: false)
format = simple ? 'csv' : 'compact'
with_details = details ? 1 : 0
with_details = simple ? 0 : 1

parsed, ptr = parse_go(name, format, with_details)
free_mem(ptr)
output(parsed, simple)
end

def self.parse_ary(ary, simple: false, details: false)
def self.parse_ary(ary, simple: false)
format = simple ? 'csv' : 'compact'
with_details = details ? 1 : 0
with_details = simple ? 0 : 1

in_ptr = FFI::MemoryPointer.new(:pointer, ary.length)
in_ptr.write_array_of_pointer(
Expand Down
2 changes: 1 addition & 1 deletion lib/biodiversity/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Biodiversity module provides a namespace for scientific name parser.
module Biodiversity
VERSION = '5.1.0'
VERSION = '5.1.1'

def self.version
VERSION
Expand Down
6 changes: 5 additions & 1 deletion spec/lib/parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
parsed = subject.parse('Homo sapiens Linn.')
expect(parsed[:canonical][:simple]).to eq 'Homo sapiens'
expect(parsed[:normalized]).to eq 'Homo sapiens Linn.'
expect(parsed[:words].size).to eq 3
end

it 'gets quality and year correctly in simple form' do
Expand All @@ -32,8 +33,9 @@
simple: true
)
expect(parsed[0][:canonical][:simple]).to eq 'Homo sapiens'
expect(parsed[1][:canonical][:simple]).to eq 'Pardosa moesta'
expect(parsed[0][:normalized]).to be_nil

expect(parsed[1][:canonical][:simple]).to eq 'Pardosa moesta'
end

it 'parsed name in full format' do
Expand All @@ -42,8 +44,10 @@
)
expect(parsed[0][:canonical][:simple]).to eq 'Homo sapiens'
expect(parsed[0][:normalized]).to eq 'Homo sapiens Linn.'
expect(parsed[0][:words].size).to eq 3
expect(parsed[1][:parsed]).to be false
expect(parsed[1][:virus]).to be true
expect(parsed[1][:words]).to be_nil
end
end
end

0 comments on commit 592f6c0

Please sign in to comment.