relaton-gb 1.18.4 → 1.19.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: a01690064106c099fc8b4cf2531876232bc3d2a4fd4b41622d4337a0707ce080
4
- data.tar.gz: 972a0679b5e1474d3ef0d9c8afefb49157dc0da042c89f736693e4ddb9b9531f
3
+ metadata.gz: 92e9e83e3558899a7705d5e279a1d8458d7a3417ade6b26f4a06835e7ac25005
4
+ data.tar.gz: 6b5bfd8af41d5ef1a8ddb3aa96b34787f2bf5372f31a729943bcba3426cb3147
5
5
  SHA512:
6
- metadata.gz: 6b8a4c456f5984105065c294a7566a9f679e16e534d36eda56c0024f5504fd378ba364d6b299039a47a9edb1a8d4d2c3f69193df0b9c683f76cbb11ec7c02031
7
- data.tar.gz: cd21352325f87070a8f0ab29a28a3bb31c2c53efca18c59d7bd642dec02cec896ed4eefdcc5e972e4e8ee546687fdced7aecb6932bd96e0b904a2244f9195ff9
6
+ metadata.gz: 0032bd0054227d78ccec76d8ba302a01a11085a15a89e8cf03d609f96088998dde81bdc93981e50a88239e6d1bf78d9d039a6f3118d011c9e4254bf91eb9872f
7
+ data.tar.gz: ad973c15f76b194dbd6c9198cc391b3e2d4b2313bce3dfa325bcf5d7f99d1f0a0b3cd7e60bfca7527a6b54ac854206b784b20159128690eccd5d83dcf96e701f
data/README.adoc CHANGED
@@ -39,24 +39,13 @@ Or install it yourself as:
39
39
 
40
40
  == Usage
41
41
 
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.
42
+ === Search document
45
43
 
46
44
  [source,ruby]
47
45
  ----
48
46
  require 'relaton_gb'
49
47
  => true
50
48
 
51
- RelatonGb.configure do |config|
52
- config.logger.level = Logger::DEBUG
53
- end
54
- ----
55
-
56
- === Search document
57
-
58
- [source,ruby]
59
- ----
60
49
  hit_collection = RelatonGb::GbBibliography.search "GB/T 20223-2006"
61
50
  [relaton-gb] (GB/T 20223-2006) Fetching from openstd.samr.gov.cn ...
62
51
  => <RelatonGb::HitCollection:0x007fc8d8a26d10 @ref= @fetched=false>
@@ -182,6 +171,10 @@ hit_collection.first.fetch.link
182
171
  => [#<RelatonBib::TypedUri:0x00007fee2c0257e8 @content=#<Addressable::URI:0x67c URI:http://openstd.samr.gov.cn/bzgk/gb/newGbInfo?hcno=083B48FA72DBD3B9BDE74507BC31736A>, @type="src">]
183
172
  ----
184
173
 
174
+ === Logging
175
+
176
+ RelatonGb uses the relaton-logger gem for logging. By default, it logs to STDOUT. To change the log levels and add other loggers, read the https://github.com/relaton/relaton-logger#usage[relaton-logger] documentation.
177
+
185
178
  == Development
186
179
 
187
180
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -244,6 +244,9 @@
244
244
  <data type="ID"/>
245
245
  </attribute>
246
246
  <attribute name="reviewer"/>
247
+ <optional>
248
+ <attribute name="type"/>
249
+ </optional>
247
250
  <optional>
248
251
  <attribute name="date">
249
252
  <data type="dateTime"/>
@@ -9,7 +9,7 @@ module RelatonGb
9
9
 
10
10
  def check_type(type)
11
11
  unless DOCTYPES.include? type
12
- Util.warn "WARNING: invalid doctype: `#{type}`"
12
+ Util.warn "invalid doctype: `#{type}`"
13
13
  end
14
14
  end
15
15
  end
@@ -17,7 +17,7 @@ module RelatonGb
17
17
  case text
18
18
  when /^(GB|GJ|GS)/
19
19
  # Scrape national standards.
20
- Util.warn "(#{text}) Fetching from openstd.samr.gov.cn ..."
20
+ Util.info "Fetching from openstd.samr.gov.cn ...", key: text
21
21
  require "relaton_gb/gb_scrapper"
22
22
  GbScrapper.scrape_page text
23
23
  # when /^ZB/
@@ -28,7 +28,7 @@ module RelatonGb
28
28
  # Enterprise standard
29
29
  when %r{^T/[^\s]{2,6}\s}
30
30
  # Scrape social standard.
31
- Util.warn "(#{text}) Fetching from www.ttbz.org.cn ..."
31
+ Util.info "Fetching from www.ttbz.org.cn ...", key: text
32
32
  require "relaton_gb/t_scrapper"
33
33
  TScrapper.scrape_page text
34
34
  else
@@ -67,17 +67,17 @@ module RelatonGb
67
67
 
68
68
  def fetch_ref_err(code, year, missed_years) # rubocop:disable Metrics/MethodLength
69
69
  # id = year ? "#{code}:#{year}" : code
70
- # Util.warn "WARNING: No match found on the GB website for `#{id}`. " \
70
+ # Util.info "WARNING: No match found on the GB website for `#{id}`. " \
71
71
  # "The code must be exactly like it is on the website."
72
72
  unless missed_years.empty?
73
- Util.warn "(There was no match for `#{year}`, though there " \
73
+ Util.info "(There was no match for `#{year}`, though there " \
74
74
  "were matches found for `#{missed_years.join('`, `')}`.)"
75
75
  end
76
76
  if /\d-\d/.match? code
77
- Util.warn "The provided document part may not exist, or " \
77
+ Util.info "The provided document part may not exist, or " \
78
78
  "the document may no longer be published in parts."
79
79
  else
80
- Util.warn "If you wanted to cite all document parts for the " \
80
+ Util.info "If you wanted to cite all document parts for the " \
81
81
  "reference, use `#{code} (all parts)`.\nIf the document " \
82
82
  "is not a standard, use its document type abbreviation " \
83
83
  "(TS, TR, PAS, Guide)."
@@ -91,10 +91,10 @@ module RelatonGb
91
91
  result = search_filter(searchcode) || return
92
92
  ret = results_filter(result, year)
93
93
  if ret[:ret]
94
- Util.warn "(#{searchcode}) Found: `#{ret[:ret].docidentifier.first.id}`"
94
+ Util.info "Found: `#{ret[:ret].docidentifier.first.id}`", key: searchcode
95
95
  ret[:ret]
96
96
  else
97
- Util.warn "(#{searchcode}) Not found."
97
+ Util.info "Not found.", key: searchcode
98
98
  fetch_ref_err(code, year, ret[:years])
99
99
  end
100
100
  end
@@ -1,9 +1,6 @@
1
1
  module RelatonGb
2
2
  module Util
3
3
  extend RelatonBib::Util
4
-
5
- def self.logger
6
- RelatonGb.configuration.logger
7
- end
4
+ PROGNAME = "relaton-gb".freeze
8
5
  end
9
6
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelatonGb
4
- VERSION = "1.18.4"
4
+ VERSION = "1.19.0"
5
5
  end
@@ -41,6 +41,10 @@ module RelatonGb
41
41
  topic: gbtype&.at("gbtopic")&.text,
42
42
  }
43
43
  end
44
+
45
+ def create_doctype(type)
46
+ DocumentType.new type: type.text, abbreviation: type[:abbreviation]
47
+ end
44
48
  end
45
49
  end
46
50
  end
data/lib/relaton_gb.rb CHANGED
@@ -3,7 +3,6 @@ require "mechanize"
3
3
  require "relaton_iso_bib"
4
4
  require "cnccs"
5
5
  require "relaton_gb/version"
6
- require "relaton_gb/config"
7
6
  require "relaton_gb/util"
8
7
  require "relaton_gb/document_type"
9
8
  require "relaton_gb/gb_bibliography"
data/relaton_gb.gemspec CHANGED
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
27
27
  spec.add_dependency "cnccs", "~> 0.1.1"
28
28
  spec.add_dependency "gb-agencies", "~> 0.0.1"
29
29
  spec.add_dependency "mechanize", "~> 2.10"
30
- spec.add_dependency "relaton-iso-bib", "~> 1.18.0"
30
+ spec.add_dependency "relaton-iso-bib", "~> 1.19.0"
31
31
  spec.add_dependency "csv", "~> 3.0"
32
32
  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.18.4
4
+ version: 1.19.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: 2024-06-19 00:00:00.000000000 Z
11
+ date: 2024-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cnccs
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.18.0
61
+ version: 1.19.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.18.0
68
+ version: 1.19.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: csv
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -108,7 +108,6 @@ files:
108
108
  - grammars/relaton-gb.rng
109
109
  - lib/relaton_gb.rb
110
110
  - lib/relaton_gb/ccs.rb
111
- - lib/relaton_gb/config.rb
112
111
  - lib/relaton_gb/document_type.rb
113
112
  - lib/relaton_gb/gb_bibliographic_item.rb
114
113
  - lib/relaton_gb/gb_bibliography.rb
@@ -1,10 +0,0 @@
1
- module RelatonGb
2
- module Config
3
- include RelatonBib::Config
4
- end
5
- extend Config
6
-
7
- class Configuration < RelatonBib::Configuration
8
- PROGNAME = "relaton-gb".freeze
9
- end
10
- end