relaton-itu 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: be0c0678a89392cad09e5dd1200d019dae98b3e6cd693a2f9fdb4e6c03fd53c3
4
- data.tar.gz: 8225f34a2b5a372b170f654e0b0646d793d04be3951fb7b8ac92ddc961c077ec
3
+ metadata.gz: 6896cc449a319a193b826b03c471c288a6a23a874aabc884c0fb7d966dc9a859
4
+ data.tar.gz: 9ae42b212ac48b0bd1f046f3401eaa04a451977f224497fac678b2cd259fa8d3
5
5
  SHA512:
6
- metadata.gz: 0a4ff2e224ce8c17145f251a47a74b0c529930d85f4d24ea240ec9c301772c3f9f5da16ff81ce701b691d7e1935eff31fe84a8d880a1ddd463a479e60a4bc59d
7
- data.tar.gz: bbcd36e70a379f44729df2e49b9cbb6323eeb791bfa5d3faf74600f3a95c099edf1c50f98d178a6d298215afa39267ef0d55d03ee8026916eb0e7d2c78f7f8ea
6
+ metadata.gz: ecb0566f856fd66dc05155e1b84806dfe9c2a4ea5002fb868b8156c7f50cfd09df7303d4da7c46e298343f73dae9fd15d025eaac3f062c9c64c0b6c7954f0e21
7
+ data.tar.gz: 2c61a6bc6394d778a45229fc29db686ffd6713ba35598015ea7e96f49cb660b30cd523fef5d5a14effe3b2f7efe71cbf75e2b7ea75b7723df29058f57d91d1f9
@@ -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>
@@ -15,6 +15,10 @@ module Relaton
15
15
  @index ||= Relaton::Index.find_or_create :itu, file: "index-v1.yaml"
16
16
  end
17
17
 
18
+ def log_error(msg)
19
+ Util.error msg
20
+ end
21
+
18
22
  def fetch(_source = nil)
19
23
  start = 0
20
24
  empty_pages = 0
@@ -30,7 +34,7 @@ module Relaton
30
34
 
31
35
  empty_pages = 0
32
36
  results.each do |result|
33
- bib = DataParserR.parse(result)
37
+ bib = DataParserR.parse(result, @errors)
34
38
  write_file(bib) if bib
35
39
  rescue => e # rubocop:disable Style/RescueStandardError
36
40
  Util.error "#{e.message}\n#{e.backtrace}"
@@ -39,6 +43,7 @@ module Relaton
39
43
  start += ROWS
40
44
  end
41
45
  index.save
46
+ report_errors
42
47
  end
43
48
 
44
49
  # @param bib [Relaton::Itu::ItemData]
@@ -18,7 +18,8 @@ module Relaton
18
18
  #
19
19
  # @return [Relaton::Itu::ItemData] bibliographic item
20
20
  #
21
- def parse(result)
21
+ def parse(result, errors = {})
22
+ @errors = errors
22
23
  doctype = fetch_doctype(result)
23
24
  return unless doctype
24
25
 
@@ -35,10 +36,12 @@ module Relaton
35
36
  def fetch_docid(result)
36
37
  title = result["Title"].to_s
37
38
  id = title.match(/^(ITU-R\s+\S+)/)&.captures&.first
38
- return [] unless id
39
+ return(@errors[:docid] &&= true; []) unless id
39
40
 
40
41
  id = id.sub(/\s*\(.*/, "")
41
- [Docidentifier.new(type: "ITU", content: id, primary: true)]
42
+ result_ids = [Docidentifier.new(type: "ITU", content: id, primary: true)]
43
+ @errors[:docid] &&= result_ids.empty?
44
+ result_ids
42
45
  end
43
46
 
44
47
  # @param result [Hash]
@@ -47,31 +50,49 @@ module Relaton
47
50
  title = result["Title"].to_s
48
51
  content = title.sub(/^[^:]+:\s*/, "").strip
49
52
  content = title unless content.length > 0
50
- [Relaton::Bib::Title.new(type: "main", content: content, language: "en", script: "Latn")]
53
+ r = [Relaton::Bib::Title.new(type: "main", content: content, language: "en", script: "Latn")]
54
+ @errors[:title] &&= r.empty?
55
+ r
51
56
  end
52
57
 
53
58
  # @param result [Hash]
54
59
  # @return [Array<Relaton::Bib::Date>]
55
60
  def fetch_date(result)
56
61
  prop = property(result, "Publication date")
57
- return [] unless prop
62
+ unless prop
63
+ @errors[:date] &&= true
64
+ return []
65
+ end
58
66
 
59
67
  date = parse_pub_date(prop)
60
- return [] unless date
68
+ unless date
69
+ @errors[:date] &&= true
70
+ return []
71
+ end
61
72
 
62
- [Relaton::Bib::Date.new(type: "published", at: date)]
73
+ r = [Relaton::Bib::Date.new(type: "published", at: date)]
74
+ @errors[:date] &&= r.empty?
75
+ r
63
76
  end
64
77
 
65
78
  # @param result [Hash]
66
79
  # @return [Array<Relaton::Bib::Uri>]
67
80
  def fetch_source(result)
68
81
  locations = result["Locations"]
69
- return [] unless locations.is_a?(Array)
82
+ unless locations.is_a?(Array)
83
+ @errors[:source] &&= true
84
+ return []
85
+ end
70
86
 
71
87
  pdf = locations.find { |l| l["Type"] == "pdf" }
72
- return [] unless pdf && pdf["RawHref"]
88
+ unless pdf && pdf["RawHref"]
89
+ @errors[:source] &&= true
90
+ return []
91
+ end
73
92
 
74
- [Relaton::Bib::Uri.new(type: "pdf", content: pdf["RawHref"])]
93
+ r = [Relaton::Bib::Uri.new(type: "pdf", content: pdf["RawHref"])]
94
+ @errors[:source] &&= r.empty?
95
+ r
75
96
  end
76
97
 
77
98
  # @param result [Hash]
@@ -79,8 +100,12 @@ module Relaton
79
100
  def fetch_doctype(result)
80
101
  type_value = property(result, "Type")
81
102
  mapped = TYPE_MAP[type_value]
82
- return unless mapped
103
+ unless mapped
104
+ @errors[:doctype] &&= true
105
+ return
106
+ end
83
107
 
108
+ @errors[:doctype] &&= false
84
109
  Doctype.new(content: mapped)
85
110
  end
86
111
 
@@ -38,7 +38,7 @@ module Relaton
38
38
  def request_document # rubocop:todo Metrics/MethodLength, Metrics/AbcSize
39
39
  Util.info "Fetching from Relaton repository ...", key: ref.to_s
40
40
  index = Relaton::Index.find_or_create :itu, url: "#{GH_ITU_R}#{INDEXFILE}.zip", file: "#{INDEXFILE}.yaml"
41
- row = index.search(ref.to_ref).min_by { |i| i[:id] }
41
+ row = index.search(ref.to_ref).max_by { |i| i[:id] }
42
42
  return unless row
43
43
 
44
44
  url = "#{GH_ITU_R}#{row[:file]}"
@@ -52,7 +52,7 @@ module Relaton
52
52
  # @return [Array<Relaton::Bib::LocalizedMarkedUpString>]
53
53
  def fetch_abstract
54
54
  array(doc["summary"]).map do |content|
55
- Relaton::Bib::LocalizedMarkedUpString.new(content: content, language: "en", script: "Latn")
55
+ Relaton::Bib::Abstract.new(content: content, language: "en", script: "Latn")
56
56
  end
57
57
  end
58
58
 
@@ -142,7 +142,7 @@ module Relaton
142
142
 
143
143
  fref = titles.empty? ? id : nil
144
144
  did = Relaton::Bib::Docidentifier.new(type: "ITU", content: id, primary: true)
145
- bibitem = Relaton::Bib::ItemData.new(title: titles, formattedref: fref, docidentifier: [did])
145
+ bibitem = Relaton::Bib::ItemData.new(title: titles, formattedref: (fref ? Relaton::Bib::Formattedref.new(content: fref) : nil), docidentifier: [did])
146
146
  Relaton::Bib::Relation.new(type: type, bibitem: bibitem)
147
147
  end
148
148
 
@@ -185,7 +185,8 @@ module Relaton
185
185
  uri: [Relaton::Bib::Uri.new(content: url)],
186
186
  )
187
187
  owner = Relaton::Bib::ContributionInfo.new(organization: org)
188
- [Relaton::Bib::Copyright.new(from: parser.doc_date, owner: [owner])]
188
+ year = parser.doc_date&.match(/\d{4}/)&.to_s
189
+ [Relaton::Bib::Copyright.new(from: year, owner: [owner])]
189
190
  end
190
191
  end
191
192
  end
@@ -1,5 +1,5 @@
1
1
  module Relaton
2
2
  module Itu
3
- VERSION = "2.0.0-alpha.2".freeze
3
+ VERSION = "2.0.0-alpha.3".freeze
4
4
  end
5
5
  end
data/relaton_itu.gemspec CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.add_dependency "mechanize", "~> 2.10"
29
29
  spec.add_dependency "parslet", "~> 2.0.0"
30
- spec.add_dependency "relaton-bib", "~> 2.0.0-alpha.4"
31
- spec.add_dependency "relaton-core", "~> 0.0.9"
30
+ spec.add_dependency "relaton-bib", "~> 2.0.0-alpha.7"
31
+ spec.add_dependency "relaton-core", "~> 0.0.13"
32
32
  spec.add_dependency "relaton-index", "~> 0.2.0"
33
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-itu
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.
@@ -43,28 +43,28 @@ dependencies:
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: 2.0.0.pre.alpha.4
46
+ version: 2.0.0.pre.alpha.7
47
47
  type: :runtime
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: 2.0.0.pre.alpha.4
53
+ version: 2.0.0.pre.alpha.7
54
54
  - !ruby/object:Gem::Dependency
55
55
  name: relaton-core
56
56
  requirement: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: 0.0.9
60
+ version: 0.0.13
61
61
  type: :runtime
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: 0.0.9
67
+ version: 0.0.13
68
68
  - !ruby/object:Gem::Dependency
69
69
  name: relaton-index
70
70
  requirement: !ruby/object:Gem::Requirement