relaton-bsi 1.16.1 → 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: 021f994bae1987a1d8dadd5b1c9425bdcb1aad9c69d62d3e4cb3d388d55bd6d7
4
- data.tar.gz: c96491e47dcd93b9281bd1deed2c5e0d1f72984c0aea401966e919dc4634b7a9
3
+ metadata.gz: 572e54dcc3a988ddc73f8a558b4e9c61fe7cbedb72de7cf766b75e3f8d17ed5b
4
+ data.tar.gz: b823fdaa3769c709e4dfe753a95c20e0de246d81f74f305f143e87db6c2d95bb
5
5
  SHA512:
6
- metadata.gz: e6b400c1153a40ede7766a6fce3be936114806d600d620eeaceb90ef521c439cb125ae3b53ca27df1dd536ed94366a33fce85e5aedfe0374ab0ebc7231a744e1
7
- data.tar.gz: 51bc43147ec74f564d0e37aa97c29622b46554e4d4adba720ef46f1271827e16efd4bd7c23a4c239151d9ff42c97cceee009d35c9a67c9358f967002549e960f
6
+ metadata.gz: 29b72f522e23bc75c3bd6fd5fbf3ad68ea2b56eff41748cfe6343387934a6f9c9d836cf9ecd8ae716e02e8aa24f265ab4263b13208e21a36c29a0d1d0e10ba51
7
+ data.tar.gz: 70a33418abcf63835650873bb1166c2f7a930cdb4514bbc66fefadd957044f5b4f5b6086596d2b3e319ad0ed039e80584bf74fdae1f6f25b48be9b3135e977ab
data/README.adoc CHANGED
@@ -27,13 +27,24 @@ Or install it yourself as:
27
27
 
28
28
  == Usage
29
29
 
30
- === Search for a standard using keywords
30
+ === Configuration
31
+
32
+ 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 `RelatonBsi.configure` block.
31
33
 
32
34
  [source,ruby]
33
35
  ----
34
36
  require 'relaton_bsi'
35
37
  => true
36
38
 
39
+ RelatonBsi.configure do |config|
40
+ config.logger.level = Logger::DEBUG
41
+ end
42
+ ----
43
+
44
+ === Search for a standard using keywords
45
+
46
+ [source,ruby]
47
+ ----
37
48
  hit_collection = RelatonBsi::BsiBibliography.search("BS EN ISO 8848")
38
49
  => <RelatonBsi::HitCollection:0x007fead49fe1f8 @ref=BS EN ISO 8848 @fetched=false>
39
50
 
@@ -89,14 +100,14 @@ item.to_xml bibdata: true
89
100
  [source,ruby]
90
101
  ----
91
102
  RelatonBsi::BsiBibliography.get "BS EN ISO 8848:2021"
92
- [relaton-bsi] ("BS EN ISO 8848:2021") fetching...
93
- [relaton-bsi] ("BS EN ISO 8848:2021") found BS EN ISO 8848:2021
103
+ [relaton-bsi] (BS EN ISO 8848:2021) Fetching from shop.bsigroup.com ...
104
+ [relaton-bsi] (BS EN ISO 8848:2021) Found: `BS EN ISO 8848:2021`
94
105
  => #<RelatonBsi::BsiBibliographicItem:0x007feb14814ca8
95
106
  ...
96
107
 
97
108
  RelatonBsi::BsiBibliography.get "BS EN ISO 8848", "2021"
98
- [relaton-bsi] ("BS EN ISO 8848") fetching...
99
- [relaton-bsi] ("BS EN ISO 8848") found BS EN ISO 8848:2021
109
+ [relaton-bsi] (BS EN ISO 8848) Fetching from shop.bsigroup.com ...
110
+ [relaton-bsi] (BS EN ISO 8848) Found: `BS EN ISO 8848:2021`
100
111
  => #<RelatonBsi::BsiBibliographicItem:0x007feaf59188a8
101
112
  ...
102
113
  ----
@@ -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>
@@ -1,12 +1,5 @@
1
1
  module RelatonBsi
2
2
  class BsiBibliographicItem < RelatonIsoBib::IsoBibliographicItem
3
- DOCTYPES = %w[
4
- british-standard draft-for-development published-document privately-subscribed-standard
5
- publicly-available-specification flex-standard international-standard technical-specification
6
- technical-report guide international-workshop-agreement industry-technical-agreement
7
- standard european-workshop-agreement fast-track-standard
8
- ].freeze
9
-
10
3
  SUBDOCTYPES = %w[specification method-of-test method-of-specifying vocabulary code-of-practice].freeze
11
4
 
12
5
  def initialize(**args) # rubocop:disable Metrics/AbcSize
@@ -53,13 +53,13 @@ module RelatonBsi
53
53
  private
54
54
 
55
55
  def fetch_ref_err(code, year, missed_years) # rubocop:disable Metrics/MethodLength
56
- y = code_parts(code)[:year]
57
- id = year && !y ? "#{code}:#{year}" : code
58
- Util.warn "WARNING: no match found online for `#{id}`. " \
59
- "The code must be exactly like it is on the standards website."
56
+ # y = code_parts(code)[:year]
57
+ # id = year && !y ? "#{code}:#{year}" : code
58
+ # Util.warn "WARNING: no match found online for `#{id}`. " \
59
+ # "The code must be exactly like it is on the standards website."
60
60
  unless missed_years.empty?
61
- Util.warn "(There was no match for `#{year}`, though there " \
62
- "were matches found for `#{missed_years.join('`, `')}`.)"
61
+ Util.warn "There was no match for `#{year}`, though there " \
62
+ "were matches found for `#{missed_years.join('`, `')}`."
63
63
  end
64
64
  # if /\d-\d/.match? code
65
65
  # warn "[relaton-bsi] The provided document part may not exist, or "\
@@ -82,8 +82,11 @@ module RelatonBsi
82
82
  #
83
83
  def search_filter(code)
84
84
  cp = code_parts code
85
- Util.warn "(#{code}) fetching..."
86
- return [] unless cp
85
+ Util.warn "(#{code}) Fetching from shop.bsigroup.com ..."
86
+ unless cp
87
+ Util.warn "(#{code}) Could not parse the reference"
88
+ return []
89
+ end
87
90
 
88
91
  search(code).filter_hits!(cp)
89
92
  end
@@ -112,9 +115,10 @@ module RelatonBsi
112
115
  result = search_filter(code) || return
113
116
  ret = results_filter(result, year)
114
117
  if ret[:ret]
115
- Util.warn "(#{code}) found `#{ret[:ret].docidentifier.first&.id}`"
118
+ Util.warn "(#{code}) Found: `#{ret[:ret].docidentifier.first&.id}`"
116
119
  ret[:ret]
117
120
  else
121
+ Util.warn "(#{code}) No found"
118
122
  fetch_ref_err(code, year, ret[:years])
119
123
  end
120
124
  end
@@ -0,0 +1,21 @@
1
+ module RelatonBsi
2
+ class DocumentType < RelatonBib::DocumentType
3
+ DOCTYPES = %w[
4
+ british-standard draft-for-development published-document privately-subscribed-standard
5
+ publicly-available-specification flex-standard international-standard technical-specification
6
+ technical-report guide international-workshop-agreement industry-technical-agreement
7
+ standard european-workshop-agreement fast-track-standard expert-commentary
8
+ ].freeze
9
+
10
+ def initialize(type:, abbreviation: nil)
11
+ check_type type
12
+ super
13
+ end
14
+
15
+ def check_type(type)
16
+ unless DOCTYPES.include? type
17
+ Util.warn "WARNING: invalid doctype: `#{type}`"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,16 +1,21 @@
1
1
  module RelatonBsi
2
- class HashConverter < RelatonIsoBib::HashConverter
3
- class << self
4
- private
2
+ module HashConverter
3
+ include RelatonIsoBib::HashConverter
4
+ extend self
5
5
 
6
- #
7
- # Ovverides superclass's method
8
- #
9
- # @param item [Hash]
10
- # @retirn [RelatonBsi::BsiBibliographicItem]
11
- def bib_item(item)
12
- BsiBibliographicItem.new(**item)
13
- end
6
+ private
7
+
8
+ #
9
+ # Ovverides superclass's method
10
+ #
11
+ # @param item [Hash]
12
+ # @retirn [RelatonBsi::BsiBibliographicItem]
13
+ def bib_item(item)
14
+ BsiBibliographicItem.new(**item)
15
+ end
16
+
17
+ def create_doctype(**args)
18
+ DocumentType.new(**args)
14
19
  end
15
20
  end
16
21
  end
@@ -10,7 +10,7 @@ module RelatonBsi
10
10
  end
11
11
 
12
12
  # @param code [String]
13
- # @param date [String, NilClass] year
13
+ # @param date [String, nil] year
14
14
  # @param opts [Hash]
15
15
  # @return [RelatonBsi::BsiBibliographicItem]
16
16
  def get(code, date, opts)
@@ -183,6 +183,10 @@ module RelatonBsi
183
183
  # @return [String] doctype
184
184
  #
185
185
  def fetch_doctype(hit)
186
+ DocumentType.new(type: doctype(hit))
187
+ end
188
+
189
+ def doctype(hit)
186
190
  case hit.hit[:code]
187
191
  when /(^|\s)Flex\s/ then "flex-standard"
188
192
  when /(^|\s)PAS\s/ then "publicly-available-specification"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelatonBsi
4
- VERSION = "1.16.1"
4
+ VERSION = "1.17.0"
5
5
  end
data/lib/relaton_bsi.rb CHANGED
@@ -4,6 +4,7 @@ require "relaton_iso_bib"
4
4
  require_relative "relaton_bsi/version"
5
5
  require "relaton_bsi/config"
6
6
  require "relaton_bsi/util"
7
+ require "relaton_bsi/document_type"
7
8
  require "relaton_bsi/bsi_bibliography"
8
9
  require "relaton_bsi/bsi_bibliographic_item"
9
10
  require "relaton_bsi/scrapper"
data/relaton_bsi.gemspec CHANGED
@@ -32,5 +32,5 @@ Gem::Specification.new do |spec|
32
32
  spec.add_dependency "algolia", "~> 2.3.0"
33
33
  spec.add_dependency "graphql", "1.13.6"
34
34
  spec.add_dependency "graphql-client", "~> 0.16.0"
35
- spec.add_dependency "relaton-iso-bib", "~> 1.16.0"
35
+ spec.add_dependency "relaton-iso-bib", "~> 1.17.0"
36
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-bsi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.16.1
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-20 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: algolia
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.16.0
61
+ version: 1.17.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.16.0
68
+ version: 1.17.0
69
69
  description: 'RelatonBsi: retrieve BSI Standards for bibliographic use using the BibliographicItem
70
70
  model'
71
71
  email:
@@ -95,6 +95,7 @@ files:
95
95
  - lib/relaton_bsi/bsi_bibliographic_item.rb
96
96
  - lib/relaton_bsi/bsi_bibliography.rb
97
97
  - lib/relaton_bsi/config.rb
98
+ - lib/relaton_bsi/document_type.rb
98
99
  - lib/relaton_bsi/hash_converter.rb
99
100
  - lib/relaton_bsi/hit.rb
100
101
  - lib/relaton_bsi/hit_collection.rb