Skip to content

Commit

Permalink
Strip quotes around string
Browse files Browse the repository at this point in the history
  • Loading branch information
dshorthouse committed Jun 17, 2024
1 parent 0aa3064 commit 6d912fb
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dwc_agent.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Gem::Specification.new do |s|
s.name = 'dwc_agent'
s.version = DwcAgent::Version.version
s.license = 'MIT'
s.date = '2024-02-11'
s.date = '2024-06-17'
s.summary = "Parse Darwin Core agent terms such as recordedBy and identifiedBy"
s.description = "Parses the typically messy content in Darwin Core terms that contain people names"
s.authors = ["David P. Shorthouse"]
Expand Down
4 changes: 3 additions & 1 deletion lib/dwc_agent/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ module DwcAgent

POST_STRIP_TIDY = %r{
^\s*[&,;.]\s*|
[\[\]]
[\[\]]|
^[`'"`]|
[`'"]$
}x

CHAR_SUBS = {
Expand Down
2 changes: 1 addition & 1 deletion lib/dwc_agent/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Version

MAJOR = 3
MINOR = 1
PATCH = 1
PATCH = 2
BUILD = 0

def self.version
Expand Down
27 changes: 27 additions & 0 deletions spec/dwc_agent/parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2116,5 +2116,32 @@ module DwcAgent
expect(parsed[2].values_at(:given, :family)).to eq(["West", nil])
end

it "should strip out quotes at the start of a name" do
input = "'Weiss, Schenck, & West"
parsed = parser.parse(input)
expect(parsed.size).to eq(3)
expect(parsed[0].values_at(:given, :family)).to eq(["Weiss", nil])
expect(parsed[1].values_at(:given, :family)).to eq(["Schenck", nil])
expect(parsed[2].values_at(:given, :family)).to eq(["West", nil])
end

it "should strip out quotes at the end of a name" do
input = "Weiss, Schenck, & West'"
parsed = parser.parse(input)
expect(parsed.size).to eq(3)
expect(parsed[0].values_at(:given, :family)).to eq(["Weiss", nil])
expect(parsed[1].values_at(:given, :family)).to eq(["Schenck", nil])
expect(parsed[2].values_at(:given, :family)).to eq(["West", nil])
end

it "should strip out quotes wrapped around a name" do
input = "'Weiss, Schenck, & West'"
parsed = parser.parse(input)
expect(parsed.size).to eq(3)
expect(parsed[0].values_at(:given, :family)).to eq(["Weiss", nil])
expect(parsed[1].values_at(:given, :family)).to eq(["Schenck", nil])
expect(parsed[2].values_at(:given, :family)).to eq(["West", nil])
end

end
end

0 comments on commit 6d912fb

Please sign in to comment.