relaton-itu 1.9.0 → 1.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/README.adoc +11 -0
- data/grammars/biblio.rng +7 -5
- data/grammars/isodoc.rng +617 -89
- data/grammars/itu.rng +4 -8
- data/grammars/reqt.rng +15 -4
- data/lib/relaton_itu/itu_bibliography.rb +17 -19
- data/lib/relaton_itu/scrapper.rb +13 -10
- data/lib/relaton_itu/version.rb +1 -1
- data/relaton-itu.gemspec +1 -1
- metadata +4 -4
data/grammars/itu.rng
CHANGED
@@ -171,14 +171,9 @@
|
|
171
171
|
</optional>
|
172
172
|
<group>
|
173
173
|
<choice>
|
174
|
-
<
|
175
|
-
<
|
176
|
-
|
177
|
-
</zeroOrMore>
|
178
|
-
<zeroOrMore>
|
179
|
-
<ref name="note"/>
|
180
|
-
</zeroOrMore>
|
181
|
-
</group>
|
174
|
+
<zeroOrMore>
|
175
|
+
<ref name="BasicBlock"/>
|
176
|
+
</zeroOrMore>
|
182
177
|
<ref name="amend"/>
|
183
178
|
</choice>
|
184
179
|
<zeroOrMore>
|
@@ -186,6 +181,7 @@
|
|
186
181
|
<ref name="clause-subsection"/>
|
187
182
|
<ref name="terms"/>
|
188
183
|
<ref name="definitions"/>
|
184
|
+
<ref name="floating-title"/>
|
189
185
|
</choice>
|
190
186
|
</zeroOrMore>
|
191
187
|
</group>
|
data/grammars/reqt.rng
CHANGED
@@ -64,9 +64,9 @@
|
|
64
64
|
<optional>
|
65
65
|
<ref name="label"/>
|
66
66
|
</optional>
|
67
|
-
<
|
67
|
+
<zeroOrMore>
|
68
68
|
<ref name="subject"/>
|
69
|
-
</
|
69
|
+
</zeroOrMore>
|
70
70
|
<zeroOrMore>
|
71
71
|
<ref name="reqinherit"/>
|
72
72
|
</zeroOrMore>
|
@@ -80,6 +80,7 @@
|
|
80
80
|
<ref name="verification"/>
|
81
81
|
<ref name="import"/>
|
82
82
|
<ref name="description"/>
|
83
|
+
<ref name="component"/>
|
83
84
|
</choice>
|
84
85
|
</zeroOrMore>
|
85
86
|
<optional>
|
@@ -105,12 +106,16 @@
|
|
105
106
|
</define>
|
106
107
|
<define name="subject">
|
107
108
|
<element name="subject">
|
108
|
-
<
|
109
|
+
<oneOrMore>
|
110
|
+
<ref name="TextElement"/>
|
111
|
+
</oneOrMore>
|
109
112
|
</element>
|
110
113
|
</define>
|
111
114
|
<define name="reqinherit">
|
112
115
|
<element name="inherit">
|
113
|
-
<
|
116
|
+
<oneOrMore>
|
117
|
+
<ref name="TextElement"/>
|
118
|
+
</oneOrMore>
|
114
119
|
</element>
|
115
120
|
</define>
|
116
121
|
<define name="measurementtarget">
|
@@ -138,6 +143,12 @@
|
|
138
143
|
<ref name="RequirementSubpart"/>
|
139
144
|
</element>
|
140
145
|
</define>
|
146
|
+
<define name="component">
|
147
|
+
<element name="component">
|
148
|
+
<attribute name="class"/>
|
149
|
+
<ref name="RequirementSubpart"/>
|
150
|
+
</element>
|
151
|
+
</define>
|
141
152
|
<define name="reqt_references">
|
142
153
|
<element name="references">
|
143
154
|
<oneOrMore>
|
@@ -39,7 +39,7 @@ module RelatonItu
|
|
39
39
|
# @return [String] Relaton XML serialisation of reference
|
40
40
|
def get(code, year = nil, opts = {}) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
41
41
|
if year.nil?
|
42
|
-
/^(?<code1>[^\s]+\s[^\s]+)\s\((
|
42
|
+
/^(?<code1>[^\s]+\s[^\s]+)\s\((?:\d{2}\/)?(?<year1>\d+)\)$/ =~ code
|
43
43
|
unless code1.nil?
|
44
44
|
code = code1
|
45
45
|
year = year1
|
@@ -78,35 +78,33 @@ module RelatonItu
|
|
78
78
|
|
79
79
|
def search_filter(code, year) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
80
80
|
%r{
|
81
|
-
^(?<pref1>ITU)?(
|
82
|
-
(
|
83
|
-
(
|
84
|
-
(
|
85
|
-
(
|
86
|
-
(
|
81
|
+
^(?<pref1>ITU)?(?:-(?<type1>\w))?\s?(?<code1>[^\s/]+(?:/\w[.\d]+)?)
|
82
|
+
(?:\s\(?(?<ver1>v\d+)\)?)?
|
83
|
+
(?:\s\((?:(?<month1>\d{2})/)?(?<year1>\d{4})\))?
|
84
|
+
(?:\s-\s(?<buldate1>\d{2}\.\w{1,4}\.\d{4}))?
|
85
|
+
(?:\s(?<corr1>(?:Amd|Cor|Amendment|Corrigendum)\.?\s?\d+))?
|
86
|
+
(?:\s\((?:(?<cormonth1>\d{2})/)?(?<coryear1>\d{4})\))?
|
87
87
|
}x =~ code
|
88
88
|
year ||= year1
|
89
|
-
# docidrx = %r{\w+\.\d+|\w\sSuppl\.\s\d+} # %r{^ITU-T\s[^\s]+}
|
90
|
-
# c = code.sub(/Imp\s?/, "").match(docidrx).to_s
|
91
89
|
warn "[relaton-itu] (\"#{code}\") fetching..."
|
92
90
|
result = search(code)
|
93
|
-
code1.sub!
|
91
|
+
code1.sub!(/(?<=\.)Imp(?=\d)/, "") if result.gi_imp
|
94
92
|
if corr1
|
95
|
-
corr1.sub!(/[
|
93
|
+
corr1.sub!(/[.\s]+/, " ").sub!("Amendment", "Amd")
|
96
94
|
corr1.sub!("Corrigendum", "Corr")
|
97
95
|
end
|
98
96
|
result.select do |i|
|
99
97
|
next true unless i.hit[:code]
|
100
98
|
|
101
99
|
%r{
|
102
|
-
^(?<pref2>ITU)?(
|
103
|
-
(
|
104
|
-
(
|
105
|
-
(
|
106
|
-
(
|
100
|
+
^(?<pref2>ITU)?(?:-(?<type2>\w))?\s?(?<code2>\S+)
|
101
|
+
(?:\s\(?(?<ver2>v\d+)\)?)?
|
102
|
+
(?:\s\((?:(?<month2>\d{2})/)?(?<year2>\d{4})\))?
|
103
|
+
(?:\s(?<corr2>(?:Amd|Cor)\.\s?\d+))?
|
104
|
+
(?:\s\((?:(?<cormonth2>\d{2})/)?(?<coryear2>\d{4})\))?
|
107
105
|
}x =~ i.hit[:code]
|
108
|
-
/:[
|
109
|
-
corr2&.sub!
|
106
|
+
/:[^(]+\((?<buldate2>\d{2}\.\w{1,4}\.\d{4})\)/ =~ i.hit[:title]
|
107
|
+
corr2&.sub!(/\.\s?/, " ")
|
110
108
|
pref1 == pref2 && (!type1 || type1 == type2) && code2.include?(code1) &&
|
111
109
|
(!year || year == year2) && (!month1 || month1 == month2) &&
|
112
110
|
corr1 == corr2 && (!coryear1 || coryear1 == coryear2) &&
|
@@ -124,7 +122,7 @@ module RelatonItu
|
|
124
122
|
def isobib_results_filter(result, year)
|
125
123
|
missed_years = []
|
126
124
|
result.each do |r|
|
127
|
-
/\((
|
125
|
+
/\((?:\d{2}\/)?(?<pyear>\d{4})\)/ =~ r.hit[:code]
|
128
126
|
if !year || year == pyear
|
129
127
|
ret = r.fetch
|
130
128
|
return { ret: ret } if ret
|
data/lib/relaton_itu/scrapper.rb
CHANGED
@@ -59,7 +59,7 @@ module RelatonItu
|
|
59
59
|
copyright: fetch_copyright(hit.hit[:code], doc),
|
60
60
|
link: fetch_link(doc),
|
61
61
|
relation: fetch_relations(doc),
|
62
|
-
place: ["Geneva"]
|
62
|
+
place: ["Geneva"],
|
63
63
|
)
|
64
64
|
end
|
65
65
|
|
@@ -86,6 +86,9 @@ module RelatonItu
|
|
86
86
|
language: "en",
|
87
87
|
script: "Latn",
|
88
88
|
}]
|
89
|
+
rescue Mechanize::ResponseCodeError => e
|
90
|
+
warn "HTTP Service Unavailable: #{e.message}"
|
91
|
+
[]
|
89
92
|
end
|
90
93
|
|
91
94
|
# Get page.
|
@@ -109,7 +112,7 @@ module RelatonItu
|
|
109
112
|
docids = doc.xpath(
|
110
113
|
"//span[@id='ctl00_content_main_uc_rec_main_info1_rpt_main_ctl00_lbl_rec']",
|
111
114
|
"//td[.='Identical standard:']/following-sibling::td",
|
112
|
-
"//div/table[1]/tr[4]/td/strong"
|
115
|
+
"//div/table[1]/tr[4]/td/strong",
|
113
116
|
).map { |c| createdocid c.text }
|
114
117
|
docids << createdocid(title) unless docids.any?
|
115
118
|
docids
|
@@ -119,18 +122,18 @@ module RelatonItu
|
|
119
122
|
# @return [RelatonBib::DocumentIdentifier]
|
120
123
|
def createdocid(text) # rubocop:disable Metrics/MethodLength
|
121
124
|
%r{
|
122
|
-
^(?<code>((ITU-\w|ISO
|
123
|
-
(
|
124
|
-
(
|
125
|
-
(
|
125
|
+
^(?<code>(?:(?:ITU-\w|ISO/IEC)\s)?[^(:]+)
|
126
|
+
(?:\((?:(?<_month>\d{2})/)?(?<_year>\d{4})\))?
|
127
|
+
(?::[^(]+\((?<buldate>\d{2}\.\w{1,4}\.\d{4})\))?
|
128
|
+
(?:\s(?<corr>(?:Amd|Cor)\.\s?\d+))?
|
126
129
|
# (\s\(((?<_cormonth>\d{2})\/)?(?<_coryear>\d{4})\))?
|
127
130
|
}x =~ text.squeeze(" ")
|
128
|
-
corr&.sub!
|
131
|
+
corr&.sub!(/\.\s?/, " ")
|
129
132
|
id = [code.sub(/[[:space:]]$/, ""), corr].compact.join " "
|
130
133
|
id += " - #{buldate}" if buldate
|
131
134
|
type = id.match(%r{^\w+}).to_s
|
132
135
|
type = "ITU" if type == "G"
|
133
|
-
RelatonBib::DocumentIdentifier.new(type: type, id: id)
|
136
|
+
RelatonBib::DocumentIdentifier.new(type: type, id: id, primary: true)
|
134
137
|
end
|
135
138
|
|
136
139
|
# Fetch status.
|
@@ -261,7 +264,7 @@ module RelatonItu
|
|
261
264
|
links = [{ type: "src", content: doc.uri.to_s }]
|
262
265
|
obp_elm = doc.at(
|
263
266
|
'//a[@title="Persistent link to download the PDF file"]',
|
264
|
-
"//font[contains(.,'PDF')]/../.."
|
267
|
+
"//font[contains(.,'PDF')]/../..",
|
265
268
|
)
|
266
269
|
links << typed_link("obp", obp_elm) if obp_elm
|
267
270
|
wrd_elm = doc.at("//font[contains(.,'Word')]/../..")
|
@@ -274,7 +277,7 @@ module RelatonItu
|
|
274
277
|
def typed_link(type, elm)
|
275
278
|
{
|
276
279
|
type: type,
|
277
|
-
content: URI.join(HitCollection::DOMAIN
|
280
|
+
content: URI.join(HitCollection::DOMAIN, elm[:href].strip).to_s,
|
278
281
|
}
|
279
282
|
end
|
280
283
|
|
data/lib/relaton_itu/version.rb
CHANGED
data/relaton-itu.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-itu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: equivalent-xml
|
@@ -142,14 +142,14 @@ dependencies:
|
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: 1.
|
145
|
+
version: 1.10.1
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: 1.
|
152
|
+
version: 1.10.1
|
153
153
|
description: 'RelatonItu: retrieve ITU Standards for bibliographic use using the BibliographicItem
|
154
154
|
model'
|
155
155
|
email:
|