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 +4 -4
- data/README.adoc +5 -12
- data/grammars/basicdoc.rng +3 -0
- data/lib/relaton_gb/document_type.rb +1 -1
- data/lib/relaton_gb/gb_bibliography.rb +8 -8
- data/lib/relaton_gb/util.rb +1 -4
- data/lib/relaton_gb/version.rb +1 -1
- data/lib/relaton_gb/xml_parser.rb +4 -0
- data/lib/relaton_gb.rb +0 -1
- data/relaton_gb.gemspec +1 -1
- metadata +4 -5
- data/lib/relaton_gb/config.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92e9e83e3558899a7705d5e279a1d8458d7a3417ade6b26f4a06835e7ac25005
|
4
|
+
data.tar.gz: 6b5bfd8af41d5ef1a8ddb3aa96b34787f2bf5372f31a729943bcba3426cb3147
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
===
|
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.
|
data/grammars/basicdoc.rng
CHANGED
@@ -17,7 +17,7 @@ module RelatonGb
|
|
17
17
|
case text
|
18
18
|
when /^(GB|GJ|GS)/
|
19
19
|
# Scrape national standards.
|
20
|
-
Util.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
94
|
+
Util.info "Found: `#{ret[:ret].docidentifier.first.id}`", key: searchcode
|
95
95
|
ret[:ret]
|
96
96
|
else
|
97
|
-
Util.
|
97
|
+
Util.info "Not found.", key: searchcode
|
98
98
|
fetch_ref_err(code, year, ret[:years])
|
99
99
|
end
|
100
100
|
end
|
data/lib/relaton_gb/util.rb
CHANGED
data/lib/relaton_gb/version.rb
CHANGED
data/lib/relaton_gb.rb
CHANGED
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.
|
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.
|
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-
|
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.
|
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.
|
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
|