relaton-gb 1.20.2 → 2.0.0.pre.alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/README.adoc +80 -75
- data/grammars/basicdoc.rng +1559 -671
- data/grammars/biblio-standoc.rng +107 -46
- data/grammars/biblio.rng +1000 -375
- data/grammars/relaton-gb.rng +0 -93
- data/lib/relaton/gb/bibdata.rb +7 -0
- data/lib/relaton/gb/bibitem.rb +7 -0
- data/lib/relaton/gb/bibliography.rb +145 -0
- data/lib/relaton/gb/ccs.rb +17 -0
- data/lib/relaton/gb/committee.rb +13 -0
- data/lib/relaton/gb/docidentifier.rb +23 -0
- data/lib/relaton/gb/doctype.rb +9 -0
- data/lib/relaton/gb/ext.rb +40 -0
- data/lib/relaton/gb/gb_scraper.rb +59 -0
- data/lib/relaton/gb/gb_type.rb +20 -0
- data/lib/relaton/gb/hit.rb +48 -0
- data/lib/relaton/gb/hit_collection.rb +19 -0
- data/lib/relaton/gb/item.rb +13 -0
- data/lib/relaton/gb/item_data.rb +6 -0
- data/lib/relaton/gb/processor.rb +45 -0
- data/lib/relaton/gb/project_number.rb +38 -0
- data/lib/relaton/gb/scraper.rb +203 -0
- data/lib/relaton/gb/sec_scraper.rb +98 -0
- data/lib/relaton/gb/stage_name.rb +13 -0
- data/lib/relaton/gb/structured_identifier.rb +26 -0
- data/lib/relaton/gb/t_scraper.rb +126 -0
- data/lib/relaton/gb/util.rb +8 -0
- data/lib/relaton/gb/version.rb +5 -0
- data/lib/relaton/gb.rb +33 -0
- data/relaton_gb.gemspec +7 -7
- metadata +43 -41
- data/CLAUDE.md +0 -74
- data/lib/relaton_gb/ccs.rb +0 -20
- data/lib/relaton_gb/document_type.rb +0 -16
- data/lib/relaton_gb/gb_bibliographic_item.rb +0 -139
- data/lib/relaton_gb/gb_bibliography.rb +0 -147
- data/lib/relaton_gb/gb_scrapper.rb +0 -59
- data/lib/relaton_gb/gb_standard_type.rb +0 -32
- data/lib/relaton_gb/gb_technical_committee.rb +0 -28
- data/lib/relaton_gb/hash_converter.rb +0 -45
- data/lib/relaton_gb/hit.rb +0 -46
- data/lib/relaton_gb/hit_collection.rb +0 -15
- data/lib/relaton_gb/processor.rb +0 -40
- data/lib/relaton_gb/scrapper.rb +0 -187
- data/lib/relaton_gb/sec_scrapper.rb +0 -96
- data/lib/relaton_gb/t_scrapper.rb +0 -125
- data/lib/relaton_gb/util.rb +0 -6
- data/lib/relaton_gb/version.rb +0 -5
- data/lib/relaton_gb/xml_parser.rb +0 -50
- data/lib/relaton_gb.rb +0 -27
- /data/lib/{relaton_gb → relaton/gb}/yaml/prefixes.yaml +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bc45456d59ae3857a4161bcf3ecff02c96a35e6919b53f1a7d2b4d7d386ddcd1
|
|
4
|
+
data.tar.gz: df75a3aa8d81d04a4a1f8f80f38346202eb38bf4b5b5ea1a0681b896e66571e3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9c54eb6f16e435a14f387714c5bfc048a929e859c31f915dde57318cb7c49887dd2340d0646051f51ef2df97281530550c1863ddb4b5eefa838e216a5cf3edf7
|
|
7
|
+
data.tar.gz: 0f529d1464a0317358c5e4c632b6f5f7517e8667110b6102992ebb83d3908c6f521fe6cb7eaabefa165695890ecacf85fc1250f08cd02f39ef038ce9d6c7d5bf
|
data/.rubocop.yml
CHANGED
data/README.adoc
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
=
|
|
1
|
+
= Relaton::Gb
|
|
2
2
|
|
|
3
3
|
image:https://img.shields.io/gem/v/relaton-gb.svg["Gem Version", link="https://rubygems.org/gems/relaton-gb"]
|
|
4
4
|
image:https://github.com/relaton/relaton-gb/workflows/macos/badge.svg["Build Status (macOS)", link="https://github.com/relaton/relaton-gb/actions?workflow=macos"]
|
|
@@ -9,7 +9,7 @@ image:https://img.shields.io/github/issues-pr-raw/relaton/relaton-gb.svg["Pull R
|
|
|
9
9
|
image:https://img.shields.io/github/commits-since/relaton/relaton-gb/latest.svg["Commits since latest",link="https://github.com/relaton/relaton-gb/releases"]
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Relaton::Gb is a Ruby gem that searches and fetches Chinese GB standards.
|
|
13
13
|
The standards scraped form:
|
|
14
14
|
|
|
15
15
|
* GB standards - http://www.std.gov.cn/gb/search
|
|
@@ -43,101 +43,99 @@ Or install it yourself as:
|
|
|
43
43
|
|
|
44
44
|
[source,ruby]
|
|
45
45
|
----
|
|
46
|
-
require '
|
|
46
|
+
require 'relaton/gb'
|
|
47
47
|
=> true
|
|
48
48
|
|
|
49
|
-
hit_collection =
|
|
50
|
-
[relaton-gb] (GB/T 20223-2006) Fetching from openstd.samr.gov.cn ...
|
|
51
|
-
=> <
|
|
49
|
+
hit_collection = Relaton::Gb::Bibliography.search "GB/T 20223-2006"
|
|
50
|
+
[relaton-gb] INFO: (GB/T 20223-2006) Fetching from openstd.samr.gov.cn ...
|
|
51
|
+
=> <Relaton::Gb::HitCollection:0x00000000001350 @ref= @fetched=false>
|
|
52
52
|
|
|
53
53
|
hit_collection.first
|
|
54
|
-
=> <
|
|
54
|
+
=> <Relaton::Gb::Hit:0x00000000001850 @fullIdentifier="" @docref="GB/T 20223-2006">
|
|
55
55
|
----
|
|
56
56
|
|
|
57
57
|
=== Scrape document form collection
|
|
58
58
|
|
|
59
59
|
[source,ruby]
|
|
60
60
|
----
|
|
61
|
-
hit_collection.first.
|
|
62
|
-
=>
|
|
63
|
-
|
|
64
|
-
hit_collection.first.
|
|
65
|
-
=> #<
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
hit_collection.first.
|
|
81
|
-
=> #<
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
@
|
|
86
|
-
|
|
87
|
-
@
|
|
88
|
-
@
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
hit_collection.first.fetch.date
|
|
97
|
-
=> [#<RelatonBib::BibliographicDate:0x000000011307f468 @from=nil, @on="2006-03-10", @to=nil, @type="published">]
|
|
61
|
+
hit_collection.first.item
|
|
62
|
+
=> #<Relaton::Gb::ItemData:0x000000012913b968
|
|
63
|
+
|
|
64
|
+
hit_collection.first.item.title.first
|
|
65
|
+
=> #<Relaton::Bib::Title:0x00000001290f2bc8
|
|
66
|
+
@content="棉短绒",
|
|
67
|
+
@format=nil,
|
|
68
|
+
@language="zh",
|
|
69
|
+
@locale=nil,
|
|
70
|
+
@script="Hans",
|
|
71
|
+
@type="title-main">
|
|
72
|
+
|
|
73
|
+
hit_collection.first.item.ext.gbtype
|
|
74
|
+
=> #<Relaton::Gb::GbType:0x00000001259687c0
|
|
75
|
+
@mandate=["recommended"],
|
|
76
|
+
@prefix="GB_national",
|
|
77
|
+
@scope=["national"],
|
|
78
|
+
@topic=["other"]>
|
|
79
|
+
|
|
80
|
+
hit_collection.first.item.ext.ccs
|
|
81
|
+
=> [#<Relaton::Gb::CCS:0x000000012913f608 @code="B32">]
|
|
82
|
+
|
|
83
|
+
hit_collection.first.item.date
|
|
84
|
+
=> [#<Relaton::Bib::Date:0x0000000129111dc0
|
|
85
|
+
@at=#<Relaton::Bib::StringDate::Value:0x00000001291111e0 @value="2006-03-10">,
|
|
86
|
+
@from=nil,
|
|
87
|
+
@text=nil,
|
|
88
|
+
@to=nil,
|
|
89
|
+
@type=["published"]>]
|
|
90
|
+
|
|
91
|
+
hit_collection.first.item.date.first.at.to_s
|
|
92
|
+
=> "2006-03-10"
|
|
93
|
+
|
|
94
|
+
hit_collection.first.item.date.first.at.to_date
|
|
95
|
+
=> #<Date: 2006-03-10 ((2453805j,0s,0n),+0s,2299161j)>
|
|
98
96
|
----
|
|
99
97
|
|
|
100
98
|
=== Get document by identifier
|
|
101
99
|
|
|
102
100
|
[source,ruby]
|
|
103
101
|
----
|
|
104
|
-
|
|
105
|
-
[relaton-gb] (GB/T 20223-2006) Fetching from openstd.samr.gov.cn ...
|
|
106
|
-
[relaton-gb] (GB/T 20223-2006) Found: `GB/T 20223-2006`
|
|
107
|
-
=>
|
|
102
|
+
Relaton::Gb::Bibliography.get "GB/T 20223-2006"
|
|
103
|
+
[relaton-gb] INFO: (GB/T 20223-2006) Fetching from openstd.samr.gov.cn ...
|
|
104
|
+
[relaton-gb] INFO: (GB/T 20223-2006) Found: `GB/T 20223-2006`
|
|
105
|
+
=> #<Relaton::Gb::ItemData:0x0000000129dd16a0
|
|
108
106
|
----
|
|
109
107
|
|
|
110
108
|
=== Get document by identifier and year
|
|
111
109
|
|
|
112
110
|
[source,ruby]
|
|
113
111
|
----
|
|
114
|
-
|
|
115
|
-
[relaton-gb] (GB/T 20223-2006) Fetching from openstd.samr.gov.cn ...
|
|
116
|
-
[relaton-gb] (GB/T 20223-2006) Found: `GB/T 20223-2006`
|
|
117
|
-
=>
|
|
112
|
+
Relaton::Gb::Bibliography.get "GB/T 20223", "2006"
|
|
113
|
+
[relaton-gb] INFO: (GB/T 20223-2006) Fetching from openstd.samr.gov.cn ...
|
|
114
|
+
[relaton-gb] INFO: (GB/T 20223-2006) Found: `GB/T 20223-2006`
|
|
115
|
+
=> #<Relaton::Gb::ItemData:0x00000001299ffdd8
|
|
118
116
|
----
|
|
119
117
|
|
|
120
118
|
=== Create bibliographic item from YAML
|
|
121
119
|
[source,ruby]
|
|
122
120
|
----
|
|
123
|
-
hash = YAML.load_file 'spec/examples/gb_bib_item.yml'
|
|
124
|
-
=> {"id"=>"JB/T13368",
|
|
125
|
-
...
|
|
126
121
|
|
|
127
|
-
|
|
128
|
-
=>
|
|
122
|
+
Relaton::Gb::Item.from_yaml File.read('spec/fixtures/item.yaml')
|
|
123
|
+
=> #<Relaton::Gb::ItemData:0x00000001292d85c8
|
|
129
124
|
----
|
|
130
125
|
|
|
131
126
|
=== Serialization
|
|
132
127
|
|
|
133
128
|
[source,ruby]
|
|
134
129
|
----
|
|
135
|
-
hit_collection.first.
|
|
136
|
-
=> "<bibitem id="
|
|
137
|
-
<fetched>
|
|
138
|
-
<title
|
|
139
|
-
<title
|
|
140
|
-
<title
|
|
130
|
+
hit_collection.first.item.to_xml
|
|
131
|
+
=> "<bibitem id="GBT202232006" type="standard" schema-version="v1.4.1">
|
|
132
|
+
<fetched>2026-01-26</fetched>
|
|
133
|
+
<title language="zh" script="Hans" type="title-main">棉短绒</title>
|
|
134
|
+
<title language="zh" script="Hans" type="main">棉短绒</title>
|
|
135
|
+
<title language="en" script="Latn" type="title-main">Cotton linter</title>
|
|
136
|
+
<title language="en" script="Latn" type="main">Cotton linter</title>
|
|
137
|
+
<uri type="src">http://openstd.samr.gov.cn/bzgk/gb/newGbInfo?hcno=083B48FA72DBD3B9BDE74507BC31736A</uri>
|
|
138
|
+
<docidentifier type="Chinese Standard" primary="true">GB/T 20223-2006</docidentifier>
|
|
141
139
|
...
|
|
142
140
|
</bibitem>"
|
|
143
141
|
----
|
|
@@ -146,13 +144,15 @@ With `bibdata: true` option XML output is wrapped with `bibdata` element and `ex
|
|
|
146
144
|
|
|
147
145
|
[source,ruby]
|
|
148
146
|
----
|
|
149
|
-
hit_collection.first.
|
|
150
|
-
=> "<bibdata type="standard" schema-version="v1.
|
|
151
|
-
<fetched>
|
|
152
|
-
<title
|
|
153
|
-
<title
|
|
154
|
-
<title
|
|
155
|
-
<title
|
|
147
|
+
hit_collection.first.item.to_xml bibdata: true
|
|
148
|
+
=> "<bibdata type="standard" schema-version="v1.4.1">
|
|
149
|
+
<fetched>2026-01-26</fetched>
|
|
150
|
+
<title language="zh" script="Hans" type="title-main">棉短绒</title>
|
|
151
|
+
<title language="zh" script="Hans" type="main">棉短绒</title>
|
|
152
|
+
<title language="en" script="Latn" type="title-main">Cotton linter</title>
|
|
153
|
+
<title language="en" script="Latn" type="main">Cotton linter</title>
|
|
154
|
+
<uri type="src">http://openstd.samr.gov.cn/bzgk/gb/newGbInfo?hcno=083B48FA72DBD3B9BDE74507BC31736A</uri>
|
|
155
|
+
<docidentifier type="Chinese Standard" primary="true">GB/T 20223-2006</docidentifier>
|
|
156
156
|
...
|
|
157
157
|
<ext schema-version="v1.0.0">
|
|
158
158
|
<doctype>standard</doctype>
|
|
@@ -161,19 +161,24 @@ hit_collection.first.fetch.to_xml bibdata: true
|
|
|
161
161
|
</bibdata>"
|
|
162
162
|
----
|
|
163
163
|
|
|
164
|
-
=== Typed links
|
|
164
|
+
=== Typed source links
|
|
165
165
|
|
|
166
|
-
Each GB document has `src` type link.
|
|
166
|
+
Each GB document has `src` type source link.
|
|
167
167
|
|
|
168
168
|
[source,ruby]
|
|
169
169
|
----
|
|
170
|
-
hit_collection.first.
|
|
171
|
-
=>
|
|
170
|
+
hit_collection.first.item.source
|
|
171
|
+
=> #<Relaton::Bib::Uri:0x0000000129112bf8
|
|
172
|
+
@content="http://openstd.samr.gov.cn/bzgk/gb/newGbInfo?hcno=083B48FA72DBD3B9BDE74507BC31736A",
|
|
173
|
+
@language=nil,
|
|
174
|
+
@locale=nil,
|
|
175
|
+
@script=nil,
|
|
176
|
+
@type="src">
|
|
172
177
|
----
|
|
173
178
|
|
|
174
179
|
=== Logging
|
|
175
180
|
|
|
176
|
-
|
|
181
|
+
Relaton::Gb 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
182
|
|
|
178
183
|
== Development
|
|
179
184
|
|