relaton-w3c 1.9.2 → 1.9.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -0
  3. data/README.adoc +70 -72
  4. data/data/reference.W3C.CR-rdf-schema.xml +16 -0
  5. data/data/reference.W3C.DSig-label.xml +32 -0
  6. data/data/reference.W3C.P3P-rdfschema.xml +26 -0
  7. data/data/reference.W3C.P3P.xml +38 -0
  8. data/data/reference.W3C.PICS-labels.xml +43 -0
  9. data/data/reference.W3C.PICS-rules.xml +38 -0
  10. data/data/reference.W3C.PICS-services.xml +37 -0
  11. data/data/reference.W3C.REC-RUBY.xml +22 -0
  12. data/data/reference.W3C.REC-XHTML.xml +12 -0
  13. data/data/reference.W3C.REC-rdf-syntax.xml +31 -0
  14. data/data/reference.W3C.REC-xml-1998.xml +20 -0
  15. data/data/reference.W3C.REC-xml-names.xml +28 -0
  16. data/data/reference.W3C.REC-xml.xml +35 -0
  17. data/data/reference.W3C.REC-xmlenc-core.xml +23 -0
  18. data/data/reference.W3C.REC-xmlschema-1.xml +23 -0
  19. data/data/reference.W3C.REC-xmlschema-2.xml +17 -0
  20. data/data/reference.W3C.daml-oil-reference.xml +39 -0
  21. data/data/reference.W3C.soap11.xml +56 -0
  22. data/data/reference.W3C.soap12-part1.xml +38 -0
  23. data/data/reference.W3C.soap12-part2.xml +38 -0
  24. data/data/reference.W3C.xkms.xml +50 -0
  25. data/data/reference.W3C.xml-c14n.xml +15 -0
  26. data/data/reference.W3C.xmldsig-core.xml +26 -0
  27. data/data/reference.W3C.xmlenc-core.xml +20 -0
  28. data/data/reference.W3C.xpath.xml +22 -0
  29. data/grammars/isodoc.rng +2106 -0
  30. data/grammars/reqt.rng +194 -0
  31. data/lib/relaton_w3c/data_fethcer.rb +4 -0
  32. data/lib/relaton_w3c/hit_collection.rb +1 -1
  33. data/lib/relaton_w3c/version.rb +1 -1
  34. data/lib/relaton_w3c/w3c_bibliography.rb +19 -6
  35. data/relaton_w3c.gemspec +1 -1
  36. metadata +31 -4
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>
@@ -47,6 +47,10 @@ module RelatonW3c
47
47
  #
48
48
  def fetch
49
49
  query.each { |sl| save_doc DataParser.parse(sl, self) }
50
+ Dir[File.expand_path("../../data/*", __dir__)].each do |file|
51
+ xml = File.read file, encoding: "UTF-8"
52
+ save_doc RelatonBib::BibXMLParser.parse(xml)
53
+ end
50
54
  end
51
55
 
52
56
  #
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module RelatonW3c
2
- VERSION = "1.9.2".freeze
2
+ VERSION = "1.9.6".freeze
3
3
  end
@@ -5,11 +5,21 @@ 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
+ return unless resp.code == "200"
19
+
20
+ hash = YAML.safe_load resp.body
21
+ item_hash = ::RelatonW3c::HashConverter.hash_to_bib(hash)
22
+ ::RelatonW3c::W3cBibliographicItem.new(**item_hash)
13
23
  rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET,
14
24
  EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
15
25
  Net::ProtocolError, Errno::ETIMEDOUT
@@ -24,11 +34,14 @@ module RelatonW3c
24
34
  def get(ref, _year = nil, _opts = {})
25
35
  warn "[relaton-w3c] (\"#{ref}\") fetching..."
26
36
  result = search(ref)
27
- return unless result.any?
37
+ unless result
38
+ warn "[relaton-w3c] (\"#{ref}\") not found."
39
+ return
40
+ end
28
41
 
29
- ret = result.first.fetch
30
- warn "[relaton-w3c] (\"#{ref}\") found #{ret.title.first.title.content}"
31
- ret
42
+ # ret = result.first.fetch
43
+ warn "[relaton-w3c] (\"#{ref}\") found #{result.title.first.title.content}"
44
+ result
32
45
  end
33
46
  end
34
47
  end
data/relaton_w3c.gemspec CHANGED
@@ -40,6 +40,6 @@ Gem::Specification.new do |spec|
40
40
  spec.add_dependency "linkeddata", "~> 3.1.0"
41
41
  spec.add_dependency "mechanize", "~> 2.8.0"
42
42
  spec.add_dependency "rdf", "~> 3.1.0"
43
- spec.add_dependency "relaton-bib", ">= 1.9.0"
43
+ spec.add_dependency "relaton-bib", ">= 1.9.19"
44
44
  spec.add_dependency "sparql", "~> 3.1.0"
45
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-w3c
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.2
4
+ version: 1.9.6
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-11-20 00:00:00.000000000 Z
11
+ date: 2022-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equivalent-xml
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - ">="
130
130
  - !ruby/object:Gem::Version
131
- version: 1.9.0
131
+ version: 1.9.19
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: 1.9.0
138
+ version: 1.9.19
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: sparql
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -170,8 +170,35 @@ files:
170
170
  - bin/console
171
171
  - bin/rspec
172
172
  - bin/setup
173
+ - data/reference.W3C.CR-rdf-schema.xml
174
+ - data/reference.W3C.DSig-label.xml
175
+ - data/reference.W3C.P3P-rdfschema.xml
176
+ - data/reference.W3C.P3P.xml
177
+ - data/reference.W3C.PICS-labels.xml
178
+ - data/reference.W3C.PICS-rules.xml
179
+ - data/reference.W3C.PICS-services.xml
180
+ - data/reference.W3C.REC-RUBY.xml
181
+ - data/reference.W3C.REC-XHTML.xml
182
+ - data/reference.W3C.REC-rdf-syntax.xml
183
+ - data/reference.W3C.REC-xml-1998.xml
184
+ - data/reference.W3C.REC-xml-names.xml
185
+ - data/reference.W3C.REC-xml.xml
186
+ - data/reference.W3C.REC-xmlenc-core.xml
187
+ - data/reference.W3C.REC-xmlschema-1.xml
188
+ - data/reference.W3C.REC-xmlschema-2.xml
189
+ - data/reference.W3C.daml-oil-reference.xml
190
+ - data/reference.W3C.soap11.xml
191
+ - data/reference.W3C.soap12-part1.xml
192
+ - data/reference.W3C.soap12-part2.xml
193
+ - data/reference.W3C.xkms.xml
194
+ - data/reference.W3C.xml-c14n.xml
195
+ - data/reference.W3C.xmldsig-core.xml
196
+ - data/reference.W3C.xmlenc-core.xml
197
+ - data/reference.W3C.xpath.xml
173
198
  - grammars/basicdoc.rng
174
199
  - grammars/biblio.rng
200
+ - grammars/isodoc.rng
201
+ - grammars/reqt.rng
175
202
  - lib/relaton_w3c.rb
176
203
  - lib/relaton_w3c/data_fethcer.rb
177
204
  - lib/relaton_w3c/data_parser.rb