Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew2net committed Mar 8, 2024
1 parent f287e0b commit fbdc22c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/relaton_bib/document_identifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def to_xml(**opts) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexi
id.sub %r{(?<=:)(?:\w{2},)*?(#{opts[:lang]})(?:,\w{2})*}, '\1'
else id
end
element = opts[:builder].docidentifier lid
element = opts[:builder].docidentifier { |b| b.parent.inner_html = lid }
element[:type] = type if type
element[:scope] = scope if scope
element[:primary] = primary if primary
Expand Down
2 changes: 1 addition & 1 deletion lib/relaton_bib/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module RelatonBib
VERSION = "1.18.2".freeze
VERSION = "1.18.3".freeze
end
23 changes: 15 additions & 8 deletions spec/relaton_bib/document_identifier_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
context "ISO" do
subject do
RelatonBib::DocumentIdentifier.new(
type: "URN", id: "urn:iso:std:iso:1111:-1:stage-60.60:ed-1:v1:en,fr"
type: "URN", id: "urn:iso:std:iso:1111:-1:stage-60.60:ed-1:v1:en,fr",
)
end

Expand All @@ -35,20 +35,18 @@
subject do
RelatonBib::DocumentIdentifier.new(
type: "URN",
id: "urn:iec:std:iec:61058-2-4:1995::csv:en:plus:amd:1:2003"
id: "urn:iec:std:iec:61058-2-4:1995::csv:en:plus:amd:1:2003",
)
end

it "remove part" do
subject.remove_part
expect(subject.id).to eq "urn:iec:std:iec:61058:1995::csv:en:plus:"\
"amd:1:2003"
expect(subject.id).to eq "urn:iec:std:iec:61058:1995::csv:en:plus:amd:1:2003"
end

it "remove date" do
subject.remove_date
expect(subject.id).to eq "urn:iec:std:iec:61058-2-4:::csv:en:plus:"\
"amd:1:2003"
expect(subject.id).to eq "urn:iec:std:iec:61058-2-4:::csv:en:plus:amd:1:2003"
end

it "set all parts" do
Expand All @@ -60,8 +58,7 @@

context "GB" do
subject do
RelatonBib::DocumentIdentifier.new(id: "1111.2-2014",
type: "Chinese Standard")
RelatonBib::DocumentIdentifier.new(id: "1111.2-2014", type: "Chinese Standard")
end

it "remove part" do
Expand All @@ -74,4 +71,14 @@
expect(subject.id).to eq "1111.2"
end
end

context "#to_xml" do
it "with superscription" do
subject = RelatonBib::DocumentIdentifier.new(id: "CIPM 43<sup>e</sup> réunion (1950)", type: "BIPM")
xml = Nokogiri::XML::Builder.new do |builder|
subject.to_xml(builder: builder, lang: "en")
end.doc.root
expect(xml.to_xml).to eq "<docidentifier type=\"BIPM\">CIPM 43<sup>e</sup> r&#xE9;union (1950)</docidentifier>"
end
end
end

0 comments on commit fbdc22c

Please sign in to comment.