relaton-bib 1.10.1 → 1.10.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/relaton_bib/bibliographic_item.rb +66 -12
- data/lib/relaton_bib/bibxml_parser.rb +39 -12
- data/lib/relaton_bib/document_relation.rb +1 -1
- data/lib/relaton_bib/person.rb +6 -7
- data/lib/relaton_bib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 826acb78507045bc31dd931b706331e248a682507b1454df64d957f97a856fce
|
4
|
+
data.tar.gz: 2a8bd874712691f4586d0a0d75f4c102731d592abf484ddd70a97cc7a2d72c24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff8a95d1afc8c44ce738e6c48cefa65d87fe2f5f2d431e5d5933d8ded66ba577797e55933b8f8082f6dc21841ec68dc3de16c8579d7b5a5af539229f183700c2
|
7
|
+
data.tar.gz: a2a7c1b255cffefcc84c93542062ff42a34b4b6e3c6b1077cb3f6a49c4c2002724ab6cb2f20d54a53fd6a06c423a7a0b43b762ebc0417be30bb85055116cc4a5
|
@@ -809,9 +809,21 @@ module RelatonBib
|
|
809
809
|
render_abstract xml
|
810
810
|
end
|
811
811
|
render_seriesinfo xml
|
812
|
+
render_format xml
|
812
813
|
end
|
813
814
|
end
|
814
815
|
|
816
|
+
def render_format(builder)
|
817
|
+
link.select { |l| l.type == "TXT" }.each do |l|
|
818
|
+
builder.format type: l.type, target: l.content
|
819
|
+
end
|
820
|
+
end
|
821
|
+
|
822
|
+
#
|
823
|
+
# Create reference attributes
|
824
|
+
#
|
825
|
+
# @return [Hash<Symbol=>String>] attributes
|
826
|
+
#
|
815
827
|
def ref_attrs
|
816
828
|
discopes = %w[anchor docName number]
|
817
829
|
attrs = docidentifier.each_with_object({}) do |di, h|
|
@@ -826,24 +838,42 @@ module RelatonBib
|
|
826
838
|
end
|
827
839
|
end
|
828
840
|
|
841
|
+
#
|
842
|
+
# Render keyword
|
843
|
+
#
|
844
|
+
# @param [Nokogiri::XML::Builder] builder xml builder
|
845
|
+
#
|
829
846
|
def render_keyword(builder)
|
830
847
|
keyword.each { |kw| builder.keyword kw.content }
|
831
848
|
end
|
832
849
|
|
850
|
+
#
|
851
|
+
# Render workgroup
|
852
|
+
#
|
853
|
+
# @param [Nokogiri::XML::Builder] builder xml builder
|
854
|
+
#
|
833
855
|
def render_workgroup(builder)
|
834
856
|
editorialgroup&.technical_committee&.each do |tc|
|
835
857
|
builder.workgroup tc.workgroup.name
|
836
858
|
end
|
837
859
|
end
|
838
860
|
|
839
|
-
#
|
861
|
+
#
|
862
|
+
# Render abstract
|
863
|
+
#
|
864
|
+
# @param [Nokogiri::XML::Builder] builder xml builder
|
865
|
+
#
|
840
866
|
def render_abstract(builder)
|
841
867
|
return unless abstract.any?
|
842
868
|
|
843
869
|
builder.abstract { |xml| xml << abstract[0].content.gsub(/(<\/?)p(>)/, '\1t\2') }
|
844
870
|
end
|
845
871
|
|
846
|
-
#
|
872
|
+
#
|
873
|
+
# Render date
|
874
|
+
#
|
875
|
+
# @param [Nokogiri::XML::Builder] builder xml builder
|
876
|
+
#
|
847
877
|
def render_date(builder)
|
848
878
|
dt = date.detect { |d| d.type == "published" }
|
849
879
|
return unless dt
|
@@ -860,7 +890,11 @@ module RelatonBib
|
|
860
890
|
# end
|
861
891
|
end
|
862
892
|
|
863
|
-
#
|
893
|
+
#
|
894
|
+
# Render seriesinfo
|
895
|
+
#
|
896
|
+
# @param [Nokogiri::XML::Builder] builder xml builder
|
897
|
+
#
|
864
898
|
def render_seriesinfo(builder)
|
865
899
|
docidentifier.each do |di|
|
866
900
|
if BibXMLParser::SERIESINFONAMES.include? di.type
|
@@ -877,7 +911,11 @@ module RelatonBib
|
|
877
911
|
end
|
878
912
|
end
|
879
913
|
|
880
|
-
#
|
914
|
+
#
|
915
|
+
# Render authors
|
916
|
+
#
|
917
|
+
# @param [Nokogiri::XML::Builder] builder xml builder
|
918
|
+
#
|
881
919
|
def render_authors(builder)
|
882
920
|
contributor.each do |c|
|
883
921
|
builder.author do |xml|
|
@@ -890,8 +928,12 @@ module RelatonBib
|
|
890
928
|
end
|
891
929
|
end
|
892
930
|
|
893
|
-
#
|
894
|
-
#
|
931
|
+
#
|
932
|
+
# Render address
|
933
|
+
#
|
934
|
+
# @param [Nokogiri::XML::Builder] builder xml builder
|
935
|
+
# @param [RelatonBib::ContributionInfo] contrib contributor
|
936
|
+
#
|
895
937
|
def render_address(builder, contrib)
|
896
938
|
# addr = contrib.entity.contact.reject do |cn|
|
897
939
|
# cn.is_a?(Address) && cn.postcode.nil?
|
@@ -913,8 +955,12 @@ module RelatonBib
|
|
913
955
|
end
|
914
956
|
end
|
915
957
|
|
916
|
-
#
|
917
|
-
#
|
958
|
+
#
|
959
|
+
# Render contact
|
960
|
+
#
|
961
|
+
# @param [Nokogiri::XML::Builder] builder xml builder
|
962
|
+
# @param [Array<RelatonBib::Address, RelatonBib::Contact>] addr contact
|
963
|
+
#
|
918
964
|
def render_contact(builder, addr)
|
919
965
|
%w[phone email uri].each do |type|
|
920
966
|
cont = addr.detect { |cn| cn.is_a?(Contact) && cn.type == type }
|
@@ -922,8 +968,12 @@ module RelatonBib
|
|
922
968
|
end
|
923
969
|
end
|
924
970
|
|
925
|
-
#
|
926
|
-
#
|
971
|
+
#
|
972
|
+
# Render person
|
973
|
+
#
|
974
|
+
# @param [Nokogiri::XML::Builder] builder xml builder
|
975
|
+
# @param [RelatonBib::Person] person person
|
976
|
+
#
|
927
977
|
def render_person(builder, person)
|
928
978
|
render_organization builder, person.affiliation.first&.organization
|
929
979
|
if person.name.completename
|
@@ -946,8 +996,12 @@ module RelatonBib
|
|
946
996
|
end
|
947
997
|
end
|
948
998
|
|
949
|
-
#
|
950
|
-
#
|
999
|
+
#
|
1000
|
+
# Render organization
|
1001
|
+
#
|
1002
|
+
# @param [Nokogiri::XML::Builder] builder xml builder
|
1003
|
+
# @param [RelatonBib::Organization] org organization
|
1004
|
+
#
|
951
1005
|
def render_organization(builder, org)
|
952
1006
|
# return unless org
|
953
1007
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module RelatonBib
|
2
2
|
module BibXMLParser
|
3
3
|
# SeriesInfo what should be saved as docidentifiers in the Relaton model.
|
4
|
-
SERIESINFONAMES = ["DOI"
|
4
|
+
SERIESINFONAMES = ["DOI"].freeze
|
5
5
|
|
6
6
|
FLAVOR = nil
|
7
7
|
|
@@ -75,27 +75,55 @@ module RelatonBib
|
|
75
75
|
#
|
76
76
|
def docids(reference, ver) # rubocop:disable Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/AbcSize
|
77
77
|
ret = []
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
ret << DocumentIdentifier.new(type:
|
78
|
+
si = reference.at("./seriesInfo[@name='Internet-Draft']",
|
79
|
+
"./front/seriesInfo[@name='Internet-Draft']")
|
80
|
+
if si
|
81
|
+
id = si[:value]
|
82
|
+
id.sub!(/(?<=-)\d{2}$/, ver) if ver
|
83
|
+
ret << DocumentIdentifier.new(type: "Internet-Draft", id: id, primary: true)
|
84
|
+
else
|
85
|
+
id = reference["anchor"] || reference["docName"] || reference["number"]
|
86
|
+
ret << create_docid(id, ver) if id
|
84
87
|
end
|
88
|
+
|
85
89
|
%w[anchor docName number].each do |atr|
|
86
90
|
if reference[atr]
|
87
|
-
|
91
|
+
type = pubid_type id
|
92
|
+
ret << DocumentIdentifier.new(id: reference[atr], type: type, scope: atr)
|
88
93
|
end
|
89
94
|
end
|
95
|
+
|
90
96
|
ret + reference.xpath("./seriesInfo", "./front/seriesInfo").map do |si|
|
91
97
|
next unless SERIESINFONAMES.include? si[:name]
|
92
98
|
|
93
99
|
id = si[:value]
|
94
|
-
id.sub!(/(?<=-)\d{2}$/, ver) if ver && si[:name] == "Internet-Draft"
|
100
|
+
# id.sub!(/(?<=-)\d{2}$/, ver) if ver && si[:name] == "Internet-Draft"
|
95
101
|
DocumentIdentifier.new(id: id, type: si[:name])
|
96
102
|
end.compact
|
97
103
|
end
|
98
104
|
|
105
|
+
def create_docid(id, ver) # rubocop:disable Metrics/MethodLength
|
106
|
+
pref, num = id_to_pref_num(id)
|
107
|
+
if %w[RFC BCP FYI STD].include?(pref)
|
108
|
+
num.sub!(/^-?0+/, "")
|
109
|
+
pid = "#{pref} #{num}"
|
110
|
+
type = pubid_type id
|
111
|
+
elsif %w[I-D draft].include?(pref)
|
112
|
+
pid = "draft-#{num}"
|
113
|
+
pid.sub!(/(?<=-)\d{2}$/, ver) if ver
|
114
|
+
type = "Internet-Draft"
|
115
|
+
else
|
116
|
+
pid = pref ? "#{pref} #{num}" : num
|
117
|
+
type = pubid_type id
|
118
|
+
end
|
119
|
+
DocumentIdentifier.new(type: type, id: pid, primary: true)
|
120
|
+
end
|
121
|
+
|
122
|
+
def id_to_pref_num(id)
|
123
|
+
tn = /^(?<pref>I-D|draft|3GPP|W3C|[A-Z]{2,})[._-]?(?<num>.+)/.match id
|
124
|
+
tn && tn.to_a[1..2]
|
125
|
+
end
|
126
|
+
|
99
127
|
#
|
100
128
|
# Extract document identifier type from identifier
|
101
129
|
#
|
@@ -104,8 +132,7 @@ module RelatonBib
|
|
104
132
|
# @return [String]
|
105
133
|
#
|
106
134
|
def pubid_type(id)
|
107
|
-
|
108
|
-
type_match && type_match[1]
|
135
|
+
id_to_pref_num(id)&.first
|
109
136
|
end
|
110
137
|
|
111
138
|
#
|
@@ -338,7 +365,7 @@ module RelatonBib
|
|
338
365
|
# return 1 if !mon || mon.empty?
|
339
366
|
return mon if /^\d+$/.match? mon
|
340
367
|
|
341
|
-
Date::MONTHNAMES.index
|
368
|
+
Date::MONTHNAMES.index { |m| m&.include? mon }.to_s.rjust 2, "0"
|
342
369
|
end
|
343
370
|
|
344
371
|
#
|
@@ -42,7 +42,7 @@ module RelatonBib
|
|
42
42
|
# @param locality [Array<RelatonBib::Locality, RelatonBib::LocalityStack>]
|
43
43
|
# @param source_locality [Array<RelatonBib::SourceLocality,
|
44
44
|
# RelatonBib::SourceLocalityStack>]
|
45
|
-
def initialize(type:, description: nil,
|
45
|
+
def initialize(type:, bibitem:, description: nil, locality: [],
|
46
46
|
source_locality: [])
|
47
47
|
type = "obsoletes" if type == "Now withdrawn"
|
48
48
|
unless self.class::TYPES.include? type
|
data/lib/relaton_bib/person.rb
CHANGED
@@ -13,8 +13,8 @@ module RelatonBib
|
|
13
13
|
# @return [Array<RelatonBib::LocalizedString>]
|
14
14
|
attr_accessor :initial
|
15
15
|
|
16
|
-
# @return [RelatonBib::LocalizedString]
|
17
|
-
attr_accessor :surname
|
16
|
+
# @return [RelatonBib::LocalizedString, nil]
|
17
|
+
attr_accessor :surname, :completename
|
18
18
|
|
19
19
|
# @return [Array<RelatonBib::LocalizedString>]
|
20
20
|
attr_accessor :addition
|
@@ -22,15 +22,14 @@ module RelatonBib
|
|
22
22
|
# @return [Array<RelatonBib::LocalizedString>]
|
23
23
|
attr_accessor :prefix
|
24
24
|
|
25
|
-
# @
|
26
|
-
|
27
|
-
|
28
|
-
# @param surname [RelatonBib::LocalizedString]
|
25
|
+
# @param surname [RelatonBib::LocalizedString, nil] surname or completename
|
26
|
+
# should be present
|
29
27
|
# @param forename [Array<RelatonBib::LocalizedString>]
|
30
28
|
# @param initial [Array<RelatonBib::LocalizedString>]
|
31
29
|
# @param addition [Array<RelatonBib::LocalizedString>]
|
32
30
|
# @param prefix [Array<RelatonBib::LocalizedString>]
|
33
|
-
# @param completename [RelatonBib::LocalizedString]
|
31
|
+
# @param completename [RelatonBib::LocalizedString, nil] completename or
|
32
|
+
# surname should be present
|
34
33
|
def initialize(**args)
|
35
34
|
unless args[:surname] || args[:completename]
|
36
35
|
raise ArgumentError, "Should be given :surname or :completename"
|
data/lib/relaton_bib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-bib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.10.
|
4
|
+
version: 1.10.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|