relaton-gb 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9cd8abd91d89b6fb41c47788c0ff4261f005839c
4
+ data.tar.gz: a3f06e43e49007a80eb1e30bb7abe8cc5d960fa6
5
+ SHA512:
6
+ metadata.gz: 6bb9dbf3dc6e7c28c4e4e4cffa5110dd6047d9018a83c6c07030d57e80ab52c63f94e245af0275f6125c5ad7c0543a2c5e19f20451e93b3c88a59ed985cef1a6
7
+ data.tar.gz: a0cc800b944e3aad8535e37052a63727ae2d92573d0042262d6adc11b684e993c1249491ab734872090047b3e0b2d241b9328aad67ec42feca96f4c1104542f7
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ .vscode/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
13
+ .rubocop-https---raw-githubusercontent-com-riboseinc-oss-guides-master-ci-rubocop-yml
@@ -0,0 +1,3 @@
1
+ ruby:
2
+ Enabled: true
3
+ config_file: .rubocop.yml
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,10 @@
1
+ # This project follows the Ribose OSS style guide.
2
+ # https://github.com/riboseinc/oss-guides
3
+ # All project-specific additions and overrides should be specified in this file.
4
+
5
+ inherit_from:
6
+ - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
7
+ AllCops:
8
+ TargetRubyVersion: 2.3
9
+ Rails:
10
+ Enabled: true
@@ -0,0 +1,17 @@
1
+ # Auto-generated !!! Do not edit it manually
2
+ # use ci-master https://github.com/metanorma/metanorma-build-scripts
3
+ language: ruby
4
+ cache: bundler
5
+ os:
6
+ - linux
7
+ - osx
8
+ rvm:
9
+ - 2.5
10
+ - 2.4
11
+ - ruby-head
12
+ before_install:
13
+ - gem install bundler -v 2.0.1
14
+ - bundle update
15
+ matrix:
16
+ allow_failures:
17
+ - rvm: ruby-head
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ Encoding.default_external = Encoding::UTF_8
2
+ Encoding.default_internal = Encoding::UTF_8
3
+
4
+ source "https://rubygems.org"
5
+
6
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
7
+
8
+ # Specify your gem's dependencies in gdbib.gemspec
9
+ gemspec
@@ -0,0 +1,84 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ relaton-gb (0.1.0)
5
+ cnccs (~> 0.1.1)
6
+ gb-agencies (~> 0.0.1)
7
+ relaton-iso-bib (~> 0.1.0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ addressable (2.6.0)
13
+ public_suffix (>= 2.0.2, < 4.0)
14
+ byebug (11.0.1)
15
+ cnccs (0.1.3)
16
+ coderay (1.1.2)
17
+ debase (0.2.2)
18
+ debase-ruby_core_source (>= 0.10.2)
19
+ debase-ruby_core_source (0.10.4)
20
+ diff-lcs (1.3)
21
+ docile (1.3.1)
22
+ equivalent-xml (0.6.0)
23
+ nokogiri (>= 1.4.3)
24
+ gb-agencies (0.0.5)
25
+ isoics (0.1.7)
26
+ json (2.2.0)
27
+ method_source (0.9.2)
28
+ mini_portile2 (2.3.0)
29
+ nokogiri (1.8.5)
30
+ mini_portile2 (~> 2.3.0)
31
+ pry (0.12.2)
32
+ coderay (~> 1.1.0)
33
+ method_source (~> 0.9.0)
34
+ pry-byebug (3.7.0)
35
+ byebug (~> 11.0)
36
+ pry (~> 0.10)
37
+ public_suffix (3.1.0)
38
+ rake (10.5.0)
39
+ relaton-bib (0.1.6)
40
+ addressable
41
+ nokogiri (~> 1.8.4)
42
+ relaton-iso-bib (0.1.0)
43
+ isoics (~> 0.1.6)
44
+ nokogiri (~> 1.8.4)
45
+ relaton-bib (~> 0.1.5)
46
+ ruby_deep_clone (~> 0.8.0)
47
+ rspec (3.8.0)
48
+ rspec-core (~> 3.8.0)
49
+ rspec-expectations (~> 3.8.0)
50
+ rspec-mocks (~> 3.8.0)
51
+ rspec-core (3.8.0)
52
+ rspec-support (~> 3.8.0)
53
+ rspec-expectations (3.8.3)
54
+ diff-lcs (>= 1.2.0, < 2.0)
55
+ rspec-support (~> 3.8.0)
56
+ rspec-mocks (3.8.0)
57
+ diff-lcs (>= 1.2.0, < 2.0)
58
+ rspec-support (~> 3.8.0)
59
+ rspec-support (3.8.0)
60
+ ruby-debug-ide (0.6.1)
61
+ rake (>= 0.8.1)
62
+ ruby_deep_clone (0.8.0)
63
+ simplecov (0.16.1)
64
+ docile (~> 1.1)
65
+ json (>= 1.8, < 3)
66
+ simplecov-html (~> 0.10.0)
67
+ simplecov-html (0.10.2)
68
+
69
+ PLATFORMS
70
+ ruby
71
+
72
+ DEPENDENCIES
73
+ bundler (~> 2.0.1)
74
+ debase
75
+ equivalent-xml (~> 0.6)
76
+ pry-byebug
77
+ rake (~> 10.0)
78
+ relaton-gb!
79
+ rspec (~> 3.0)
80
+ ruby-debug-ide
81
+ simplecov
82
+
83
+ BUNDLED WITH
84
+ 2.0.1
@@ -0,0 +1,25 @@
1
+ BSD 2-Clause License
2
+
3
+ Copyright (c) 2018, Ribose
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,202 @@
1
+ = RelatonGb
2
+
3
+ image:https://img.shields.io/gem/v/relaton-gb.svg["Gem Version", link="https://rubygems.org/gems/relaton-gb"]
4
+ image:https://img.shields.io/travis/metanorma/relaton-gb/master.svg["Build Status", link="https://travis-ci.com/metanorma/relaton-gb"]
5
+ image:https://ci.appveyor.com/api/projects/status/7sgnnqlf38jwf4ds?svg=true["Appveyor Build Status", link="https://ci.appveyor.com/project/ribose/relaton-gb"]
6
+ image:https://codeclimate.com/github/metanorma/relaton-gb/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/relaton-gb"]
7
+
8
+
9
+ RelatonGb is a Ruby gem that search and fetch Chinese GB standards.
10
+ The standards scraped form:
11
+
12
+ * GB standards - http://www.std.gov.cn/gb/search
13
+ * Social organization standards - http://www.ttbz.org.cn
14
+ * Sector standards - http://www.std.gov.cn/hb
15
+
16
+ NOTE: Unlike the ISO website, the GB websites require the year of publication to be included in the search.
17
+ So a standard will not be found successfully through this gem unless the year is included in its document
18
+ identifier: for example, not `CN(GB/T 1.1)`, but `CN(GB/T 1.1-2009)`.
19
+
20
+ == Installation
21
+
22
+ Add this line to your application's Gemfile:
23
+
24
+ [source,ruby]
25
+ ----
26
+ gem 'relaton-gb'
27
+ ----
28
+
29
+ And then execute:
30
+
31
+ $ bundle
32
+
33
+ Or install it yourself as:
34
+
35
+ $ gem install relaton-gb
36
+
37
+ == Usage
38
+
39
+ === Search document
40
+
41
+ [source,ruby]
42
+ ----
43
+ require 'relaton_gb'
44
+
45
+ hit_collection = RelatonGb::GbBibliography.search "GB/T 20223-2006"
46
+ => [<RelatonGb::Hit:0x007f97572b7348 @fullIdentifier="" @title="GB/T 20223-2006  棉短绒">,
47
+ <RelatonGb::Hit:0x007f97572b7208 @fullIdentifier="" @title="20010320-T-424  棉短绒">,
48
+ <RelatonGb::Hit:0x007f97572b70c8 @fullIdentifier="" @title="GB/T 20223-2018  棉短绒">,
49
+ <RelatonGb::Hit:0x007f97572b6fb0 @fullIdentifier="" @title="NB/T 20223-2013  核电厂安全重要机械设备维修指南">,
50
+ <RelatonGb::Hit:0x007f97572b6e98 @fullIdentifier="" @title="20130458-T-424  棉短绒">,
51
+ <RelatonGb::Hit:0x007f97572b6d80 @fullIdentifier="" @title="GB 12995-2006  机动轮椅车">,
52
+ <RelatonGb::Hit:0x007f97572b6c68 @fullIdentifier="" @title="GB 14866-2006  个人用眼护具技术要求">,
53
+ <RelatonGb::Hit:0x007f97572b6b28 @fullIdentifier="" @title="GB/T 20788-2006  饲草揉碎机">,
54
+ <RelatonGb::Hit:0x007f97572b6a10 @fullIdentifier="" @title="GB/T 20707-2006  可可脂">,
55
+ <RelatonGb::Hit:0x007f97572b68f8 @fullIdentifier="" @title="GB/T 20706-2006  可可粉">]
56
+
57
+ hit_collection.size
58
+ => 10
59
+
60
+ hit_collection.first
61
+ => <RelatonGb::Hit:0x007f97572b7348 @fullIdentifier="" @title="GB/T 20223-2006  棉短绒">
62
+
63
+ hit_collection[1]
64
+ => <RelatonGb::Hit:0x007f97572b7208 @fullIdentifier="" @title="20010320-T-424  棉短绒">
65
+
66
+ hit_collection.first.title
67
+ => "GB/T 20223-2006  棉短绒"
68
+ ----
69
+
70
+ === Scrape document form collection
71
+
72
+ [source,ruby]
73
+ ----
74
+ hit_collection.first.fetch
75
+ => <RelatonGb::GbBibliographicItem:0x007f975a0219c8>
76
+
77
+ hit_collection.first.fetch.committee
78
+ => #<RelatonGb::GbTechnicalCommittee:0x007f975713c450 @name="中国纤维检验局", @type="technical">
79
+
80
+ hit_collection.first.fetch.gbtype
81
+ => #<RelatonGb::GbStandardType:0x007f9758087018 @mandate="recommended", @prefix="GB_national", @scope="national">
82
+
83
+ hit_collection.first.fetch.ccs
84
+ => [#<Cnccs::Ccs:0x007f975713c090
85
+ @code="B32",
86
+ @description="纤维作物与产品",
87
+ @description_full="农业、林业; 经济作物; 纤维作物与产品",
88
+ @fieldcode="B",
89
+ @groupcode="30/39",
90
+ @notes=[#<Cnccs::Note:0x007f975716edb0 @ccs_code="", @text="棉、麻等">],
91
+ @subgroupcode="32">]
92
+
93
+ hit_collection.first.fetch.title
94
+ => [#<RelatonIsoBib::TypedTitleString:0x007f975714cfa8
95
+ @title=#<RelatonBib::FormattedString:0x007f975714cb20 @content="棉短绒", @format="text/plain", @language=["zh"], @script=["Hans"]>,
96
+ @type="title-main">,
97
+ #<RelatonIsoBib::TypedTitleString:0x007f975714c580
98
+ @title=#<RelatonBib::FormattedString:0x007f9757147f08 @content="棉短绒", @format="text/plain", @language=["zh"], @script=["Hans"]>,
99
+ @type="main">,
100
+ #<RelatonIsoBib::TypedTitleString:0x007f97571477d8
101
+ @title=#<RelatonBib::FormattedString:0x007f9757146ec8 @content="Cotton linter", @format="text/plain", @language=["en"], @script=["Latn"]>,
102
+ @type="title-main">,
103
+ #<RelatonIsoBib::TypedTitleString:0x007f97571465e0
104
+ @title=#<RelatonBib::FormattedString:0x007f9757146158 @content="Cotton linter", @format="text/plain", @language=["en"], @script=["Latn"]>,
105
+ @type="main">]
106
+
107
+ hit_collection.first.fetch.dates
108
+ => [#<RelatonBib::BibliographicDate:0x007f975a0207d0 @from=nil, @on=2006-03-10 00:00:00 +0100, @to=nil, @type="published">]
109
+ ----
110
+
111
+ === Serialization
112
+
113
+ [source,ruby]
114
+ ----
115
+ hit_collection.first.fetch.to_xml
116
+ =>"<bibitem id="GB/T20223-2006" type="international-standard">
117
+ <title type="title-main" format="text/plain" language="zh" script="Hans">棉短绒</title>
118
+ <title type="main" format="text/plain" language="zh" script="Hans">棉短绒</title>
119
+ <title type="title-main" format="text/plain" language="en" script="Latn">Cotton linter</title>
120
+ <title type="main" format="text/plain" language="en" script="Latn">Cotton linter</title>
121
+ <uri type="src">http://www.std.gov.cn/gb/search/gbDetailed?id=71F772D778ADD3A7E05397BE0A0AB82A</uri>
122
+ <docidentifier type="Chinese Standard">GB/T 20223-2006</docidentifier>
123
+ <date type="published">
124
+ <on>2006</on>
125
+ </date>
126
+ <contributor>
127
+ <role type="publisher"/>
128
+ <organization>
129
+ <name language="en">General Administration of Quality Supervision, Inspection and Quarantine; Standardization Administration of China</name>
130
+ <name language="zh">中华人民共和国国家质量监督检验检疫总局 中国国家标准化管理委员会</name>
131
+ </organization>
132
+ </contributor>
133
+ <language>zh</language>
134
+ <script>Hans</script>
135
+ <status>
136
+ <stage>obsoleted</stage>
137
+ </status>
138
+ </bibitem>"
139
+ ----
140
+ With `bibdata: true` option XML output wrapped with `bibdata` element and `ext` element added.
141
+ [source,ruby]
142
+ ----
143
+ hit_collection.first.fetch.to_xml bibdata: true
144
+ =>"<bibdata type="international-standard">
145
+ <title type="title-main" format="text/plain" language="zh" script="Hans">棉短绒</title>
146
+ <title type="main" format="text/plain" language="zh" script="Hans">棉短绒</title>
147
+ <title type="title-main" format="text/plain" language="en" script="Latn">Cotton linter</title>
148
+ <title type="main" format="text/plain" language="en" script="Latn">Cotton linter</title>
149
+ <uri type="src">http://www.std.gov.cn/gb/search/gbDetailed?id=71F772D778ADD3A7E05397BE0A0AB82A</uri>
150
+ <docidentifier type="Chinese Standard">GB/T 20223-2006</docidentifier>
151
+ <date type="published">
152
+ <on>2006</on>
153
+ </date>
154
+ <contributor>
155
+ <role type="publisher"/>
156
+ <organization>
157
+ <name language="en">General Administration of Quality Supervision, Inspection and Quarantine; Standardization Administration of China</name>
158
+ <name language="zh">中华人民共和国国家质量监督检验检疫总局 中国国家标准化管理委员会</name>
159
+ </organization>
160
+ </contributor>
161
+ <language>zh</language>
162
+ <script>Hans</script>
163
+ <status>
164
+ <stage>obsoleted</stage>
165
+ </status>
166
+ <ext>
167
+ <doctype>international-standard</doctype>
168
+ <gbcommittee type="technical">中国纤维检验局</gbcommittee>
169
+ <ics>
170
+ <code>59.060.10</code>
171
+ <text>Natural fibres</text>
172
+ </ics>
173
+ <structuredidentifier type="Chinese Standard">
174
+ <project-number>GB/T 20223</project-number>
175
+ </structuredidentifier>
176
+ <gbtype>
177
+ <gbscope>national</gbscope>
178
+ <gbprefix>GB_national</gbprefix>
179
+ <gbmandate>recommended</gbmandate>
180
+ </gbtype>
181
+ <ccs>
182
+ <code>B32</code>
183
+ <text>纤维作物与产品</text>
184
+ </ccs>
185
+ <gbplannumber>GB/T 20223</gbplannumber>
186
+ </ext>
187
+ </bibdata>"
188
+ ----
189
+
190
+ == Development
191
+
192
+ 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.
193
+
194
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
195
+
196
+ == Contributing
197
+
198
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gdbib.
199
+
200
+ == License
201
+
202
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,35 @@
1
+ # Auto-generated !!! Do not edit it manually
2
+ # use ci-master https://github.com/metanorma/metanorma-build-scripts
3
+ version: '{build}'
4
+
5
+ cache:
6
+ - vendor/bundle
7
+
8
+ environment:
9
+ matrix:
10
+ - RUBY_VERSION: 25
11
+ - RUBY_VERSION: 24
12
+ - RUBY_VERSION: _trunk
13
+
14
+ matrix:
15
+ allow_failures:
16
+ - RUBY_VERSION: _trunk
17
+
18
+ install:
19
+ - ps: . { iwr -useb https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/appveyor.ps1 } | iex
20
+ - refreshenv
21
+
22
+ build_script:
23
+ - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
24
+ - set GIT_TERMINAL_PROMPT=0
25
+ - bundle config --local path vendor/bundle
26
+ - bundle update
27
+ - bundle install
28
+
29
+ before_test:
30
+ - ruby -v
31
+ - gem -v
32
+ - bundle -v
33
+
34
+ test_script:
35
+ - bundle exec rake
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "relaton_gb"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)