relaton-oasis 1.18.0 → 1.18.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7af584f19a16f6f912b1242faab1684145903c6692e296dcfb22a8d447ec4111
4
- data.tar.gz: 9cbcfa115749c4b3437d8779b1e629d9091626c63bb0acee052e477eb90bc8bb
3
+ metadata.gz: dac6ccdcd3852748aecbcc84c9ed6e5228fe321ab6659de9d7bf2233f9850c5a
4
+ data.tar.gz: 285d6b583d9ba375a41be2c82dc1c025353cb39e160c76652eef266170fbbf69
5
5
  SHA512:
6
- metadata.gz: 1e16bd7e46e2b93ae7302d8a05e440dd16aa546eca389424f14f316bea536ac4ce99fdb73bac4d3ddf0ec1041f84cedd0e17eec26216157d4b0619dfee6ee86f
7
- data.tar.gz: e7d0d75e90aea7b43ad3c16f02ac2656cdcca891ad935629ed1a3c68b88fc3b3a864426c744185c15ab9999ae55397d13af1b363485a4fd587aa98b04cf9a0ee
6
+ metadata.gz: a9ff1cebaef0e7b8ea8e995aa47b9686042ff3e7ceb764dd6abbb4b60f3f16eee529514bd3a029d818ed55c1e1d05f214c578a4430592dc2f8231d356a94db66
7
+ data.tar.gz: d814e66a65fb439b70ba32ce02942d26c20ea83c741f0ebb14b9299eb38ada6ae90367db992554c168f7f4d04f556501ca9e6eaedf8d2e043473faad1a7dae4a
@@ -244,6 +244,9 @@
244
244
  <data type="ID"/>
245
245
  </attribute>
246
246
  <attribute name="reviewer"/>
247
+ <optional>
248
+ <attribute name="type"/>
249
+ </optional>
247
250
  <optional>
248
251
  <attribute name="date">
249
252
  <data type="dateTime"/>
@@ -165,14 +165,17 @@ module RelatonOasis
165
165
 
166
166
  #
167
167
  # Parse document number.
168
+ # If the docuemnt has no parts, the document number is constructed from the title.
169
+ # If the document had one part, the document number is constructed from the part.
170
+ # If the document has parts, the document number is constructed from the parts.
168
171
  #
169
172
  # @return [String] document number
170
173
  #
171
174
  def parse_docnumber
172
175
  parts = document_part_refs
173
176
  case parts.size
174
- when 0 then title_to_docid @node.at("./summary/div/h2").text
175
- when 1 then parse_spec(parts[0])
177
+ when 0 then parse_spec title_to_docid(@node.at("./summary/div/h2").text)
178
+ when 1 then parse_part parse_spec(parts[0])
176
179
  else parts_to_docid parts
177
180
  end
178
181
  end
@@ -194,7 +197,7 @@ module RelatonOasis
194
197
  end
195
198
  end
196
199
  end.join("-")
197
- parse_spec(id)
200
+ parse_part parse_spec(id)
198
201
  end
199
202
 
200
203
  #
@@ -34,12 +34,30 @@ module RelatonOasis
34
34
  if link_node && link_node[:href].match?(/\.html$/)
35
35
  agent = Mechanize.new
36
36
  agent.agent.allowed_error_codes = [404]
37
- sleep 1 # to avoid 429 error
38
- resp = agent.get link_node[:href]
39
- @page = resp if resp.code == "200"
37
+ resp = retry_page(link_node[:href], agent)
38
+ @page = resp if resp && resp.code == "200"
40
39
  end
41
40
  end
42
41
 
42
+ #
43
+ # Retry to get page.
44
+ #
45
+ # @param [String] url page URL
46
+ # @param [Mechanize] agent HTTP client
47
+ # @param [Integer] retries number of retries
48
+ #
49
+ # @return [Mechanize::Page, nil] page or nil
50
+ #
51
+ def retry_page(url, agent, retries = 3)
52
+ sleep 1 # to avoid 429 error
53
+ agent.get url
54
+ rescue Errno::ETIMEDOUT, Net::OpenTimeout => e
55
+ retry if (retries -= 1).positive?
56
+ Util.error "Failed to get page `#{url}`"
57
+ Util.error e.message
58
+ nil
59
+ end
60
+
43
61
  def parse_chairs
44
62
  return [] unless page
45
63
 
@@ -96,12 +114,11 @@ module RelatonOasis
96
114
  # @return [String] document identifier with specification if needed
97
115
  #
98
116
  def parse_spec(num)
99
- id = case text
100
- when /OASIS Project Specification (\d+)/ then "#{num}-PS#{$1}"
101
- when /Committee Specification (\d+)/ then "#{num}-CS#{$1}"
102
- else num
103
- end
104
- parse_part(id)
117
+ case text
118
+ when /OASIS Project Specification (\d+)/ then "#{num}-PS#{$1}"
119
+ when /Committee Specification (\d+)/ then "#{num}-CS#{$1}"
120
+ else num
121
+ end
105
122
  end
106
123
 
107
124
  #
@@ -169,9 +186,9 @@ module RelatonOasis
169
186
  # @return [Array<String>] technology areas
170
187
  #
171
188
  def parse_technology_area(node)
172
- node.xpath(
173
- "./summary/div/div/ul[@class='technology-areas__list']/li/a",
174
- ).map { |ta| ta.text.strip.gsub(/\s/, "-") }
189
+ node.xpath("./summary/div/div/ul[@class='technology-areas__list']/li/a").map do |ta|
190
+ ta.text.strip.gsub(/\s/, "-").sub("development", "Development")
191
+ end
175
192
  end
176
193
  end
177
194
  end
@@ -13,9 +13,15 @@ module RelatonOasis
13
13
  end
14
14
 
15
15
  def text
16
- @text ||= @node.xpath(
17
- "./strong/following-sibling::text()|./span/strong/../following-sibling::text()",
18
- ).text.strip
16
+ return @text if @text
17
+
18
+ if @node.at("./strong/following-sibling::text()|./span[strong]/following-sibling::text()")
19
+ @text = @node.xpath(
20
+ "./strong/following-sibling::node()|./span[strong]/following-sibling::node()",
21
+ ).text.strip
22
+ else
23
+ @text = @node.xpath("./following-sibling::p[1][em]").text.strip
24
+ end
19
25
  end
20
26
 
21
27
  def title
@@ -72,7 +78,7 @@ module RelatonOasis
72
78
  id = parse_errata(num)
73
79
  # some part references need to be added by "Pt" to be distinguishable from root doc
74
80
  id += "-Pt" if %w[CMIS-v1.1 DocBook-5.0 XACML-V3.0 mqtt-v3.1.1 OData-JSON-Format-v4.0].include?(id)
75
- parse_spec id
81
+ parse_part parse_spec id
76
82
  end
77
83
 
78
84
  #
@@ -81,8 +87,7 @@ module RelatonOasis
81
87
  # @return [Array<RelatonBib::TypedTitleString>] link
82
88
  #
83
89
  def parse_link
84
- l = @node.at("./a")
85
- [RelatonBib::TypedUri.new(type: "src", content: l[:href])]
90
+ [RelatonBib::TypedUri.new(type: "src", content: link_node[:href])]
86
91
  end
87
92
 
88
93
  #
@@ -139,7 +144,7 @@ module RelatonOasis
139
144
  end
140
145
 
141
146
  def link_node
142
- @link_node = @node.at("./a")
147
+ @link_node = @node.at("./a|./following-sibling::p[1]/a")
143
148
  end
144
149
 
145
150
  #
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelatonOasis
4
- VERSION = "1.18.0"
4
+ VERSION = "1.18.1"
5
5
  end
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
32
  spec.require_paths = ["lib"]
33
33
 
34
- spec.add_dependency "mechanize", "~> 2.8.0"
34
+ spec.add_dependency "mechanize", "~> 2.10"
35
35
  spec.add_dependency "multi_json", "~> 1.15.0"
36
36
  spec.add_dependency "relaton-bib", "~> 1.18.0"
37
37
  spec.add_dependency "relaton-index", "~> 0.2.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-oasis
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.0
4
+ version: 1.18.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: 2024-01-08 00:00:00.000000000 Z
11
+ date: 2024-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.8.0
19
+ version: '2.10'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.8.0
26
+ version: '2.10'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: multi_json
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  - !ruby/object:Gem::Version
129
129
  version: '0'
130
130
  requirements: []
131
- rubygems_version: 3.3.26
131
+ rubygems_version: 3.3.27
132
132
  signing_key:
133
133
  specification_version: 4
134
134
  summary: 'RelatonOasis: retrieve OASIS Standards for bibliographic use using the BibliographicItem