nistbib 0.1.0 → 0.1.1

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
- SHA1:
3
- metadata.gz: ef1ae9dcd37608cd47b565f151b291adcf85cca5
4
- data.tar.gz: 953dce58fd24be8d0e39a3ec9622a3a5508bbb2c
2
+ SHA256:
3
+ metadata.gz: d4ef478920734e534e1826dbe3f4797f0d7efb6ec0be12d20d2524a51ce4e8eb
4
+ data.tar.gz: 2f22189c970b05874d390af4f95f322e9b7412ad65568c56740af2985359d4f5
5
5
  SHA512:
6
- metadata.gz: 25007561f152223a16046b5b05811312d4bda2feb5cb2663a351a61da64fe3cd2edee5ce104aeb21918203a1f44529ae4f5ace9f8c8c1f3299eed91966b3b4c7
7
- data.tar.gz: 1e98dca81f2a883899b4f0ae7f3a8fc057293b208adce21b4e36186db813667e669e534bf8071685ee872d70ccca039918c1f145476c1e6890abe9eb9fe34faa
6
+ metadata.gz: 28f16fbd808e2e59a341201dd61e26960c1243d9650ef5862c16b8205b7e459b943645780cbf841d3d329f42fc743fee33718253e401b20cb388bec57fa429bf
7
+ data.tar.gz: ffdb848ef8d9c949dc246f197487eaa80e5364c1827f6207cdbab062a89ff93d7352c87b781ee0854fb4dab8280a5a18ffebab345b441996e434d2576a3f4b9b
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ .vscode/
9
10
 
10
11
  # rspec failure tracking
11
12
  .rspec_status
data/Gemfile CHANGED
@@ -1,3 +1,6 @@
1
+ Encoding.default_external = Encoding::UTF_8
2
+ Encoding.default_internal = Encoding::UTF_8
3
+
1
4
  source "https://rubygems.org"
2
5
 
3
6
  # Specify your gem's dependencies in nistbib.gemspec
data/Gemfile.lock CHANGED
@@ -9,10 +9,13 @@ GEM
9
9
  specs:
10
10
  addressable (2.6.0)
11
11
  public_suffix (>= 2.0.2, < 4.0)
12
- byebug (10.0.2)
12
+ byebug (11.0.1)
13
13
  coderay (1.1.2)
14
14
  crack (0.4.3)
15
15
  safe_yaml (~> 1.0.0)
16
+ debase (0.2.2)
17
+ debase-ruby_core_source (>= 0.10.2)
18
+ debase-ruby_core_source (0.10.4)
16
19
  diff-lcs (1.3)
17
20
  docile (1.3.1)
18
21
  equivalent-xml (0.6.0)
@@ -23,7 +26,7 @@ GEM
23
26
  nokogiri (~> 1.8.4)
24
27
  ruby_deep_clone (~> 0.8.0)
25
28
  isoics (0.1.7)
26
- json (2.1.0)
29
+ json (2.2.0)
27
30
  method_source (0.9.2)
28
31
  mini_portile2 (2.3.0)
29
32
  nokogiri (1.8.5)
@@ -31,8 +34,8 @@ GEM
31
34
  pry (0.12.2)
32
35
  coderay (~> 1.1.0)
33
36
  method_source (~> 0.9.0)
34
- pry-byebug (3.6.0)
35
- byebug (~> 10.0)
37
+ pry-byebug (3.7.0)
38
+ byebug (~> 11.0)
36
39
  pry (~> 0.10)
37
40
  public_suffix (3.0.3)
38
41
  rake (10.5.0)
@@ -49,8 +52,10 @@ GEM
49
52
  diff-lcs (>= 1.2.0, < 2.0)
50
53
  rspec-support (~> 3.8.0)
51
54
  rspec-support (3.8.0)
55
+ ruby-debug-ide (0.6.1)
56
+ rake (>= 0.8.1)
52
57
  ruby_deep_clone (0.8.0)
53
- safe_yaml (1.0.4)
58
+ safe_yaml (1.0.5)
54
59
  simplecov (0.16.1)
55
60
  docile (~> 1.1)
56
61
  json (>= 1.8, < 3)
@@ -68,11 +73,13 @@ PLATFORMS
68
73
  DEPENDENCIES
69
74
  bundler (~> 2.0)
70
75
  byebug
76
+ debase
71
77
  equivalent-xml (~> 0.6)
72
78
  nistbib!
73
79
  pry-byebug
74
80
  rake (~> 10.0)
75
81
  rspec (~> 3.0)
82
+ ruby-debug-ide
76
83
  simplecov
77
84
  vcr
78
85
  webmock
data/README.adoc ADDED
@@ -0,0 +1,81 @@
1
+ = NistBib: retrieve NIST Standards for bibliographic use using the BibliographicItem model
2
+
3
+ image:https://img.shields.io/gem/v/nistbib.svg["Gem Version", link="https://rubygems.org/gems/nistbib"]
4
+ image:https://img.shields.io/travis/metanorma/nistbib/master.svg["Build Status", link="https://travis-ci.com/metanorma/nistbib"]
5
+ image:https://ci.appveyor.com/api/projects/status/vk85u3df4f3kertr?svg=true["Appveyor Build Status", link="https://ci.appveyor.com/project/ribose/nistbib"]
6
+ image:https://codeclimate.com/github/metanorma/nistbib/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/nistbib"]
7
+
8
+
9
+ NistBib is a Ruby gem that implements the https://github.com/metanorma/metanorma-model-iso#iso-bibliographic-item[IsoBibliographicItem model].
10
+
11
+ You can use it to retrieve metadata of NIST Standards from https://csrc.nist.gov, and access such metadata through the `IsoBibliographicItem` object.
12
+
13
+ == Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ [source,ruby]
18
+ ----
19
+ gem 'nistbib'
20
+ ----
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install nistbib
29
+
30
+ == Usage
31
+
32
+ === Search for a standard using keywords
33
+
34
+ [source,ruby]
35
+ ----
36
+ require 'nistbib'
37
+
38
+ hit_collection = NistBib::NistBibliography.search("8200")
39
+ => [<NistBib::Hit:0x007f82b9b2b298 @text="8200" @fetched="false" @fullIdentifier="" @title="8200">,
40
+ <NistBib::Hit:0x007f82b9b2a1e0 @text="8200" @fetched="false" @fullIdentifier="" @title="8200">]
41
+
42
+ item = hit_collection[1].fetch
43
+ => #<IsoBibItem::IsoBibliographicItem:0x007f82b986e668
44
+ ...
45
+ ----
46
+
47
+ === XML serialization
48
+ [source,ruby]
49
+ ----
50
+ item.to_xml
51
+ => "<bibitem type="" id="NISTIR8200(DRAFT)">
52
+ <fetched>2019-02-11</fetched>
53
+ <title format="text/plain" language="en" script="Latn">
54
+ Interagency Report on Status of International Cybersecurity Standardization for the Internet of Things (IoT)
55
+ </title>
56
+ ...
57
+ </bibitem>"
58
+ ----
59
+
60
+ === Get code, and year
61
+ [source,ruby]
62
+ ----
63
+ NistBib::NistBibliography.get("8200", "2018", {})
64
+ fetching 8200...
65
+ => #<IsoBibItem::IsoBibliographicItem:0x007f82bb3370a8
66
+ ...
67
+ ----
68
+
69
+ == Development
70
+
71
+ 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.
72
+
73
+ 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).
74
+
75
+ == Contributing
76
+
77
+ Bug reports and pull requests are welcome on GitHub at https://github.com/metanorma/nistbib.
78
+
79
+ == License
80
+
81
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/appveyor.yml ADDED
@@ -0,0 +1,30 @@
1
+ version: '{build}'
2
+
3
+ environment:
4
+ matrix:
5
+ - RUBY_VERSION: 25
6
+ - RUBY_VERSION: 24
7
+ - RUBY_VERSION: 23
8
+ - RUBY_VERSION: _trunk
9
+
10
+ matrix:
11
+ allow_failures:
12
+ - RUBY_VERSION: _trunk
13
+
14
+ install:
15
+ - ps: . { iwr -useb https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/appveyor.ps1 } | iex
16
+ - refreshenv
17
+
18
+ build_script:
19
+ - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
20
+ - bundle update
21
+ - bundle install
22
+
23
+ before_test:
24
+ - ruby -v
25
+ - gem -v
26
+ - bundle -v
27
+
28
+ test_script:
29
+ - bundle exec rake
30
+
data/lib/nistbib.rb CHANGED
@@ -1,6 +1,11 @@
1
1
  require "nistbib/version"
2
2
  require 'nistbib/nist_bibliography'
3
3
 
4
+ if defined? Relaton
5
+ require_relative 'relaton/processor'
6
+ Relaton::Registry.instance.register(Relaton::NistBib::Processor)
7
+ end
8
+
4
9
  module NistBib
5
10
  class Error < StandardError; end
6
11
  # Your code goes here...
@@ -17,7 +17,15 @@ module NistBib
17
17
  # @param year [String] the year the standard was published (optional)
18
18
  # @param opts [Hash] options; restricted to :all_parts if all-parts reference is required
19
19
  # @return [String] Relaton XML serialisation of reference
20
- def get(code, year, opts)
20
+ def get(code, year = nil, opts = {})
21
+ if year.nil?
22
+ /^(?<code1>[^:]+):(?<year1>[^:]+)$/ =~ code
23
+ unless code1.nil?
24
+ code = code1
25
+ year = year1
26
+ end
27
+ end
28
+
21
29
  code += '-1' if opts[:all_parts]
22
30
  ret = nistbib_get1(code, year, opts)
23
31
  return nil if ret.nil?
@@ -1,3 +1,3 @@
1
1
  module NistBib
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  require "relaton/processor"
2
2
 
3
3
  module Relaton
4
- module Isobib
4
+ module NistBib
5
5
  class Processor < Relaton::Processor
6
6
 
7
7
  def initialize
data/nistbib.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
 
12
12
  spec.summary = %q{NistBib: retrive NIST standards.}
13
13
  spec.description = %q{NistBib: retrive NIST standards.}
14
- spec.homepage = "https://github.com/riboseinc/nistbib"
14
+ spec.homepage = "https://github.com/metanorma/nistbib"
15
15
  spec.license = "MIT"
16
16
 
17
17
  # Specify which files should be added to the gem when it is released.
@@ -32,6 +32,8 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency 'simplecov'
33
33
  spec.add_development_dependency 'vcr'
34
34
  spec.add_development_dependency 'webmock'
35
+ spec.add_development_dependency 'ruby-debug-ide'
36
+ spec.add_development_dependency 'debase'
35
37
 
36
38
  spec.add_dependency 'iso-bib-item', '~> 0.4.2'
37
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nistbib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-07 00:00:00.000000000 Z
11
+ date: 2019-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -136,6 +136,34 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: ruby-debug-ide
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: debase
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
139
167
  - !ruby/object:Gem::Dependency
140
168
  name: iso-bib-item
141
169
  requirement: !ruby/object:Gem::Requirement
@@ -163,8 +191,9 @@ files:
163
191
  - Gemfile
164
192
  - Gemfile.lock
165
193
  - LICENSE.txt
166
- - README.md
194
+ - README.adoc
167
195
  - Rakefile
196
+ - appveyor.yml
168
197
  - bin/console
169
198
  - bin/setup
170
199
  - lib/nistbib.rb
@@ -176,7 +205,7 @@ files:
176
205
  - lib/nistbib/workers_pool.rb
177
206
  - lib/relaton/processor.rb
178
207
  - nistbib.gemspec
179
- homepage: https://github.com/riboseinc/nistbib
208
+ homepage: https://github.com/metanorma/nistbib
180
209
  licenses:
181
210
  - MIT
182
211
  metadata: {}
@@ -196,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
225
  version: '0'
197
226
  requirements: []
198
227
  rubyforge_project:
199
- rubygems_version: 2.6.12
228
+ rubygems_version: 2.7.6
200
229
  signing_key:
201
230
  specification_version: 4
202
231
  summary: 'NistBib: retrive NIST standards.'
data/README.md DELETED
@@ -1,39 +0,0 @@
1
- # Nistbib
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/nistbib`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'nistbib'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install nistbib
22
-
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- 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
-
31
- 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
-
33
- ## Contributing
34
-
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/nistbib.
36
-
37
- ## License
38
-
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).