relaton-w3c 1.9.2 → 1.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +68 -70
- data/grammars/isodoc.rng +2106 -0
- data/grammars/reqt.rng +194 -0
- data/lib/relaton_w3c/hit_collection.rb +1 -1
- data/lib/relaton_w3c/version.rb +1 -1
- data/lib/relaton_w3c/w3c_bibliography.rb +14 -6
- metadata +3 -1
data/grammars/reqt.rng
ADDED
@@ -0,0 +1,194 @@
|
|
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="number"/>
|
35
|
+
</optional>
|
36
|
+
<optional>
|
37
|
+
<attribute name="subsequence"/>
|
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>
|
49
|
+
<attribute name="id">
|
50
|
+
<data type="ID"/>
|
51
|
+
</attribute>
|
52
|
+
<optional>
|
53
|
+
<attribute name="filename"/>
|
54
|
+
</optional>
|
55
|
+
<optional>
|
56
|
+
<attribute name="model"/>
|
57
|
+
</optional>
|
58
|
+
<optional>
|
59
|
+
<attribute name="type"/>
|
60
|
+
</optional>
|
61
|
+
<optional>
|
62
|
+
<ref name="reqtitle"/>
|
63
|
+
</optional>
|
64
|
+
<optional>
|
65
|
+
<ref name="label"/>
|
66
|
+
</optional>
|
67
|
+
<optional>
|
68
|
+
<ref name="subject"/>
|
69
|
+
</optional>
|
70
|
+
<zeroOrMore>
|
71
|
+
<ref name="reqinherit"/>
|
72
|
+
</zeroOrMore>
|
73
|
+
<zeroOrMore>
|
74
|
+
<ref name="classification"/>
|
75
|
+
</zeroOrMore>
|
76
|
+
<zeroOrMore>
|
77
|
+
<choice>
|
78
|
+
<ref name="measurementtarget"/>
|
79
|
+
<ref name="specification"/>
|
80
|
+
<ref name="verification"/>
|
81
|
+
<ref name="import"/>
|
82
|
+
<ref name="description"/>
|
83
|
+
</choice>
|
84
|
+
</zeroOrMore>
|
85
|
+
<optional>
|
86
|
+
<ref name="reqt_references"/>
|
87
|
+
</optional>
|
88
|
+
<zeroOrMore>
|
89
|
+
<choice>
|
90
|
+
<ref name="requirement"/>
|
91
|
+
<ref name="recommendation"/>
|
92
|
+
<ref name="permission"/>
|
93
|
+
</choice>
|
94
|
+
</zeroOrMore>
|
95
|
+
</define>
|
96
|
+
<define name="reqtitle">
|
97
|
+
<element name="title">
|
98
|
+
<ref name="FormattedString"/>
|
99
|
+
</element>
|
100
|
+
</define>
|
101
|
+
<define name="label">
|
102
|
+
<element name="label">
|
103
|
+
<text/>
|
104
|
+
</element>
|
105
|
+
</define>
|
106
|
+
<define name="subject">
|
107
|
+
<element name="subject">
|
108
|
+
<text/>
|
109
|
+
</element>
|
110
|
+
</define>
|
111
|
+
<define name="reqinherit">
|
112
|
+
<element name="inherit">
|
113
|
+
<text/>
|
114
|
+
</element>
|
115
|
+
</define>
|
116
|
+
<define name="measurementtarget">
|
117
|
+
<element name="measurement-target">
|
118
|
+
<ref name="RequirementSubpart"/>
|
119
|
+
</element>
|
120
|
+
</define>
|
121
|
+
<define name="specification">
|
122
|
+
<element name="specification">
|
123
|
+
<ref name="RequirementSubpart"/>
|
124
|
+
</element>
|
125
|
+
</define>
|
126
|
+
<define name="verification">
|
127
|
+
<element name="verification">
|
128
|
+
<ref name="RequirementSubpart"/>
|
129
|
+
</element>
|
130
|
+
</define>
|
131
|
+
<define name="import">
|
132
|
+
<element name="import">
|
133
|
+
<ref name="RequirementSubpart"/>
|
134
|
+
</element>
|
135
|
+
</define>
|
136
|
+
<define name="description">
|
137
|
+
<element name="description">
|
138
|
+
<ref name="RequirementSubpart"/>
|
139
|
+
</element>
|
140
|
+
</define>
|
141
|
+
<define name="reqt_references">
|
142
|
+
<element name="references">
|
143
|
+
<oneOrMore>
|
144
|
+
<ref name="bibitem"/>
|
145
|
+
</oneOrMore>
|
146
|
+
</element>
|
147
|
+
</define>
|
148
|
+
<define name="RequirementSubpart">
|
149
|
+
<optional>
|
150
|
+
<attribute name="type"/>
|
151
|
+
</optional>
|
152
|
+
<optional>
|
153
|
+
<attribute name="exclude">
|
154
|
+
<data type="boolean"/>
|
155
|
+
</attribute>
|
156
|
+
</optional>
|
157
|
+
<optional>
|
158
|
+
<attribute name="keep-with-next">
|
159
|
+
<data type="boolean"/>
|
160
|
+
</attribute>
|
161
|
+
</optional>
|
162
|
+
<optional>
|
163
|
+
<attribute name="keep-lines-together">
|
164
|
+
<data type="boolean"/>
|
165
|
+
</attribute>
|
166
|
+
</optional>
|
167
|
+
<oneOrMore>
|
168
|
+
<ref name="BasicBlock"/>
|
169
|
+
</oneOrMore>
|
170
|
+
</define>
|
171
|
+
<define name="ObligationType">
|
172
|
+
<choice>
|
173
|
+
<value>requirement</value>
|
174
|
+
<value>recommendation</value>
|
175
|
+
<value>permission</value>
|
176
|
+
</choice>
|
177
|
+
</define>
|
178
|
+
<define name="classification">
|
179
|
+
<element name="classification">
|
180
|
+
<ref name="classification_tag"/>
|
181
|
+
<ref name="classification_value"/>
|
182
|
+
</element>
|
183
|
+
</define>
|
184
|
+
<define name="classification_tag">
|
185
|
+
<element name="tag">
|
186
|
+
<text/>
|
187
|
+
</element>
|
188
|
+
</define>
|
189
|
+
<define name="classification_value">
|
190
|
+
<element name="value">
|
191
|
+
<text/>
|
192
|
+
</element>
|
193
|
+
</define>
|
194
|
+
</grammar>
|
@@ -60,7 +60,7 @@ module RelatonW3c
|
|
60
60
|
# @param date [String]
|
61
61
|
# @return [TrueClass, FalseClass]
|
62
62
|
def type_date_filter(hit, type, date) # rubocop:disable Metrics/AbcSize
|
63
|
-
if type && hit["type"] != short_type(type) || date && hit["date"] != date
|
63
|
+
if (type && hit["type"] != short_type(type)) || (date && hit["date"] != date)
|
64
64
|
history = get_history hit, type, date
|
65
65
|
return false unless history.any?
|
66
66
|
|
data/lib/relaton_w3c/version.rb
CHANGED
@@ -5,11 +5,19 @@ require "net/http"
|
|
5
5
|
module RelatonW3c
|
6
6
|
# Class methods for search W3C standards.
|
7
7
|
class W3cBibliography
|
8
|
+
SOURCE = "https://raw.githubusercontent.com/relaton/relaton-data-w3c/main/data/"
|
9
|
+
|
8
10
|
class << self
|
9
11
|
# @param text [String]
|
10
12
|
# @return [RelatonW3c::HitCollection]
|
11
|
-
def search(text)
|
12
|
-
HitCollection.new text
|
13
|
+
def search(text) # rubocop:disable Metrics/MethodLength
|
14
|
+
# HitCollection.new text
|
15
|
+
file = text.sub(/^W3C\s/, "").gsub(/[\s,:\/]/, "_").squeeze("_").upcase
|
16
|
+
url = "#{SOURCE}#{file}.yaml"
|
17
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
18
|
+
hash = YAML.safe_load resp.body
|
19
|
+
item_hash = ::RelatonW3c::HashConverter.hash_to_bib(hash)
|
20
|
+
::RelatonW3c::W3cBibliographicItem.new(**item_hash)
|
13
21
|
rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET,
|
14
22
|
EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
|
15
23
|
Net::ProtocolError, Errno::ETIMEDOUT
|
@@ -24,11 +32,11 @@ module RelatonW3c
|
|
24
32
|
def get(ref, _year = nil, _opts = {})
|
25
33
|
warn "[relaton-w3c] (\"#{ref}\") fetching..."
|
26
34
|
result = search(ref)
|
27
|
-
return unless result.any?
|
35
|
+
return unless result # .any?
|
28
36
|
|
29
|
-
ret = result.first.fetch
|
30
|
-
warn "[relaton-w3c] (\"#{ref}\") found #{
|
31
|
-
|
37
|
+
# ret = result.first.fetch
|
38
|
+
warn "[relaton-w3c] (\"#{ref}\") found #{result.title.first.title.content}"
|
39
|
+
result
|
32
40
|
end
|
33
41
|
end
|
34
42
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-w3c
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
@@ -172,6 +172,8 @@ files:
|
|
172
172
|
- bin/setup
|
173
173
|
- grammars/basicdoc.rng
|
174
174
|
- grammars/biblio.rng
|
175
|
+
- grammars/isodoc.rng
|
176
|
+
- grammars/reqt.rng
|
175
177
|
- lib/relaton_w3c.rb
|
176
178
|
- lib/relaton_w3c/data_fethcer.rb
|
177
179
|
- lib/relaton_w3c/data_parser.rb
|