relaton-gb 1.16.1 → 1.16.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: 9abe3c75ca613bc38c155fd5f116ecd967b06eecd7abc78610b498f107d6ec8f
4
- data.tar.gz: a01b3c0b36e744d4518a54c2e41576a3c87a996468ff17b19a7981c5ed1a058d
3
+ metadata.gz: 77a65c710fb3f90a55360e83741f5fabe4e19cd5e7af7c7f3c9fe9407b0da29e
4
+ data.tar.gz: 81b88ce4507b1d6b91ea4dcee2179369b9139a1cc6799ec52d179bbc8c15db16
5
5
  SHA512:
6
- metadata.gz: f10cfd40d9314992bae8b704118d53b519ce1c5f2145139e61f816559f28adbc17703a34e02556af92694e99f5b78371d6fbcea2732d3d3556d181dc7876d811
7
- data.tar.gz: f6373a69761f186b254ef5dfacbee6f195143b6cf522dc2da06a9667a4bfd4df90be3ac001de734034655b48072ab7dbca632f73f77ebf2fe196f19ff8a081d2
6
+ metadata.gz: 8bf26e37145d5c50a3f55e90d6d330adb9f76b1e9faa9670eda7629174355c793c5b3182e791d42ac346c17275d5d393b776ed31ebf920fca6408e72a6172295
7
+ data.tar.gz: 7bbdae2269caf3045f7af542700d0366a46733561135c5704c52fef0be2d0e8ca79bc19a59e9bb28396267fa2aa9bd8fbd68ac9522eda80f685bc3fd537168a9
data/README.adoc CHANGED
@@ -39,14 +39,26 @@ Or install it yourself as:
39
39
 
40
40
  == Usage
41
41
 
42
- === Search document
42
+ === Configuration
43
+
44
+ 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 `RelatonGb.configure` block.
43
45
 
44
46
  [source,ruby]
45
47
  ----
46
48
  require 'relaton_gb'
47
49
  => true
48
50
 
51
+ RelatonGb.configure do |config|
52
+ config.logger.level = Logger::DEBUG
53
+ end
54
+ ----
55
+
56
+ === Search document
57
+
58
+ [source,ruby]
59
+ ----
49
60
  hit_collection = RelatonGb::GbBibliography.search "GB/T 20223-2006"
61
+ [relaton-gb] (GB/T 20223-2006) Fetching from openstd.samr.gov.cn ...
50
62
  => <RelatonGb::HitCollection:0x007fc8d8a26d10 @ref= @fetched=false>
51
63
 
52
64
  hit_collection.first
@@ -64,7 +76,7 @@ hit_collection.first.fetch.committee
64
76
  => #<RelatonGb::GbTechnicalCommittee:0x007f975713c450 @name="中国纤维检验局", @type="technical">
65
77
 
66
78
  hit_collection.first.fetch.gbtype
67
- => #<RelatonGb::GbStandardType:0x007f9758087018 @mandate="recommended", @prefix="GB_national", @scope="national">
79
+ => #<RelatonGb::GbStandardType:0x0000000112957dc0 @mandate="recommended", @prefix="GB_national", @scope="national", @topic="other">
68
80
 
69
81
  hit_collection.first.fetch.ccs
70
82
  => [#<Cnccs::Ccs:0x007f975713c090
@@ -77,21 +89,43 @@ hit_collection.first.fetch.ccs
77
89
  @subgroupcode="32">]
78
90
 
79
91
  hit_collection.first.fetch.title
80
- => [#<RelatonIsoBib::TypedTitleString:0x007f975714cfa8
81
- @title=#<RelatonBib::FormattedString:0x007f975714cb20 @content="棉短绒", @format="text/plain", @language=["zh"], @script=["Hans"]>,
82
- @type="title-main">,
83
- #<RelatonIsoBib::TypedTitleString:0x007f975714c580
84
- @title=#<RelatonBib::FormattedString:0x007f9757147f08 @content="棉短绒", @format="text/plain", @language=["zh"], @script=["Hans"]>,
85
- @type="main">,
86
- #<RelatonIsoBib::TypedTitleString:0x007f97571477d8
87
- @title=#<RelatonBib::FormattedString:0x007f9757146ec8 @content="Cotton linter", @format="text/plain", @language=["en"], @script=["Latn"]>,
88
- @type="title-main">,
89
- #<RelatonIsoBib::TypedTitleString:0x007f97571465e0
90
- @title=#<RelatonBib::FormattedString:0x007f9757146158 @content="Cotton linter", @format="text/plain", @language=["en"], @script=["Latn"]>,
91
- @type="main">]
92
+ => #<RelatonBib::TypedTitleStringCollection:0x0000000112a1ac08
93
+ @array=
94
+ [#<RelatonBib::TypedTitleString:0x0000000112a1f438
95
+ @title=#<RelatonBib::FormattedString:0x0000000112cd6050 @content="棉短绒", @format="text/plain", @language=["zh"], @script=["Hans"]>,
96
+ @type="title-main">,
97
+ #<RelatonBib::TypedTitleString:0x0000000112a1eb78
98
+ @title=#<RelatonBib::FormattedString:0x0000000112cd6000 @content="棉短绒", @format="text/plain", @language=["zh"], @script=["Hans"]>,
99
+ @type="main">,
100
+ #<RelatonBib::TypedTitleString:0x0000000112a1c198
101
+ @title=#<RelatonBib::FormattedString:0x0000000112cd5ce0 @content="Cotton linter", @format="text/plain", @language=["en"], @script=["Latn"]>,
102
+ @type="title-main">,
103
+ #<RelatonBib::TypedTitleString:0x0000000112a1bba8
104
+ @title=#<RelatonBib::FormattedString:0x0000000112cd5c40 @content="Cotton linter", @format="text/plain", @language=["en"], @script=["Latn"]>,
105
+ @type="main">]>
92
106
 
93
107
  hit_collection.first.fetch.date
94
- => [#<RelatonBib::BibliographicDate:0x007f975a0207d0 @from=nil, @on=2006-03-10 00:00:00 +0100, @to=nil, @type="published">]
108
+ => [#<RelatonBib::BibliographicDate:0x000000011307f468 @from=nil, @on="2006-03-10", @to=nil, @type="published">]
109
+ ----
110
+
111
+ === Get document by identifier
112
+
113
+ [source,ruby]
114
+ ----
115
+ RelatonGb::GbBibliography.get "GB/T 20223-2006"
116
+ [relaton-gb] (GB/T 20223-2006) Fetching from openstd.samr.gov.cn ...
117
+ [relaton-gb] (GB/T 20223-2006) Found: `GB/T 20223-2006`
118
+ => <RelatonGb::GbBibliographicItem:0x000000000011f8>
119
+ ----
120
+
121
+ === Get document by identifier and year
122
+
123
+ [source,ruby]
124
+ ----
125
+ RelatonGb::GbBibliography.get "GB/T 20223", "2006"
126
+ [relaton-gb] (GB/T 20223-2006) Fetching from openstd.samr.gov.cn ...
127
+ [relaton-gb] (GB/T 20223-2006) Found: `GB/T 20223-2006`
128
+ => <RelatonGb::GbBibliographicItem:0x00000000001248>
95
129
  ----
96
130
 
97
131
  === Create bibliographic item from YAML
@@ -9,6 +9,8 @@ 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
13
+
12
14
  # @return [RelatonGb::GbTechnicalCommittee]
13
15
  attr_reader :committee
14
16
 
@@ -15,10 +15,11 @@ module RelatonGb
15
15
  # @return [RelatonGb::HitCollection]
16
16
  def search(text)
17
17
  case text
18
- # when /^(GB|GJ|GS)/
18
+ when /^(GB|GJ|GS)/
19
19
  # Scrape national standards.
20
- # require "relaton_gb/gb_scrapper"
21
- # GbScrapper.scrape_page text
20
+ Util.warn "(#{text}) Fetching from openstd.samr.gov.cn ..."
21
+ require "relaton_gb/gb_scrapper"
22
+ GbScrapper.scrape_page text
22
23
  # when /^ZB/
23
24
  # Scrape proffesional.
24
25
  # when /^DB/
@@ -27,6 +28,7 @@ module RelatonGb
27
28
  # Enterprise standard
28
29
  when %r{^T/[^\s]{2,6}\s}
29
30
  # Scrape social standard.
31
+ Util.warn "(#{text}) Fetching from www.ttbz.org.cn ..."
30
32
  require "relaton_gb/t_scrapper"
31
33
  TScrapper.scrape_page text
32
34
  else
@@ -64,9 +66,9 @@ module RelatonGb
64
66
  private
65
67
 
66
68
  def fetch_ref_err(code, year, missed_years) # rubocop:disable Metrics/MethodLength
67
- id = year ? "#{code}:#{year}" : code
68
- Util.warn "WARNING: no match found on the GB website for `#{id}`. " \
69
- "The code must be exactly like it is on the website."
69
+ # id = year ? "#{code}:#{year}" : code
70
+ # Util.warn "WARNING: No match found on the GB website for `#{id}`. " \
71
+ # "The code must be exactly like it is on the website."
70
72
  unless missed_years.empty?
71
73
  Util.warn "(There was no match for `#{year}`, though there " \
72
74
  "were matches found for `#{missed_years.join('`, `')}`.)"
@@ -89,9 +91,10 @@ module RelatonGb
89
91
  result = search_filter(searchcode) || return
90
92
  ret = results_filter(result, year)
91
93
  if ret[:ret]
92
- Util.warn "(#{code}) found `#{ret[:ret].docidentifier.first.id}`"
94
+ Util.warn "(#{searchcode}) Found: `#{ret[:ret].docidentifier.first.id}`"
93
95
  ret[:ret]
94
96
  else
97
+ Util.warn "(#{searchcode}) Not found."
95
98
  fetch_ref_err(code, year, ret[:years])
96
99
  end
97
100
  end
@@ -99,7 +102,6 @@ module RelatonGb
99
102
  def search_filter(code)
100
103
  # search filter needs to incorporate year
101
104
  docidrx = %r{^[^\s]+\s[\d.-]+}
102
- Util.warn "(#{code}) fetching..."
103
105
  result = search(code)
104
106
  result.select do |hit|
105
107
  hit.docref && hit.docref.match(docidrx).to_s.include?(code)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelatonGb
4
- VERSION = "1.16.1"
4
+ VERSION = "1.16.2"
5
5
  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.1
4
+ version: 1.16.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-09-20 00:00:00.000000000 Z
11
+ date: 2023-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cnccs