= RelatonGb image:https://img.shields.io/gem/v/relaton-gb.svg["Gem Version", link="https://rubygems.org/gems/relaton-gb"] image:https://img.shields.io/travis/metanorma/relaton-gb/master.svg["Build Status", link="https://travis-ci.com/metanorma/relaton-gb"] image:https://ci.appveyor.com/api/projects/status/7sgnnqlf38jwf4ds?svg=true["Appveyor Build Status", link="https://ci.appveyor.com/project/ribose/relaton-gb"] image:https://codeclimate.com/github/metanorma/relaton-gb/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/relaton-gb"] RelatonGb is a Ruby gem that search and fetch Chinese GB standards. The standards scraped form: * GB standards - http://www.std.gov.cn/gb/search * Social organization standards - http://www.ttbz.org.cn * Sector standards - http://www.std.gov.cn/hb NOTE: Unlike the ISO website, the GB websites require the year of publication to be included in the search. So a standard will not be found successfully through this gem unless the year is included in its document identifier: for example, not `CN(GB/T 1.1)`, but `CN(GB/T 1.1-2009)`. == Installation Add this line to your application's Gemfile: [source,ruby] ---- gem 'relaton-gb' ---- And then execute: $ bundle Or install it yourself as: $ gem install relaton-gb == Usage === Search document [source,ruby] ---- require 'relaton_gb' hit_collection = RelatonGb::GbBibliography.search "GB/T 20223-2006" => [, , , , , , , , , ] hit_collection.size => 10 hit_collection.first => hit_collection[1] => hit_collection.first.title => "GB/T 20223-2006  棉短绒" ---- === Scrape document form collection [source,ruby] ---- hit_collection.first.fetch => hit_collection.first.fetch.committee => # hit_collection.first.fetch.gbtype => # hit_collection.first.fetch.ccs => [#], @subgroupcode="32">] hit_collection.first.fetch.title => [#, @type="title-main">, #, @type="main">, #, @type="title-main">, #, @type="main">] hit_collection.first.fetch.date => [#] ---- === Create bibliographic item form YAML [source,ruby] ---- hash = YAML.load_file 'spec/examples/gb_bib_item.yml' => {"id"=>"JB/T13368", ... bib_hash = RelatonGb::HashConverter.hash_to_bib hash => {:id=>"JB/T13368", ... RelatonGb::GbBibliographicItem.new bib_hash => ---- === Serialization [source,ruby] ---- hit_collection.first.fetch.to_xml =>" 棉短绒 棉短绒 Cotton linter Cotton linter http://www.std.gov.cn/gb/search/gbDetailed?id=71F772D778ADD3A7E05397BE0A0AB82A GB/T 20223-2006 2006 General Administration of Quality Supervision, Inspection and Quarantine; Standardization Administration of China 中华人民共和国国家质量监督检验检疫总局 中国国家标准化管理委员会 zh obsoleted " ---- With `bibdata: true` option XML output wrapped with `bibdata` element and `ext` element added. [source,ruby] ---- hit_collection.first.fetch.to_xml bibdata: true =>" 棉短绒 棉短绒 Cotton linter Cotton linter http://www.std.gov.cn/gb/search/gbDetailed?id=71F772D778ADD3A7E05397BE0A0AB82A GB/T 20223-2006 2006 General Administration of Quality Supervision, Inspection and Quarantine; Standardization Administration of China 中华人民共和国国家质量监督检验检疫总局 中国国家标准化管理委员会 zh obsoleted international-standard 中国纤维检验局 59.060.10 Natural fibres GB/T 20223 national GB_national recommended B32 纤维作物与产品 GB/T 20223 " ---- == Development 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. 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). == Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gdbib. == License The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).