relaton-w3c 2.0.0.pre.alpha.2 → 2.0.0.pre.alpha.3
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/grammars/basicdoc.rng +14 -1
- data/grammars/biblio.rng +8 -8
- data/lib/relaton/w3c/data_fetcher.rb +6 -1
- data/lib/relaton/w3c/data_parser.rb +61 -31
- data/lib/relaton/w3c/version.rb +1 -1
- data/relaton_w3c.gemspec +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e66091ac00e7a3627997d643fae3005bb08040a9a1b78af24c9999fe17395a3d
|
|
4
|
+
data.tar.gz: d51269340fb6078839dd76428f17bb162bf732c94e9e907e85122655bf90fd15
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f220190b3521496cc9aefce09bd9e26b0a7d028650abb691b599d1093ce7685a092da47839379067e036f9c4c763257f7239164a5e41743fa6206f800592f366
|
|
7
|
+
data.tar.gz: ae4809955aa747f00ff44cb582c9eeb4fa2e709966c5691a7bc90b715b252e2cb6d1ee4904497ce01a9035b6bdb8faebb127a3acf8cffc6f3fad1ca6e95e6f7f
|
data/grammars/basicdoc.rng
CHANGED
|
@@ -187,6 +187,15 @@ Applicable to modify and delete</a:documentation>
|
|
|
187
187
|
<a:documentation>Optional caption of this block</a:documentation>
|
|
188
188
|
</attribute>
|
|
189
189
|
</optional>
|
|
190
|
+
<optional>
|
|
191
|
+
<attribute name="position">
|
|
192
|
+
<a:documentation>For an "add" change, whether the change is added before or after the location</a:documentation>
|
|
193
|
+
<choice>
|
|
194
|
+
<value>before</value>
|
|
195
|
+
<value>after</value>
|
|
196
|
+
</choice>
|
|
197
|
+
</attribute>
|
|
198
|
+
</optional>
|
|
190
199
|
<optional>
|
|
191
200
|
<element name="location">
|
|
192
201
|
<a:documentation>The location(s) in the original document which have undergone the change described in this block</a:documentation>
|
|
@@ -208,11 +217,15 @@ Applicable to modify and delete</a:documentation>
|
|
|
208
217
|
</zeroOrMore>
|
|
209
218
|
<optional>
|
|
210
219
|
<element name="newcontent">
|
|
211
|
-
<a:documentation>New content to be added to the document; applicable to add and modify
|
|
220
|
+
<a:documentation>New content to be added to the document; applicable to add and modify.
|
|
221
|
+
Can be blocks and/or sections</a:documentation>
|
|
212
222
|
<ref name="OptionalId"/>
|
|
213
223
|
<zeroOrMore>
|
|
214
224
|
<ref name="BasicBlock"/>
|
|
215
225
|
</zeroOrMore>
|
|
226
|
+
<zeroOrMore>
|
|
227
|
+
<ref name="section"/>
|
|
228
|
+
</zeroOrMore>
|
|
216
229
|
</element>
|
|
217
230
|
</optional>
|
|
218
231
|
<zeroOrMore>
|
data/grammars/biblio.rng
CHANGED
|
@@ -1142,11 +1142,11 @@ NOTE: This should preferably be encoded as a URI or short identifier, rather th
|
|
|
1142
1142
|
<a:documentation>Information about how long the current description of the bibliographic item is valid for</a:documentation>
|
|
1143
1143
|
</ref>
|
|
1144
1144
|
</optional>
|
|
1145
|
-
<
|
|
1145
|
+
<zeroOrMore>
|
|
1146
1146
|
<ref name="depiction">
|
|
1147
1147
|
<a:documentation>Depiction of the bibliographic item, typically an image</a:documentation>
|
|
1148
1148
|
</ref>
|
|
1149
|
-
</
|
|
1149
|
+
</zeroOrMore>
|
|
1150
1150
|
</define>
|
|
1151
1151
|
<define name="ReducedBibliographicItem">
|
|
1152
1152
|
<a:documentation>Reduced description of a bibliographic resource, without mandatory title and docidentifier, used for document relations
|
|
@@ -1939,10 +1939,10 @@ Detailed in https://www.relaton.org/model/relations/</a:documentation>
|
|
|
1939
1939
|
<value>hasAnnotation</value>
|
|
1940
1940
|
<value>draftOf</value>
|
|
1941
1941
|
<value>hasDraft</value>
|
|
1942
|
-
<value>
|
|
1943
|
-
<value>
|
|
1944
|
-
<value>
|
|
1945
|
-
<value>
|
|
1942
|
+
<value>predecessorDraftOf</value>
|
|
1943
|
+
<value>hasPredecessorDraft</value>
|
|
1944
|
+
<value>successorDraftOf</value>
|
|
1945
|
+
<value>hasSuccessorDraft</value>
|
|
1946
1946
|
<value>editionOf</value>
|
|
1947
1947
|
<value>hasEdition</value>
|
|
1948
1948
|
<value>updates</value>
|
|
@@ -2063,13 +2063,13 @@ provided that it is not the entire bibliographic item that is so related</a:docu
|
|
|
2063
2063
|
<ref name="LocalizedString"/>
|
|
2064
2064
|
</element>
|
|
2065
2065
|
</optional>
|
|
2066
|
-
<
|
|
2066
|
+
<zeroOrMore>
|
|
2067
2067
|
<element name="taxon">
|
|
2068
2068
|
<a:documentation>The keywords as a hierarchical taxonomy. For example, the sequence of `taxon` elements
|
|
2069
2069
|
`pump`, `centrifugal pump`, `line shaft pump` represents a taxonomic classification</a:documentation>
|
|
2070
2070
|
<ref name="LocalizedString"/>
|
|
2071
2071
|
</element>
|
|
2072
|
-
</
|
|
2072
|
+
</zeroOrMore>
|
|
2073
2073
|
<zeroOrMore>
|
|
2074
2074
|
<ref name="vocabid">
|
|
2075
2075
|
<a:documentation>Identifiers for the keyword as a controlled vocabulary</a:documentation>
|
|
@@ -14,6 +14,10 @@ module Relaton
|
|
|
14
14
|
@index ||= Relaton::Index.find_or_create(:W3C, file: "#{INDEXFILE}.yaml")
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
def log_error(msg)
|
|
18
|
+
Util.error msg
|
|
19
|
+
end
|
|
20
|
+
|
|
17
21
|
def client
|
|
18
22
|
@client ||= W3cApi::Client.new
|
|
19
23
|
end
|
|
@@ -33,11 +37,12 @@ module Relaton
|
|
|
33
37
|
specs = specs.next
|
|
34
38
|
end
|
|
35
39
|
index.save
|
|
40
|
+
report_errors
|
|
36
41
|
end
|
|
37
42
|
|
|
38
43
|
def fetch_spec(unrealized_spec)
|
|
39
44
|
spec = realize unrealized_spec
|
|
40
|
-
save_doc DataParser.parse(spec)
|
|
45
|
+
save_doc DataParser.parse(spec, @errors)
|
|
41
46
|
|
|
42
47
|
if spec.links.respond_to?(:version_history) && spec.links.version_history
|
|
43
48
|
version_history = realize spec.links.version_history
|
|
@@ -27,8 +27,13 @@ module Relaton
|
|
|
27
27
|
#
|
|
28
28
|
# @param [W3cApi::Models::SpecVersion] spec
|
|
29
29
|
#
|
|
30
|
-
|
|
30
|
+
ERROR_KEYS = %i[status title doc_uri formattedref series date
|
|
31
|
+
relation contributor doctype].freeze
|
|
32
|
+
|
|
33
|
+
def initialize(spec, errors = {})
|
|
31
34
|
@spec = spec
|
|
35
|
+
@errors = errors
|
|
36
|
+
ERROR_KEYS.each { |k| @errors[k] = true unless @errors.key?(k) }
|
|
32
37
|
end
|
|
33
38
|
|
|
34
39
|
#
|
|
@@ -38,8 +43,8 @@ module Relaton
|
|
|
38
43
|
#
|
|
39
44
|
# @return [Relaton::W3c::ItemData, nil] bibliographic item
|
|
40
45
|
#
|
|
41
|
-
def self.parse(spec)
|
|
42
|
-
new(spec).parse
|
|
46
|
+
def self.parse(spec, errors = {})
|
|
47
|
+
new(spec, errors).parse
|
|
43
48
|
end
|
|
44
49
|
|
|
45
50
|
#
|
|
@@ -52,9 +57,9 @@ module Relaton
|
|
|
52
57
|
type: "standard",
|
|
53
58
|
language: ["en"],
|
|
54
59
|
script: ["Latn"],
|
|
55
|
-
status:
|
|
60
|
+
status: parse_status,
|
|
56
61
|
title: parse_title,
|
|
57
|
-
source:
|
|
62
|
+
source: parse_source,
|
|
58
63
|
docidentifier: parse_docid,
|
|
59
64
|
formattedref: parse_formattedref,
|
|
60
65
|
docnumber: identifier,
|
|
@@ -73,7 +78,8 @@ module Relaton
|
|
|
73
78
|
#
|
|
74
79
|
def parse_ext
|
|
75
80
|
dt = parse_doctype
|
|
76
|
-
Ext.new(doctype: dt, flavor: "w3c")
|
|
81
|
+
result = Ext.new(doctype: dt, flavor: "w3c")
|
|
82
|
+
result
|
|
77
83
|
end
|
|
78
84
|
|
|
79
85
|
#
|
|
@@ -81,10 +87,12 @@ module Relaton
|
|
|
81
87
|
#
|
|
82
88
|
# @return [Bib::Status, nil] document status
|
|
83
89
|
#
|
|
84
|
-
def
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
90
|
+
def parse_status
|
|
91
|
+
result = if @spec.respond_to?(:status) && @spec.status
|
|
92
|
+
Bib::Status.new(stage: Bib::Status::Stage.new(content: @spec.status))
|
|
93
|
+
end
|
|
94
|
+
@errors[:status] &&= result.nil?
|
|
95
|
+
result
|
|
88
96
|
end
|
|
89
97
|
|
|
90
98
|
#
|
|
@@ -93,11 +101,17 @@ module Relaton
|
|
|
93
101
|
# @return [Array<Bib::Title>] title
|
|
94
102
|
#
|
|
95
103
|
def parse_title(spec = @spec)
|
|
96
|
-
[
|
|
104
|
+
return [] unless spec&.title && spec.title.strip != ""
|
|
105
|
+
|
|
106
|
+
result = [Bib::Title.new(content: spec.title, language: "en", script: "Latn")]
|
|
107
|
+
@errors[:title] &&= result.empty?
|
|
108
|
+
result
|
|
97
109
|
end
|
|
98
110
|
|
|
99
111
|
def doc_uri(spec = @spec)
|
|
100
|
-
spec.respond_to?(:uri) ? spec.uri : spec.shortlink
|
|
112
|
+
result = spec.respond_to?(:uri) ? spec.uri : spec.shortlink
|
|
113
|
+
@errors[:doc_uri] &&= result.nil?
|
|
114
|
+
result
|
|
101
115
|
end
|
|
102
116
|
|
|
103
117
|
#
|
|
@@ -105,7 +119,7 @@ module Relaton
|
|
|
105
119
|
#
|
|
106
120
|
# @return [Array<Bib::Uri>] link
|
|
107
121
|
#
|
|
108
|
-
def
|
|
122
|
+
def parse_source
|
|
109
123
|
[Bib::Uri.new(type: "src", content: doc_uri)]
|
|
110
124
|
end
|
|
111
125
|
|
|
@@ -159,10 +173,14 @@ module Relaton
|
|
|
159
173
|
# @return [Array<Bib::Series>] series
|
|
160
174
|
#
|
|
161
175
|
def parse_series
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
176
|
+
result = if type
|
|
177
|
+
title = Bib::Title.new(content: "W3C #{type}", language: "en", script: "Latn")
|
|
178
|
+
[Bib::Series.new(title: [title], number: identifier)]
|
|
179
|
+
else
|
|
180
|
+
[]
|
|
181
|
+
end
|
|
182
|
+
@errors[:series] &&= result.empty?
|
|
183
|
+
result
|
|
166
184
|
end
|
|
167
185
|
|
|
168
186
|
#
|
|
@@ -181,7 +199,9 @@ module Relaton
|
|
|
181
199
|
#
|
|
182
200
|
def parse_doctype
|
|
183
201
|
t = DOCTYPES[type] || DOCTYPES[type_from_link]
|
|
184
|
-
Doctype.new(content: t) if t
|
|
202
|
+
result = Doctype.new(content: t) if t
|
|
203
|
+
@errors[:doctype] &&= result.nil?
|
|
204
|
+
result
|
|
185
205
|
end
|
|
186
206
|
|
|
187
207
|
#
|
|
@@ -199,9 +219,13 @@ module Relaton
|
|
|
199
219
|
# @return [Array<Bib::Date>] date
|
|
200
220
|
#
|
|
201
221
|
def parse_date
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
222
|
+
result = if @spec.respond_to?(:date)
|
|
223
|
+
[Bib::Date.new(type: "published", at: @spec.date.to_date.to_s)]
|
|
224
|
+
else
|
|
225
|
+
[]
|
|
226
|
+
end
|
|
227
|
+
@errors[:date] &&= result.empty?
|
|
228
|
+
result
|
|
205
229
|
end
|
|
206
230
|
|
|
207
231
|
#
|
|
@@ -210,12 +234,14 @@ module Relaton
|
|
|
210
234
|
# @return [Array<Bib::Relation>] relation
|
|
211
235
|
#
|
|
212
236
|
def parse_relation
|
|
213
|
-
if @spec.links.respond_to?(:version_history)
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
237
|
+
result = if @spec.links.respond_to?(:version_history)
|
|
238
|
+
version_history = realize @spec.links.version_history
|
|
239
|
+
version_history.links.spec_versions.map { |version| create_relation(version, "hasEdition") }
|
|
240
|
+
else
|
|
241
|
+
relations
|
|
242
|
+
end
|
|
243
|
+
@errors[:relation] &&= result.empty?
|
|
244
|
+
result
|
|
219
245
|
end
|
|
220
246
|
|
|
221
247
|
#
|
|
@@ -268,9 +294,11 @@ module Relaton
|
|
|
268
294
|
# @return [String, nil] formattedref
|
|
269
295
|
#
|
|
270
296
|
def parse_formattedref
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
297
|
+
result = if @spec.respond_to?(:uri)
|
|
298
|
+
Bib::Formattedref.new(content: pub_id(@spec.uri))
|
|
299
|
+
end
|
|
300
|
+
@errors[:formattedref] &&= result.nil?
|
|
301
|
+
result
|
|
274
302
|
end
|
|
275
303
|
|
|
276
304
|
#
|
|
@@ -292,7 +320,9 @@ module Relaton
|
|
|
292
320
|
end
|
|
293
321
|
end
|
|
294
322
|
|
|
295
|
-
contribs + parse_deliverers
|
|
323
|
+
result = contribs + parse_deliverers
|
|
324
|
+
@errors[:contributor] &&= result.empty?
|
|
325
|
+
result
|
|
296
326
|
end
|
|
297
327
|
|
|
298
328
|
def create_editor(unrealized_editor)
|
data/lib/relaton/w3c/version.rb
CHANGED
data/relaton_w3c.gemspec
CHANGED
|
@@ -35,8 +35,8 @@ Gem::Specification.new do |spec|
|
|
|
35
35
|
spec.add_dependency "mechanize", "~> 2.10"
|
|
36
36
|
spec.add_dependency "rdf", "~> 3.2"
|
|
37
37
|
spec.add_dependency "rdf-normalize", "~> 0.6"
|
|
38
|
-
spec.add_dependency "relaton-bib", "~> 2.0.0-alpha.
|
|
39
|
-
spec.add_dependency "relaton-core", "~> 0.0.
|
|
38
|
+
spec.add_dependency "relaton-bib", "~> 2.0.0-alpha.7"
|
|
39
|
+
spec.add_dependency "relaton-core", "~> 0.0.13"
|
|
40
40
|
spec.add_dependency "relaton-index", "~> 0.2.8"
|
|
41
41
|
spec.add_dependency "rubyzip", "~> 2.3"
|
|
42
42
|
spec.add_dependency "shex", "~> 0.7"
|
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: 2.0.0.pre.alpha.
|
|
4
|
+
version: 2.0.0.pre.alpha.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -71,28 +71,28 @@ dependencies:
|
|
|
71
71
|
requirements:
|
|
72
72
|
- - "~>"
|
|
73
73
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: 2.0.0.pre.alpha.
|
|
74
|
+
version: 2.0.0.pre.alpha.7
|
|
75
75
|
type: :runtime
|
|
76
76
|
prerelease: false
|
|
77
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
78
78
|
requirements:
|
|
79
79
|
- - "~>"
|
|
80
80
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: 2.0.0.pre.alpha.
|
|
81
|
+
version: 2.0.0.pre.alpha.7
|
|
82
82
|
- !ruby/object:Gem::Dependency
|
|
83
83
|
name: relaton-core
|
|
84
84
|
requirement: !ruby/object:Gem::Requirement
|
|
85
85
|
requirements:
|
|
86
86
|
- - "~>"
|
|
87
87
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: 0.0.
|
|
88
|
+
version: 0.0.13
|
|
89
89
|
type: :runtime
|
|
90
90
|
prerelease: false
|
|
91
91
|
version_requirements: !ruby/object:Gem::Requirement
|
|
92
92
|
requirements:
|
|
93
93
|
- - "~>"
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: 0.0.
|
|
95
|
+
version: 0.0.13
|
|
96
96
|
- !ruby/object:Gem::Dependency
|
|
97
97
|
name: relaton-index
|
|
98
98
|
requirement: !ruby/object:Gem::Requirement
|