gbbib 0.1.1 → 0.1.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
  SHA1:
3
- metadata.gz: e94e58f431712c11db853088d91e4c7601fc26b7
4
- data.tar.gz: 4d64f7151f10c5b10a7bc2ac282012416d73130a
3
+ metadata.gz: 70a5b32f9d54f9f84fd1aec25d2b716dfddf181c
4
+ data.tar.gz: 6d99606779147b68ef43d8d0ec0715b6824ff90d
5
5
  SHA512:
6
- metadata.gz: f5345a3ee6710d18b07fd983bfc6e3a770f07f185953b016c3d6a2505059af4ab0ecf6536e51c996faf99dd20a7a1a1c959e67b926b23aecc1c429bc0f6956e9
7
- data.tar.gz: af506b07af405632946a92797ed4dea393235135b6b3d620dbd1f98f3237e502ea8b4b564678702cbab44fbbc301be826cfd4c6ca8a3cfcde232774e71cacc08
6
+ metadata.gz: c0be604c6780e5bc54caf6fc78f5ad96b2751a82d61db8e3fb3f4fb6165a7cc208d2e09fa2b148877d99f93662ba9d93737a7047be1446b24ace9646e321db71
7
+ data.tar.gz: e9f4cc89beec66bee84fb3319125bb5b79c62d1e2e57e2c24bb0d7d2f09e5ead99be61f9cfb944fe394e5d1b4c7d90246164304e5bea4fe02a81fd40cb8cda1c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gbbib (0.1.1)
4
+ gbbib (0.1.2)
5
5
  cnccs
6
6
  iso-bib-item
7
7
 
@@ -13,7 +13,7 @@ GEM
13
13
  coderay (1.1.2)
14
14
  diff-lcs (1.3)
15
15
  docile (1.1.5)
16
- iso-bib-item (0.1.4)
16
+ iso-bib-item (0.1.5)
17
17
  isoics (~> 0.1.6)
18
18
  nokogiri
19
19
  isoics (0.1.6)
data/README.adoc CHANGED
@@ -1,16 +1,20 @@
1
- # Gdbib
1
+ = Gdbib
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/gdbib`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ GbBib is a Ruby gem that search and fetch Chinese GB standards.
4
+ The standards scraped form:
4
5
 
5
- TODO: Delete this and the text above, and describe your gem
6
+ * GB standards - http://www.std.gov.cn/gb/search
7
+ * Social organization standards - http://www.ttbz.org.cn
8
+ * Sector standards - http://www.std.gov.cn/hb
6
9
 
7
- ## Installation
10
+ == Installation
8
11
 
9
12
  Add this line to your application's Gemfile:
10
13
 
11
- ```ruby
14
+ [source,ruby]
15
+ ----
12
16
  gem 'gdbib'
13
- ```
17
+ ----
14
18
 
15
19
  And then execute:
16
20
 
@@ -20,20 +24,87 @@ Or install it yourself as:
20
24
 
21
25
  $ gem install gdbib
22
26
 
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
27
+ == Usage
28
+
29
+ === Search document
30
+
31
+ [source,ruby]
32
+ ----
33
+ hit_collection = Gbbib::GbBibliography.search "GB/T 20223-2006"
34
+
35
+ hit_collection.size
36
+ => 10
37
+ hit_collection.first
38
+ => <Gbbib::Hit:0x007ffa85128770 @fullIdentifier="" @title="GB/T 20223-2006  棉短绒">
39
+ hit_collection[1]
40
+ => <Gbbib::Hit:0x007ffa85128040 @fullIdentifier="" @title="GB/T 20223-2018  棉短绒">
41
+ res.first.title
42
+ => "GB/T 20223-2006  棉短绒"
43
+ ----
44
+
45
+ === Scrape document form collection
46
+
47
+ [source,ruby]
48
+ ----
49
+ res.first.fetch
50
+ => <Gbbib::GbBibliographicItem:0x007fba1115f798>
51
+ res.first.fetch.committee
52
+ => <Gbbib::GbTechnicalCommittee:0x007fba1114dd68 @name="中国纤维检验局", @type="technical">
53
+ res.first.fetch.gbtype
54
+ => <Gbbib::GbStandardType:0x007fba11175fc0 @mandate="recommended", @prefix="GB_national", @scope="national">
55
+ res.first.fetch.ccs
56
+ => [<Cnccs::Ccs:0x007fba1114d9d0
57
+ @code="B32",
58
+ @description="纤维作物与产品",
59
+ @description_full="农业、林业; 经济作物; 纤维作物与产品",
60
+ @fieldcode="B",
61
+ @groupcode="30/39",
62
+ @notes=[<Cnccs::Note:0x007fba1120d730 @ccs_code="", @text="棉、麻等">],
63
+ @subgroupcode="32">]
64
+ res.first.fetch.title
65
+ => [<IsoBibItem::IsoLocalizedTitle:0x007fba111567b0 @language="zh", @script="Hans", @title_intro="棉短绒", @title_main="[ -- ]", @title_part=nil>,
66
+ <IsoBibItem::IsoLocalizedTitle:0x007fba11156558 @language="en", @script="Latn", @title_intro="Cotton linter", @title_main="[ -- ]", @title_part=nil>]
67
+ res.first.fetch.dates
68
+ => [<IsoBibItem::BibliographicDate:0x007fba1115cc28 @on=2006-01-03 00:00:00 +0100, @type="published">]
69
+ ----
70
+
71
+ === Serialization
72
+
73
+ [source,ruby]
74
+ ----
75
+ hit_collection.first.fetch.to_xml
76
+ =><bibitem type='standard' id='20223-2006'>
77
+ <title format='text/plain' language='zh' script='Hans'>棉短绒 -- [ -- ]</title>
78
+ <title format='text/plain' language='en' script='Latn'>Cotton linter -- [ -- ]</title>
79
+ <source type='src'>http://www.std.gov.cn/gb/search/gbDetailed?id=5DDA8BA00FC618DEE05397BE0A0A95A7</source>
80
+ <docidentifier>20223-2006</docidentifier>
81
+ <date type='published'>
82
+ <on>2006</on>
83
+ </date>
84
+ <language>zh</language>
85
+ <script>Hans</script>
86
+ <status>obsoleted</status>
87
+ <ics>Natural fibres</ics>
88
+ <gbcommittee type='technical'>中国纤维检验局</gbcommittee>
89
+ <gbtype>
90
+ <gbscope>national</gbscope>
91
+ <gbprefix>GB_national</gbprefix>
92
+ <gbmandate>recommended</gbmandate>
93
+ </gbtype>
94
+ <ccs>纤维作物与产品</ccs>
95
+ </bibitem>
96
+ ----
97
+
98
+ == Development
28
99
 
29
100
  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.
30
101
 
31
102
  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).
32
103
 
33
- ## Contributing
104
+ == Contributing
34
105
 
35
106
  Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gdbib.
36
107
 
37
- ## License
108
+ == License
38
109
 
39
110
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -46,13 +46,31 @@ module Gbbib
46
46
  end
47
47
  end
48
48
 
49
+ # @return [String]
50
+ def inspect
51
+ "<#{self.class}:#{format('%#.14x', object_id << 1)}>"
52
+ # "@fullIdentifier=\"#{@fetch&.shortref}\" "\
53
+ # "@title=\"#{title}\">"
54
+ end
55
+
56
+ # @return [String]
57
+ def to_s
58
+ inspect
59
+ end
60
+
49
61
  private
50
62
 
51
63
  # @param builder [Nokogiri::XML::Builder]
52
64
  def render_gbxml(builder)
53
65
  committee.to_xml builder
54
66
  gbtype.to_xml builder
55
- ccs.each { |c| builder.ccs c.description } if ccs.any?
67
+ return unless ccs.any?
68
+ ccs.each do |c|
69
+ builder.ccs do
70
+ builder.code c.code
71
+ builder.text_ c.description
72
+ end
73
+ end
56
74
  end
57
75
  end
58
76
  end
data/lib/gbbib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gbbib
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gbbib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.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: 2018-06-05 00:00:00.000000000 Z
11
+ date: 2018-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler