relaton-bib 1.9.23 → 1.10.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/grammars/basicdoc.rng +26 -7
- data/grammars/biblio.rng +7 -5
- data/grammars/isodoc.rng +617 -89
- data/grammars/reqt.rng +34 -5
- data/lib/relaton_bib/bibliographic_item.rb +66 -12
- data/lib/relaton_bib/bibxml_parser.rb +16 -24
- data/lib/relaton_bib/copyright_association.rb +2 -2
- data/lib/relaton_bib/document_identifier.rb +10 -2
- data/lib/relaton_bib/document_relation.rb +1 -1
- data/lib/relaton_bib/hash_converter.rb +3 -2
- data/lib/relaton_bib/localized_string.rb +1 -1
- data/lib/relaton_bib/person.rb +6 -7
- data/lib/relaton_bib/validity.rb +2 -2
- data/lib/relaton_bib/version.rb +1 -1
- data/lib/relaton_bib/xml_parser.rb +2 -1
- metadata +2 -2
data/grammars/reqt.rng
CHANGED
@@ -58,15 +58,23 @@
|
|
58
58
|
<optional>
|
59
59
|
<attribute name="type"/>
|
60
60
|
</optional>
|
61
|
+
<optional>
|
62
|
+
<attribute name="tag"/>
|
63
|
+
</optional>
|
64
|
+
<optional>
|
65
|
+
<attribute name="multilingual-rendering">
|
66
|
+
<ref name="MultilingualRenderingType"/>
|
67
|
+
</attribute>
|
68
|
+
</optional>
|
61
69
|
<optional>
|
62
70
|
<ref name="reqtitle"/>
|
63
71
|
</optional>
|
64
72
|
<optional>
|
65
73
|
<ref name="label"/>
|
66
74
|
</optional>
|
67
|
-
<
|
75
|
+
<zeroOrMore>
|
68
76
|
<ref name="subject"/>
|
69
|
-
</
|
77
|
+
</zeroOrMore>
|
70
78
|
<zeroOrMore>
|
71
79
|
<ref name="reqinherit"/>
|
72
80
|
</zeroOrMore>
|
@@ -80,6 +88,7 @@
|
|
80
88
|
<ref name="verification"/>
|
81
89
|
<ref name="import"/>
|
82
90
|
<ref name="description"/>
|
91
|
+
<ref name="component"/>
|
83
92
|
</choice>
|
84
93
|
</zeroOrMore>
|
85
94
|
<optional>
|
@@ -100,17 +109,23 @@
|
|
100
109
|
</define>
|
101
110
|
<define name="label">
|
102
111
|
<element name="label">
|
103
|
-
<
|
112
|
+
<oneOrMore>
|
113
|
+
<ref name="TextElement"/>
|
114
|
+
</oneOrMore>
|
104
115
|
</element>
|
105
116
|
</define>
|
106
117
|
<define name="subject">
|
107
118
|
<element name="subject">
|
108
|
-
<
|
119
|
+
<oneOrMore>
|
120
|
+
<ref name="TextElement"/>
|
121
|
+
</oneOrMore>
|
109
122
|
</element>
|
110
123
|
</define>
|
111
124
|
<define name="reqinherit">
|
112
125
|
<element name="inherit">
|
113
|
-
<
|
126
|
+
<oneOrMore>
|
127
|
+
<ref name="TextElement"/>
|
128
|
+
</oneOrMore>
|
114
129
|
</element>
|
115
130
|
</define>
|
116
131
|
<define name="measurementtarget">
|
@@ -138,6 +153,12 @@
|
|
138
153
|
<ref name="RequirementSubpart"/>
|
139
154
|
</element>
|
140
155
|
</define>
|
156
|
+
<define name="component">
|
157
|
+
<element name="component">
|
158
|
+
<attribute name="class"/>
|
159
|
+
<ref name="RequirementSubpart"/>
|
160
|
+
</element>
|
161
|
+
</define>
|
141
162
|
<define name="reqt_references">
|
142
163
|
<element name="references">
|
143
164
|
<oneOrMore>
|
@@ -164,6 +185,14 @@
|
|
164
185
|
<data type="boolean"/>
|
165
186
|
</attribute>
|
166
187
|
</optional>
|
188
|
+
<optional>
|
189
|
+
<attribute name="tag"/>
|
190
|
+
</optional>
|
191
|
+
<optional>
|
192
|
+
<attribute name="multilingual-rendering">
|
193
|
+
<ref name="MultilingualRenderingType"/>
|
194
|
+
</attribute>
|
195
|
+
</optional>
|
167
196
|
<oneOrMore>
|
168
197
|
<ref name="BasicBlock"/>
|
169
198
|
</oneOrMore>
|
@@ -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
|
|
@@ -8,6 +8,7 @@ module RelatonBib
|
|
8
8
|
ORGNAMES = {
|
9
9
|
"IEEE" => "Istitute of Electrical and Electronics Engineers",
|
10
10
|
"W3C" => "World Wide Web Consortium",
|
11
|
+
"3GPP" => "3rd Generation Partnership Project",
|
11
12
|
}.freeze
|
12
13
|
|
13
14
|
def parse(bibxml, url: nil, is_relation: false, ver: nil)
|
@@ -74,39 +75,18 @@ module RelatonBib
|
|
74
75
|
#
|
75
76
|
def docids(reference, ver) # rubocop:disable Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/AbcSize
|
76
77
|
ret = []
|
77
|
-
# sfid = reference.at("./seriesInfo[@name='#{self::FLAVOR}']",
|
78
|
-
# "./front/seriesInfo[@name='#{self::FLAVOR}']")
|
79
|
-
# if sfid
|
80
|
-
# type = sfid[:name]
|
81
|
-
# id = sfid[:value]
|
82
|
-
# # scope = "series"
|
83
|
-
# else # if self::FLAVOR
|
84
|
-
# id, scope = if reference[:anchor] then [reference[:anchor], "anchor"]
|
85
|
-
# elsif reference[:docName] then [reference[:docName], "docName"]
|
86
|
-
# elsif reference[:number] then [reference[:number], "number"]
|
87
|
-
# end
|
88
78
|
id = reference["anchor"] || reference["docName"] || reference["number"]
|
89
|
-
type_match = id&.match(/^(3GPP|W3C|[A-Z]{2,})(?:\.(?=[A-Z])|(?=\d))/)
|
90
|
-
type = self::FLAVOR || (type_match && type_match[1])
|
91
79
|
if id
|
92
80
|
/^(?<pref>I-D|3GPP|W3C|[A-Z]{2,})[._]?(?<num>.+)/ =~ id
|
93
81
|
num.sub!(/^-?0+/, "") if %w[RFC BCP FYI STD].include?(pref)
|
94
82
|
pid = pref ? "#{pref} #{num}" : id
|
95
|
-
ret << DocumentIdentifier.new(type:
|
83
|
+
ret << DocumentIdentifier.new(type: pubid_type(id), id: pid, primary: true)
|
96
84
|
end
|
97
85
|
%w[anchor docName number].each do |atr|
|
98
86
|
if reference[atr]
|
99
|
-
ret << DocumentIdentifier.new(id: reference[atr], type:
|
87
|
+
ret << DocumentIdentifier.new(id: reference[atr], type: pubid_type(id), scope: atr)
|
100
88
|
end
|
101
89
|
end
|
102
|
-
# end
|
103
|
-
# if id
|
104
|
-
# ret << DocumentIdentifier.new(type: type, id: id)
|
105
|
-
# ret << DocumentIdentifier.new(type: type, id: id, scope: scope) if scope
|
106
|
-
# end
|
107
|
-
# if (id = reference[:anchor])
|
108
|
-
# ret << DocumentIdentifier.new(type: "rfc-anchor", id: id)
|
109
|
-
# end
|
110
90
|
ret + reference.xpath("./seriesInfo", "./front/seriesInfo").map do |si|
|
111
91
|
next unless SERIESINFONAMES.include? si[:name]
|
112
92
|
|
@@ -116,6 +96,18 @@ module RelatonBib
|
|
116
96
|
end.compact
|
117
97
|
end
|
118
98
|
|
99
|
+
#
|
100
|
+
# Extract document identifier type from identifier
|
101
|
+
#
|
102
|
+
# @param [String] id identifier
|
103
|
+
#
|
104
|
+
# @return [String]
|
105
|
+
#
|
106
|
+
def pubid_type(id)
|
107
|
+
type_match = id&.match(/^(3GPP|W3C|[A-Z]{2,})(?:\.(?=[A-Z])|(?=\d))/)
|
108
|
+
type_match && type_match[1]
|
109
|
+
end
|
110
|
+
|
119
111
|
#
|
120
112
|
# extract status
|
121
113
|
# @param reference [Nokogiri::XML::Element]
|
@@ -346,7 +338,7 @@ module RelatonBib
|
|
346
338
|
# return 1 if !mon || mon.empty?
|
347
339
|
return mon if /^\d+$/.match? mon
|
348
340
|
|
349
|
-
Date::MONTHNAMES.index
|
341
|
+
Date::MONTHNAMES.index { |m| m&.include? mon }.to_s.rjust 2, "0"
|
350
342
|
end
|
351
343
|
|
352
344
|
#
|
@@ -33,7 +33,7 @@ module RelatonBib
|
|
33
33
|
o.is_a?(Hash) ? ContributionInfo.new(entity: Organization.new(**o)) : o
|
34
34
|
end
|
35
35
|
|
36
|
-
@from = Date.strptime(from.to_s, "%Y") if from.to_s.match?
|
36
|
+
@from = Date.strptime(from.to_s, "%Y") if from.to_s.match?(/\d{4}/)
|
37
37
|
@to = Date.strptime(to.to_s, "%Y") unless to.to_s.empty?
|
38
38
|
@scope = scope
|
39
39
|
end
|
@@ -45,7 +45,7 @@ module RelatonBib
|
|
45
45
|
opts[:builder].copyright do |builder|
|
46
46
|
builder.from from ? from.year : "unknown"
|
47
47
|
builder.to to.year if to
|
48
|
-
owner.each { |o| builder.owner { o.to_xml
|
48
|
+
owner.each { |o| builder.owner { o.to_xml(**opts) } }
|
49
49
|
builder.scope scope if scope
|
50
50
|
end
|
51
51
|
end
|
@@ -7,13 +7,18 @@ module RelatonBib
|
|
7
7
|
# @return [String, NilClass]
|
8
8
|
attr_reader :type, :scope
|
9
9
|
|
10
|
+
# @param type [Boolean, nil]
|
11
|
+
attr_reader :primary
|
12
|
+
|
10
13
|
# @param id [String]
|
11
14
|
# @param type [String, NilClass]
|
12
15
|
# @param scope [String, NilClass]
|
13
|
-
|
16
|
+
# @param priority [Bolean]
|
17
|
+
def initialize(id:, type: nil, scope: nil, primary: false)
|
14
18
|
@id = id
|
15
19
|
@type = type
|
16
20
|
@scope = scope
|
21
|
+
@primary = primary
|
17
22
|
end
|
18
23
|
|
19
24
|
# in docid manipulations, assume ISO as the default: id-part:year
|
@@ -56,6 +61,7 @@ module RelatonBib
|
|
56
61
|
element = opts[:builder].docidentifier lid
|
57
62
|
element[:type] = type if type
|
58
63
|
element[:scope] = scope if scope
|
64
|
+
element[:primary] = primary if primary
|
59
65
|
end
|
60
66
|
|
61
67
|
# @return [Hash]
|
@@ -63,19 +69,21 @@ module RelatonBib
|
|
63
69
|
hash = { "id" => id }
|
64
70
|
hash["type"] = type if type
|
65
71
|
hash["scope"] = scope if scope
|
72
|
+
hash["primary"] = primary if primary
|
66
73
|
hash
|
67
74
|
end
|
68
75
|
|
69
76
|
# @param prefix [String]
|
70
77
|
# @param count [Integer] number of docids
|
71
78
|
# @return [String]
|
72
|
-
def to_asciibib(prefix = "", count = 1) # rubocop:disable Metrics/CyclomaticComplexity
|
79
|
+
def to_asciibib(prefix = "", count = 1) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize
|
73
80
|
pref = prefix.empty? ? prefix : "#{prefix}."
|
74
81
|
return "#{pref}docid:: #{id}\n" unless type || scope
|
75
82
|
|
76
83
|
out = count > 1 ? "#{pref}docid::\n" : ""
|
77
84
|
out += "#{pref}docid.type:: #{type}\n" if type
|
78
85
|
out += "#{pref}docid.scope:: #{scope}\n" if scope
|
86
|
+
out += "#{pref}docid.primary:: #{primary}\n" if primary
|
79
87
|
out + "#{pref}docid.id:: #{id}\n"
|
80
88
|
end
|
81
89
|
|
@@ -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
|
@@ -126,8 +126,9 @@ module RelatonBib
|
|
126
126
|
ret[:docid] = array(ret[:docid])
|
127
127
|
ret[:docid]&.each_with_index do |id, i|
|
128
128
|
type = id[:type] || id[:id].match(/^\w+(?=\s)/)&.to_s
|
129
|
-
ret[:docid][i] = DocumentIdentifier.new(
|
130
|
-
|
129
|
+
ret[:docid][i] = DocumentIdentifier.new(
|
130
|
+
id: id[:id], type: type, scope: id[:scope], primary: id[:primary],
|
131
|
+
)
|
131
132
|
end
|
132
133
|
end
|
133
134
|
|
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/validity.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module RelatonBib
|
2
2
|
class Validity
|
3
|
-
FORMAT = "%Y-%m-%d %H:%M"
|
3
|
+
FORMAT = "%Y-%m-%d %H:%M".freeze
|
4
4
|
|
5
5
|
# @return [Time, NilClass]
|
6
6
|
attr_reader :begins
|
@@ -41,7 +41,7 @@ module RelatonBib
|
|
41
41
|
# @param prefix [String]
|
42
42
|
# @return [String]
|
43
43
|
def to_asciibib(prefix = "")
|
44
|
-
pref = prefix.empty? ? "validity." : prefix
|
44
|
+
pref = prefix.empty? ? "validity." : "#{prefix}.validity."
|
45
45
|
out = ""
|
46
46
|
out += "#{pref}begins:: #{begins.strftime(FORMAT)}\n" if begins
|
47
47
|
out += "#{pref}ends:: #{ends.strftime(FORMAT)}\n" if ends
|
data/lib/relaton_bib/version.rb
CHANGED
@@ -161,8 +161,9 @@ module RelatonBib
|
|
161
161
|
# @return [Array<RelatonBib::DocumentIdentifier>]
|
162
162
|
def fetch_docid(item)
|
163
163
|
item.xpath("./docidentifier").map do |did|
|
164
|
+
primary = true if did[:primary] == "true"
|
164
165
|
DocumentIdentifier.new(id: did.text, type: did[:type],
|
165
|
-
scope: did[:scope])
|
166
|
+
scope: did[:scope], primary: primary)
|
166
167
|
end
|
167
168
|
end
|
168
169
|
|
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.
|
4
|
+
version: 1.10.3
|
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-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|