relaton-gb 1.16.2 → 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: 77a65c710fb3f90a55360e83741f5fabe4e19cd5e7af7c7f3c9fe9407b0da29e
4
- data.tar.gz: 81b88ce4507b1d6b91ea4dcee2179369b9139a1cc6799ec52d179bbc8c15db16
3
+ metadata.gz: 53cd256c857a13c478b3d76fed719c5aab7a1ab716efafec164013da692d0c6e
4
+ data.tar.gz: b6d73b1296ac658de87cda32b776f11d69bb28b3b0e665843089c8e719113c80
5
5
  SHA512:
6
- metadata.gz: 8bf26e37145d5c50a3f55e90d6d330adb9f76b1e9faa9670eda7629174355c793c5b3182e791d42ac346c17275d5d393b776ed31ebf920fca6408e72a6172295
7
- data.tar.gz: 7bbdae2269caf3045f7af542700d0366a46733561135c5704c52fef0be2d0e8ca79bc19a59e9bb28396267fa2aa9bd8fbd68ac9522eda80f685bc3fd537168a9
6
+ metadata.gz: 207fd52a45bcaaa959d951639fb0a16dcdace2be5db19e50c6f56bad479a7c9b3f2755dd125daaac67731907caa2a93da0878b0421b9556da50d32cb762f75c6
7
+ data.tar.gz: ee2a7ab80c231ad97382670840d78d14768c11a92dc53aa43fcf6b056a3d9e7d8dd3de48d37c31685304725a035f23bd100338fb614a88c96c9befd188c44c16
@@ -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,16 @@
1
+ module RelatonGb
2
+ class DocumentType < RelatonBib::DocumentType
3
+ DOCTYPES = %w[standard reccomendation].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
@@ -9,7 +9,7 @@ require "relaton_gb/ccs"
9
9
  module RelatonGb
10
10
  # GB bibliographic item class.
11
11
  class GbBibliographicItem < RelatonIsoBib::IsoBibliographicItem
12
- DOCTYPES = %w[standard reccomendation].freeze
12
+ SUBDOCTYPES = %w[specification method-of-test vocabulary code-of-practice].freeze
13
13
 
14
14
  # @return [RelatonGb::GbTechnicalCommittee]
15
15
  attr_reader :committee
@@ -59,7 +59,7 @@ module RelatonGb
59
59
  super(**opts) do |b|
60
60
  if opts[:bibdata] && has_ext_attrs?
61
61
  ext = b.ext do
62
- b.doctype doctype if doctype
62
+ doctype&.to_xml b
63
63
  b.horizontal horizontal unless horizontal.nil?
64
64
  # b.docsubtype docsubtype if docsubtype
65
65
  committee&.to_xml b
@@ -15,8 +15,8 @@ module RelatonGb
15
15
  # @param text [Strin] code of standard for serarch
16
16
  # @return [RelatonGb::HitCollection]
17
17
  def scrape_page(text) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
18
- host = "http://openstd.samr.gov.cn/bzgk/gb/std_list"
19
- search_html = OpenURI.open_uri("#{host}?p.p2=#{text}")
18
+ host = "https://openstd.samr.gov.cn/bzgk/gb/std_list"
19
+ search_html = OpenURI.open_uri("#{host}?p.p2=#{text}", ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE)
20
20
  result = Nokogiri::HTML search_html
21
21
  hits = result.xpath(
22
22
  "//table[contains(@class, 'result_list')]/tbody[2]/tr",
@@ -35,7 +35,7 @@ module RelatonGb
35
35
  # @return [RelatonGb::GbBibliographicItem]
36
36
  def scrape_doc(hit)
37
37
  src = "http://openstd.samr.gov.cn/bzgk/gb/newGbInfo?hcno=#{hit.pid}"
38
- doc = Nokogiri::HTML OpenURI.open_uri(src)
38
+ doc = Nokogiri::HTML OpenURI.open_uri(src, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE)
39
39
  GbBibliographicItem.new(**scrapped_data(doc, src, hit))
40
40
  rescue OpenURI::HTTPError, SocketError, OpenSSL::SSL::SSLError, Net::OpenTimeout
41
41
  raise RelatonBib::RequestError, "Cannot access #{src}"
@@ -1,36 +1,39 @@
1
- require "yaml"
2
-
3
1
  module RelatonGb
4
- class HashConverter < RelatonIsoBib::HashConverter
5
- class << self
6
- # @override RelatonBib::HashConverter.hash_to_bib
7
- # @param args [Hash]
8
- # @param nested [TrueClass, FalseClass]
9
- # @return [Hash]
10
- def hash_to_bib(args)
11
- ret = super
12
- return if ret.nil?
2
+ module HashConverter
3
+ include RelatonIsoBib::HashConverter
4
+ extend self
13
5
 
14
- ccs_hash_to_bib(ret)
15
- ret
16
- end
6
+ # @override RelatonBib::HashConverter.hash_to_bib
7
+ # @param args [Hash]
8
+ # @param nested [TrueClass, FalseClass]
9
+ # @return [Hash]
10
+ def hash_to_bib(args)
11
+ ret = super
12
+ return if ret.nil?
17
13
 
18
- private
14
+ ccs_hash_to_bib(ret)
15
+ ret
16
+ end
19
17
 
20
- #
21
- # Ovverides superclass's method
22
- #
23
- # @param item [Hash]
24
- # @retirn [RelatonGb::GbBibliographicItem]
25
- def bib_item(item)
26
- GbBibliographicItem.new(item)
27
- end
18
+ private
28
19
 
29
- def ccs_hash_to_bib(ret)
30
- ret[:ccs] = RelatonBib.array(ret[:ccs]).map do |ccs|
31
- (ccs[:code] && Cnccs.fetch(ccs[:code])) || Cnccs.fetch(ccs)
32
- end
20
+ #
21
+ # Ovverides superclass's method
22
+ #
23
+ # @param item [Hash]
24
+ # @retirn [RelatonGb::GbBibliographicItem]
25
+ def bib_item(item)
26
+ GbBibliographicItem.new(item)
27
+ end
28
+
29
+ def ccs_hash_to_bib(ret)
30
+ ret[:ccs] = RelatonBib.array(ret[:ccs]).map do |ccs|
31
+ (ccs[:code] && Cnccs.fetch(ccs[:code])) || Cnccs.fetch(ccs)
33
32
  end
34
33
  end
34
+
35
+ def create_doctype(**args)
36
+ DocumentType.new(**args)
37
+ end
35
38
  end
36
39
  end
@@ -92,7 +92,7 @@ module RelatonGb
92
92
  end
93
93
 
94
94
  def get_type
95
- "standard"
95
+ DocumentType.new type: "standard"
96
96
  end
97
97
 
98
98
  # @param doc [Nokogiri::HTML::Document]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelatonGb
4
- VERSION = "1.16.2"
4
+ VERSION = "1.17.0"
5
5
  end
data/lib/relaton_gb.rb CHANGED
@@ -4,6 +4,7 @@ require "cnccs"
4
4
  require "relaton_gb/version"
5
5
  require "relaton_gb/config"
6
6
  require "relaton_gb/util"
7
+ require "relaton_gb/document_type"
7
8
  require "relaton_gb/gb_bibliography"
8
9
 
9
10
  # if defined? Relaton
data/relaton_gb.gemspec CHANGED
@@ -26,5 +26,5 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.add_dependency "cnccs", "~> 0.1.1"
28
28
  spec.add_dependency "gb-agencies", "~> 0.0.1"
29
- spec.add_dependency "relaton-iso-bib", "~> 1.16.0"
29
+ spec.add_dependency "relaton-iso-bib", "~> 1.17.0"
30
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-gb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.16.2
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-10-11 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: cnccs
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.16.0
47
+ version: 1.17.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.16.0
54
+ version: 1.17.0
55
55
  description: 'RelatonGb: retrieve Chinese GB Standards for bibliographic use using
56
56
  the BibliographicItem model.'
57
57
  email:
@@ -81,6 +81,7 @@ files:
81
81
  - lib/relaton_gb.rb
82
82
  - lib/relaton_gb/ccs.rb
83
83
  - lib/relaton_gb/config.rb
84
+ - lib/relaton_gb/document_type.rb
84
85
  - lib/relaton_gb/gb_bibliographic_item.rb
85
86
  - lib/relaton_gb/gb_bibliography.rb
86
87
  - lib/relaton_gb/gb_scrapper.rb