= RelatonGb image:https://img.shields.io/gem/v/relaton-gb.svg["Gem Version", link="https://rubygems.org/gems/relaton-gb"] image:https://github.com/relaton/relaton-gb/workflows/macos/badge.svg["Build Status (macOS)", link="https://github.com/relaton/relaton-gb/actions?workflow=macos"] image:https://github.com/relaton/relaton-gb/workflows/windows/badge.svg["Build Status (Windows)", link="https://github.com/relaton/relaton-gb/actions?workflow=windows"] image:https://github.com/relaton/relaton-gb/workflows/ubuntu/badge.svg["Build Status (Ubuntu)", link="https://github.com/relaton/relaton-gb/actions?workflow=ubuntu"] image:https://codeclimate.com/github/relaton/relaton-gb/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/relaton/relaton-gb"] image:https://img.shields.io/github/issues-pr-raw/relaton/relaton-gb.svg["Pull Requests", link="https://github.com/relaton/relaton-gb/pulls"] image:https://img.shields.io/github/commits-since/relaton/relaton-gb/latest.svg["Commits since latest",link="https://github.com/relaton/relaton-gb/releases"] 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.first => ---- === 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 from 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).