relaton-w3c 1.16.0 → 1.17.0

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: 845e2b18fd329b3f50315eebb7cdf91bd467d53397c65cd2a9124b09d9683e61
4
- data.tar.gz: ed906f6bd964ac5af614c1ff88b485d73af30eb4006c6fdea7372f130ebd54cc
3
+ metadata.gz: 2be8f996d2817de1178521c3e44076641c356a5070b80ed224f08c81e90c4013
4
+ data.tar.gz: 402ef37f8f0e22f6c7887df9d11665f79b1bd4ab16545c67b63a1fa2cd65d675
5
5
  SHA512:
6
- metadata.gz: debbdc5fb438e7290748f825859dd432d75d19b4937ef5d749f66c0e899c0e6d9ba3e5287239898b1c773ec9c3832fed89050abacb913fee7171446211d015ea
7
- data.tar.gz: 7e007f96fe6a1d712f9cb8766df8b844d1bcd61965e038fb28a3954b50b9d5d485bd7d6849627edc4a13902a94f2de9a0136f98adb4eaffabc194c701f8757fc
6
+ metadata.gz: 199b908dac06eee499d675bf44cf9d0c8df53968ee639a11f4f914c6ae2ac03281d01dce19cafe92c1427a03f342a93ce071556eccf11c612df8c8f41961f7ad
7
+ data.tar.gz: f65c63b39d3a6b2210ae02402f241951254f5f6c2c6eec108ba62c29ed8ad796bbb55362ca4e3710373cc911bd8b8eec4074464c4636bb1c1dd954e719c37549
data/README.adoc CHANGED
@@ -23,16 +23,27 @@ Or install it yourself as:
23
23
 
24
24
  == Usage
25
25
 
26
- === Search for a standard using keywords
26
+ === Configuration
27
+
28
+ Configuration is optional. The available option is `logger` which is a `Logger` instance. By default, the logger is `Logger.new($stderr)` with `Logger::WARN` level. To change the logger level, use `RelatonW3c.configure` block.
27
29
 
28
30
  [source,ruby]
29
31
  ----
30
32
  require 'relaton_w3c'
31
33
  => true
32
34
 
35
+ RelatonW3c.configure do |config|
36
+ config.logger.level = Logger::DEBUG
37
+ end
38
+ ----
39
+
40
+ === Search for a standard using keywords
41
+
42
+ [source,ruby]
43
+ ----
33
44
  item = RelatonW3c::W3cBibliography.get "W3C REC-json-ld11-20200716"
34
- [relaton-w3c] ("W3C REC-json-ld11-20200716") fetching...
35
- [relaton-w3c] ("W3C REC-json-ld11-20200716") found REC-json-ld11-20200716
45
+ [relaton-w3c] (W3C REC-json-ld11-20200716) Fetching from Relaton repository ...
46
+ [relaton-w3c] (W3C REC-json-ld11-20200716) Found: `REC-json-ld11-20200716`
36
47
  => #<RelatonW3c::W3cBibliographicItem:0x00007fc4ea03c6c0
37
48
  ...
38
49
  ----
@@ -346,6 +346,8 @@
346
346
  <ref name="keyword"/>
347
347
  <ref name="xref"/>
348
348
  <ref name="hyperlink"/>
349
+ <ref name="index"/>
350
+ <ref name="index-xref"/>
349
351
  </choice>
350
352
  </oneOrMore>
351
353
  </element>
@@ -623,6 +625,8 @@
623
625
  <ref name="eref"/>
624
626
  <ref name="xref"/>
625
627
  <ref name="hyperlink"/>
628
+ <ref name="index"/>
629
+ <ref name="index-xref"/>
626
630
  </choice>
627
631
  </zeroOrMore>
628
632
  </element>
@@ -636,6 +640,8 @@
636
640
  <ref name="eref"/>
637
641
  <ref name="xref"/>
638
642
  <ref name="hyperlink"/>
643
+ <ref name="index"/>
644
+ <ref name="index-xref"/>
639
645
  </choice>
640
646
  </zeroOrMore>
641
647
  </element>
@@ -648,6 +654,8 @@
648
654
  <ref name="eref"/>
649
655
  <ref name="xref"/>
650
656
  <ref name="hyperlink"/>
657
+ <ref name="index"/>
658
+ <ref name="index-xref"/>
651
659
  </choice>
652
660
  </zeroOrMore>
653
661
  </element>
@@ -655,7 +663,11 @@
655
663
  <define name="keyword">
656
664
  <element name="keyword">
657
665
  <zeroOrMore>
658
- <ref name="PureTextElement"/>
666
+ <choice>
667
+ <ref name="PureTextElement"/>
668
+ <ref name="index"/>
669
+ <ref name="index-xref"/>
670
+ </choice>
659
671
  </zeroOrMore>
660
672
  </element>
661
673
  </define>
@@ -676,7 +688,11 @@
676
688
  <define name="strike">
677
689
  <element name="strike">
678
690
  <zeroOrMore>
679
- <ref name="PureTextElement"/>
691
+ <choice>
692
+ <ref name="PureTextElement"/>
693
+ <ref name="index"/>
694
+ <ref name="index-xref"/>
695
+ </choice>
680
696
  </zeroOrMore>
681
697
  </element>
682
698
  </define>
data/grammars/biblio.rng CHANGED
@@ -942,6 +942,7 @@
942
942
  <value>obsoleted</value>
943
943
  <value>confirmed</value>
944
944
  <value>updated</value>
945
+ <value>corrected</value>
945
946
  <value>issued</value>
946
947
  <value>transmitted</value>
947
948
  <value>copied</value>
@@ -0,0 +1,10 @@
1
+ module RelatonW3c
2
+ module Config
3
+ include RelatonBib::Config
4
+ end
5
+ extend Config
6
+
7
+ class Configuration < RelatonBib::Configuration
8
+ PROGNAME = "relaton-w3c".freeze
9
+ end
10
+ end
@@ -222,7 +222,8 @@ module RelatonW3c
222
222
  # @return [String, nil] doctype
223
223
  #
224
224
  def parse_doctype
225
- DOCTYPES[type] || DOCTYPES[type_from_link]
225
+ type = DOCTYPES[type] || DOCTYPES[type_from_link]
226
+ DocumentType.new(type: type) if type
226
227
  end
227
228
 
228
229
  #
@@ -434,7 +435,7 @@ module RelatonW3c
434
435
  rwg = RelatonBib::WorkGroup.new name: wg["name"]
435
436
  obj << RelatonBib::TechnicalCommittee.new(rwg)
436
437
  else
437
- warn "Working group name not found for #{edg.home_page}"
438
+ Util.warn "WARNING: Working group name not found for: `#{edg.home_page}`"
438
439
  end
439
440
  end
440
441
  RelatonBib::EditorialGroup.new tc
@@ -0,0 +1,16 @@
1
+ module RelatonW3c
2
+ class DocumentType < RelatonBib::DocumentType
3
+ DOCTYPES = %w[groupNote technicalReport].freeze
4
+
5
+ def initialize(type:, abbreviation: nil)
6
+ check_type type
7
+ super
8
+ end
9
+
10
+ def check_type(type)
11
+ unless DOCTYPES.include? type
12
+ Util.warn "WARNING: invalid doctype: `#{type}`"
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,11 +1,12 @@
1
1
  module RelatonW3c
2
- class HashConverter < RelatonBib::HashConverter
3
- class << self
4
- # @param item_hash [Hash]
5
- # @return [RelatonW3c::W3cBibliographicItem]
6
- def bib_item(item_hash)
7
- W3cBibliographicItem.new(**item_hash)
8
- end
2
+ module HashConverter
3
+ include RelatonBib::HashConverter
4
+ extend self
5
+
6
+ # @param item_hash [Hash]
7
+ # @return [RelatonW3c::W3cBibliographicItem]
8
+ def bib_item(item_hash)
9
+ W3cBibliographicItem.new(**item_hash)
9
10
  end
10
11
  end
11
12
  end
@@ -0,0 +1,7 @@
1
+ module RelatonW3c
2
+ class Hit
3
+ def initialize(rows)
4
+ @array = rows.map { |r| Hit.new(**r) }
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module RelatonW3c
2
+ class HitCollection < RelatonBib::HitCollection
3
+ def initialize(rows)
4
+ @array = rows.map { |r| Hit.new(**r) }
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ module RelatonW3c
2
+ module Util
3
+ extend RelatonBib::Util
4
+
5
+ def self.logger
6
+ RelatonW3c.configuration.logger
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module RelatonW3c
2
- VERSION = "1.16.0".freeze
2
+ VERSION = "1.17.0".freeze
3
3
  end
@@ -1,17 +1,8 @@
1
1
  module RelatonW3c
2
2
  class W3cBibliographicItem < RelatonBib::BibliographicItem
3
- TYPES = %w[
4
- candidateRecommendation groupNote proposedEditedRecommendation
5
- proposedRecommendation recommendation retired workingDraft technicalReport
6
- ].freeze
7
-
8
- # @param doctype [String]
9
- def initialize(**args)
10
- if args[:doctype] && !TYPES.include?(args[:doctype])
11
- warn "[relaton-w3c] invalid document type: #{args[:doctype]}"
12
- end
13
- super
14
- end
3
+ # def initialize(**args)
4
+ # super
5
+ # end
15
6
 
16
7
  #
17
8
  # Fetch flavor schema version
@@ -39,15 +39,15 @@ module RelatonW3c
39
39
  # @param opts [Hash] options
40
40
  # @return [RelatonW3c::W3cBibliographicItem]
41
41
  def get(ref, _year = nil, _opts = {})
42
- warn "[relaton-w3c] (\"#{ref}\") fetching..."
42
+ Util.warn "(#{ref}) Fetching from Relaton repository ..."
43
43
  result = search(ref)
44
44
  unless result
45
- warn "[relaton-w3c] (\"#{ref}\") not found."
45
+ Util.warn "(#{ref}) Not found."
46
46
  return
47
47
  end
48
48
 
49
49
  found = result.docnumber
50
- warn "[relaton-w3c] (\"#{ref}\") found #{found}"
50
+ Util.warn "(#{ref}) Found: `#{found}`"
51
51
  result
52
52
  end
53
53
  end
@@ -8,10 +8,10 @@ module RelatonW3c
8
8
  # @returtn [Hash]
9
9
  def item_data(item)
10
10
  data = super
11
- ext = item.at "./ext"
12
- return data unless ext
11
+ # ext = item.at "./ext"
12
+ # return data unless ext
13
13
 
14
- data[:doctype] = ext.at("./doctype")&.text
14
+ # data[:doctype] = ext.at("./doctype")&.text
15
15
  data
16
16
  end
17
17
 
data/lib/relaton_w3c.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  require "relaton_bib"
2
2
  require "relaton/index"
3
3
  require "relaton_w3c/version"
4
+ require "relaton_w3c/config"
5
+ require "relaton_w3c/util"
6
+ require "relaton_w3c/document_type"
4
7
  require "relaton_w3c/w3c_bibliography"
5
8
  require "relaton_w3c/w3c_bibliographic_item"
6
9
  require "relaton_w3c/xml_parser"
@@ -16,9 +19,9 @@ module RelatonW3c
16
19
  # Returns hash of XML reammar
17
20
  # @return [String]
18
21
  def self.grammar_hash
19
- gem_path = File.expand_path "..", __dir__
20
- grammars_path = File.join gem_path, "grammars", "*"
21
- grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
22
- Digest::MD5.hexdigest grammars
22
+ # gem_path = File.expand_path "..", __dir__
23
+ # grammars_path = File.join gem_path, "grammars", "*"
24
+ # grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
25
+ Digest::MD5.hexdigest RelatonW3c::VERSION + RelatonBib::VERSION # grammars
23
26
  end
24
27
  end
data/relaton_w3c.gemspec CHANGED
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
35
35
  spec.add_dependency "mechanize", "~> 2.8.0"
36
36
  spec.add_dependency "rdf", "~> 3.2.0"
37
37
  spec.add_dependency "rdf-normalize", "~> 0.5.0"
38
- spec.add_dependency "relaton-bib", "~> 1.16.0"
38
+ spec.add_dependency "relaton-bib", "~> 1.17.0"
39
39
  spec.add_dependency "relaton-index", "~> 0.2.4"
40
40
  spec.add_dependency "rubyzip", "~> 2.3.0"
41
41
  spec.add_dependency "shex", "~> 0.7.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.16.0
4
+ version: 1.17.0
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-09-03 00:00:00.000000000 Z
11
+ date: 2023-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: linkeddata
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.16.0
75
+ version: 1.17.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 1.16.0
82
+ version: 1.17.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: relaton-index
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -164,12 +164,17 @@ files:
164
164
  - grammars/relaton-w3c.rng
165
165
  - lib/relaton_w3c.rb
166
166
  - lib/relaton_w3c/bibxml_parser.rb
167
+ - lib/relaton_w3c/config.rb
167
168
  - lib/relaton_w3c/data_fetcher.rb
168
169
  - lib/relaton_w3c/data_index.rb
169
170
  - lib/relaton_w3c/data_parser.rb
171
+ - lib/relaton_w3c/document_type.rb
170
172
  - lib/relaton_w3c/hash_converter.rb
173
+ - lib/relaton_w3c/hit.rb
174
+ - lib/relaton_w3c/hit_collection.rb
171
175
  - lib/relaton_w3c/processor.rb
172
176
  - lib/relaton_w3c/pubid.rb
177
+ - lib/relaton_w3c/util.rb
173
178
  - lib/relaton_w3c/version.rb
174
179
  - lib/relaton_w3c/w3c_bibliographic_item.rb
175
180
  - lib/relaton_w3c/w3c_bibliography.rb