relaton-itu 1.8.1 → 1.10.1

Sign up to get free protection for your applications and to get access to all the features.
data/grammars/itu.rng CHANGED
@@ -87,6 +87,9 @@
87
87
  <optional>
88
88
  <ref name="doctype"/>
89
89
  </optional>
90
+ <optional>
91
+ <ref name="docsubtype"/>
92
+ </optional>
90
93
  <ref name="editorialgroup"/>
91
94
  <zeroOrMore>
92
95
  <ref name="ics"/>
@@ -130,6 +133,59 @@
130
133
  </oneOrMore>
131
134
  </element>
132
135
  </define>
136
+ <define name="Clause-Section">
137
+ <optional>
138
+ <attribute name="id">
139
+ <data type="ID"/>
140
+ </attribute>
141
+ </optional>
142
+ <optional>
143
+ <attribute name="language"/>
144
+ </optional>
145
+ <optional>
146
+ <attribute name="script"/>
147
+ </optional>
148
+ <optional>
149
+ <attribute name="inline-header">
150
+ <data type="boolean"/>
151
+ </attribute>
152
+ </optional>
153
+ <optional>
154
+ <attribute name="obligation">
155
+ <choice>
156
+ <value>normative</value>
157
+ <value>informative</value>
158
+ </choice>
159
+ </attribute>
160
+ </optional>
161
+ <optional>
162
+ <attribute name="type"/>
163
+ </optional>
164
+ <optional>
165
+ <attribute name="unnumbered">
166
+ <data type="boolean"/>
167
+ </attribute>
168
+ </optional>
169
+ <optional>
170
+ <ref name="section-title"/>
171
+ </optional>
172
+ <group>
173
+ <choice>
174
+ <zeroOrMore>
175
+ <ref name="BasicBlock"/>
176
+ </zeroOrMore>
177
+ <ref name="amend"/>
178
+ </choice>
179
+ <zeroOrMore>
180
+ <choice>
181
+ <ref name="clause-subsection"/>
182
+ <ref name="terms"/>
183
+ <ref name="definitions"/>
184
+ <ref name="floating-title"/>
185
+ </choice>
186
+ </zeroOrMore>
187
+ </group>
188
+ </define>
133
189
  </include>
134
190
  <define name="meeting">
135
191
  <element name="meeting">
@@ -177,36 +233,6 @@
177
233
  <text/>
178
234
  </element>
179
235
  </define>
180
- <define name="TextElement" combine="choice">
181
- <choice>
182
- <ref name="add"/>
183
- <ref name="del"/>
184
- </choice>
185
- </define>
186
- <define name="add">
187
- <element name="add">
188
- <choice>
189
- <ref name="PureTextElement"/>
190
- <ref name="eref"/>
191
- <ref name="stem"/>
192
- <ref name="keyword"/>
193
- <ref name="xref"/>
194
- <ref name="hyperlink"/>
195
- </choice>
196
- </element>
197
- </define>
198
- <define name="del">
199
- <element name="del">
200
- <choice>
201
- <ref name="PureTextElement"/>
202
- <ref name="eref"/>
203
- <ref name="stem"/>
204
- <ref name="keyword"/>
205
- <ref name="xref"/>
206
- <ref name="hyperlink"/>
207
- </choice>
208
- </element>
209
- </define>
210
236
  <define name="ipnoticereceived">
211
237
  <element name="ip-notice-received">
212
238
  <data type="boolean"/>
@@ -329,6 +355,9 @@
329
355
  <zeroOrMore>
330
356
  <ref name="termdocsource"/>
331
357
  </zeroOrMore>
358
+ <optional>
359
+ <ref name="misccontainer"/>
360
+ </optional>
332
361
  <optional>
333
362
  <ref name="boilerplate"/>
334
363
  </optional>
@@ -340,6 +369,9 @@
340
369
  <ref name="annex"/>
341
370
  </zeroOrMore>
342
371
  <ref name="bibliography"/>
372
+ <zeroOrMore>
373
+ <ref name="indexsect"/>
374
+ </zeroOrMore>
343
375
  </element>
344
376
  </define>
345
377
  </grammar>
data/grammars/reqt.rng CHANGED
@@ -30,9 +30,22 @@
30
30
  <data type="boolean"/>
31
31
  </attribute>
32
32
  </optional>
33
+ <optional>
34
+ <attribute name="number"/>
35
+ </optional>
33
36
  <optional>
34
37
  <attribute name="subsequence"/>
35
38
  </optional>
39
+ <optional>
40
+ <attribute name="keep-with-next">
41
+ <data type="boolean"/>
42
+ </attribute>
43
+ </optional>
44
+ <optional>
45
+ <attribute name="keep-lines-together">
46
+ <data type="boolean"/>
47
+ </attribute>
48
+ </optional>
36
49
  <attribute name="id">
37
50
  <data type="ID"/>
38
51
  </attribute>
@@ -40,17 +53,23 @@
40
53
  <attribute name="filename"/>
41
54
  </optional>
42
55
  <optional>
43
- <ref name="reqtitle"/>
56
+ <attribute name="model"/>
44
57
  </optional>
45
58
  <optional>
46
- <ref name="label"/>
59
+ <attribute name="type"/>
47
60
  </optional>
48
61
  <optional>
49
- <ref name="subject"/>
62
+ <ref name="reqtitle"/>
50
63
  </optional>
51
64
  <optional>
52
- <ref name="reqinherit"/>
65
+ <ref name="label"/>
53
66
  </optional>
67
+ <zeroOrMore>
68
+ <ref name="subject"/>
69
+ </zeroOrMore>
70
+ <zeroOrMore>
71
+ <ref name="reqinherit"/>
72
+ </zeroOrMore>
54
73
  <zeroOrMore>
55
74
  <ref name="classification"/>
56
75
  </zeroOrMore>
@@ -61,6 +80,7 @@
61
80
  <ref name="verification"/>
62
81
  <ref name="import"/>
63
82
  <ref name="description"/>
83
+ <ref name="component"/>
64
84
  </choice>
65
85
  </zeroOrMore>
66
86
  <optional>
@@ -86,12 +106,16 @@
86
106
  </define>
87
107
  <define name="subject">
88
108
  <element name="subject">
89
- <text/>
109
+ <oneOrMore>
110
+ <ref name="TextElement"/>
111
+ </oneOrMore>
90
112
  </element>
91
113
  </define>
92
114
  <define name="reqinherit">
93
115
  <element name="inherit">
94
- <text/>
116
+ <oneOrMore>
117
+ <ref name="TextElement"/>
118
+ </oneOrMore>
95
119
  </element>
96
120
  </define>
97
121
  <define name="measurementtarget">
@@ -119,6 +143,12 @@
119
143
  <ref name="RequirementSubpart"/>
120
144
  </element>
121
145
  </define>
146
+ <define name="component">
147
+ <element name="component">
148
+ <attribute name="class"/>
149
+ <ref name="RequirementSubpart"/>
150
+ </element>
151
+ </define>
122
152
  <define name="reqt_references">
123
153
  <element name="references">
124
154
  <oneOrMore>
@@ -135,6 +165,16 @@
135
165
  <data type="boolean"/>
136
166
  </attribute>
137
167
  </optional>
168
+ <optional>
169
+ <attribute name="keep-with-next">
170
+ <data type="boolean"/>
171
+ </attribute>
172
+ </optional>
173
+ <optional>
174
+ <attribute name="keep-lines-together">
175
+ <data type="boolean"/>
176
+ </attribute>
177
+ </optional>
138
178
  <oneOrMore>
139
179
  <ref name="BasicBlock"/>
140
180
  </oneOrMore>
@@ -18,7 +18,7 @@ module RelatonItu
18
18
  # @param ref [String]
19
19
  # @param year [String]
20
20
  def initialize(ref, year = nil) # rubocop:todo Metrics/MethodLength
21
- text = ref.sub /(?<=\.)Imp\s?(?=\d)/, ""
21
+ text = ref.sub(/(?<=\.)Imp\s?(?=\d)/, "")
22
22
  super text, year
23
23
  @agent = Mechanize.new
24
24
  agent.user_agent_alias = "Mac Safari"
@@ -27,8 +27,8 @@ module RelatonItu
27
27
  case ref
28
28
  when /^(ITU-T|ITU-R\sRR)/
29
29
  request_search
30
- when /^ITU-R\s([-_.\w]+)$/
31
- request_document($1.upcase)
30
+ when /^ITU-R\s/
31
+ request_document(ref)
32
32
  end
33
33
  end
34
34
 
@@ -45,7 +45,7 @@ module RelatonItu
45
45
  def request_document(ref) # rubocop:todo Metrics/MethodLength
46
46
  uri = URI::HTTPS.build(
47
47
  host: "raw.githubusercontent.com",
48
- path: "/relaton/relaton-data-itu-r/master/data/#{ref}.yaml"
48
+ path: "/relaton/relaton-data-itu-r/master/data/#{ref.gsub(/[\s.]/, '_')}.yaml",
49
49
  )
50
50
  resp = Net::HTTP.get_response(uri)
51
51
  if resp.code == "404"
@@ -55,7 +55,7 @@ module RelatonItu
55
55
 
56
56
  hash = YAML.safe_load resp.body
57
57
  item_hash = HashConverter.hash_to_bib(hash)
58
- item = ItuBibliographicItem.new **item_hash
58
+ item = ItuBibliographicItem.new(**item_hash)
59
59
  hit = Hit.new({ url: uri.to_s }, self)
60
60
  hit.fetch = item
61
61
  @array = [hit]
@@ -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\((\d{2}\/)?(?<year1>\d+)\)$/ =~ code
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)?(-(?<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})\))?
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! /(?<=\.)Imp(?=\d)/, "" if result.gi_imp
91
+ code1.sub!(/(?<=\.)Imp(?=\d)/, "") if result.gi_imp
94
92
  if corr1
95
- corr1.sub!(/[\.\s]+/, " ").sub!("Amendment", "Amd")
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)?(-(?<type2>\w))?\s?(?<code2>[\S]+)
103
- (\s\(?(?<ver2>v\d+)\)?)?
104
- (\s\(((?<month2>\d{2})\/)?(?<year2>\d{4})\))?
105
- (\s(?<corr2>(Amd|Cor)\.\s?\d+))?
106
- (\s\(((?<cormonth2>\d{2})\/)?(?<coryear2>\d{4})\))?
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
- /:[^\(]+\((?<buldate2>\d{2}\.\w{1,4}\.\d{4})\)/ =~ i.hit[:title]
109
- corr2&.sub! /\.\s?/, " "
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
- /\((\d{2}\/)?(?<pyear>\d{4})\)/ =~ r.hit[:code]
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
@@ -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
 
@@ -109,7 +109,7 @@ module RelatonItu
109
109
  docids = doc.xpath(
110
110
  "//span[@id='ctl00_content_main_uc_rec_main_info1_rpt_main_ctl00_lbl_rec']",
111
111
  "//td[.='Identical standard:']/following-sibling::td",
112
- "//div/table[1]/tr[4]/td/strong"
112
+ "//div/table[1]/tr[4]/td/strong",
113
113
  ).map { |c| createdocid c.text }
114
114
  docids << createdocid(title) unless docids.any?
115
115
  docids
@@ -119,18 +119,18 @@ module RelatonItu
119
119
  # @return [RelatonBib::DocumentIdentifier]
120
120
  def createdocid(text) # rubocop:disable Metrics/MethodLength
121
121
  %r{
122
- ^(?<code>((ITU-\w|ISO\/IEC)\s)?[^\(:]+)
123
- (\(((?<_month>\d{2})\/)?(?<_year>\d{4})\))?
124
- (:[^\(]+\((?<buldate>\d{2}\.\w{1,4}\.\d{4})\))?
125
- (\s(?<corr>(Amd|Cor)\.\s?\d+))?
122
+ ^(?<code>(?:(?:ITU-\w|ISO/IEC)\s)?[^(:]+)
123
+ (?:\((?:(?<_month>\d{2})/)?(?<_year>\d{4})\))?
124
+ (?::[^(]+\((?<buldate>\d{2}\.\w{1,4}\.\d{4})\))?
125
+ (?:\s(?<corr>(?:Amd|Cor)\.\s?\d+))?
126
126
  # (\s\(((?<_cormonth>\d{2})\/)?(?<_coryear>\d{4})\))?
127
127
  }x =~ text.squeeze(" ")
128
- corr&.sub! /\.\s?/, " "
128
+ corr&.sub!(/\.\s?/, " ")
129
129
  id = [code.sub(/[[:space:]]$/, ""), corr].compact.join " "
130
130
  id += " - #{buldate}" if buldate
131
131
  type = id.match(%r{^\w+}).to_s
132
132
  type = "ITU" if type == "G"
133
- RelatonBib::DocumentIdentifier.new(type: type, id: id)
133
+ RelatonBib::DocumentIdentifier.new(type: type, id: id, primary: true)
134
134
  end
135
135
 
136
136
  # Fetch status.
@@ -261,7 +261,7 @@ module RelatonItu
261
261
  links = [{ type: "src", content: doc.uri.to_s }]
262
262
  obp_elm = doc.at(
263
263
  '//a[@title="Persistent link to download the PDF file"]',
264
- "//font[contains(.,'PDF')]/../.."
264
+ "//font[contains(.,'PDF')]/../..",
265
265
  )
266
266
  links << typed_link("obp", obp_elm) if obp_elm
267
267
  wrd_elm = doc.at("//font[contains(.,'Word')]/../..")
@@ -274,7 +274,7 @@ module RelatonItu
274
274
  def typed_link(type, elm)
275
275
  {
276
276
  type: type,
277
- content: URI.join(HitCollection::DOMAIN + elm[:href].strip).to_s,
277
+ content: URI.join(HitCollection::DOMAIN, elm[:href].strip).to_s,
278
278
  }
279
279
  end
280
280
 
@@ -1,3 +1,3 @@
1
1
  module RelatonItu
2
- VERSION = "1.8.1".freeze
2
+ VERSION = "1.10.1".freeze
3
3
  end
data/relaton-itu.gemspec CHANGED
@@ -24,19 +24,17 @@ Gem::Specification.new do |spec|
24
24
  spec.bindir = "exe"
25
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
26
  spec.require_paths = ["lib"]
27
- spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
27
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
28
28
 
29
- # spec.add_development_dependency "debase"
30
29
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
31
30
  spec.add_development_dependency "pry-byebug"
32
31
  spec.add_development_dependency "rake", "~> 13.0"
33
32
  spec.add_development_dependency "rspec", "~> 3.0"
34
- # spec.add_development_dependency "ruby-debug-ide"
35
33
  spec.add_development_dependency "ruby-jing"
36
34
  spec.add_development_dependency "simplecov"
37
35
  spec.add_development_dependency "vcr", "~> 5.0.0"
38
36
  spec.add_development_dependency "webmock"
39
37
 
40
- spec.add_dependency "mechanize", "~> 2.7.0"
41
- spec.add_dependency "relaton-bib", "~> 1.8.0"
38
+ spec.add_dependency "mechanize", "~> 2.8.0"
39
+ spec.add_dependency "relaton-bib", "~> 1.10.1"
42
40
  end
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.8.1
4
+ version: 1.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-31 00:00:00.000000000 Z
11
+ date: 2022-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equivalent-xml
@@ -128,28 +128,28 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 2.7.0
131
+ version: 2.8.0
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 2.7.0
138
+ version: 2.8.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: relaton-bib
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 1.8.0
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.8.0
152
+ version: 1.10.1
153
153
  description: 'RelatonItu: retrieve ITU Standards for bibliographic use using the BibliographicItem
154
154
  model'
155
155
  email:
@@ -200,7 +200,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
200
200
  requirements:
201
201
  - - ">="
202
202
  - !ruby/object:Gem::Version
203
- version: 2.4.0
203
+ version: 2.5.0
204
204
  required_rubygems_version: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - ">="