relaton-iec 0.10.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.adoc +1 -1
- data/grammars/basicdoc.rng +986 -0
- data/grammars/biblio.rng +1180 -0
- data/grammars/iec.rng +43 -0
- data/grammars/isodoc.rng +1058 -0
- data/{grammars → grammars/isostandard.rng} +137 -472
- data/grammars/reqt.rng +165 -0
- data/lib/relaton_iec.rb +12 -9
- data/lib/relaton_iec/hash_converter.rb +14 -0
- data/lib/relaton_iec/hit.rb +1 -1
- data/lib/relaton_iec/hit_collection.rb +0 -1
- data/lib/relaton_iec/iec_bibliographic_item.rb +9 -0
- data/lib/relaton_iec/iec_bibliography.rb +3 -8
- data/lib/relaton_iec/processor.rb +7 -7
- data/lib/relaton_iec/scrapper.rb +3 -5
- data/lib/relaton_iec/version.rb +1 -1
- data/lib/relaton_iec/xml_parser.rb +14 -0
- data/relaton_iec.gemspec +6 -5
- metadata +29 -7
data/grammars/reqt.rng
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
|
3
|
+
<!--
|
4
|
+
Presupposes isodoc.rnc, is included in it
|
5
|
+
include "isodoc.rnc" { }
|
6
|
+
-->
|
7
|
+
<define name="requirement">
|
8
|
+
<element name="requirement">
|
9
|
+
<ref name="RequirementType"/>
|
10
|
+
</element>
|
11
|
+
</define>
|
12
|
+
<define name="recommendation">
|
13
|
+
<element name="recommendation">
|
14
|
+
<ref name="RequirementType"/>
|
15
|
+
</element>
|
16
|
+
</define>
|
17
|
+
<define name="permission">
|
18
|
+
<element name="permission">
|
19
|
+
<ref name="RequirementType"/>
|
20
|
+
</element>
|
21
|
+
</define>
|
22
|
+
<define name="RequirementType">
|
23
|
+
<optional>
|
24
|
+
<attribute name="obligation">
|
25
|
+
<ref name="ObligationType"/>
|
26
|
+
</attribute>
|
27
|
+
</optional>
|
28
|
+
<optional>
|
29
|
+
<attribute name="unnumbered">
|
30
|
+
<data type="boolean"/>
|
31
|
+
</attribute>
|
32
|
+
</optional>
|
33
|
+
<optional>
|
34
|
+
<attribute name="subsequence"/>
|
35
|
+
</optional>
|
36
|
+
<attribute name="id">
|
37
|
+
<data type="ID"/>
|
38
|
+
</attribute>
|
39
|
+
<optional>
|
40
|
+
<attribute name="filename"/>
|
41
|
+
</optional>
|
42
|
+
<optional>
|
43
|
+
<ref name="reqtitle"/>
|
44
|
+
</optional>
|
45
|
+
<optional>
|
46
|
+
<ref name="label"/>
|
47
|
+
</optional>
|
48
|
+
<optional>
|
49
|
+
<ref name="subject"/>
|
50
|
+
</optional>
|
51
|
+
<optional>
|
52
|
+
<ref name="reqinherit"/>
|
53
|
+
</optional>
|
54
|
+
<zeroOrMore>
|
55
|
+
<ref name="classification"/>
|
56
|
+
</zeroOrMore>
|
57
|
+
<zeroOrMore>
|
58
|
+
<choice>
|
59
|
+
<ref name="measurementtarget"/>
|
60
|
+
<ref name="specification"/>
|
61
|
+
<ref name="verification"/>
|
62
|
+
<ref name="import"/>
|
63
|
+
<ref name="description"/>
|
64
|
+
</choice>
|
65
|
+
</zeroOrMore>
|
66
|
+
<optional>
|
67
|
+
<ref name="reqt_references"/>
|
68
|
+
</optional>
|
69
|
+
<zeroOrMore>
|
70
|
+
<choice>
|
71
|
+
<ref name="requirement"/>
|
72
|
+
<ref name="recommendation"/>
|
73
|
+
<ref name="permission"/>
|
74
|
+
</choice>
|
75
|
+
</zeroOrMore>
|
76
|
+
</define>
|
77
|
+
<define name="reqtitle">
|
78
|
+
<element name="title">
|
79
|
+
<ref name="FormattedString"/>
|
80
|
+
</element>
|
81
|
+
</define>
|
82
|
+
<define name="label">
|
83
|
+
<element name="label">
|
84
|
+
<text/>
|
85
|
+
</element>
|
86
|
+
</define>
|
87
|
+
<define name="subject">
|
88
|
+
<element name="subject">
|
89
|
+
<text/>
|
90
|
+
</element>
|
91
|
+
</define>
|
92
|
+
<define name="reqinherit">
|
93
|
+
<element name="inherit">
|
94
|
+
<text/>
|
95
|
+
</element>
|
96
|
+
</define>
|
97
|
+
<define name="measurementtarget">
|
98
|
+
<element name="measurement-target">
|
99
|
+
<ref name="RequirementSubpart"/>
|
100
|
+
</element>
|
101
|
+
</define>
|
102
|
+
<define name="specification">
|
103
|
+
<element name="specification">
|
104
|
+
<ref name="RequirementSubpart"/>
|
105
|
+
</element>
|
106
|
+
</define>
|
107
|
+
<define name="verification">
|
108
|
+
<element name="verification">
|
109
|
+
<ref name="RequirementSubpart"/>
|
110
|
+
</element>
|
111
|
+
</define>
|
112
|
+
<define name="import">
|
113
|
+
<element name="import">
|
114
|
+
<ref name="RequirementSubpart"/>
|
115
|
+
</element>
|
116
|
+
</define>
|
117
|
+
<define name="description">
|
118
|
+
<element name="description">
|
119
|
+
<ref name="RequirementSubpart"/>
|
120
|
+
</element>
|
121
|
+
</define>
|
122
|
+
<define name="reqt_references">
|
123
|
+
<element name="references">
|
124
|
+
<oneOrMore>
|
125
|
+
<ref name="bibitem"/>
|
126
|
+
</oneOrMore>
|
127
|
+
</element>
|
128
|
+
</define>
|
129
|
+
<define name="RequirementSubpart">
|
130
|
+
<optional>
|
131
|
+
<attribute name="type"/>
|
132
|
+
</optional>
|
133
|
+
<optional>
|
134
|
+
<attribute name="exclude">
|
135
|
+
<data type="boolean"/>
|
136
|
+
</attribute>
|
137
|
+
</optional>
|
138
|
+
<oneOrMore>
|
139
|
+
<ref name="BasicBlock"/>
|
140
|
+
</oneOrMore>
|
141
|
+
</define>
|
142
|
+
<define name="ObligationType">
|
143
|
+
<choice>
|
144
|
+
<value>requirement</value>
|
145
|
+
<value>recommendation</value>
|
146
|
+
<value>permission</value>
|
147
|
+
</choice>
|
148
|
+
</define>
|
149
|
+
<define name="classification">
|
150
|
+
<element name="classification">
|
151
|
+
<ref name="classification_tag"/>
|
152
|
+
<ref name="classification_value"/>
|
153
|
+
</element>
|
154
|
+
</define>
|
155
|
+
<define name="classification_tag">
|
156
|
+
<element name="tag">
|
157
|
+
<text/>
|
158
|
+
</element>
|
159
|
+
</define>
|
160
|
+
<define name="classification_value">
|
161
|
+
<element name="value">
|
162
|
+
<text/>
|
163
|
+
</element>
|
164
|
+
</define>
|
165
|
+
</grammar>
|
data/lib/relaton_iec.rb
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
require "relaton_iec/version"
|
2
2
|
require "relaton_iec/iec_bibliography"
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
# return if caller.detect { |c| c.include? "register_gems" }
|
8
|
-
|
9
|
-
# Relaton::Registry.instance.register(RelatonIec::Processor)
|
10
|
-
# end
|
3
|
+
require "relaton_iec/iec_bibliographic_item"
|
4
|
+
require "relaton_iec/xml_parser"
|
5
|
+
require "relaton_iec/hash_converter"
|
6
|
+
require "digest/md5"
|
11
7
|
|
12
8
|
module RelatonIec
|
13
|
-
#
|
9
|
+
# Returns hash of XML reammar
|
10
|
+
# @return [String]
|
11
|
+
def self.grammar_hash
|
12
|
+
gem_path = File.expand_path "..", __dir__
|
13
|
+
grammars_path = File.join gem_path, "grammars", "*"
|
14
|
+
grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
|
15
|
+
Digest::MD5.hexdigest grammars
|
16
|
+
end
|
14
17
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module RelatonIec
|
2
|
+
class HashConverter < RelatonIsoBib::HashConverter
|
3
|
+
class << self
|
4
|
+
#
|
5
|
+
# Ovverides superclass's method
|
6
|
+
#
|
7
|
+
# @param item [Hash]
|
8
|
+
# @retirn [RelatonIec::IecBibliographicItem]
|
9
|
+
def bib_item(item)
|
10
|
+
IecBibliographicItem.new(item)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/relaton_iec/hit.rb
CHANGED
@@ -17,15 +17,10 @@ module RelatonIec
|
|
17
17
|
raise RelatonBib::RequestError, "Could not access http://www.iec.ch"
|
18
18
|
end
|
19
19
|
|
20
|
-
# @param text [String]
|
21
|
-
# @return [Array<IsoBibliographicItem>]
|
22
|
-
# def search_and_fetch(text, year = nil)
|
23
|
-
# Scrapper.get(text, year)
|
24
|
-
# end
|
25
|
-
|
26
20
|
# @param code [String] the ISO standard Code to look up (e..g "ISO 9000")
|
27
21
|
# @param year [String] the year the standard was published (optional)
|
28
|
-
# @param opts [Hash] options; restricted to :all_parts if all-parts
|
22
|
+
# @param opts [Hash] options; restricted to :all_parts if all-parts
|
23
|
+
# reference is required
|
29
24
|
# @return [String] Relaton XML serialisation of reference
|
30
25
|
def get(code, year = nil, opts = {})
|
31
26
|
if year.nil?
|
@@ -72,7 +67,7 @@ module RelatonIec
|
|
72
67
|
workers.worker { |w| { i: w[:i], hit: w[:hit].fetch } }
|
73
68
|
s.each_with_index { |hit, i| workers << { i: i, hit: hit } }
|
74
69
|
workers.end
|
75
|
-
workers.result.
|
70
|
+
workers.result.sort_by { |a| a[:i] }.map { |x| x[:hit] }
|
76
71
|
end
|
77
72
|
|
78
73
|
def isobib_search_filter(code)
|
@@ -12,28 +12,28 @@ module RelatonIec
|
|
12
12
|
# @param code [String]
|
13
13
|
# @param date [String, NilClass] year
|
14
14
|
# @param opts [Hash]
|
15
|
-
# @return [RelatonIsoBib::
|
15
|
+
# @return [RelatonIsoBib::IecBibliographicItem]
|
16
16
|
def get(code, date, opts)
|
17
17
|
::RelatonIec::IecBibliography.get(code, date, opts)
|
18
18
|
end
|
19
19
|
|
20
20
|
# @param xml [String]
|
21
|
-
# @return [RelatonIsoBib::
|
21
|
+
# @return [RelatonIsoBib::IecBibliographicItem]
|
22
22
|
def from_xml(xml)
|
23
|
-
|
23
|
+
RelatonIec::XMLParser.from_xml xml
|
24
24
|
end
|
25
25
|
|
26
26
|
# @param hash [Hash]
|
27
|
-
# @return [RelatonIsoBib::
|
27
|
+
# @return [RelatonIsoBib::IecBibliographicItem]
|
28
28
|
def hash_to_bib(hash)
|
29
|
-
item_hash = ::
|
30
|
-
::
|
29
|
+
item_hash = ::RelatonIec::HashConverter.hash_to_bib(hash)
|
30
|
+
::RelatonIec::IecBibliographicItem.new item_hash
|
31
31
|
end
|
32
32
|
|
33
33
|
# Returns hash of XML grammar
|
34
34
|
# @return [String]
|
35
35
|
def grammar_hash
|
36
|
-
@grammar_hash ||= ::
|
36
|
+
@grammar_hash ||= ::RelatonIec.grammar_hash
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
data/lib/relaton_iec/scrapper.rb
CHANGED
@@ -56,7 +56,7 @@ module RelatonIec
|
|
56
56
|
|
57
57
|
status, relations = fetch_status_relations hit_data[:url]
|
58
58
|
|
59
|
-
|
59
|
+
IecBibliographicItem.new(
|
60
60
|
fetched: Date.today.to_s,
|
61
61
|
docid: [RelatonBib::DocumentIdentifier.new(id: hit_data[:code], type: "IEC")],
|
62
62
|
structuredidentifier: fetch_structuredidentifier(doc),
|
@@ -246,7 +246,7 @@ module RelatonIec
|
|
246
246
|
doc.xpath('//ROW[STATUS[.!="PREPARING"]][STATUS[.!="PUBLISHED"]]').map do |r|
|
247
247
|
r_type = r.at("STATUS").text.downcase
|
248
248
|
type = case r_type
|
249
|
-
|
249
|
+
# when 'published' then 'obsoletes' # Valid
|
250
250
|
when "revised", "replaced" then "updates"
|
251
251
|
when "withdrawn" then "obsoletes"
|
252
252
|
else r_type
|
@@ -255,9 +255,7 @@ module RelatonIec
|
|
255
255
|
fref = RelatonBib::FormattedRef.new(
|
256
256
|
content: r.at("FULL_NAME").text, format: "text/plain",
|
257
257
|
)
|
258
|
-
bibitem =
|
259
|
-
formattedref: fref,
|
260
|
-
)
|
258
|
+
bibitem = IecBibliographicItem.new(formattedref: fref)
|
261
259
|
{ type: type, bibitem: bibitem }
|
262
260
|
end
|
263
261
|
end
|
data/lib/relaton_iec/version.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
module RelatonIec
|
2
|
+
class XMLParser < RelatonIsoBib::XMLParser
|
3
|
+
class << self
|
4
|
+
private
|
5
|
+
|
6
|
+
# override RelatonIsoBib::IsoBibliographicItem.bib_item method
|
7
|
+
# @param item_hash [Hash]
|
8
|
+
# @return [RelatonIec::IecBibliographicItem]
|
9
|
+
def bib_item(item_hash)
|
10
|
+
IecBibliographicItem.new item_hash
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/relaton_iec.gemspec
CHANGED
@@ -8,10 +8,10 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["Ribose Inc."]
|
9
9
|
spec.email = ["open.source@ribose.com"]
|
10
10
|
|
11
|
-
spec.summary = "RelatonIec: retrieve IEC Standards for bibliographic
|
12
|
-
"using the
|
13
|
-
spec.description = "RelatonIec: retrieve IEC Standards for bibliographic
|
14
|
-
"using the
|
11
|
+
spec.summary = "RelatonIec: retrieve IEC Standards for bibliographic "\
|
12
|
+
"use using the IecBibliographicItem model"
|
13
|
+
spec.description = "RelatonIec: retrieve IEC Standards for bibliographic "\
|
14
|
+
"use using the IecBibliographicItem model"
|
15
15
|
spec.homepage = "https://github.com/metanorma/relaton-iec"
|
16
16
|
spec.license = "MIT"
|
17
17
|
|
@@ -29,10 +29,11 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_development_dependency "rake", "~> 10.0"
|
30
30
|
spec.add_development_dependency "rspec", "~> 3.0"
|
31
31
|
spec.add_development_dependency "ruby-debug-ide"
|
32
|
+
spec.add_development_dependency "ruby-jing"
|
32
33
|
spec.add_development_dependency "simplecov"
|
33
34
|
spec.add_development_dependency "vcr"
|
34
35
|
spec.add_development_dependency "webmock"
|
35
36
|
|
36
37
|
spec.add_dependency "addressable"
|
37
|
-
spec.add_dependency "relaton-iso-bib", "~> 0.
|
38
|
+
spec.add_dependency "relaton-iso-bib", "~> 1.0.0"
|
38
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-iec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.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: 2020-
|
11
|
+
date: 2020-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: debase
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: ruby-jing
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: simplecov
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,15 +170,15 @@ dependencies:
|
|
156
170
|
requirements:
|
157
171
|
- - "~>"
|
158
172
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0.
|
173
|
+
version: 1.0.0
|
160
174
|
type: :runtime
|
161
175
|
prerelease: false
|
162
176
|
version_requirements: !ruby/object:Gem::Requirement
|
163
177
|
requirements:
|
164
178
|
- - "~>"
|
165
179
|
- !ruby/object:Gem::Version
|
166
|
-
version: 0.
|
167
|
-
description: 'RelatonIec: retrieve IEC Standards for bibliographic use using the
|
180
|
+
version: 1.0.0
|
181
|
+
description: 'RelatonIec: retrieve IEC Standards for bibliographic use using the IecBibliographicItem
|
168
182
|
model'
|
169
183
|
email:
|
170
184
|
- open.source@ribose.com
|
@@ -184,15 +198,23 @@ files:
|
|
184
198
|
- Rakefile
|
185
199
|
- bin/console
|
186
200
|
- bin/setup
|
187
|
-
- grammars
|
201
|
+
- grammars/basicdoc.rng
|
202
|
+
- grammars/biblio.rng
|
203
|
+
- grammars/iec.rng
|
204
|
+
- grammars/isodoc.rng
|
205
|
+
- grammars/isostandard.rng
|
206
|
+
- grammars/reqt.rng
|
188
207
|
- lib/relaton_iec.rb
|
208
|
+
- lib/relaton_iec/hash_converter.rb
|
189
209
|
- lib/relaton_iec/hit.rb
|
190
210
|
- lib/relaton_iec/hit_collection.rb
|
211
|
+
- lib/relaton_iec/iec_bibliographic_item.rb
|
191
212
|
- lib/relaton_iec/iec_bibliography.rb
|
192
213
|
- lib/relaton_iec/processor.rb
|
193
214
|
- lib/relaton_iec/scrapper.rb
|
194
215
|
- lib/relaton_iec/statuses.yml
|
195
216
|
- lib/relaton_iec/version.rb
|
217
|
+
- lib/relaton_iec/xml_parser.rb
|
196
218
|
- relaton_iec.gemspec
|
197
219
|
homepage: https://github.com/metanorma/relaton-iec
|
198
220
|
licenses:
|
@@ -216,6 +238,6 @@ requirements: []
|
|
216
238
|
rubygems_version: 3.0.6
|
217
239
|
signing_key:
|
218
240
|
specification_version: 4
|
219
|
-
summary: 'RelatonIec: retrieve IEC Standards for bibliographic use using the
|
241
|
+
summary: 'RelatonIec: retrieve IEC Standards for bibliographic use using the IecBibliographicItem
|
220
242
|
model'
|
221
243
|
test_files: []
|