relaton-ogc 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90678f8153fbe6d491167a572472f8d39e9068f7ff7a85329cf15d15c89e6714
4
- data.tar.gz: 3643899f4251f2f5855db1793c01b6e696cf9afb14fc7e5dbfc35e318cfe4dd0
3
+ metadata.gz: 9cfbc84c1c8b6e734df1aa7ee14a9e7ad70ba6d700cf4a3742c55a6ce682d7a0
4
+ data.tar.gz: 66cbf24bea596b7324bc61731165b528937a85393d5b9fe5d94248b397a60c99
5
5
  SHA512:
6
- metadata.gz: ba824ba54cc142c4ab836461ad0973fe1db823a1955cf8e07385360aa1e905f4c26c5d4b567813466c61d6accfb7e5e62b56b3478c4cd1bbc7e2b7301d1b36cb
7
- data.tar.gz: 0b0f923561036d8cc54fb989efe0fcbc7ac753cd008007c83a50910b9894838b82ba4459f14054ce00527f7d8ba0c21dccf7a1235809b06dc37ad6b23a893aec
6
+ metadata.gz: 8fed77dee49a7fe3ae389a12f46b25c74ba499f09de7a5270ce29332639c85e911213f824e3104628a34cd99999e4f68d593458e90a104cf7a106ebbc02b5487
7
+ data.tar.gz: a3e244bc4e45743a0f07527a7dbfb042a436805805b244839047c2842b71f6dfbe76ff7f4bfe8b093b32e041ca8a9c20d741bfdf367750fde726790f5c29c56c
@@ -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</a:documentation>
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
- <optional>
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
- </optional>
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>preliminaryDraftOf</value>
1943
- <value>hasPreliminaryDraft</value>
1944
- <value>revisionDraftOf</value>
1945
- <value>hasRevisionDraft</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
- <oneOrMore>
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
- </oneOrMore>
2072
+ </zeroOrMore>
2073
2073
  <zeroOrMore>
2074
2074
  <ref name="vocabid">
2075
2075
  <a:documentation>Identifiers for the keyword as a controlled vocabulary</a:documentation>
@@ -18,10 +18,6 @@ module Relaton
18
18
  @dupids = Set.new
19
19
  end
20
20
 
21
- def gh_issue_channel
22
- ["relaton/relaton-ogc", "Error fetching OGC documents"]
23
- end
24
-
25
21
  def log_error(msg)
26
22
  Util.error msg
27
23
  end
@@ -39,13 +35,14 @@ module Relaton
39
35
  end
40
36
  self.etag = etag if no_errors
41
37
  index.save
38
+ report_errors
42
39
  end
43
40
  end
44
41
 
45
42
  def fetch_doc(hit)
46
43
  return if hit["type"] == "CC"
47
44
 
48
- bib = Scraper.parse_page hit
45
+ bib = Scraper.parse_page hit, @errors
49
46
  write_document bib
50
47
  true
51
48
  rescue StandardError => e
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Relaton
4
4
  module Ogc
5
- module Scraper
5
+ class Scraper
6
6
  TYPES = {
7
7
  "AS" => { type: "abstract-specification-topic" },
8
8
  "BP" => { type: "best-practice", subtype: "general" },
@@ -30,173 +30,195 @@ module Relaton
30
30
  "RP" => { type: "discussion-paper" },
31
31
  }.freeze
32
32
 
33
- class << self
34
- # @param hit [Hash]
35
- # @return [Relaton::Ogc::Item]
36
- def parse_page(hit) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
37
- type = fetch_type(hit["type"])
38
- contribs = fetch_contributor(hit)
39
- contribs << fetch_editorialgroup_contributor
40
- ItemData.new(
41
- type: "standard",
42
- title: fetch_title(hit["title"]),
43
- docidentifier: fetch_docid(hit["identifier"]),
44
- source: fetch_link(hit),
45
- status: fetch_status(type[:stage]),
46
- edition: fetch_edition(hit["identifier"]),
47
- abstract: fetch_abstract(hit["description"]),
48
- contributor: contribs,
49
- language: ["en"],
50
- script: ["Latn"],
51
- date: fetch_date(hit["date"]),
52
- ext: Ext.new(
53
- doctype: fetch_doctype(type[:type]),
54
- subdoctype: type[:subtype],
55
- flavor: "ogc",
56
- ),
57
- )
58
- end
33
+ def self.parse_page(hit, errors = Hash.new(true))
34
+ new(hit, errors).parse
35
+ end
59
36
 
60
- private
61
-
62
- def fetch_editorialgroup_contributor # rubocop:disable Metrics/MethodLength
63
- desc = Bib::LocalizedMarkedUpString.new(content: "committee")
64
- role = Bib::Contributor::Role.new(
65
- type: "author", description: [desc],
66
- )
67
- ogc = "Open Geospatial Consortium"
68
- org = Bib::Organization.new(
69
- name: [Bib::TypedLocalizedString.new(content: ogc)],
70
- abbreviation: Bib::LocalizedString.new(content: "OGC"),
71
- subdivision: [Bib::Subdivision.new(
72
- type: "technical-committee",
73
- name: [Bib::TypedLocalizedString.new(content: "technical")],
74
- )],
75
- )
76
- Bib::Contributor.new(role: [role], organization: org)
77
- end
37
+ # @param hit [Hash]
38
+ # @param errors [Hash]
39
+ def initialize(hit, errors = Hash.new(true))
40
+ @hit = hit
41
+ @errors = errors
42
+ end
78
43
 
79
- # @param title [String]
80
- # @return [Array<Bib::Title>]
81
- def fetch_title(title)
82
- Bib::Title.from_string title, "en", "Latn"
83
- end
44
+ # @return [Relaton::Ogc::ItemData]
45
+ def parse # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
46
+ type = fetch_type(@hit["type"])
47
+ contribs = fetch_contributor(@hit)
48
+ contribs << fetch_editorialgroup_contributor
49
+ ItemData.new(
50
+ type: "standard",
51
+ title: fetch_title(@hit["title"]),
52
+ docidentifier: fetch_docid(@hit["identifier"]),
53
+ source: fetch_link(@hit),
54
+ status: fetch_status(type[:stage]),
55
+ edition: fetch_edition(@hit["identifier"]),
56
+ abstract: fetch_abstract(@hit["description"]),
57
+ contributor: contribs,
58
+ language: ["en"],
59
+ script: ["Latn"],
60
+ date: fetch_date(@hit["date"]),
61
+ ext: Ext.new(
62
+ doctype: fetch_doctype(type[:type]),
63
+ subdoctype: type[:subtype],
64
+ flavor: "ogc",
65
+ ),
66
+ )
67
+ end
84
68
 
85
- # @param identifier [String]
86
- # @return [Array<Bib::Docidentifier>]
87
- def fetch_docid(identifier)
88
- id = Docidentifier.new(
89
- content: identifier, type: "OGC", primary: true,
90
- )
91
- [id]
92
- end
69
+ private
70
+
71
+ def fetch_editorialgroup_contributor # rubocop:disable Metrics/MethodLength
72
+ desc = Bib::LocalizedMarkedUpString.new(content: "committee")
73
+ role = Bib::Contributor::Role.new(
74
+ type: "author", description: [desc],
75
+ )
76
+ ogc = "Open Geospatial Consortium"
77
+ org = Bib::Organization.new(
78
+ name: [Bib::TypedLocalizedString.new(content: ogc)],
79
+ abbreviation: Bib::LocalizedString.new(content: "OGC"),
80
+ subdivision: [Bib::Subdivision.new(
81
+ type: "technical-committee",
82
+ name: [Bib::TypedLocalizedString.new(content: "technical")],
83
+ )],
84
+ )
85
+ Bib::Contributor.new(role: [role], organization: org)
86
+ end
93
87
 
94
- # @param hit [Hash]
95
- # @return [Array<Bib::Uri>]
96
- def fetch_link(hit) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
97
- link = []
98
- uri = hit["URI"].to_s.strip
99
- unless uri.empty?
100
- link << Bib::Uri.new(type: "src", content: uri)
101
- end
102
- return link unless hit["URL"] && !hit["URL"].strip.empty?
103
-
104
- type = link_type(hit["URL"])
105
- link << Bib::Uri.new(type: type, content: hit["URL"].strip)
106
- end
88
+ # @param title [String]
89
+ # @return [Array<Bib::Title>]
90
+ def fetch_title(title)
91
+ result = Bib::Title.from_string title, "en", "Latn"
92
+ @errors[:title] &&= result.empty?
93
+ result
94
+ end
107
95
 
108
- def link_type(url)
109
- ext = url.match(/(?<=\.)(?<ext>pdf|html|doc)$/)
110
- return ext[:ext] if ext
96
+ # @param identifier [String]
97
+ # @return [Array<Bib::Docidentifier>]
98
+ def fetch_docid(identifier)
99
+ @errors[:docid] &&= identifier.to_s.strip.empty?
100
+ id = Docidentifier.new(
101
+ content: identifier, type: "OGC", primary: true,
102
+ )
103
+ [id]
104
+ end
111
105
 
112
- case url
113
- when /portal\.(ogc|opengeospatial)\.org/,
114
- /usgif\.org/
115
- "pdf"
116
- else "html"
117
- end
106
+ # @param hit [Hash]
107
+ # @return [Array<Bib::Uri>]
108
+ def fetch_link(hit) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
109
+ link = []
110
+ uri = hit["URI"].to_s.strip
111
+ unless uri.empty?
112
+ link << Bib::Uri.new(type: "src", content: uri)
118
113
  end
114
+ return link unless hit["URL"] && !hit["URL"].strip.empty?
119
115
 
120
- # @param type [String]
121
- # @return [Doctype]
122
- def fetch_doctype(type)
123
- Doctype.new(content: type)
124
- end
116
+ type = link_type(hit["URL"])
117
+ link << Bib::Uri.new(type: type, content: hit["URL"].strip)
118
+ ensure
119
+ @errors[:link] &&= link.empty?
120
+ end
125
121
 
126
- # @param type [String]
127
- # @return [Hash]
128
- def fetch_type(type)
129
- TYPES[type.sub(/^D-/, "")] || { type: "other" }
122
+ def link_type(url)
123
+ ext = url.match(/(?<=\.)(?<ext>pdf|html|doc)$/)
124
+ return ext[:ext] if ext
125
+
126
+ case url
127
+ when /portal\.(ogc|opengeospatial)\.org/,
128
+ /usgif\.org/
129
+ "pdf"
130
+ else "html"
130
131
  end
132
+ end
131
133
 
132
- # @param stage [String, nil]
133
- # @return [Bib::Status, nil]
134
- def fetch_status(stage)
135
- return unless stage
134
+ # @param type [String]
135
+ # @return [Doctype]
136
+ def fetch_doctype(type)
137
+ Doctype.new(content: type)
138
+ end
136
139
 
137
- stg = Bib::Status::Stage.new(content: stage)
138
- Bib::Status.new(stage: stg)
139
- end
140
+ # @param type [String]
141
+ # @return [Hash]
142
+ def fetch_type(type)
143
+ TYPES[type.sub(/^D-/, "")] || { type: "other" }
144
+ end
140
145
 
141
- # @param identifier [String]
142
- # @return [String, nil]
143
- def fetch_edition(identifier)
144
- %r{(?<=r)(?<edition>\d+)$} =~ identifier
145
- edition && Bib::Edition.new(content: edition)
146
- end
146
+ # @param stage [String, nil]
147
+ # @return [Bib::Status, nil]
148
+ def fetch_status(stage)
149
+ @errors[:status] &&= stage.nil?
150
+ return unless stage
147
151
 
148
- # @param description [String]
149
- # @return [Array<Bib::LocalizedMarkedUpString>]
150
- def fetch_abstract(description)
151
- abs = Bib::LocalizedMarkedUpString.new(
152
- content: description, language: "en", script: "Latn",
153
- )
154
- [abs]
155
- end
152
+ stg = Bib::Status::Stage.new(content: stage)
153
+ Bib::Status.new(stage: stg)
154
+ end
156
155
 
157
- # @param doc [Hash]
158
- # @return [Array<Bib::Contributor>]
159
- def fetch_contributor(doc)
160
- contribs = doc["creator"].to_s.split(", ").map do |name|
161
- person_contrib name
162
- end
163
- contribs << org_contrib(doc["publisher"]) if doc["publisher"]
164
- contribs
165
- end
156
+ # @param identifier [String]
157
+ # @return [String, nil]
158
+ def fetch_edition(identifier)
159
+ %r{(?<=r)(?<edition>\d+)$} =~ identifier
160
+ @errors[:edition] &&= edition.nil?
161
+ edition && Bib::Edition.new(content: edition)
162
+ end
166
163
 
167
- # @param name [String]
168
- # @return [Bib::Contributor]
169
- def person_contrib(name)
170
- Bib::Contributor.new(
171
- person: Bib::Person.new(
172
- name: Bib::FullName.new(
173
- completename: Bib::LocalizedString.new(content: name),
174
- ),
175
- ),
176
- role: [Bib::Contributor::Role.new(type: "author")],
177
- )
164
+ # @param description [String]
165
+ # @return [Array<Bib::LocalizedMarkedUpString>]
166
+ def fetch_abstract(description)
167
+ @errors[:abstract] &&= description.to_s.strip.empty?
168
+ abs = Bib::Abstract.new(
169
+ content: description, language: "en", script: "Latn",
170
+ )
171
+ [abs]
172
+ end
173
+
174
+ # @param doc [Hash]
175
+ # @return [Array<Bib::Contributor>]
176
+ def fetch_contributor(doc)
177
+ contribs = doc["creator"].to_s.split(", ").map do |name|
178
+ person_contrib name
178
179
  end
180
+ contribs << org_contrib(doc["publisher"]) if doc["publisher"]
181
+ @errors[:contributor] &&= contribs.empty?
182
+ contribs
183
+ end
179
184
 
180
- # @param name [String]
181
- # @return [Bib::Contributor]
182
- def org_contrib(name)
183
- Bib::Contributor.new(
184
- organization: Bib::Organization.new(
185
- name: [Bib::TypedLocalizedString.new(content: name)],
185
+ # @param name [String]
186
+ # @return [Bib::Contributor]
187
+ def person_contrib(name)
188
+ Bib::Contributor.new(
189
+ person: Bib::Person.new(
190
+ name: Bib::FullName.new(
191
+ completename: Bib::LocalizedString.new(content: name),
186
192
  ),
187
- role: [Bib::Contributor::Role.new(type: "publisher")],
188
- )
189
- end
193
+ ),
194
+ role: [Bib::Contributor::Role.new(type: "author")],
195
+ )
196
+ end
190
197
 
191
- # @param date [String, nil]
192
- # @return [Array<Bib::Date>]
193
- def fetch_date(date)
194
- return [] unless date
198
+ # @param name [String]
199
+ # @return [Bib::Contributor]
200
+ def org_contrib(name)
201
+ Bib::Contributor.new(
202
+ organization: Bib::Organization.new(
203
+ name: [Bib::TypedLocalizedString.new(content: name)],
204
+ ),
205
+ role: [Bib::Contributor::Role.new(type: "publisher")],
206
+ )
207
+ end
195
208
 
196
- [Bib::Date.new(type: "published", at: date)]
197
- rescue Date::Error
198
- []
199
- end
209
+ # @param date [String, nil]
210
+ # @return [Array<Bib::Date>]
211
+ def fetch_date(date)
212
+ result = if date
213
+ [Bib::Date.new(type: "published", at: date)]
214
+ else
215
+ []
216
+ end
217
+ @errors[:date] &&= result.empty?
218
+ result
219
+ rescue Date::Error
220
+ @errors[:date] &&= true
221
+ []
200
222
  end
201
223
  end
202
224
  end
@@ -1,5 +1,5 @@
1
1
  module Relaton
2
2
  module Ogc
3
- VERSION = "2.0.0-alpha.2".freeze
3
+ VERSION = "2.0.0-alpha.3".freeze
4
4
  end
5
5
  end
data/relaton_ogc.gemspec CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.required_ruby_version = Gem::Requirement.new(">= 3.2.0")
27
27
 
28
28
  spec.add_dependency "faraday", "~> 2.7"
29
+ spec.add_dependency "relaton-core", "~> 0.0.13"
29
30
  spec.add_dependency "relaton-index", "~> 0.2.0"
30
- spec.add_dependency "relaton-iso", "~> 2.0.0-alpha.2"
31
+ spec.add_dependency "relaton-iso", "~> 2.0.0-alpha.7"
31
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-ogc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre.alpha.2
4
+ version: 2.0.0.pre.alpha.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -23,6 +23,20 @@ dependencies:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
25
  version: '2.7'
26
+ - !ruby/object:Gem::Dependency
27
+ name: relaton-core
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: 0.0.13
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 0.0.13
26
40
  - !ruby/object:Gem::Dependency
27
41
  name: relaton-index
28
42
  requirement: !ruby/object:Gem::Requirement
@@ -43,14 +57,14 @@ dependencies:
43
57
  requirements:
44
58
  - - "~>"
45
59
  - !ruby/object:Gem::Version
46
- version: 2.0.0.pre.alpha.2
60
+ version: 2.0.0.pre.alpha.7
47
61
  type: :runtime
48
62
  prerelease: false
49
63
  version_requirements: !ruby/object:Gem::Requirement
50
64
  requirements:
51
65
  - - "~>"
52
66
  - !ruby/object:Gem::Version
53
- version: 2.0.0.pre.alpha.2
67
+ version: 2.0.0.pre.alpha.7
54
68
  description: 'Relaton::Ogc: retrieve OGC Standards for bibliographic use using the
55
69
  OgcBibliographicItem model'
56
70
  email: