relaton-oasis 1.18.0 → 1.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +10 -17
- data/grammars/basicdoc.rng +3 -0
- data/lib/relaton_oasis/data_fetcher.rb +1 -1
- data/lib/relaton_oasis/data_parser.rb +6 -3
- data/lib/relaton_oasis/data_parser_utils.rb +28 -12
- data/lib/relaton_oasis/data_part_parser.rb +12 -7
- data/lib/relaton_oasis/document_type.rb +3 -3
- data/lib/relaton_oasis/index.rb +1 -1
- data/lib/relaton_oasis/oasis_bibliographic_item.rb +2 -2
- data/lib/relaton_oasis/oasis_bibliography.rb +3 -3
- data/lib/relaton_oasis/util.rb +1 -4
- data/lib/relaton_oasis/version.rb +1 -1
- data/lib/relaton_oasis/xml_parser.rb +4 -0
- data/lib/relaton_oasis.rb +0 -1
- data/relaton_oasis.gemspec +2 -2
- metadata +7 -8
- data/lib/relaton_oasis/config.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17e6c9703f4210dd9ce8674da36d2f55d3333adeae4327cead1916500568f379
|
4
|
+
data.tar.gz: b1949a584249b5b509e1b8178de12b9abd8c1c8cb8ca03da620ce7c2a8cb9d2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fba601c6195bb9bacc28fa4ed4e58f6ed0d1fdcaa944f313c1019b96e5b371e0c606214fe1ccc116bbf0e0e4195480fdf04ad40951a41819a8e3652a537dde8e
|
7
|
+
data.tar.gz: f2e4fc968c99c09d0704692221fbd16a1427e26001d22c1fff5c39816c5a39501a0c4ddf05ed21ea55163e8e61ebff3b6f673850190368c8b6f6b212fc8a30ee
|
data/README.adoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
=
|
1
|
+
= RelatonOasis: retrieve OASIS Standards for bibliographic use using the BibliographicItem model
|
2
2
|
|
3
3
|
image:https://img.shields.io/gem/v/relaton-oasis.svg["Gem Version", link="https://rubygems.org/gems/relaton-oasis"]
|
4
4
|
image:https://github.com/relaton/relaton-oasis/workflows/macos/badge.svg["Build Status (macOS)", link="https://github.com/relaton/relaton-oasis/actions?workflow=macos"]
|
@@ -30,26 +30,15 @@ Or install it yourself as:
|
|
30
30
|
|
31
31
|
== Usage
|
32
32
|
|
33
|
-
===
|
33
|
+
=== Get standard using reference.
|
34
34
|
|
35
|
-
|
35
|
+
All the OASIS documents are parsed from https://www.oasis-open.org/standards/ and stored in a GitHub repository https://github.com/relaton/relaton-data-oasis. You can find all possible references on the index page https://relaton.github.io/relaton-data-oasis/.
|
36
36
|
|
37
37
|
[source,ruby]
|
38
38
|
----
|
39
39
|
require 'relaton_oasis'
|
40
40
|
=> true
|
41
41
|
|
42
|
-
RelatonOasis.configure do |config|
|
43
|
-
config.logger.level = Logger::DEBUG
|
44
|
-
end
|
45
|
-
----
|
46
|
-
|
47
|
-
=== Get standard using reference.
|
48
|
-
|
49
|
-
All the OASIS documents are parsed from https://www.oasis-open.org/standards/ and stored in a GitHub repository https://github.com/relaton/relaton-data-oasis. You can find all possible references on the index page https://relaton.github.io/relaton-data-oasis/.
|
50
|
-
|
51
|
-
[source,ruby]
|
52
|
-
----
|
53
42
|
item = RelatonOasis::OasisBibliography.get "OASIS amqp-core"
|
54
43
|
[relaton-oasis] (OASIS) amqp-core Fetching from Relaton repository ...
|
55
44
|
[relaton-oasis] (OASIS amqp-core) Found: `OASIS amqp-core`
|
@@ -62,7 +51,7 @@ item = RelatonOasis::OasisBibliography.get "OASIS amqp-core"
|
|
62
51
|
[source,ruby]
|
63
52
|
----
|
64
53
|
item.to_xml
|
65
|
-
=> "<bibitem id="OASISamqp-core" type="standard" schema-version="v1.2.
|
54
|
+
=> "<bibitem id="OASISamqp-core" type="standard" schema-version="v1.2.9">
|
66
55
|
<fetched>2022-12-05</fetched>
|
67
56
|
<title type="main" format="text/plain" language="en" script="Latn">Advanced Message Queueing Protocol (AMQP) v1.0</title>
|
68
57
|
<docidentifier type="OASIS" primary="true">OASIS amqp-core</docidentifier>
|
@@ -75,7 +64,7 @@ With argument `bibdata: true` it ouputs XML wrapped by `bibdata` element and add
|
|
75
64
|
[source,ruby]
|
76
65
|
----
|
77
66
|
item.to_xml bibdata: true
|
78
|
-
=> "<bibdata type="standard" schema-version="v1.2.
|
67
|
+
=> "<bibdata type="standard" schema-version="v1.2.9">
|
79
68
|
<fetched>2022-12-05</fetched>
|
80
69
|
<title type="main" format="text/plain" language="en" script="Latn">Advanced Message Queueing Protocol (AMQP) v1.0</title>
|
81
70
|
<docidentifier type="OASIS" primary="true">OASIS amqp-core</docidentifier>
|
@@ -121,7 +110,7 @@ RelatonOasis::XMLParser.from_xml File.read("spec/fixtures/oasis_bibdata.xml")
|
|
121
110
|
[source,ruby]
|
122
111
|
----
|
123
112
|
hash = YAML.load_file "spec/fixtures/oasis_bibdata.yaml"
|
124
|
-
=> {"schema-version"=>"v1.2.
|
113
|
+
=> {"schema-version"=>"v1.2.9",
|
125
114
|
"id"=>"OASISamqp-core",
|
126
115
|
...
|
127
116
|
|
@@ -150,6 +139,10 @@ Done in: 5 sec.
|
|
150
139
|
=> nil
|
151
140
|
----
|
152
141
|
|
142
|
+
=== Logging
|
143
|
+
|
144
|
+
RelatonOasis uses the relaton-logger gem for logging. By default, it logs to STDOUT. To change the log levels and add other loggers, read the https://github.com/relaton/relaton-logger#usage[relaton-logger] documentation.
|
145
|
+
|
153
146
|
== Development
|
154
147
|
|
155
148
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/grammars/basicdoc.rng
CHANGED
@@ -73,7 +73,7 @@ module RelatonOasis
|
|
73
73
|
end
|
74
74
|
file = file_name doc
|
75
75
|
if @files.include? file
|
76
|
-
warn "File #{file} already exists. Document: #{doc.docnumber}"
|
76
|
+
Util.warn "File #{file} already exists. Document: #{doc.docnumber}"
|
77
77
|
else
|
78
78
|
@files << file
|
79
79
|
@index[doc] = file
|
@@ -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
|
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,29 @@ 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
|
-
|
38
|
-
|
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}`\n#{e.message}"
|
57
|
+
nil
|
58
|
+
end
|
59
|
+
|
43
60
|
def parse_chairs
|
44
61
|
return [] unless page
|
45
62
|
|
@@ -96,12 +113,11 @@ module RelatonOasis
|
|
96
113
|
# @return [String] document identifier with specification if needed
|
97
114
|
#
|
98
115
|
def parse_spec(num)
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
parse_part(id)
|
116
|
+
case text
|
117
|
+
when /OASIS Project Specification (\d+)/ then "#{num}-PS#{$1}"
|
118
|
+
when /Committee Specification (\d+)/ then "#{num}-CS#{$1}"
|
119
|
+
else num
|
120
|
+
end
|
105
121
|
end
|
106
122
|
|
107
123
|
#
|
@@ -169,9 +185,9 @@ module RelatonOasis
|
|
169
185
|
# @return [Array<String>] technology areas
|
170
186
|
#
|
171
187
|
def parse_technology_area(node)
|
172
|
-
node.xpath(
|
173
|
-
"
|
174
|
-
|
188
|
+
node.xpath("./summary/div/div/ul[@class='technology-areas__list']/li/a").map do |ta|
|
189
|
+
ta.text.strip.gsub(/\s/, "-").sub("development", "Development")
|
190
|
+
end
|
175
191
|
end
|
176
192
|
end
|
177
193
|
end
|
@@ -13,9 +13,15 @@ module RelatonOasis
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def text
|
16
|
-
@text
|
17
|
-
|
18
|
-
|
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
|
-
|
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,6 +1,6 @@
|
|
1
1
|
module RelatonOasis
|
2
2
|
class DocumentType < RelatonBib::DocumentType
|
3
|
-
|
3
|
+
DOCTYPES = %w[specification memorandum resolution standard].freeze
|
4
4
|
|
5
5
|
def initialize(type:, abbreviation: nil)
|
6
6
|
chceck_type type
|
@@ -8,8 +8,8 @@ module RelatonOasis
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def chceck_type(type)
|
11
|
-
unless
|
12
|
-
Util.warn "
|
11
|
+
unless DOCTYPES.include? type
|
12
|
+
Util.warn "invalid doctype: `#{type}`"
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
data/lib/relaton_oasis/index.rb
CHANGED
@@ -17,8 +17,8 @@ module RelatonOasis
|
|
17
17
|
uta = @technology_area.reject { |a| AREAS.include? a }
|
18
18
|
if uta.any?
|
19
19
|
area = uta.size > 1 ? "areas" : "area"
|
20
|
-
Util.warn "
|
21
|
-
|
20
|
+
Util.warn "Unknown technology #{area}: `#{uta.join('`, `')}`\n" \
|
21
|
+
"Valid values are: `#{AREAS.join('`, `')}`"
|
22
22
|
end
|
23
23
|
super
|
24
24
|
end
|
@@ -36,13 +36,13 @@ module RelatonOasis
|
|
36
36
|
# reference is required
|
37
37
|
# @return [RelatonOasis::OasisBibliographicItem, nil]
|
38
38
|
def get(code, year = nil, _opts = {}) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
39
|
-
Util.
|
39
|
+
Util.info "Fetching from Relaton repository ...", key: code
|
40
40
|
bibitem = search code, year
|
41
41
|
if bibitem
|
42
42
|
docid = bibitem.docidentifier.detect(&:primary).id
|
43
|
-
Util.
|
43
|
+
Util.info "Found: `#{docid}`", key: code
|
44
44
|
else
|
45
|
-
Util.
|
45
|
+
Util.info "Not found.", key: code
|
46
46
|
end
|
47
47
|
bibitem
|
48
48
|
end
|
data/lib/relaton_oasis/util.rb
CHANGED
data/lib/relaton_oasis.rb
CHANGED
@@ -4,7 +4,6 @@ require "mechanize"
|
|
4
4
|
require "relaton/index"
|
5
5
|
require "relaton_bib"
|
6
6
|
require_relative "relaton_oasis/version"
|
7
|
-
require_relative "relaton_oasis/config"
|
8
7
|
require_relative "relaton_oasis/util"
|
9
8
|
require_relative "relaton_oasis/document_type"
|
10
9
|
require_relative "relaton_oasis/oasis_bibliographic_item"
|
data/relaton_oasis.gemspec
CHANGED
@@ -31,9 +31,9 @@ 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.
|
34
|
+
spec.add_dependency "mechanize", "~> 2.10"
|
35
35
|
spec.add_dependency "multi_json", "~> 1.15.0"
|
36
|
-
spec.add_dependency "relaton-bib", "~> 1.
|
36
|
+
spec.add_dependency "relaton-bib", "~> 1.19.0"
|
37
37
|
spec.add_dependency "relaton-index", "~> 0.2.0"
|
38
38
|
|
39
39
|
# For more information and examples about making a new gem, checkout our
|
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.
|
4
|
+
version: 1.19.0
|
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-
|
11
|
+
date: 2024-07-04 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.
|
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.
|
26
|
+
version: '2.10'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: multi_json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
47
|
+
version: 1.19.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
54
|
+
version: 1.19.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: relaton-index
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,7 +92,6 @@ files:
|
|
92
92
|
- grammars/relaton-oasis-compile.rng
|
93
93
|
- grammars/relaton-oasis.rng
|
94
94
|
- lib/relaton_oasis.rb
|
95
|
-
- lib/relaton_oasis/config.rb
|
96
95
|
- lib/relaton_oasis/data_fetcher.rb
|
97
96
|
- lib/relaton_oasis/data_parser.rb
|
98
97
|
- lib/relaton_oasis/data_parser_utils.rb
|
@@ -128,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
127
|
- !ruby/object:Gem::Version
|
129
128
|
version: '0'
|
130
129
|
requirements: []
|
131
|
-
rubygems_version: 3.3.
|
130
|
+
rubygems_version: 3.3.27
|
132
131
|
signing_key:
|
133
132
|
specification_version: 4
|
134
133
|
summary: 'RelatonOasis: retrieve OASIS Standards for bibliographic use using the BibliographicItem
|