relaton-w3c 1.14.1 → 1.14.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98704ba5a2584740f2b47ac2710a68ead213e027ff7a1ee319e40180210c5b34
4
- data.tar.gz: 4ae2f3cee7bfef6432ed4542f49d43e7e63bd52f4c8bdba2e5e37058d3adca10
3
+ metadata.gz: 3fa2cf3c72f102ca4939b69644daa84953456cf718e647043cd96821b60d76fc
4
+ data.tar.gz: 712c67760c7810fe30a915e11c9e5c50c829db4ff9dac5421b233445d19d6c04
5
5
  SHA512:
6
- metadata.gz: 481c6d393908896813dd6f523d9b4e6f48dc15d825ff416cf8c5df70d95f29cd2013e80eb45704c126847c82b6addda8f02aeec214bc3bea0c226bd485da7d95
7
- data.tar.gz: f6d8a22c1d3385c4e808b937f6d32f2c6f394f868168323f2c734d7d2a18f818e6ea304b122a6ef20766a05f9ffae8fc03b984856dca1148210e3dca2d12fa64
6
+ metadata.gz: 9974031951fd2938d8d7fa272df81a77d9c6f35be90374442c51344f0996d7488d1ec4b1b22d1af09b4b0913da65f4392bfa72344f13a3cb2d0fb4522a8ec4dc
7
+ data.tar.gz: 3f1bd4e90a671e3f3564fe80327096e7f26bc9371ffef46f2ed9e47be953e398c676ccac07d1083383fde2dce229af9fb0176b9b7d2c95e28ba4f2a520bdc69e
@@ -5,6 +5,7 @@ name: rake
5
5
  on:
6
6
  push:
7
7
  branches: [ master, main ]
8
+ tags: [ v* ]
8
9
  pull_request:
9
10
 
10
11
  jobs:
@@ -10,8 +10,9 @@ on:
10
10
  Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
11
11
  required: true
12
12
  default: 'skip'
13
- push:
14
- tags: [ v* ]
13
+ repository_dispatch:
14
+ types: [ do-release ]
15
+
15
16
 
16
17
  jobs:
17
18
  release:
data/Gemfile CHANGED
@@ -5,3 +5,8 @@ gemspec
5
5
 
6
6
  gem "rake", "~> 13.0"
7
7
  gem "rspec", "~> 3.0"
8
+
9
+ gem "ruby-jing"
10
+ gem "simplecov"
11
+ gem "vcr"
12
+ gem "webmock"
@@ -522,7 +522,6 @@
522
522
  <value>tip</value>
523
523
  <value>important</value>
524
524
  <value>caution</value>
525
- <value>statement</value>
526
525
  </choice>
527
526
  </define>
528
527
  <define name="figure">
data/grammars/biblio.rng CHANGED
@@ -216,6 +216,9 @@
216
216
  <optional>
217
217
  <ref name="fullname"/>
218
218
  </optional>
219
+ <zeroOrMore>
220
+ <ref name="credential"/>
221
+ </zeroOrMore>
219
222
  <zeroOrMore>
220
223
  <ref name="affiliation"/>
221
224
  </zeroOrMore>
@@ -232,6 +235,11 @@
232
235
  <ref name="FullNameType"/>
233
236
  </element>
234
237
  </define>
238
+ <define name="credential">
239
+ <element name="credential">
240
+ <text/>
241
+ </element>
242
+ </define>
235
243
  <define name="FullNameType">
236
244
  <choice>
237
245
  <group>
@@ -305,7 +313,9 @@
305
313
  <zeroOrMore>
306
314
  <ref name="affiliationdescription"/>
307
315
  </zeroOrMore>
308
- <ref name="organization"/>
316
+ <optional>
317
+ <ref name="organization"/>
318
+ </optional>
309
319
  </element>
310
320
  </define>
311
321
  <define name="affiliationname">
@@ -1316,7 +1326,7 @@
1316
1326
  <value>commentaryOf</value>
1317
1327
  <value>hasCommentary</value>
1318
1328
  <value>related</value>
1319
- <value>complements</value>
1329
+ <value>hasComplement</value>
1320
1330
  <value>complementOf</value>
1321
1331
  <value>obsoletes</value>
1322
1332
  <value>obsoletedBy</value>
@@ -21,6 +21,7 @@ module RelatonW3c
21
21
  dir = File.dirname(File.expand_path(__FILE__))
22
22
  @group_names = YAML.load_file(File.join(dir, "workgroups.yaml"))
23
23
  @index = DataIndex.create_from_file
24
+ @index1 = Relaton::Index.find_or_create :W3C, file: "index1.yaml"
24
25
  end
25
26
 
26
27
  #
@@ -60,6 +61,7 @@ module RelatonW3c
60
61
  end
61
62
  end
62
63
  @index.sort!.save
64
+ @index1.save
63
65
  end
64
66
 
65
67
  #
@@ -218,7 +220,9 @@ module RelatonW3c
218
220
  if @files.include?(file)
219
221
  warn "File #{file} already exists. Document: #{bib.docnumber}" if warn_duplicate
220
222
  else
221
- @index.add bib.docnumber, file
223
+ pubid = PubId.parse bib.docnumber
224
+ @index.add pubid, file
225
+ @index1.add_or_update pubid.to_hash, file
222
226
  @files << file
223
227
  File.write file, c, encoding: "UTF-8"
224
228
  end
@@ -16,19 +16,21 @@ module RelatonW3c
16
16
  #
17
17
  # Add document to index or update it if already exists
18
18
  #
19
- # @param [String] docnumber document number
19
+ # @param [RelatonW3c::PubId] pubid document number
20
20
  # @param [String] file path to document file
21
21
  #
22
- def add(docnumber, file) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
23
- dnparts = self.class.docnumber_to_parts docnumber
22
+ def add(pubid, file) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
23
+ # dnparts = self.class.docnumber_to_parts docnumber
24
+ # pubid = PubId.parse docnumber
24
25
  rec = @index.detect { |i| i[:file] == file }
25
26
  if rec
26
- rec[:code] = dnparts[:code]
27
- dnparts[:stage] ? rec[:stage] = dnparts[:stage] : rec.delete(:stage)
28
- dnparts[:type] ? rec[:type] = dnparts[:type] : rec.delete(:type)
29
- dnparts[:date] ? rec[:date] = dnparts[:date] : rec.delete(:date)
30
- dnparts[:suff] ? rec[:suff] = dnparts[:suff] : rec.delete(:suff)
27
+ rec[:code] = pubid.code
28
+ pubid.stage ? rec[:stage] = pubid.stage : rec.delete(:stage)
29
+ pubid.type ? rec[:type] = pubid.type : rec.delete(:type)
30
+ pubid.date ? rec[:date] = pubid.date : rec.delete(:date)
31
+ pubid.suff ? rec[:suff] = pubid.suff : rec.delete(:suff)
31
32
  else
33
+ dnparts = pubid.to_hash
32
34
  dnparts[:file] = file
33
35
  @index << dnparts
34
36
  end
@@ -58,19 +60,19 @@ module RelatonW3c
58
60
  #
59
61
  # @return [String] document's filename
60
62
  #
61
- def search(ref) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
62
- dparts = self.class.docnumber_to_parts(ref)
63
- return if dparts[:code].nil?
63
+ # def search(ref) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
64
+ # pubid = PubId.parse(ref)
65
+ # return if pubid.code.nil?
64
66
 
65
- @index.detect do |parts|
66
- parts[:code].match?(/^#{Regexp.escape dparts[:code]}/i) &&
67
- (dparts[:stage].nil? || dparts[:stage].casecmp?(parts[:stage])) &&
68
- (dparts[:type].nil? || dparts[:type].casecmp?(parts[:type]) ||
69
- (parts[:type].nil? && dparts[:type] == "TR")) &&
70
- (dparts[:date].nil? || dparts[:date] == parts[:date]) &&
71
- (dparts[:suff].nil? || dparts[:suff].casecmp?(parts[:suff]))
72
- end&.fetch(:file)
73
- end
67
+ # @index.detect do |parts|
68
+ # parts[:code].match?(/^#{Regexp.escape pubid.code}/i) &&
69
+ # (pubid.stage.nil? || pubid.stage.casecmp?(parts[:stage])) &&
70
+ # (pubid.type.nil? || pubid.type.casecmp?(parts[:type]) ||
71
+ # (parts[:type].nil? && pubid.type == "TR")) &&
72
+ # (pubid.date.nil? || pubid.date == parts[:date]) &&
73
+ # (pubid.suff.nil? || pubid.suff.casecmp?(parts[:suff]))
74
+ # end&.fetch(:file)
75
+ # end
74
76
 
75
77
  #
76
78
  # Compare index items
@@ -120,13 +122,13 @@ module RelatonW3c
120
122
  #
121
123
  # @return [RelatonW3c::DataIndex] data index
122
124
  #
123
- def create_from_repo
124
- uri = URI("#{W3cBibliography::SOURCE}index-w3c.zip").open
125
- resp = Zip::InputStream.new uri
126
- zip = resp.get_next_entry
127
- index = RelatonBib.parse_yaml(zip.get_input_stream.read, [Symbol])
128
- new index: index
129
- end
125
+ # def create_from_repo
126
+ # uri = URI("#{W3cBibliography::SOURCE}index-w3c.zip").open
127
+ # resp = Zip::InputStream.new uri
128
+ # zip = resp.get_next_entry
129
+ # index = RelatonBib.parse_yaml(zip.get_input_stream.read, [Symbol])
130
+ # new index: index
131
+ # end
130
132
 
131
133
  #
132
134
  # Create index from a file
@@ -142,28 +144,6 @@ module RelatonW3c
142
144
  end
143
145
  new index_file: index_file, index: index
144
146
  end
145
-
146
- #
147
- # Parse document number to parts
148
- #
149
- # @param [String] docnumber document number
150
- #
151
- # @return [Hash{Symbol=>String}] document parts
152
- #
153
- def docnumber_to_parts(docnumber) # rubocop:disable Metrics/MethodLength
154
- %r{
155
- ^(?:(?:(?<stage>WD|CRD|CR|PR|PER|REC|SPSD|OBSL|RET)|(?<type>D?NOTE|TR))-)?
156
- (?<code>\w+(?:[+-][\w.]+)*?)
157
- (?:-(?<date>\d{8}|\d{6}|\d{4}))?
158
- (?:/(?<suff>\w+))?$
159
- }xi =~ docnumber
160
- entry = { code: code }
161
- entry[:stage] = stage if stage
162
- entry[:type] = type if type
163
- entry[:date] = date if date
164
- entry[:suff] = suff if suff
165
- entry
166
- end
167
147
  end
168
148
  end
169
149
  end
@@ -50,5 +50,12 @@ module RelatonW3c
50
50
  def grammar_hash
51
51
  @grammar_hash ||= ::RelatonW3c.grammar_hash
52
52
  end
53
+
54
+ #
55
+ # Remove index file
56
+ #
57
+ def remove_index_file
58
+ Relaton::Index.find_or_create(:W3C, url: true, file: "#{W3cBibliography::INDEX}.yaml").remove_file
59
+ end
53
60
  end
54
61
  end
@@ -0,0 +1,54 @@
1
+ module RelatonW3c
2
+ class PubId
3
+ PARTS = %i[code stage type date suff].freeze
4
+
5
+ PARTS.each { |part| attr_accessor part }
6
+
7
+ def initialize(**parts)
8
+ PARTS.each { |part| send "#{part}=", parts[part] }
9
+ end
10
+
11
+ #
12
+ # Parse document identifier.
13
+ #
14
+ # @param [String] docnumber document identifier
15
+ #
16
+ # @return [RelatonW3c::PubId] document identifier parts
17
+ #
18
+ def self.parse(docnumber) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
19
+ %r{
20
+ (?:^|/)(?:(?:(?<stage>WD|CRD|CR|PR|PER|REC|SPSD|OBSL|RET)|(?<type>D?NOTE|TR))[\s/-])?
21
+ (?<code>\w+(?:[+-][\w.]+)*?)
22
+ (?:-(?<date>\d{8}|\d{6}|\d{4}))?
23
+ (?:/(?<suff>\w+))?(?:$|/)
24
+ }xi =~ docnumber
25
+ entry = { code: code }
26
+ entry[:stage] = stage if stage
27
+ entry[:type] = type if type && type != "TR"
28
+ entry[:date] = date if date
29
+ entry[:suff] = suff if suff
30
+ new(**entry)
31
+ end
32
+
33
+ #
34
+ # Compare document identifiers against Hash ID representation.
35
+ #
36
+ # @param [Hash] other hash of document identifier parts
37
+ #
38
+ # @return [Boolean] true if document identifiers are same
39
+ #
40
+ def ==(other) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
41
+ other[:code].casecmp?(code) && other[:stage] == stage && other[:type] == type &&
42
+ (date.nil? || other[:date] == date) && (suff.nil? || other[:suff]&.casecmp?(suff))
43
+ end
44
+
45
+ #
46
+ # Convert docidentifier identifier to hash.
47
+ #
48
+ # @return [Hash] hash of docidentifier parts
49
+ #
50
+ def to_hash
51
+ PARTS.each_with_object({}) { |part, hash| hash[part] = send part if send part }
52
+ end
53
+ end
54
+ end
@@ -1,3 +1,3 @@
1
1
  module RelatonW3c
2
- VERSION = "1.14.1".freeze
2
+ VERSION = "1.14.2".freeze
3
3
  end
@@ -6,16 +6,18 @@ module RelatonW3c
6
6
  # Class methods for search W3C standards.
7
7
  class W3cBibliography
8
8
  SOURCE = "https://raw.githubusercontent.com/relaton/relaton-data-w3c/main/"
9
+ INDEX = "index1"
9
10
 
10
11
  class << self
11
12
  # @param text [String]
12
13
  # @return [RelatonW3c::W3cBibliographicItem]
13
14
  def search(text) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
14
- ref = DataParser.parse_identifier text.sub(/^W3C\s/, "")
15
- file = DataIndex.create_from_repo.search ref.gsub(" ", "-").squeeze("-")
16
- return unless file
15
+ pubid = PubId.parse text.sub(/^W3C\s/, "")
16
+ index = Relaton::Index.find_or_create :W3C, url: "#{SOURCE}#{INDEX}.zip", file: "#{INDEX}.yaml"
17
+ row = index.search { |r| pubid == r[:id] }.first
18
+ return unless row
17
19
 
18
- url = "#{SOURCE}#{file}"
20
+ url = "#{SOURCE}#{row[:file]}"
19
21
  resp = Net::HTTP.get_response(URI.parse(url))
20
22
  return unless resp.code == "200"
21
23
 
data/lib/relaton_w3c.rb CHANGED
@@ -1,10 +1,12 @@
1
1
  require "relaton_bib"
2
+ require "relaton/index"
2
3
  require "relaton_w3c/version"
3
4
  require "relaton_w3c/w3c_bibliography"
4
5
  require "relaton_w3c/w3c_bibliographic_item"
5
6
  require "relaton_w3c/xml_parser"
6
7
  require "relaton_w3c/bibxml_parser"
7
8
  require "relaton_w3c/hash_converter"
9
+ require "relaton_w3c/pubid"
8
10
  require "relaton_w3c/data_fetcher"
9
11
  require "relaton_w3c/data_index"
10
12
 
data/relaton_w3c.gemspec CHANGED
@@ -32,16 +32,13 @@ Gem::Specification.new do |spec|
32
32
  spec.require_paths = ["lib"]
33
33
 
34
34
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
35
- spec.add_development_dependency "ruby-jing"
36
- spec.add_development_dependency "simplecov"
37
- spec.add_development_dependency "vcr"
38
- spec.add_development_dependency "webmock"
39
35
 
40
36
  spec.add_dependency "linkeddata", "~> 3.2.0"
41
37
  spec.add_dependency "mechanize", "~> 2.8.0"
42
38
  spec.add_dependency "rdf", "~> 3.2.0"
43
39
  spec.add_dependency "rdf-normalize", "~> 0.5.0"
44
40
  spec.add_dependency "relaton-bib", "~> 1.14.0"
41
+ spec.add_dependency "relaton-index", "~> 0.2.0"
45
42
  spec.add_dependency "rubyzip", "~> 2.3.0"
46
43
  spec.add_dependency "shex", "~> 0.7.0"
47
44
  spec.add_dependency "sparql", "~> 3.2.0"
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.14.1
4
+ version: 1.14.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-20 00:00:00.000000000 Z
11
+ date: 2023-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equivalent-xml
@@ -24,62 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.6'
27
- - !ruby/object:Gem::Dependency
28
- name: ruby-jing
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: simplecov
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: vcr
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: webmock
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
27
  - !ruby/object:Gem::Dependency
84
28
  name: linkeddata
85
29
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +94,20 @@ dependencies:
150
94
  - - "~>"
151
95
  - !ruby/object:Gem::Version
152
96
  version: 1.14.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: relaton-index
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.2.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.2.0
153
111
  - !ruby/object:Gem::Dependency
154
112
  name: rubyzip
155
113
  requirement: !ruby/object:Gem::Requirement
@@ -225,6 +183,7 @@ files:
225
183
  - lib/relaton_w3c/data_parser.rb
226
184
  - lib/relaton_w3c/hash_converter.rb
227
185
  - lib/relaton_w3c/processor.rb
186
+ - lib/relaton_w3c/pubid.rb
228
187
  - lib/relaton_w3c/version.rb
229
188
  - lib/relaton_w3c/w3c_bibliographic_item.rb
230
189
  - lib/relaton_w3c/w3c_bibliography.rb
@@ -251,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
251
210
  - !ruby/object:Gem::Version
252
211
  version: '0'
253
212
  requirements: []
254
- rubygems_version: 3.1.6
213
+ rubygems_version: 3.3.26
255
214
  signing_key:
256
215
  specification_version: 4
257
216
  summary: 'RelatonIso: retrieve W3C Standards for bibliographic using the IsoBibliographicItem