nistbib 0.1.2 → 0.1.5
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.
- checksums.yaml +5 -5
 - data/.gitignore +1 -0
 - data/.rubocop.yml +10 -0
 - data/Gemfile.lock +7 -10
 - data/README.adoc +30 -5
 - data/lib/nistbib.rb +2 -2
 - data/lib/nistbib/comment_period.rb +30 -0
 - data/lib/nistbib/document_status.rb +44 -0
 - data/lib/nistbib/hit.rb +5 -12
 - data/lib/nistbib/hit_collection.rb +21 -9
 - data/lib/nistbib/keyword.rb +16 -0
 - data/lib/nistbib/nist_bibliographic_item.rb +75 -0
 - data/lib/nistbib/nist_bibliography.rb +51 -22
 - data/lib/nistbib/nist_series.rb +35 -0
 - data/lib/nistbib/scrapper.rb +187 -100
 - data/lib/nistbib/version.rb +1 -1
 - data/lib/nistbib/xml_parser.rb +53 -0
 - data/lib/relaton/processor.rb +1 -1
 - data/nistbib.gemspec +11 -12
 - metadata +38 -31
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 93e42e10363b0cf5ace10ea2540e20a7d96bacfa
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 958b66ae4601efb35dbd366a80b5c09ea22a50bd
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 4fb26a328169066da7e921df16b525a67baa6fc5b8ddebb14fbcb08af41decddd6e27b40a173aa9015972e9a22f844ceea4ee7dd711444600efac36a240a49eb
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: e71f295627f4f640f81432508783365ccbc868cc98f277ecb153e920a9e62339d6cf79f81f64d8ee731b09ede32414d3322a9ab162dce416b543fc040da0055b
         
     | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/.rubocop.yml
    ADDED
    
    | 
         @@ -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
         
     | 
    
        data/Gemfile.lock
    CHANGED
    
    | 
         @@ -1,8 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            PATH
         
     | 
| 
       2 
2 
     | 
    
         
             
              remote: .
         
     | 
| 
       3 
3 
     | 
    
         
             
              specs:
         
     | 
| 
       4 
     | 
    
         
            -
                nistbib (0.1. 
     | 
| 
       5 
     | 
    
         
            -
                   
     | 
| 
      
 4 
     | 
    
         
            +
                nistbib (0.1.5)
         
     | 
| 
      
 5 
     | 
    
         
            +
                  relaton-bib (~> 0.1.1)
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
            GEM
         
     | 
| 
       8 
8 
     | 
    
         
             
              remote: https://rubygems.org/
         
     | 
| 
         @@ -20,12 +20,7 @@ GEM 
     | 
|
| 
       20 
20 
     | 
    
         
             
                docile (1.3.1)
         
     | 
| 
       21 
21 
     | 
    
         
             
                equivalent-xml (0.6.0)
         
     | 
| 
       22 
22 
     | 
    
         
             
                  nokogiri (>= 1.4.3)
         
     | 
| 
       23 
     | 
    
         
            -
                hashdiff (0.3. 
     | 
| 
       24 
     | 
    
         
            -
                iso-bib-item (0.4.5)
         
     | 
| 
       25 
     | 
    
         
            -
                  isoics (~> 0.1.6)
         
     | 
| 
       26 
     | 
    
         
            -
                  nokogiri (~> 1.8.4)
         
     | 
| 
       27 
     | 
    
         
            -
                  ruby_deep_clone (~> 0.8.0)
         
     | 
| 
       28 
     | 
    
         
            -
                isoics (0.1.7)
         
     | 
| 
      
 23 
     | 
    
         
            +
                hashdiff (0.3.9)
         
     | 
| 
       29 
24 
     | 
    
         
             
                json (2.2.0)
         
     | 
| 
       30 
25 
     | 
    
         
             
                method_source (0.9.2)
         
     | 
| 
       31 
26 
     | 
    
         
             
                mini_portile2 (2.3.0)
         
     | 
| 
         @@ -39,13 +34,16 @@ GEM 
     | 
|
| 
       39 
34 
     | 
    
         
             
                  pry (~> 0.10)
         
     | 
| 
       40 
35 
     | 
    
         
             
                public_suffix (3.0.3)
         
     | 
| 
       41 
36 
     | 
    
         
             
                rake (10.5.0)
         
     | 
| 
      
 37 
     | 
    
         
            +
                relaton-bib (0.1.3)
         
     | 
| 
      
 38 
     | 
    
         
            +
                  addressable
         
     | 
| 
      
 39 
     | 
    
         
            +
                  nokogiri (~> 1.8.4)
         
     | 
| 
       42 
40 
     | 
    
         
             
                rspec (3.8.0)
         
     | 
| 
       43 
41 
     | 
    
         
             
                  rspec-core (~> 3.8.0)
         
     | 
| 
       44 
42 
     | 
    
         
             
                  rspec-expectations (~> 3.8.0)
         
     | 
| 
       45 
43 
     | 
    
         
             
                  rspec-mocks (~> 3.8.0)
         
     | 
| 
       46 
44 
     | 
    
         
             
                rspec-core (3.8.0)
         
     | 
| 
       47 
45 
     | 
    
         
             
                  rspec-support (~> 3.8.0)
         
     | 
| 
       48 
     | 
    
         
            -
                rspec-expectations (3.8. 
     | 
| 
      
 46 
     | 
    
         
            +
                rspec-expectations (3.8.3)
         
     | 
| 
       49 
47 
     | 
    
         
             
                  diff-lcs (>= 1.2.0, < 2.0)
         
     | 
| 
       50 
48 
     | 
    
         
             
                  rspec-support (~> 3.8.0)
         
     | 
| 
       51 
49 
     | 
    
         
             
                rspec-mocks (3.8.0)
         
     | 
| 
         @@ -54,7 +52,6 @@ GEM 
     | 
|
| 
       54 
52 
     | 
    
         
             
                rspec-support (3.8.0)
         
     | 
| 
       55 
53 
     | 
    
         
             
                ruby-debug-ide (0.6.1)
         
     | 
| 
       56 
54 
     | 
    
         
             
                  rake (>= 0.8.1)
         
     | 
| 
       57 
     | 
    
         
            -
                ruby_deep_clone (0.8.0)
         
     | 
| 
       58 
55 
     | 
    
         
             
                safe_yaml (1.0.5)
         
     | 
| 
       59 
56 
     | 
    
         
             
                simplecov (0.16.1)
         
     | 
| 
       60 
57 
     | 
    
         
             
                  docile (~> 1.1)
         
     | 
    
        data/README.adoc
    CHANGED
    
    | 
         @@ -40,7 +40,7 @@ hit_collection = NistBib::NistBibliography.search("8200") 
     | 
|
| 
       40 
40 
     | 
    
         
             
             <NistBib::Hit:0x007f82b9b2a1e0 @text="8200" @fetched="false" @fullIdentifier="" @title="8200">]
         
     | 
| 
       41 
41 
     | 
    
         | 
| 
       42 
42 
     | 
    
         
             
             item = hit_collection[1].fetch
         
     | 
| 
       43 
     | 
    
         
            -
             => #< 
     | 
| 
      
 43 
     | 
    
         
            +
             => #<NistBib::NistBibliographicItem:0x007f82b986e668
         
     | 
| 
       44 
44 
     | 
    
         
             
             ...
         
     | 
| 
       45 
45 
     | 
    
         
             
            ----
         
     | 
| 
       46 
46 
     | 
    
         | 
| 
         @@ -48,13 +48,13 @@ hit_collection = NistBib::NistBibliography.search("8200") 
     | 
|
| 
       48 
48 
     | 
    
         
             
            [source,ruby]
         
     | 
| 
       49 
49 
     | 
    
         
             
            ----
         
     | 
| 
       50 
50 
     | 
    
         
             
            item.to_xml
         
     | 
| 
       51 
     | 
    
         
            -
            => "< 
     | 
| 
       52 
     | 
    
         
            -
                  <fetched>2019- 
     | 
| 
      
 51 
     | 
    
         
            +
            => "<nist-standard>
         
     | 
| 
      
 52 
     | 
    
         
            +
                  <fetched>2019-05-03</fetched>
         
     | 
| 
       53 
53 
     | 
    
         
             
                  <title format="text/plain" language="en" script="Latn">
         
     | 
| 
       54 
54 
     | 
    
         
             
                    Interagency Report on Status of International Cybersecurity Standardization for the Internet of Things (IoT)
         
     | 
| 
       55 
55 
     | 
    
         
             
                  </title>
         
     | 
| 
       56 
56 
     | 
    
         
             
                  ...
         
     | 
| 
       57 
     | 
    
         
            -
                </ 
     | 
| 
      
 57 
     | 
    
         
            +
                </nist-standard>"
         
     | 
| 
       58 
58 
     | 
    
         
             
            ----
         
     | 
| 
       59 
59 
     | 
    
         | 
| 
       60 
60 
     | 
    
         
             
            === Get code, and year
         
     | 
| 
         @@ -62,7 +62,32 @@ item.to_xml 
     | 
|
| 
       62 
62 
     | 
    
         
             
            ----
         
     | 
| 
       63 
63 
     | 
    
         
             
            NistBib::NistBibliography.get("8200", "2018", {})
         
     | 
| 
       64 
64 
     | 
    
         
             
            fetching 8200...
         
     | 
| 
       65 
     | 
    
         
            -
            => #< 
     | 
| 
      
 65 
     | 
    
         
            +
            => #<NistBib::NistBibliographicItem:0x007f82bb3370a8
         
     | 
| 
      
 66 
     | 
    
         
            +
            ...
         
     | 
| 
      
 67 
     | 
    
         
            +
            ----
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
            === Get short citation
         
     | 
| 
      
 70 
     | 
    
         
            +
            Short citation is a convetion about a citation's format. The format for NIST publications is:
         
     | 
| 
      
 71 
     | 
    
         
            +
            ----
         
     | 
| 
      
 72 
     | 
    
         
            +
            NIST {abbrev(series)} {docnumber} {(edition), optional} {(stage), optioal}
         
     | 
| 
      
 73 
     | 
    
         
            +
            # or
         
     | 
| 
      
 74 
     | 
    
         
            +
            {abbrev(series)} {docnumber} {(edition), optional} {(stage), optioal}
         
     | 
| 
      
 75 
     | 
    
         
            +
            ----
         
     | 
| 
      
 76 
     | 
    
         
            +
            - `(stage)` is empty if the state is "final" (published)
         
     | 
| 
      
 77 
     | 
    
         
            +
            - `(edition)` is the date of publication or update
         
     | 
| 
      
 78 
     | 
    
         
            +
            - `docnumber` is the full NIST number, including revision, e.g., 800-52
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
            The format for FIPS publications is:
         
     | 
| 
      
 81 
     | 
    
         
            +
            ----
         
     | 
| 
      
 82 
     | 
    
         
            +
            FIPS {docnumber}
         
     | 
| 
      
 83 
     | 
    
         
            +
            # or
         
     | 
| 
      
 84 
     | 
    
         
            +
            NIST FIPS {docnumber}
         
     | 
| 
      
 85 
     | 
    
         
            +
            ----
         
     | 
| 
      
 86 
     | 
    
         
            +
            [source,ruby]
         
     | 
| 
      
 87 
     | 
    
         
            +
            ----
         
     | 
| 
      
 88 
     | 
    
         
            +
            NistBib::NistBibliography.get("8200", "2018", {})
         
     | 
| 
      
 89 
     | 
    
         
            +
            fetching 8200...
         
     | 
| 
      
 90 
     | 
    
         
            +
            => #<NistBib::NistBibliographicItem:0x007f82bb3370a8
         
     | 
| 
       66 
91 
     | 
    
         
             
            ...
         
     | 
| 
       67 
92 
     | 
    
         
             
            ----
         
     | 
| 
       68 
93 
     | 
    
         | 
    
        data/lib/nistbib.rb
    CHANGED
    
    | 
         @@ -1,8 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require "nistbib/version"
         
     | 
| 
       2 
     | 
    
         
            -
            require  
     | 
| 
      
 2 
     | 
    
         
            +
            require "nistbib/nist_bibliography"
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            if defined? Relaton
         
     | 
| 
       5 
     | 
    
         
            -
              require_relative  
     | 
| 
      
 5 
     | 
    
         
            +
              require_relative "relaton/processor"
         
     | 
| 
       6 
6 
     | 
    
         
             
              Relaton::Registry.instance.register(Relaton::NistBib::Processor)
         
     | 
| 
       7 
7 
     | 
    
         
             
            end
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module NistBib
         
     | 
| 
      
 2 
     | 
    
         
            +
              class CommentPeriod
         
     | 
| 
      
 3 
     | 
    
         
            +
                # @return [Date]
         
     | 
| 
      
 4 
     | 
    
         
            +
                attr_reader :from
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                # @rerurn [Date, NilClass]
         
     | 
| 
      
 7 
     | 
    
         
            +
                attr_reader :to
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                # @return [Date, NilClass]
         
     | 
| 
      
 10 
     | 
    
         
            +
                attr_reader :extended
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                # @param from [Date]
         
     | 
| 
      
 13 
     | 
    
         
            +
                # @param to [Date, NilClass]
         
     | 
| 
      
 14 
     | 
    
         
            +
                # @param extended [Date, NilClass]
         
     | 
| 
      
 15 
     | 
    
         
            +
                def initialize(from, to = nil, extended = nil)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  @from = from
         
     | 
| 
      
 17 
     | 
    
         
            +
                  @to = to
         
     | 
| 
      
 18 
     | 
    
         
            +
                  @extended = extended
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                # @param [Nokogiri::XML::Builder]
         
     | 
| 
      
 22 
     | 
    
         
            +
                def to_xml(builder)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  builder.commentperiod do
         
     | 
| 
      
 24 
     | 
    
         
            +
                    builder.from from.to_s
         
     | 
| 
      
 25 
     | 
    
         
            +
                    builder.to to.to_s if to
         
     | 
| 
      
 26 
     | 
    
         
            +
                    builder.extended extended.to_s if extended
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,44 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module NistBib
         
     | 
| 
      
 2 
     | 
    
         
            +
              class DocumentStatus
         
     | 
| 
      
 3 
     | 
    
         
            +
                STAGES = %w[
         
     | 
| 
      
 4 
     | 
    
         
            +
                  draft-internal draft-wip draft-prelim draft-public final final-review
         
     | 
| 
      
 5 
     | 
    
         
            +
                ].freeze
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                SUBSTAGES = %w[active retired withdrawn].freeze
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                # @return [String]
         
     | 
| 
      
 10 
     | 
    
         
            +
                attr_reader :stage
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                # @return [String, NilClass]
         
     | 
| 
      
 13 
     | 
    
         
            +
                attr_reader :substage
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                # @return [String, NilClass]
         
     | 
| 
      
 16 
     | 
    
         
            +
                attr_reader :iteration
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                # @param stage [String]
         
     | 
| 
      
 19 
     | 
    
         
            +
                # @param substage [String, NilClass]
         
     | 
| 
      
 20 
     | 
    
         
            +
                # @param iteration [String, NilClass]
         
     | 
| 
      
 21 
     | 
    
         
            +
                def initialize(stage:, substage: nil, iteration: nil)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  unless STAGES.include? stage
         
     | 
| 
      
 23 
     | 
    
         
            +
                    raise ArgumentError, "invalid argument: stage (#{stage})"
         
     | 
| 
      
 24 
     | 
    
         
            +
                  end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                  if substage && !SUBSTAGES.include?(substage)
         
     | 
| 
      
 27 
     | 
    
         
            +
                    raise ArgumentError, "invalid argument: substage (#{substage})"
         
     | 
| 
      
 28 
     | 
    
         
            +
                  end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                  @stage = stage
         
     | 
| 
      
 31 
     | 
    
         
            +
                  @substage = substage
         
     | 
| 
      
 32 
     | 
    
         
            +
                  @iteration = iteration
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                # @param builder [Nokogiri::XML::Builder]
         
     | 
| 
      
 36 
     | 
    
         
            +
                def to_xml(builder)
         
     | 
| 
      
 37 
     | 
    
         
            +
                  builder.status do
         
     | 
| 
      
 38 
     | 
    
         
            +
                    builder.stage stage
         
     | 
| 
      
 39 
     | 
    
         
            +
                    builder.substage substage if substage
         
     | 
| 
      
 40 
     | 
    
         
            +
                    builder.iteration iteration if iteration
         
     | 
| 
      
 41 
     | 
    
         
            +
                  end
         
     | 
| 
      
 42 
     | 
    
         
            +
                end
         
     | 
| 
      
 43 
     | 
    
         
            +
              end
         
     | 
| 
      
 44 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/nistbib/hit.rb
    CHANGED
    
    | 
         @@ -3,21 +3,21 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module NistBib
         
     | 
| 
       4 
4 
     | 
    
         
             
              # Hit.
         
     | 
| 
       5 
5 
     | 
    
         
             
              class Hit
         
     | 
| 
       6 
     | 
    
         
            -
                # @return [ 
     | 
| 
      
 6 
     | 
    
         
            +
                # @return [NistBib::HitCollection]
         
     | 
| 
       7 
7 
     | 
    
         
             
                attr_reader :hit_collection
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
                # @return [Array<Hash>]
         
     | 
| 
       10 
10 
     | 
    
         
             
                attr_reader :hit
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
                # @param hit [Hash]
         
     | 
| 
       13 
     | 
    
         
            -
                # @param hit_collection [ 
     | 
| 
      
 13 
     | 
    
         
            +
                # @param hit_collection [NistBib:HitCollection]
         
     | 
| 
       14 
14 
     | 
    
         
             
                def initialize(hit, hit_collection = nil)
         
     | 
| 
       15 
15 
     | 
    
         
             
                  @hit            = hit
         
     | 
| 
       16 
16 
     | 
    
         
             
                  @hit_collection = hit_collection
         
     | 
| 
       17 
17 
     | 
    
         
             
                end
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
                # Parse page.
         
     | 
| 
       20 
     | 
    
         
            -
                # @return [ 
     | 
| 
      
 20 
     | 
    
         
            +
                # @return [NistBib::NistBliographicItem]
         
     | 
| 
       21 
21 
     | 
    
         
             
                def fetch
         
     | 
| 
       22 
22 
     | 
    
         
             
                  @fetch ||= Scrapper.parse_page @hit
         
     | 
| 
       23 
23 
     | 
    
         
             
                end
         
     | 
| 
         @@ -37,15 +37,8 @@ module NistBib 
     | 
|
| 
       37 
37 
     | 
    
         
             
                end
         
     | 
| 
       38 
38 
     | 
    
         | 
| 
       39 
39 
     | 
    
         
             
                # @return [String]
         
     | 
| 
       40 
     | 
    
         
            -
                def to_xml 
     | 
| 
       41 
     | 
    
         
            -
                   
     | 
| 
       42 
     | 
    
         
            -
                    #fetch.to_xml builder, opts
         
     | 
| 
       43 
     | 
    
         
            -
                  #else
         
     | 
| 
       44 
     | 
    
         
            -
                    builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
         
     | 
| 
       45 
     | 
    
         
            -
                      fetch.to_xml xml, opts
         
     | 
| 
       46 
     | 
    
         
            -
                    end
         
     | 
| 
       47 
     | 
    
         
            -
                    builder.doc.root.to_xml
         
     | 
| 
       48 
     | 
    
         
            -
                  #end
         
     | 
| 
      
 40 
     | 
    
         
            +
                def to_xml
         
     | 
| 
      
 41 
     | 
    
         
            +
                  fetch.to_xml
         
     | 
| 
       49 
42 
     | 
    
         
             
                end
         
     | 
| 
       50 
43 
     | 
    
         
             
              end
         
     | 
| 
       51 
44 
     | 
    
         
             
            end
         
     | 
| 
         @@ -22,23 +22,35 @@ module NistBib 
     | 
|
| 
       22 
22 
     | 
    
         | 
| 
       23 
23 
     | 
    
         
             
                # @param ref_nbr [String]
         
     | 
| 
       24 
24 
     | 
    
         
             
                # @param year [String]
         
     | 
| 
       25 
     | 
    
         
            -
                 
     | 
| 
      
 25 
     | 
    
         
            +
                # @param opts [Hash]
         
     | 
| 
      
 26 
     | 
    
         
            +
                def initialize(ref_nbr, year = nil, opts)
         
     | 
| 
       26 
27 
     | 
    
         
             
                  @text = ref_nbr
         
     | 
| 
       27 
28 
     | 
    
         
             
                  @year = year
         
     | 
| 
       28 
29 
     | 
    
         
             
                  from, to = nil
         
     | 
| 
       29 
30 
     | 
    
         
             
                  if year
         
     | 
| 
       30 
     | 
    
         
            -
                    d = Date.strptime year,  
     | 
| 
       31 
     | 
    
         
            -
                    from = d.strftime  
     | 
| 
       32 
     | 
    
         
            -
                    to   = d.next_year.prev_day.strftime  
     | 
| 
      
 31 
     | 
    
         
            +
                    d = Date.strptime year, "%Y"
         
     | 
| 
      
 32 
     | 
    
         
            +
                    from = d.strftime "%m/%d/%Y"
         
     | 
| 
      
 33 
     | 
    
         
            +
                    to   = d.next_year.prev_day.strftime "%m/%d/%Y"
         
     | 
| 
       33 
34 
     | 
    
         
             
                  end
         
     | 
| 
       34 
     | 
    
         
            -
                  url  = "#{DOMAIN}/publications/search?keywords-lg=#{ref_nbr} 
     | 
| 
      
 35 
     | 
    
         
            +
                  url  = "#{DOMAIN}/publications/search?keywords-lg=#{ref_nbr}"
         
     | 
| 
      
 36 
     | 
    
         
            +
                  url += "&dateFrom-lg=#{from}" if from
         
     | 
| 
      
 37 
     | 
    
         
            +
                  url += "&dateTo-lg=#{to}" if to
         
     | 
| 
      
 38 
     | 
    
         
            +
                  url += "&status-lg=Draft" if /PD/ =~ opts[:stage]
         
     | 
| 
       35 
39 
     | 
    
         
             
                  doc  = Nokogiri::HTML OpenURI.open_uri(::Addressable::URI.parse(url).normalize)
         
     | 
| 
       36 
     | 
    
         
            -
                  hits = doc.css( 
     | 
| 
       37 
     | 
    
         
            -
                    link  = h.at( 
     | 
| 
       38 
     | 
    
         
            -
                     
     | 
| 
      
 40 
     | 
    
         
            +
                  hits = doc.css("table.publications-table > tbody > tr").map do |h|
         
     | 
| 
      
 41 
     | 
    
         
            +
                    link  = h.at("td/div/strong/a")
         
     | 
| 
      
 42 
     | 
    
         
            +
                    serie = h.at("td[1]").text.strip
         
     | 
| 
      
 43 
     | 
    
         
            +
                    code  = h.at("td[2]").text.strip
         
     | 
| 
       39 
44 
     | 
    
         
             
                    title = link.text
         
     | 
| 
       40 
45 
     | 
    
         
             
                    url   = DOMAIN + link[:href]
         
     | 
| 
       41 
     | 
    
         
            -
                     
     | 
| 
      
 46 
     | 
    
         
            +
                    status = h.at("td[4]").text.strip.downcase
         
     | 
| 
      
 47 
     | 
    
         
            +
                    release_date = Date.strptime h.at("td[5]").text.strip, "%m/%d/%Y"
         
     | 
| 
      
 48 
     | 
    
         
            +
                    Hit.new(
         
     | 
| 
      
 49 
     | 
    
         
            +
                      {
         
     | 
| 
      
 50 
     | 
    
         
            +
                        code: code, serie: serie, title: title, url: url, status: status,
         
     | 
| 
      
 51 
     | 
    
         
            +
                        release_date: release_date
         
     | 
| 
      
 52 
     | 
    
         
            +
                      }, self
         
     | 
| 
      
 53 
     | 
    
         
            +
                    )
         
     | 
| 
       42 
54 
     | 
    
         
             
                  end
         
     | 
| 
       43 
55 
     | 
    
         
             
                  concat hits
         
     | 
| 
       44 
56 
     | 
    
         
             
                  # concat(hits.map { |h| Hit.new(h, self) })
         
     | 
| 
         @@ -0,0 +1,16 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module NistBib
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Keyword
         
     | 
| 
      
 3 
     | 
    
         
            +
                # @return [Nokogiri::XML::DocumentFragment]
         
     | 
| 
      
 4 
     | 
    
         
            +
                attr_reader :element
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                # @param element [String]
         
     | 
| 
      
 7 
     | 
    
         
            +
                def initialize(element)
         
     | 
| 
      
 8 
     | 
    
         
            +
                  @element = Nokogiri::XML.fragment element
         
     | 
| 
      
 9 
     | 
    
         
            +
                end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                # @param builder [Nokogiri::XML::Builder]
         
     | 
| 
      
 12 
     | 
    
         
            +
                def to_xml(builder)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  builder.keyword element.to_xml
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,75 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module NistBib
         
     | 
| 
      
 2 
     | 
    
         
            +
              class NistBibliographicItem < RelatonBib::BibliographicItem
         
     | 
| 
      
 3 
     | 
    
         
            +
                # @return [NistBib::NistSeries, NilClass]
         
     | 
| 
      
 4 
     | 
    
         
            +
                attr_reader :nistseries
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                # @return [Array<NistBib::Keyword>]
         
     | 
| 
      
 7 
     | 
    
         
            +
                attr_reader :keyword
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                # @return [NistBib::CommentPeriod]
         
     | 
| 
      
 10 
     | 
    
         
            +
                attr_reader :commentperiod
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                # @param id [String, NilClass]
         
     | 
| 
      
 13 
     | 
    
         
            +
                # @param title [Array<RelatonBib::TypedTitleString>]
         
     | 
| 
      
 14 
     | 
    
         
            +
                # @param formattedref [RelatonBib::FormattedRef, NilClass]
         
     | 
| 
      
 15 
     | 
    
         
            +
                # @param type [String, NilClass]
         
     | 
| 
      
 16 
     | 
    
         
            +
                # @param docid [Array<RelatonBib::DocumentIdentifier>]
         
     | 
| 
      
 17 
     | 
    
         
            +
                # @param docnumber [String, NilClass]
         
     | 
| 
      
 18 
     | 
    
         
            +
                # @param language [Arra<String>]
         
     | 
| 
      
 19 
     | 
    
         
            +
                # @param script [Array<String>]
         
     | 
| 
      
 20 
     | 
    
         
            +
                # @param docstatus [NistBib::DocumentStatus, NilClass]
         
     | 
| 
      
 21 
     | 
    
         
            +
                # @param edition [String, NilClass]
         
     | 
| 
      
 22 
     | 
    
         
            +
                # @param version [RelatonBib::BibliographicItem::Version, NilClass]
         
     | 
| 
      
 23 
     | 
    
         
            +
                # @param biblionote [Array<RelatonBib::FormattedStrong>]
         
     | 
| 
      
 24 
     | 
    
         
            +
                # @param series [Array<RelatonBib::Series>]
         
     | 
| 
      
 25 
     | 
    
         
            +
                # @param medium [RelatonBib::Medium, NilClas]
         
     | 
| 
      
 26 
     | 
    
         
            +
                # @param place [Array<String>]
         
     | 
| 
      
 27 
     | 
    
         
            +
                # @param extent [Array<Relaton::BibItemLocality>]
         
     | 
| 
      
 28 
     | 
    
         
            +
                # @param accesslocation [Array<String>]
         
     | 
| 
      
 29 
     | 
    
         
            +
                # @param classification [RelatonBib::Classification, NilClass]
         
     | 
| 
      
 30 
     | 
    
         
            +
                # @param validity [RelatonBib:Validity, NilClass]
         
     | 
| 
      
 31 
     | 
    
         
            +
                # @param fetched [Date, NilClass] default nil
         
     | 
| 
      
 32 
     | 
    
         
            +
                # @param keyword [Array<NistBib::Keyword>]
         
     | 
| 
      
 33 
     | 
    
         
            +
                # @param commentperiod [NistBib::CommentPeriod]
         
     | 
| 
      
 34 
     | 
    
         
            +
                #
         
     | 
| 
      
 35 
     | 
    
         
            +
                # @param dates [Array<Hash>]
         
     | 
| 
      
 36 
     | 
    
         
            +
                # @option dates [String] :type
         
     | 
| 
      
 37 
     | 
    
         
            +
                # @option dates [String] :from
         
     | 
| 
      
 38 
     | 
    
         
            +
                # @option dates [String] :to
         
     | 
| 
      
 39 
     | 
    
         
            +
                #
         
     | 
| 
      
 40 
     | 
    
         
            +
                # @param contributors [Array<Hash>]
         
     | 
| 
      
 41 
     | 
    
         
            +
                # @option contributors [String] :type
         
     | 
| 
      
 42 
     | 
    
         
            +
                # @option contributors [String] :from
         
     | 
| 
      
 43 
     | 
    
         
            +
                # @option contributirs [String] :to
         
     | 
| 
      
 44 
     | 
    
         
            +
                # @option contributors [String] :abbreviation
         
     | 
| 
      
 45 
     | 
    
         
            +
                # @option contributors [Array<String>] :roles
         
     | 
| 
      
 46 
     | 
    
         
            +
                #
         
     | 
| 
      
 47 
     | 
    
         
            +
                # @param abstract [Array<Hash>]
         
     | 
| 
      
 48 
     | 
    
         
            +
                # @option abstract [String] :content
         
     | 
| 
      
 49 
     | 
    
         
            +
                # @option abstract [String] :language
         
     | 
| 
      
 50 
     | 
    
         
            +
                # @option abstract [String] :script
         
     | 
| 
      
 51 
     | 
    
         
            +
                # @option abstract [String] :type
         
     | 
| 
      
 52 
     | 
    
         
            +
                #
         
     | 
| 
      
 53 
     | 
    
         
            +
                # @param relations [Array<Hash>]
         
     | 
| 
      
 54 
     | 
    
         
            +
                # @option relations [String] :type
         
     | 
| 
      
 55 
     | 
    
         
            +
                # @option relations [RelatonBib::BibliographicItem] :bibitem
         
     | 
| 
      
 56 
     | 
    
         
            +
                # @option relations [Array<RelatonBib::BibItemLocality>] :bib_locality
         
     | 
| 
      
 57 
     | 
    
         
            +
                #
         
     | 
| 
      
 58 
     | 
    
         
            +
                # @param nistseries [Nist::NistSeries, NilClass]
         
     | 
| 
      
 59 
     | 
    
         
            +
                def initialize(**args)
         
     | 
| 
      
 60 
     | 
    
         
            +
                  @nistseries = args.delete :nistseries
         
     | 
| 
      
 61 
     | 
    
         
            +
                  @keyword = args.delete(:keyword) || []
         
     | 
| 
      
 62 
     | 
    
         
            +
                  @commentperiod = args.delete :commentperiod
         
     | 
| 
      
 63 
     | 
    
         
            +
                  super
         
     | 
| 
      
 64 
     | 
    
         
            +
                end
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                # @param builder [Nokogiri::XML::Builder]
         
     | 
| 
      
 67 
     | 
    
         
            +
                def to_xml(builder = nil)
         
     | 
| 
      
 68 
     | 
    
         
            +
                  super builder, root: :bibitem, date_format: :short do |b|
         
     | 
| 
      
 69 
     | 
    
         
            +
                    nistseries&.to_xml b
         
     | 
| 
      
 70 
     | 
    
         
            +
                    keyword.each { |kw| kw.to_xml b }
         
     | 
| 
      
 71 
     | 
    
         
            +
                    commentperiod&.to_xml b
         
     | 
| 
      
 72 
     | 
    
         
            +
                  end
         
     | 
| 
      
 73 
     | 
    
         
            +
                end
         
     | 
| 
      
 74 
     | 
    
         
            +
              end
         
     | 
| 
      
 75 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,16 +1,23 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require  
     | 
| 
       2 
     | 
    
         
            -
            require  
     | 
| 
      
 1 
     | 
    
         
            +
            require "relaton_bib"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require "nistbib/nist_bibliographic_item"
         
     | 
| 
      
 3 
     | 
    
         
            +
            require "nistbib/scrapper"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "nistbib/hit_collection"
         
     | 
| 
      
 5 
     | 
    
         
            +
            require "nistbib/nist_series"
         
     | 
| 
      
 6 
     | 
    
         
            +
            require "nistbib/xml_parser"
         
     | 
| 
      
 7 
     | 
    
         
            +
            require "nistbib/keyword"
         
     | 
| 
      
 8 
     | 
    
         
            +
            require "nistbib/comment_period"
         
     | 
| 
      
 9 
     | 
    
         
            +
            require "nistbib/document_status"
         
     | 
| 
       3 
10 
     | 
    
         | 
| 
       4 
11 
     | 
    
         
             
            module NistBib
         
     | 
| 
       5 
12 
     | 
    
         
             
              class NistBibliography
         
     | 
| 
       6 
13 
     | 
    
         
             
                class << self
         
     | 
| 
       7 
14 
     | 
    
         
             
                  # @param text [String]
         
     | 
| 
       8 
15 
     | 
    
         
             
                  # @return [NistBib::HitCollection]
         
     | 
| 
       9 
     | 
    
         
            -
                  def search(text, year = nil)
         
     | 
| 
       10 
     | 
    
         
            -
                    HitCollection.new text, year
         
     | 
| 
      
 16 
     | 
    
         
            +
                  def search(text, year = nil, opts = {})
         
     | 
| 
      
 17 
     | 
    
         
            +
                    HitCollection.new text, year, opts
         
     | 
| 
       11 
18 
     | 
    
         
             
                  rescue
         
     | 
| 
       12 
19 
     | 
    
         
             
                    warn "Could not access https://www.nist.gov"
         
     | 
| 
       13 
     | 
    
         
            -
                    [] 
     | 
| 
      
 20 
     | 
    
         
            +
                    []
         
     | 
| 
       14 
21 
     | 
    
         
             
                  end
         
     | 
| 
       15 
22 
     | 
    
         | 
| 
       16 
23 
     | 
    
         
             
                  # @param code [String] the NIST standard Code to look up (e..g "8200")
         
     | 
| 
         @@ -18,6 +25,19 @@ module NistBib 
     | 
|
| 
       18 
25 
     | 
    
         
             
                  # @param opts [Hash] options; restricted to :all_parts if all-parts reference is required
         
     | 
| 
       19 
26 
     | 
    
         
             
                  # @return [String] Relaton XML serialisation of reference
         
     | 
| 
       20 
27 
     | 
    
         
             
                  def get(code, year = nil, opts = {})
         
     | 
| 
      
 28 
     | 
    
         
            +
                    /^(?<code2>[^\(]+)\((?<date2>\w+\s(\d{2},\s)?\d{4})\)(\s\()?(?<stage>[^\)]+)?/ =~ code
         
     | 
| 
      
 29 
     | 
    
         
            +
                    if code2
         
     | 
| 
      
 30 
     | 
    
         
            +
                      code = code2.strip
         
     | 
| 
      
 31 
     | 
    
         
            +
                      if date2
         
     | 
| 
      
 32 
     | 
    
         
            +
                        if /\w+\s\d{4}/ =~ date2
         
     | 
| 
      
 33 
     | 
    
         
            +
                          opts[:issued_date] = Time.strptime date2, "%B %Y"
         
     | 
| 
      
 34 
     | 
    
         
            +
                        elsif /\w+\s\d{2},\s\d{4}/ =~ date2
         
     | 
| 
      
 35 
     | 
    
         
            +
                          opts[:updated_date] = Time.strptime date2, "%B %d, %Y"
         
     | 
| 
      
 36 
     | 
    
         
            +
                        end
         
     | 
| 
      
 37 
     | 
    
         
            +
                      end
         
     | 
| 
      
 38 
     | 
    
         
            +
                      opts[:stage] = stage if stage
         
     | 
| 
      
 39 
     | 
    
         
            +
                    end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
       21 
41 
     | 
    
         
             
                    if year.nil?
         
     | 
| 
       22 
42 
     | 
    
         
             
                      /^(?<code1>[^:]+):(?<year1>[^:]+)$/ =~ code
         
     | 
| 
       23 
43 
     | 
    
         
             
                      unless code1.nil?
         
     | 
| 
         @@ -26,36 +46,48 @@ module NistBib 
     | 
|
| 
       26 
46 
     | 
    
         
             
                      end
         
     | 
| 
       27 
47 
     | 
    
         
             
                    end
         
     | 
| 
       28 
48 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
                    code +=  
     | 
| 
      
 49 
     | 
    
         
            +
                    code += "-1" if opts[:all_parts]
         
     | 
| 
       30 
50 
     | 
    
         
             
                    ret = nistbib_get1(code, year, opts)
         
     | 
| 
       31 
     | 
    
         
            -
                    return nil if ret.nil?
         
     | 
| 
       32 
     | 
    
         
            -
                    ret.to_most_recent_reference unless year || opts[:keep_year]
         
     | 
| 
       33 
     | 
    
         
            -
                    ret.to_all_parts if opts[:all_parts]
         
     | 
| 
      
 51 
     | 
    
         
            +
                    # return nil if ret.nil?
         
     | 
| 
      
 52 
     | 
    
         
            +
                    # ret.to_most_recent_reference unless year || opts[:keep_year]
         
     | 
| 
      
 53 
     | 
    
         
            +
                    # ret.to_all_parts if opts[:all_parts]
         
     | 
| 
       34 
54 
     | 
    
         
             
                    ret
         
     | 
| 
       35 
55 
     | 
    
         
             
                  end
         
     | 
| 
       36 
56 
     | 
    
         | 
| 
       37 
57 
     | 
    
         
             
                  private
         
     | 
| 
       38 
58 
     | 
    
         | 
| 
       39 
59 
     | 
    
         
             
                  def nistbib_get1(code, year, opts)
         
     | 
| 
       40 
     | 
    
         
            -
                    result = nistbib_search_filter(code, year) or return nil
         
     | 
| 
       41 
     | 
    
         
            -
                    ret = nistbib_results_filter(result, year)
         
     | 
| 
      
 60 
     | 
    
         
            +
                    result = nistbib_search_filter(code, year, opts) or return nil
         
     | 
| 
      
 61 
     | 
    
         
            +
                    ret = nistbib_results_filter(result, year, opts)
         
     | 
| 
       42 
62 
     | 
    
         
             
                    return ret[:ret] if ret[:ret]
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
       43 
64 
     | 
    
         
             
                    fetch_ref_err(code, year, ret[:years])
         
     | 
| 
       44 
65 
     | 
    
         
             
                  end
         
     | 
| 
       45 
66 
     | 
    
         | 
| 
       46 
     | 
    
         
            -
                  # Sort through the results from  
     | 
| 
      
 67 
     | 
    
         
            +
                  # Sort through the results from NistBib, fetching them three at a time,
         
     | 
| 
       47 
68 
     | 
    
         
             
                  # and return the first result that matches the code,
         
     | 
| 
       48 
69 
     | 
    
         
             
                  # matches the year (if provided), and which # has a title (amendments do not).
         
     | 
| 
       49 
70 
     | 
    
         
             
                  # Only expects the first page of results to be populated.
         
     | 
| 
       50 
71 
     | 
    
         
             
                  # Does not match corrigenda etc (e.g. ISO 3166-1:2006/Cor 1:2007)
         
     | 
| 
       51 
72 
     | 
    
         
             
                  # If no match, returns any years which caused mismatch, for error reporting
         
     | 
| 
       52 
     | 
    
         
            -
                  def nistbib_results_filter(result, year)
         
     | 
| 
      
 73 
     | 
    
         
            +
                  def nistbib_results_filter(result, year, opts)
         
     | 
| 
       53 
74 
     | 
    
         
             
                    missed_years = []
         
     | 
| 
       54 
75 
     | 
    
         
             
                    result.each_slice(3) do |s| # ISO website only allows 3 connections
         
     | 
| 
       55 
     | 
    
         
            -
                      fetch_pages(s, 3).each_with_index do |r,  
     | 
| 
      
 76 
     | 
    
         
            +
                      fetch_pages(s, 3).each_with_index do |r, _i|
         
     | 
| 
      
 77 
     | 
    
         
            +
                        if opts[:issued_date]
         
     | 
| 
      
 78 
     | 
    
         
            +
                          r.dates.select { |d| d.type == "issued" }.each do |d|
         
     | 
| 
      
 79 
     | 
    
         
            +
                            return { ret: r } if opts[:issued_date] == d.on
         
     | 
| 
      
 80 
     | 
    
         
            +
                          end
         
     | 
| 
      
 81 
     | 
    
         
            +
                        elsif opts[:updated_date]
         
     | 
| 
      
 82 
     | 
    
         
            +
                          r.dates.select { |d| d.type == "published" }.each do |d|
         
     | 
| 
      
 83 
     | 
    
         
            +
                            return { ret: r } if opts[:updated_date] == d.on
         
     | 
| 
      
 84 
     | 
    
         
            +
                          end
         
     | 
| 
      
 85 
     | 
    
         
            +
                        end
         
     | 
| 
       56 
86 
     | 
    
         
             
                        return { ret: r } if !year
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
       57 
88 
     | 
    
         
             
                        r.dates.select { |d| d.type == "published" }.each do |d|
         
     | 
| 
       58 
89 
     | 
    
         
             
                          return { ret: r } if year.to_i == d.on.year
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
       59 
91 
     | 
    
         
             
                          missed_years << d.on.year
         
     | 
| 
       60 
92 
     | 
    
         
             
                        end
         
     | 
| 
       61 
93 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -71,16 +103,13 @@ module NistBib 
     | 
|
| 
       71 
103 
     | 
    
         
             
                    workers.result.sort { |x, y| x[:i] <=> y[:i] }.map { |x| x[:hit] }
         
     | 
| 
       72 
104 
     | 
    
         
             
                  end
         
     | 
| 
       73 
105 
     | 
    
         | 
| 
       74 
     | 
    
         
            -
                  def nistbib_search_filter(code, year)
         
     | 
| 
       75 
     | 
    
         
            -
                     
     | 
| 
       76 
     | 
    
         
            -
                     
     | 
| 
      
 106 
     | 
    
         
            +
                  def nistbib_search_filter(code, year, opts)
         
     | 
| 
      
 107 
     | 
    
         
            +
                    docid = code.match(%r{[0-9-]{3,}}).to_s
         
     | 
| 
      
 108 
     | 
    
         
            +
                    serie = code.match(%r{(FISP|SP|NISTIR)(?=\s)})
         
     | 
| 
       77 
109 
     | 
    
         
             
                    warn "fetching #{code}..."
         
     | 
| 
       78 
     | 
    
         
            -
                    result = search(code, year)
         
     | 
| 
      
 110 
     | 
    
         
            +
                    result = search(code, year, opts)
         
     | 
| 
       79 
111 
     | 
    
         
             
                    result.select do |i|
         
     | 
| 
       80 
     | 
    
         
            -
                       
     | 
| 
       81 
     | 
    
         
            -
                    #   i.hit[:code] &&
         
     | 
| 
       82 
     | 
    
         
            -
                    #     i.hit[:code].match(docidrx).to_s == code &&
         
     | 
| 
       83 
     | 
    
         
            -
                    #     corrigrx !~ i.hit[:code]
         
     | 
| 
      
 112 
     | 
    
         
            +
                      i.hit[:code]&.include?(docid) && (!serie || i.hit[:serie] == serie.to_s)
         
     | 
| 
       84 
113 
     | 
    
         
             
                    end
         
     | 
| 
       85 
114 
     | 
    
         
             
                  end
         
     | 
| 
       86 
115 
     | 
    
         | 
| 
         @@ -0,0 +1,35 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module NistBib
         
     | 
| 
      
 2 
     | 
    
         
            +
              class NistSeries
         
     | 
| 
      
 3 
     | 
    
         
            +
                ABBREVIATIONS = {
         
     | 
| 
      
 4 
     | 
    
         
            +
                  "NISTIR" => "NIST Interagency/Internal Report",
         
     | 
| 
      
 5 
     | 
    
         
            +
                  "NIST SP" => "NIST Special Publication",
         
     | 
| 
      
 6 
     | 
    
         
            +
                  "NIST FIPS" => "NIST Federal Information Processing Standards",
         
     | 
| 
      
 7 
     | 
    
         
            +
                }.freeze
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                # @return [String]
         
     | 
| 
      
 10 
     | 
    
         
            +
                attr_reader :type
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                # @return [String]
         
     | 
| 
      
 13 
     | 
    
         
            +
                attr_reader :title
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                # @return [RalatonBib::LocalizedString, NilClass]
         
     | 
| 
      
 16 
     | 
    
         
            +
                attr_reader :abbreviation
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                # @param abbreviation [RelatonBib::LocalizedString, NilClass]
         
     | 
| 
      
 19 
     | 
    
         
            +
                def initialize(abbreviation)
         
     | 
| 
      
 20 
     | 
    
         
            +
                  @type = "main"
         
     | 
| 
      
 21 
     | 
    
         
            +
                  @abbreviation = RelatonBib::LocalizedString.new(
         
     | 
| 
      
 22 
     | 
    
         
            +
                    abbreviation.downcase.gsub(" ", "-"), "en", "Latn"
         
     | 
| 
      
 23 
     | 
    
         
            +
                  )
         
     | 
| 
      
 24 
     | 
    
         
            +
                  @title = ABBREVIATIONS[abbreviation]
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                # @param builder [Nokogiri::XML::Builder]
         
     | 
| 
      
 28 
     | 
    
         
            +
                def to_xml(builder)
         
     | 
| 
      
 29 
     | 
    
         
            +
                  builder.series type: type do
         
     | 
| 
      
 30 
     | 
    
         
            +
                    builder.title title
         
     | 
| 
      
 31 
     | 
    
         
            +
                    builder.abbreviation { abbreviation.to_xml builder } if abbreviation
         
     | 
| 
      
 32 
     | 
    
         
            +
                  end
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/nistbib/scrapper.rb
    CHANGED
    
    | 
         @@ -1,9 +1,9 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require  
     | 
| 
      
 1 
     | 
    
         
            +
            require "relaton_bib"
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            module NistBib
         
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
      
 4 
     | 
    
         
            +
              class Scrapper
         
     | 
| 
       5 
5 
     | 
    
         
             
                class << self
         
     | 
| 
       6 
     | 
    
         
            -
                  DOMAIN =  
     | 
| 
      
 6 
     | 
    
         
            +
                  DOMAIN = "https://csrc.nist.gov".freeze
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                  # Parse page.
         
     | 
| 
       9 
9 
     | 
    
         
             
                  # @param hit_data [Hash]
         
     | 
| 
         @@ -12,22 +12,25 @@ module NistBib 
     | 
|
| 
       12 
12 
     | 
    
         
             
                  def parse_page(hit_data)
         
     | 
| 
       13 
13 
     | 
    
         
             
                    doc = get_page hit_data[:url]
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
                     
     | 
| 
       16 
     | 
    
         
            -
                       
     | 
| 
       17 
     | 
    
         
            -
                       
     | 
| 
       18 
     | 
    
         
            -
                       
     | 
| 
       19 
     | 
    
         
            -
                       
     | 
| 
       20 
     | 
    
         
            -
                       
     | 
| 
       21 
     | 
    
         
            -
                       
     | 
| 
       22 
     | 
    
         
            -
                       
     | 
| 
       23 
     | 
    
         
            -
                       
     | 
| 
       24 
     | 
    
         
            -
                       
     | 
| 
       25 
     | 
    
         
            -
                       
     | 
| 
       26 
     | 
    
         
            -
                       
     | 
| 
       27 
     | 
    
         
            -
                      abstract: 
     | 
| 
       28 
     | 
    
         
            -
                       
     | 
| 
       29 
     | 
    
         
            -
                       
     | 
| 
       30 
     | 
    
         
            -
                      relations: 
     | 
| 
      
 15 
     | 
    
         
            +
                    NistBibliographicItem.new(
         
     | 
| 
      
 16 
     | 
    
         
            +
                      fetched: Date.today.to_s,
         
     | 
| 
      
 17 
     | 
    
         
            +
                      type: "standard",
         
     | 
| 
      
 18 
     | 
    
         
            +
                      id: fetch_id(doc),
         
     | 
| 
      
 19 
     | 
    
         
            +
                      titles: fetch_titles(hit_data),
         
     | 
| 
      
 20 
     | 
    
         
            +
                      link: fetch_link(doc),
         
     | 
| 
      
 21 
     | 
    
         
            +
                      docid: fetch_docid(doc),
         
     | 
| 
      
 22 
     | 
    
         
            +
                      dates: fetch_dates(doc, hit_data[:release_date]),
         
     | 
| 
      
 23 
     | 
    
         
            +
                      contributors: fetch_contributors(doc),
         
     | 
| 
      
 24 
     | 
    
         
            +
                      edition: nil,
         
     | 
| 
      
 25 
     | 
    
         
            +
                      language: ["en"],
         
     | 
| 
      
 26 
     | 
    
         
            +
                      script: ["Latn"],
         
     | 
| 
      
 27 
     | 
    
         
            +
                      abstract: fetch_abstract(doc),
         
     | 
| 
      
 28 
     | 
    
         
            +
                      docstatus: fetch_status(doc, hit_data[:status]),
         
     | 
| 
      
 29 
     | 
    
         
            +
                      copyright: fetch_copyright(doc),
         
     | 
| 
      
 30 
     | 
    
         
            +
                      relations: fetch_relations(doc),
         
     | 
| 
      
 31 
     | 
    
         
            +
                      nistseries: fetch_nistseries(doc),
         
     | 
| 
      
 32 
     | 
    
         
            +
                      keyword: fetch_keywords(doc),
         
     | 
| 
      
 33 
     | 
    
         
            +
                      commentperiod: fetch_commentperiod(doc),
         
     | 
| 
       31 
34 
     | 
    
         
             
                    )
         
     | 
| 
       32 
35 
     | 
    
         
             
                  end
         
     | 
| 
       33 
36 
     | 
    
         | 
| 
         @@ -38,7 +41,7 @@ module NistBib 
     | 
|
| 
       38 
41 
     | 
    
         
             
                  # @return [Array<Nokogiri::HTML::Document, String>]
         
     | 
| 
       39 
42 
     | 
    
         
             
                  def get_page(url)
         
     | 
| 
       40 
43 
     | 
    
         
             
                    uri = URI url
         
     | 
| 
       41 
     | 
    
         
            -
                    resp = Net::HTTP.get_response(uri) 
     | 
| 
      
 44 
     | 
    
         
            +
                    resp = Net::HTTP.get_response(uri) # .encode("UTF-8")
         
     | 
| 
       42 
45 
     | 
    
         
             
                    Nokogiri::HTML(resp.body)
         
     | 
| 
       43 
46 
     | 
    
         
             
                  end
         
     | 
| 
       44 
47 
     | 
    
         | 
| 
         @@ -46,88 +49,127 @@ module NistBib 
     | 
|
| 
       46 
49 
     | 
    
         
             
                  # @param doc [Nokogiri::HTML::Document]
         
     | 
| 
       47 
50 
     | 
    
         
             
                  # @return [Hash]
         
     | 
| 
       48 
51 
     | 
    
         
             
                  def fetch_docid(doc)
         
     | 
| 
       49 
     | 
    
         
            -
                    item_ref = doc.at("//div[contains(@class, 'publications-detail')]/h3"). 
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
                     
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
      
 52 
     | 
    
         
            +
                    item_ref = doc.at("//div[contains(@class, 'publications-detail')]/h3").
         
     | 
| 
      
 53 
     | 
    
         
            +
                      text.strip
         
     | 
| 
      
 54 
     | 
    
         
            +
                    return [RelatonBib::DocumentIdentifier.new(type: "nist", id: "?")] unless item_ref
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                    [RelatonBib::DocumentIdentifier.new(id: item_ref, type: "nist")]
         
     | 
| 
      
 57 
     | 
    
         
            +
                  end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                  # Fetch id.
         
     | 
| 
      
 60 
     | 
    
         
            +
                  # @param doc [Nokogiri::HTML::Document]
         
     | 
| 
      
 61 
     | 
    
         
            +
                  # @return [String]
         
     | 
| 
      
 62 
     | 
    
         
            +
                  def fetch_id(doc)
         
     | 
| 
      
 63 
     | 
    
         
            +
                    doc.at("//div[contains(@class, 'publications-detail')]/h3").text.
         
     | 
| 
      
 64 
     | 
    
         
            +
                      strip.gsub(/\s/, "")
         
     | 
| 
       62 
65 
     | 
    
         
             
                  end
         
     | 
| 
       63 
66 
     | 
    
         | 
| 
       64 
67 
     | 
    
         
             
                  # Fetch status.
         
     | 
| 
       65 
68 
     | 
    
         
             
                  # @param doc [Nokogiri::HTML::Document]
         
     | 
| 
       66 
69 
     | 
    
         
             
                  # @param status [String]
         
     | 
| 
       67 
70 
     | 
    
         
             
                  # @return [Hash]
         
     | 
| 
       68 
     | 
    
         
            -
                  def fetch_status(doc)
         
     | 
| 
       69 
     | 
    
         
            -
                     
     | 
| 
       70 
     | 
    
         
            -
                     
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
                     
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
      
 71 
     | 
    
         
            +
                  def fetch_status(doc, status)
         
     | 
| 
      
 72 
     | 
    
         
            +
                    case status
         
     | 
| 
      
 73 
     | 
    
         
            +
                    when "draft (withdrawn)"
         
     | 
| 
      
 74 
     | 
    
         
            +
                      stage = "draft-public"
         
     | 
| 
      
 75 
     | 
    
         
            +
                      substage = "withdrawn"
         
     | 
| 
      
 76 
     | 
    
         
            +
                    when "retired draft"
         
     | 
| 
      
 77 
     | 
    
         
            +
                      stage = "draft-public"
         
     | 
| 
      
 78 
     | 
    
         
            +
                      substage = "retired"
         
     | 
| 
      
 79 
     | 
    
         
            +
                    when "withdrawn"
         
     | 
| 
      
 80 
     | 
    
         
            +
                      stage = "final"
         
     | 
| 
      
 81 
     | 
    
         
            +
                      substage = "withdrawn"
         
     | 
| 
      
 82 
     | 
    
         
            +
                    when "draft"
         
     | 
| 
      
 83 
     | 
    
         
            +
                      stage = "draft-public"
         
     | 
| 
      
 84 
     | 
    
         
            +
                      substage = "active"
         
     | 
| 
       79 
85 
     | 
    
         
             
                    else
         
     | 
| 
       80 
     | 
    
         
            -
                       
     | 
| 
      
 86 
     | 
    
         
            +
                      stage = status
         
     | 
| 
      
 87 
     | 
    
         
            +
                      substage = "active"
         
     | 
| 
       81 
88 
     | 
    
         
             
                    end
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
                    # if doc.at "//p/strong[text()='Withdrawn:']"
         
     | 
| 
      
 91 
     | 
    
         
            +
                    #   substage = "withdrawn"
         
     | 
| 
      
 92 
     | 
    
         
            +
                    # else
         
     | 
| 
      
 93 
     | 
    
         
            +
                    #   substage = "active"
         
     | 
| 
      
 94 
     | 
    
         
            +
                    #   item_ref = doc.at(
         
     | 
| 
      
 95 
     | 
    
         
            +
                    #     "//div[contains(@class, 'publications-detail')]/h3",
         
     | 
| 
      
 96 
     | 
    
         
            +
                    #   ).text.strip
         
     | 
| 
      
 97 
     | 
    
         
            +
                    #   wip = item_ref.match(/(?<=\()\w+/).to_s
         
     | 
| 
      
 98 
     | 
    
         
            +
                    #   stage = "draft-public" if wip == "DRAFT"
         
     | 
| 
      
 99 
     | 
    
         
            +
                    # end
         
     | 
| 
      
 100 
     | 
    
         
            +
                    NistBib::DocumentStatus.new(stage: stage, substage: substage)
         
     | 
| 
       82 
101 
     | 
    
         
             
                  end
         
     | 
| 
       83 
102 
     | 
    
         | 
| 
       84 
103 
     | 
    
         
             
                  # Fetch titles.
         
     | 
| 
       85 
104 
     | 
    
         
             
                  # @param hit_data [Hash]
         
     | 
| 
       86 
105 
     | 
    
         
             
                  # @return [Array<Hash>]
         
     | 
| 
       87 
106 
     | 
    
         
             
                  def fetch_titles(hit_data)
         
     | 
| 
       88 
     | 
    
         
            -
                     
     | 
| 
       89 
     | 
    
         
            -
                    # case titles.size
         
     | 
| 
       90 
     | 
    
         
            -
                    # when 0
         
     | 
| 
       91 
     | 
    
         
            -
                    #   intro, main, part = nil, "", nil
         
     | 
| 
       92 
     | 
    
         
            -
                    # when 1
         
     | 
| 
       93 
     | 
    
         
            -
                      intro, main, part = nil, titles[0], nil
         
     | 
| 
       94 
     | 
    
         
            -
                    # when 2
         
     | 
| 
       95 
     | 
    
         
            -
                    #   if /^(Part|Partie) \d+:/ =~ titles[1]
         
     | 
| 
       96 
     | 
    
         
            -
                    #     intro, main, part = nil, titles[0], titles[1]
         
     | 
| 
       97 
     | 
    
         
            -
                    #   else
         
     | 
| 
       98 
     | 
    
         
            -
                    #     intro, main, part = titles[0], titles[1], nil
         
     | 
| 
       99 
     | 
    
         
            -
                    #   end
         
     | 
| 
       100 
     | 
    
         
            -
                    # when 3
         
     | 
| 
       101 
     | 
    
         
            -
                    #   intro, main, part = titles[0], titles[1], titles[2]
         
     | 
| 
       102 
     | 
    
         
            -
                    # else
         
     | 
| 
       103 
     | 
    
         
            -
                    #   intro, main, part = titles[0], titles[1], titles[2..-1]&.join(" -- ")
         
     | 
| 
       104 
     | 
    
         
            -
                    # end
         
     | 
| 
       105 
     | 
    
         
            -
                    [{
         
     | 
| 
       106 
     | 
    
         
            -
                      title_intro: intro,
         
     | 
| 
       107 
     | 
    
         
            -
                      title_main:  main,
         
     | 
| 
       108 
     | 
    
         
            -
                      title_part:  part,
         
     | 
| 
       109 
     | 
    
         
            -
                      language:    'en',
         
     | 
| 
       110 
     | 
    
         
            -
                      script:      'Latn'
         
     | 
| 
       111 
     | 
    
         
            -
                    }]
         
     | 
| 
      
 107 
     | 
    
         
            +
                    [{ content: hit_data[:title], language: "en", script: "Latn", format: "text/plain" }]
         
     | 
| 
       112 
108 
     | 
    
         
             
                  end
         
     | 
| 
       113 
109 
     | 
    
         | 
| 
       114 
110 
     | 
    
         
             
                  # Fetch dates
         
     | 
| 
       115 
111 
     | 
    
         
             
                  # @param doc [Nokogiri::HTML::Document]
         
     | 
| 
       116 
112 
     | 
    
         
             
                  # @return [Array<Hash>]
         
     | 
| 
       117 
     | 
    
         
            -
                  def fetch_dates(doc)
         
     | 
| 
       118 
     | 
    
         
            -
                    dates = []
         
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
       120 
     | 
    
         
            -
                     
     | 
| 
       121 
     | 
    
         
            -
                     
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
      
 113 
     | 
    
         
            +
                  def fetch_dates(doc, release_date)
         
     | 
| 
      
 114 
     | 
    
         
            +
                    dates = [{ type: "published", on: release_date.to_s }]
         
     | 
| 
      
 115 
     | 
    
         
            +
             
     | 
| 
      
 116 
     | 
    
         
            +
                    d = doc.at("//span[@id='pub-release-date']").text.strip
         
     | 
| 
      
 117 
     | 
    
         
            +
                    date = if /(?<date>\w+\s\d{4})/ =~ d
         
     | 
| 
      
 118 
     | 
    
         
            +
                             Date.strptime(date, "%B %Y")
         
     | 
| 
      
 119 
     | 
    
         
            +
                           elsif /(?<date>\w+\s\d{2},\s\d{4})/ =~ d
         
     | 
| 
      
 120 
     | 
    
         
            +
                             Date.strptime(date, "%B %d, %Y")
         
     | 
| 
      
 121 
     | 
    
         
            +
                           end
         
     | 
| 
      
 122 
     | 
    
         
            +
                    dates << { type: "issued", on: date.to_s }
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
       124 
124 
     | 
    
         
             
                    dates
         
     | 
| 
       125 
125 
     | 
    
         
             
                  end
         
     | 
| 
       126 
126 
     | 
    
         | 
| 
       127 
     | 
    
         
            -
                  def fetch_contributors
         
     | 
| 
       128 
     | 
    
         
            -
                    name =  
     | 
| 
       129 
     | 
    
         
            -
                     
     | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
      
 127 
     | 
    
         
            +
                  def fetch_contributors(doc)
         
     | 
| 
      
 128 
     | 
    
         
            +
                    name = "National Institute of Standards and Technology"
         
     | 
| 
      
 129 
     | 
    
         
            +
                    org = RelatonBib::Organization.new(
         
     | 
| 
      
 130 
     | 
    
         
            +
                      name: name, url: "www.nist.gov", abbreviation: "NIST",
         
     | 
| 
      
 131 
     | 
    
         
            +
                    )
         
     | 
| 
      
 132 
     | 
    
         
            +
                    contribs = [
         
     | 
| 
      
 133 
     | 
    
         
            +
                      RelatonBib::ContributionInfo.new(entity: org, role: ["publisher"]),
         
     | 
| 
      
 134 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 135 
     | 
    
         
            +
             
     | 
| 
      
 136 
     | 
    
         
            +
                    authors = doc.at('//h4[.="Author(s)"]/following-sibling::p')
         
     | 
| 
      
 137 
     | 
    
         
            +
                    contribs += contributors(authors, "author")
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
                    editors = doc.at('//h4[.="Editor(s)"]/following-sibling::p')
         
     | 
| 
      
 140 
     | 
    
         
            +
                    contribs + contributors(editors, "editor")
         
     | 
| 
      
 141 
     | 
    
         
            +
                  end
         
     | 
| 
      
 142 
     | 
    
         
            +
             
     | 
| 
      
 143 
     | 
    
         
            +
                  def contributors(doc, role)
         
     | 
| 
      
 144 
     | 
    
         
            +
                    return [] if doc.nil?
         
     | 
| 
      
 145 
     | 
    
         
            +
             
     | 
| 
      
 146 
     | 
    
         
            +
                    doc.text.split(", ").map do |contr|
         
     | 
| 
      
 147 
     | 
    
         
            +
                      /(?<an>.+?)(\s+\((?<abbrev>.+?)\))?$/ =~ contr
         
     | 
| 
      
 148 
     | 
    
         
            +
                      if abbrev && an.downcase !~ /(task|force|group)/ && an.split.size.between?(2, 3)
         
     | 
| 
      
 149 
     | 
    
         
            +
                        fullname = RelatonBib::FullName.new(
         
     | 
| 
      
 150 
     | 
    
         
            +
                          completename: RelatonBib::LocalizedString.new(an, "en", "Latn"),
         
     | 
| 
      
 151 
     | 
    
         
            +
                        )
         
     | 
| 
      
 152 
     | 
    
         
            +
                        case abbrev
         
     | 
| 
      
 153 
     | 
    
         
            +
                        when "NIST"
         
     | 
| 
      
 154 
     | 
    
         
            +
                          org_name = "National Institute of Standards and Technology"
         
     | 
| 
      
 155 
     | 
    
         
            +
                          url = "www.nist.gov"
         
     | 
| 
      
 156 
     | 
    
         
            +
                        when "MITRE"
         
     | 
| 
      
 157 
     | 
    
         
            +
                          org_name = abbrev
         
     | 
| 
      
 158 
     | 
    
         
            +
                          url = "www.mitre.org"
         
     | 
| 
      
 159 
     | 
    
         
            +
                        else
         
     | 
| 
      
 160 
     | 
    
         
            +
                          org_name = abbrev
         
     | 
| 
      
 161 
     | 
    
         
            +
                          url = nil
         
     | 
| 
      
 162 
     | 
    
         
            +
                        end
         
     | 
| 
      
 163 
     | 
    
         
            +
                        org = RelatonBib::Organization.new name: org_name, url: url, abbreviation: abbrev
         
     | 
| 
      
 164 
     | 
    
         
            +
                        affiliation = RelatonBib::Affilation.new org
         
     | 
| 
      
 165 
     | 
    
         
            +
                        entity = RelatonBib::Person.new(
         
     | 
| 
      
 166 
     | 
    
         
            +
                          name: fullname, affiliation: [affiliation], contacts: [],
         
     | 
| 
      
 167 
     | 
    
         
            +
                        )
         
     | 
| 
      
 168 
     | 
    
         
            +
                      else
         
     | 
| 
      
 169 
     | 
    
         
            +
                        entity = RelatonBib::Organization.new name: an, abbreviation: abbrev
         
     | 
| 
      
 170 
     | 
    
         
            +
                      end
         
     | 
| 
      
 171 
     | 
    
         
            +
                      RelatonBib::ContributionInfo.new entity: entity, role: [role]
         
     | 
| 
      
 172 
     | 
    
         
            +
                    end
         
     | 
| 
       131 
173 
     | 
    
         
             
                  end
         
     | 
| 
       132 
174 
     | 
    
         | 
| 
       133 
175 
     | 
    
         
             
                  # Fetch abstracts.
         
     | 
| 
         @@ -136,9 +178,10 @@ module NistBib 
     | 
|
| 
       136 
178 
     | 
    
         
             
                  def fetch_abstract(doc)
         
     | 
| 
       137 
179 
     | 
    
         
             
                    abstract_content = doc.xpath('//div[contains(@class, "pub-abstract-callout")]/div[1]/p').text
         
     | 
| 
       138 
180 
     | 
    
         
             
                    [{
         
     | 
| 
       139 
     | 
    
         
            -
                      content: 
     | 
| 
       140 
     | 
    
         
            -
                      language:  
     | 
| 
       141 
     | 
    
         
            -
                      script: 
     | 
| 
      
 181 
     | 
    
         
            +
                      content: abstract_content,
         
     | 
| 
      
 182 
     | 
    
         
            +
                      language: "en",
         
     | 
| 
      
 183 
     | 
    
         
            +
                      script: "Latn",
         
     | 
| 
      
 184 
     | 
    
         
            +
                      format: "text/plain",
         
     | 
| 
       142 
185 
     | 
    
         
             
                    }]
         
     | 
| 
       143 
186 
     | 
    
         
             
                  end
         
     | 
| 
       144 
187 
     | 
    
         | 
| 
         @@ -146,39 +189,83 @@ module NistBib 
     | 
|
| 
       146 
189 
     | 
    
         
             
                  # @param title [String]
         
     | 
| 
       147 
190 
     | 
    
         
             
                  # @return [Hash]
         
     | 
| 
       148 
191 
     | 
    
         
             
                  def fetch_copyright(doc)
         
     | 
| 
       149 
     | 
    
         
            -
                    name =  
     | 
| 
       150 
     | 
    
         
            -
                    url =  
     | 
| 
       151 
     | 
    
         
            -
                    d = doc.at("// 
     | 
| 
       152 
     | 
    
         
            -
                    from = d.match(/\d{4} 
     | 
| 
       153 
     | 
    
         
            -
                    { owner: { name: name, abbreviation:  
     | 
| 
      
 192 
     | 
    
         
            +
                    name = "National Institute of Standards and Technology"
         
     | 
| 
      
 193 
     | 
    
         
            +
                    url = "www.nist.gov"
         
     | 
| 
      
 194 
     | 
    
         
            +
                    d = doc.at("//span[@id='pub-release-date']").text.strip
         
     | 
| 
      
 195 
     | 
    
         
            +
                    from = d.match(/\d{4}/).to_s
         
     | 
| 
      
 196 
     | 
    
         
            +
                    { owner: { name: name, abbreviation: "NIST", url: url }, from: from }
         
     | 
| 
       154 
197 
     | 
    
         
             
                  end
         
     | 
| 
       155 
198 
     | 
    
         | 
| 
       156 
199 
     | 
    
         
             
                  # Fetch links.
         
     | 
| 
       157 
200 
     | 
    
         
             
                  # @param doc [Nokogiri::HTML::Document]
         
     | 
| 
       158 
     | 
    
         
            -
                  # @param url [String]
         
     | 
| 
       159 
201 
     | 
    
         
             
                  # @return [Array<Hash>]
         
     | 
| 
       160 
     | 
    
         
            -
                  def fetch_link(doc 
     | 
| 
       161 
     | 
    
         
            -
                     
     | 
| 
       162 
     | 
    
         
            -
                     
     | 
| 
       163 
     | 
    
         
            -
                     
     | 
| 
      
 202 
     | 
    
         
            +
                  def fetch_link(doc)
         
     | 
| 
      
 203 
     | 
    
         
            +
                    pub = doc.at "//p/strong[.='Publication:']"
         
     | 
| 
      
 204 
     | 
    
         
            +
                    links = []
         
     | 
| 
      
 205 
     | 
    
         
            +
                    pdf = pub.at "./following-sibling::a[.=' Local Download']"
         
     | 
| 
      
 206 
     | 
    
         
            +
                    links << { type: "pdf", content: pdf[:href] } if pdf
         
     | 
| 
      
 207 
     | 
    
         
            +
                    doi = pub.at("./following-sibling::a[contains(.,'(DOI)')]")
         
     | 
| 
      
 208 
     | 
    
         
            +
                    links << { type: "doi", content: doi[:href] } if doi
         
     | 
| 
       164 
209 
     | 
    
         
             
                    links
         
     | 
| 
       165 
210 
     | 
    
         
             
                  end
         
     | 
| 
       166 
211 
     | 
    
         | 
| 
       167 
212 
     | 
    
         
             
                  # Fetch relations.
         
     | 
| 
       168 
213 
     | 
    
         
             
                  # @param doc [Nokogiri::HTML::Document]
         
     | 
| 
       169 
214 
     | 
    
         
             
                  # @return [Array<Hash>]
         
     | 
| 
       170 
     | 
    
         
            -
                  # rubocop:disable Metrics/MethodLength
         
     | 
| 
       171 
215 
     | 
    
         
             
                  def fetch_relations(doc)
         
     | 
| 
       172 
     | 
    
         
            -
                    relations = doc.xpath('// 
     | 
| 
       173 
     | 
    
         
            -
                       
     | 
| 
      
 216 
     | 
    
         
            +
                    relations = doc.xpath('//span[@id="pub-supersedes-container"]/a').map do |r|
         
     | 
| 
      
 217 
     | 
    
         
            +
                      doc_relation "supersedes", r
         
     | 
| 
       174 
218 
     | 
    
         
             
                    end
         
     | 
| 
       175 
219 
     | 
    
         | 
| 
       176 
     | 
    
         
            -
                    doc.xpath('// 
     | 
| 
       177 
     | 
    
         
            -
                       
     | 
| 
      
 220 
     | 
    
         
            +
                    relations += doc.xpath('//span[@id="pub-part-container"]/a').map do |r|
         
     | 
| 
      
 221 
     | 
    
         
            +
                      doc_relation "partOf", r
         
     | 
| 
      
 222 
     | 
    
         
            +
                    end
         
     | 
| 
      
 223 
     | 
    
         
            +
             
     | 
| 
      
 224 
     | 
    
         
            +
                    relations + doc.xpath('//span[@id="pub-related-container"]/a').map do |r|
         
     | 
| 
      
 225 
     | 
    
         
            +
                      doc_relation "updates", r
         
     | 
| 
      
 226 
     | 
    
         
            +
                    end
         
     | 
| 
      
 227 
     | 
    
         
            +
                  end
         
     | 
| 
      
 228 
     | 
    
         
            +
             
     | 
| 
      
 229 
     | 
    
         
            +
                  def doc_relation(type, ref)
         
     | 
| 
      
 230 
     | 
    
         
            +
                    RelatonBib::DocumentRelation.new(
         
     | 
| 
      
 231 
     | 
    
         
            +
                      type: type,
         
     | 
| 
      
 232 
     | 
    
         
            +
                      bibitem: RelatonBib::BibliographicItem.new(
         
     | 
| 
      
 233 
     | 
    
         
            +
                        formattedref: RelatonBib::FormattedRef.new(
         
     | 
| 
      
 234 
     | 
    
         
            +
                          content: ref.text, language: "en", script: "Latn", format: "text/plain",
         
     | 
| 
      
 235 
     | 
    
         
            +
                        ),
         
     | 
| 
      
 236 
     | 
    
         
            +
                        link: [RelatonBib::TypedUri.new(type: "src", content: DOMAIN + ref[:href])],
         
     | 
| 
      
 237 
     | 
    
         
            +
                      ),
         
     | 
| 
      
 238 
     | 
    
         
            +
                    )
         
     | 
| 
      
 239 
     | 
    
         
            +
                  end
         
     | 
| 
      
 240 
     | 
    
         
            +
             
     | 
| 
      
 241 
     | 
    
         
            +
                  def fetch_nistseries(doc)
         
     | 
| 
      
 242 
     | 
    
         
            +
                    doc.xpath("//p/strong[.='Document History:']/following-sibling::*[not(self::br)]").each do |s|
         
     | 
| 
      
 243 
     | 
    
         
            +
                      NistSeries::ABBREVIATIONS.each do |k, _v|
         
     | 
| 
      
 244 
     | 
    
         
            +
                        return NistSeries.new k if s.text.include? k
         
     | 
| 
      
 245 
     | 
    
         
            +
                      end
         
     | 
| 
       178 
246 
     | 
    
         
             
                    end
         
     | 
| 
      
 247 
     | 
    
         
            +
                    nil
         
     | 
| 
      
 248 
     | 
    
         
            +
                  end
         
     | 
| 
      
 249 
     | 
    
         
            +
             
     | 
| 
      
 250 
     | 
    
         
            +
                  def fetch_keywords(doc)
         
     | 
| 
      
 251 
     | 
    
         
            +
                    kws = doc.xpath "//span[@id='pub-keywords-container']/span"
         
     | 
| 
      
 252 
     | 
    
         
            +
                    kws.map { |kw| Keyword.new kw.text }
         
     | 
| 
      
 253 
     | 
    
         
            +
                  end
         
     | 
| 
      
 254 
     | 
    
         
            +
             
     | 
| 
      
 255 
     | 
    
         
            +
                  def fetch_commentperiod(doc)
         
     | 
| 
      
 256 
     | 
    
         
            +
                    cp = doc.at "//span[@id='pub-comments-due']"
         
     | 
| 
      
 257 
     | 
    
         
            +
                    return unless cp
         
     | 
| 
      
 258 
     | 
    
         
            +
             
     | 
| 
      
 259 
     | 
    
         
            +
                    to = Date.strptime cp.text.strip, "%B %d, %Y"
         
     | 
| 
      
 260 
     | 
    
         
            +
             
     | 
| 
      
 261 
     | 
    
         
            +
                    d = doc.at("//span[@id='pub-release-date']").text.strip
         
     | 
| 
      
 262 
     | 
    
         
            +
                    from = Date.strptime(d, "%B %Y").to_s
         
     | 
| 
       179 
263 
     | 
    
         | 
| 
       180 
     | 
    
         
            -
                     
     | 
| 
      
 264 
     | 
    
         
            +
                    ex = doc.at "//strong[contains(.,'The comment closing date has been extended to')]"
         
     | 
| 
      
 265 
     | 
    
         
            +
                    ext = ex&.text&.match(/\w+\s\d{2},\s\d{4}/).to_s
         
     | 
| 
      
 266 
     | 
    
         
            +
                    extended = ext.empty? ? nil : Date.strptime(ext, "%B %d, %Y")
         
     | 
| 
      
 267 
     | 
    
         
            +
                    CommentPeriod.new from, to, extended
         
     | 
| 
       181 
268 
     | 
    
         
             
                  end
         
     | 
| 
       182 
269 
     | 
    
         
             
                end
         
     | 
| 
       183 
270 
     | 
    
         
             
              end
         
     | 
| 
       184 
     | 
    
         
            -
            end
         
     | 
| 
      
 271 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/nistbib/version.rb
    CHANGED
    
    
| 
         @@ -0,0 +1,53 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module NistBib
         
     | 
| 
      
 2 
     | 
    
         
            +
              class XMLParser < RelatonBib::XMLParser
         
     | 
| 
      
 3 
     | 
    
         
            +
                class << self
         
     | 
| 
      
 4 
     | 
    
         
            +
                  def from_xml(xml)
         
     | 
| 
      
 5 
     | 
    
         
            +
                    doc = Nokogiri::XML xml
         
     | 
| 
      
 6 
     | 
    
         
            +
                    nistitem = doc.at("/bibitem") || doc.at("/bibdata")
         
     | 
| 
      
 7 
     | 
    
         
            +
                    NistBibliographicItem.new(item_data(nistitem))
         
     | 
| 
      
 8 
     | 
    
         
            +
                  end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                  private
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  def item_data(nistitem)
         
     | 
| 
      
 13 
     | 
    
         
            +
                    data = super
         
     | 
| 
      
 14 
     | 
    
         
            +
                    data.delete :series
         
     | 
| 
      
 15 
     | 
    
         
            +
                    data[:nistseries] = fetch_nistseries(nistitem)
         
     | 
| 
      
 16 
     | 
    
         
            +
                    data[:keyword] = fetch_keyword(nistitem)
         
     | 
| 
      
 17 
     | 
    
         
            +
                    data[:commentperiod] = fetch_commentperiod(nistitem)
         
     | 
| 
      
 18 
     | 
    
         
            +
                    data
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                  def fetch_status(item)
         
     | 
| 
      
 22 
     | 
    
         
            +
                    status = item.at "./status"
         
     | 
| 
      
 23 
     | 
    
         
            +
                    return unless status
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                    DocumentStatus.new(
         
     | 
| 
      
 26 
     | 
    
         
            +
                      stage: status.at("stage")&.text,
         
     | 
| 
      
 27 
     | 
    
         
            +
                      substage: status.at("substage")&.text,
         
     | 
| 
      
 28 
     | 
    
         
            +
                      iteration: status.at("iteraton")&.text,
         
     | 
| 
      
 29 
     | 
    
         
            +
                    )
         
     | 
| 
      
 30 
     | 
    
         
            +
                  end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                  def fetch_commentperiod(item)
         
     | 
| 
      
 33 
     | 
    
         
            +
                    cp = item.at "./commentperiod"
         
     | 
| 
      
 34 
     | 
    
         
            +
                    return unless cp
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                    CommentPeriod.new cp.at("from").text, cp.at("to")&.text, cp.at("extended")&.text
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                  def fetch_keyword(item)
         
     | 
| 
      
 40 
     | 
    
         
            +
                    item.xpath("./keyword").map do |kw|
         
     | 
| 
      
 41 
     | 
    
         
            +
                      Keyword.new kw.children.first.to_xml
         
     | 
| 
      
 42 
     | 
    
         
            +
                    end
         
     | 
| 
      
 43 
     | 
    
         
            +
                  end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                  def fetch_nistseries(item)
         
     | 
| 
      
 46 
     | 
    
         
            +
                    series = item.at "./series"
         
     | 
| 
      
 47 
     | 
    
         
            +
                    return unless series
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                    NistSeries.new series.at("./abbreviation").text.upcase.gsub("-", " ")
         
     | 
| 
      
 50 
     | 
    
         
            +
                  end
         
     | 
| 
      
 51 
     | 
    
         
            +
                end
         
     | 
| 
      
 52 
     | 
    
         
            +
              end
         
     | 
| 
      
 53 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/relaton/processor.rb
    CHANGED
    
    
    
        data/nistbib.gemspec
    CHANGED
    
    | 
         @@ -1,4 +1,3 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
1 
     | 
    
         
             
            lib = File.expand_path("../lib", __FILE__)
         
     | 
| 
       3 
2 
     | 
    
         
             
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         
     | 
| 
       4 
3 
     | 
    
         
             
            require "nistbib/version"
         
     | 
| 
         @@ -9,14 +8,14 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       9 
8 
     | 
    
         
             
              spec.authors       = ["Ribose Inc."]
         
     | 
| 
       10 
9 
     | 
    
         
             
              spec.email         = ["open.source@ribose.com"]
         
     | 
| 
       11 
10 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
              spec.summary       =  
     | 
| 
       13 
     | 
    
         
            -
              spec.description   =  
     | 
| 
      
 11 
     | 
    
         
            +
              spec.summary       = "NistBib: retrive NIST standards."
         
     | 
| 
      
 12 
     | 
    
         
            +
              spec.description   = "NistBib: retrive NIST standards."
         
     | 
| 
       14 
13 
     | 
    
         
             
              spec.homepage      = "https://github.com/metanorma/nistbib"
         
     | 
| 
       15 
14 
     | 
    
         
             
              spec.license       = "MIT"
         
     | 
| 
       16 
15 
     | 
    
         | 
| 
       17 
16 
     | 
    
         
             
              # Specify which files should be added to the gem when it is released.
         
     | 
| 
       18 
17 
     | 
    
         
             
              # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
         
     | 
| 
       19 
     | 
    
         
            -
              spec.files         = Dir.chdir(File.expand_path( 
     | 
| 
      
 18 
     | 
    
         
            +
              spec.files         = Dir.chdir(File.expand_path( __dir__)) do
         
     | 
| 
       20 
19 
     | 
    
         
             
                `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
         
     | 
| 
       21 
20 
     | 
    
         
             
              end
         
     | 
| 
       22 
21 
     | 
    
         
             
              spec.bindir        = "exe"
         
     | 
| 
         @@ -24,16 +23,16 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       24 
23 
     | 
    
         
             
              spec.require_paths = ["lib"]
         
     | 
| 
       25 
24 
     | 
    
         | 
| 
       26 
25 
     | 
    
         
             
              spec.add_development_dependency "bundler", "~> 2.0"
         
     | 
| 
       27 
     | 
    
         
            -
              spec.add_development_dependency 'equivalent-xml', '~> 0.6'
         
     | 
| 
       28 
     | 
    
         
            -
              spec.add_development_dependency "pry-byebug"
         
     | 
| 
       29 
26 
     | 
    
         
             
              spec.add_development_dependency "byebug"
         
     | 
| 
      
 27 
     | 
    
         
            +
              spec.add_development_dependency "debase"
         
     | 
| 
      
 28 
     | 
    
         
            +
              spec.add_development_dependency "equivalent-xml", "~> 0.6"
         
     | 
| 
      
 29 
     | 
    
         
            +
              spec.add_development_dependency "pry-byebug"
         
     | 
| 
       30 
30 
     | 
    
         
             
              spec.add_development_dependency "rake", "~> 10.0"
         
     | 
| 
       31 
31 
     | 
    
         
             
              spec.add_development_dependency "rspec", "~> 3.0"
         
     | 
| 
       32 
     | 
    
         
            -
              spec.add_development_dependency  
     | 
| 
       33 
     | 
    
         
            -
              spec.add_development_dependency  
     | 
| 
       34 
     | 
    
         
            -
              spec.add_development_dependency  
     | 
| 
       35 
     | 
    
         
            -
              spec.add_development_dependency  
     | 
| 
       36 
     | 
    
         
            -
              spec.add_development_dependency 'debase'
         
     | 
| 
      
 32 
     | 
    
         
            +
              spec.add_development_dependency "ruby-debug-ide"
         
     | 
| 
      
 33 
     | 
    
         
            +
              spec.add_development_dependency "simplecov"
         
     | 
| 
      
 34 
     | 
    
         
            +
              spec.add_development_dependency "vcr"
         
     | 
| 
      
 35 
     | 
    
         
            +
              spec.add_development_dependency "webmock"
         
     | 
| 
       37 
36 
     | 
    
         | 
| 
       38 
     | 
    
         
            -
              spec.add_dependency  
     | 
| 
      
 37 
     | 
    
         
            +
              spec.add_dependency "relaton-bib", "~> 0.1.1"
         
     | 
| 
       39 
38 
     | 
    
         
             
            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. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.5
         
     | 
| 
       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- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2019-05-13 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -25,21 +25,21 @@ dependencies: 
     | 
|
| 
       25 
25 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
26 
     | 
    
         
             
                    version: '2.0'
         
     | 
| 
       27 
27 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       28 
     | 
    
         
            -
              name:  
     | 
| 
      
 28 
     | 
    
         
            +
              name: byebug
         
     | 
| 
       29 
29 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       30 
30 
     | 
    
         
             
                requirements:
         
     | 
| 
       31 
     | 
    
         
            -
                - - " 
     | 
| 
      
 31 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       32 
32 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       33 
     | 
    
         
            -
                    version: '0 
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
       34 
34 
     | 
    
         
             
              type: :development
         
     | 
| 
       35 
35 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       36 
36 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       37 
37 
     | 
    
         
             
                requirements:
         
     | 
| 
       38 
     | 
    
         
            -
                - - " 
     | 
| 
      
 38 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       39 
39 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       40 
     | 
    
         
            -
                    version: '0 
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
       41 
41 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       42 
     | 
    
         
            -
              name:  
     | 
| 
      
 42 
     | 
    
         
            +
              name: debase
         
     | 
| 
       43 
43 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       44 
44 
     | 
    
         
             
                requirements:
         
     | 
| 
       45 
45 
     | 
    
         
             
                - - ">="
         
     | 
| 
         @@ -53,7 +53,21 @@ dependencies: 
     | 
|
| 
       53 
53 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       54 
54 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       55 
55 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       56 
     | 
    
         
            -
              name:  
     | 
| 
      
 56 
     | 
    
         
            +
              name: equivalent-xml
         
     | 
| 
      
 57 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 58 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 59 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 60 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 61 
     | 
    
         
            +
                    version: '0.6'
         
     | 
| 
      
 62 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 63 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 64 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 65 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 66 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 67 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 68 
     | 
    
         
            +
                    version: '0.6'
         
     | 
| 
      
 69 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 70 
     | 
    
         
            +
              name: pry-byebug
         
     | 
| 
       57 
71 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       58 
72 
     | 
    
         
             
                requirements:
         
     | 
| 
       59 
73 
     | 
    
         
             
                - - ">="
         
     | 
| 
         @@ -95,21 +109,7 @@ dependencies: 
     | 
|
| 
       95 
109 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       96 
110 
     | 
    
         
             
                    version: '3.0'
         
     | 
| 
       97 
111 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       98 
     | 
    
         
            -
              name:  
     | 
| 
       99 
     | 
    
         
            -
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       100 
     | 
    
         
            -
                requirements:
         
     | 
| 
       101 
     | 
    
         
            -
                - - ">="
         
     | 
| 
       102 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       103 
     | 
    
         
            -
                    version: '0'
         
     | 
| 
       104 
     | 
    
         
            -
              type: :development
         
     | 
| 
       105 
     | 
    
         
            -
              prerelease: false
         
     | 
| 
       106 
     | 
    
         
            -
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       107 
     | 
    
         
            -
                requirements:
         
     | 
| 
       108 
     | 
    
         
            -
                - - ">="
         
     | 
| 
       109 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       110 
     | 
    
         
            -
                    version: '0'
         
     | 
| 
       111 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency
         
     | 
| 
       112 
     | 
    
         
            -
              name: vcr
         
     | 
| 
      
 112 
     | 
    
         
            +
              name: ruby-debug-ide
         
     | 
| 
       113 
113 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       114 
114 
     | 
    
         
             
                requirements:
         
     | 
| 
       115 
115 
     | 
    
         
             
                - - ">="
         
     | 
| 
         @@ -123,7 +123,7 @@ dependencies: 
     | 
|
| 
       123 
123 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       124 
124 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       125 
125 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       126 
     | 
    
         
            -
              name:  
     | 
| 
      
 126 
     | 
    
         
            +
              name: simplecov
         
     | 
| 
       127 
127 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       128 
128 
     | 
    
         
             
                requirements:
         
     | 
| 
       129 
129 
     | 
    
         
             
                - - ">="
         
     | 
| 
         @@ -137,7 +137,7 @@ dependencies: 
     | 
|
| 
       137 
137 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       138 
138 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       139 
139 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       140 
     | 
    
         
            -
              name:  
     | 
| 
      
 140 
     | 
    
         
            +
              name: vcr
         
     | 
| 
       141 
141 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       142 
142 
     | 
    
         
             
                requirements:
         
     | 
| 
       143 
143 
     | 
    
         
             
                - - ">="
         
     | 
| 
         @@ -151,7 +151,7 @@ dependencies: 
     | 
|
| 
       151 
151 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       152 
152 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       153 
153 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       154 
     | 
    
         
            -
              name:  
     | 
| 
      
 154 
     | 
    
         
            +
              name: webmock
         
     | 
| 
       155 
155 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       156 
156 
     | 
    
         
             
                requirements:
         
     | 
| 
       157 
157 
     | 
    
         
             
                - - ">="
         
     | 
| 
         @@ -165,19 +165,19 @@ dependencies: 
     | 
|
| 
       165 
165 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       166 
166 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       167 
167 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       168 
     | 
    
         
            -
              name:  
     | 
| 
      
 168 
     | 
    
         
            +
              name: relaton-bib
         
     | 
| 
       169 
169 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       170 
170 
     | 
    
         
             
                requirements:
         
     | 
| 
       171 
171 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       172 
172 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       173 
     | 
    
         
            -
                    version: 0. 
     | 
| 
      
 173 
     | 
    
         
            +
                    version: 0.1.1
         
     | 
| 
       174 
174 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       175 
175 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       176 
176 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       177 
177 
     | 
    
         
             
                requirements:
         
     | 
| 
       178 
178 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       179 
179 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       180 
     | 
    
         
            -
                    version: 0. 
     | 
| 
      
 180 
     | 
    
         
            +
                    version: 0.1.1
         
     | 
| 
       181 
181 
     | 
    
         
             
            description: 'NistBib: retrive NIST standards.'
         
     | 
| 
       182 
182 
     | 
    
         
             
            email:
         
     | 
| 
       183 
183 
     | 
    
         
             
            - open.source@ribose.com
         
     | 
| 
         @@ -187,6 +187,7 @@ extra_rdoc_files: [] 
     | 
|
| 
       187 
187 
     | 
    
         
             
            files:
         
     | 
| 
       188 
188 
     | 
    
         
             
            - ".gitignore"
         
     | 
| 
       189 
189 
     | 
    
         
             
            - ".rspec"
         
     | 
| 
      
 190 
     | 
    
         
            +
            - ".rubocop.yml"
         
     | 
| 
       190 
191 
     | 
    
         
             
            - ".travis.yml"
         
     | 
| 
       191 
192 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       192 
193 
     | 
    
         
             
            - Gemfile.lock
         
     | 
| 
         @@ -197,12 +198,18 @@ files: 
     | 
|
| 
       197 
198 
     | 
    
         
             
            - bin/console
         
     | 
| 
       198 
199 
     | 
    
         
             
            - bin/setup
         
     | 
| 
       199 
200 
     | 
    
         
             
            - lib/nistbib.rb
         
     | 
| 
      
 201 
     | 
    
         
            +
            - lib/nistbib/comment_period.rb
         
     | 
| 
      
 202 
     | 
    
         
            +
            - lib/nistbib/document_status.rb
         
     | 
| 
       200 
203 
     | 
    
         
             
            - lib/nistbib/hit.rb
         
     | 
| 
       201 
204 
     | 
    
         
             
            - lib/nistbib/hit_collection.rb
         
     | 
| 
      
 205 
     | 
    
         
            +
            - lib/nistbib/keyword.rb
         
     | 
| 
      
 206 
     | 
    
         
            +
            - lib/nistbib/nist_bibliographic_item.rb
         
     | 
| 
       202 
207 
     | 
    
         
             
            - lib/nistbib/nist_bibliography.rb
         
     | 
| 
      
 208 
     | 
    
         
            +
            - lib/nistbib/nist_series.rb
         
     | 
| 
       203 
209 
     | 
    
         
             
            - lib/nistbib/scrapper.rb
         
     | 
| 
       204 
210 
     | 
    
         
             
            - lib/nistbib/version.rb
         
     | 
| 
       205 
211 
     | 
    
         
             
            - lib/nistbib/workers_pool.rb
         
     | 
| 
      
 212 
     | 
    
         
            +
            - lib/nistbib/xml_parser.rb
         
     | 
| 
       206 
213 
     | 
    
         
             
            - lib/relaton/processor.rb
         
     | 
| 
       207 
214 
     | 
    
         
             
            - nistbib.gemspec
         
     | 
| 
       208 
215 
     | 
    
         
             
            homepage: https://github.com/metanorma/nistbib
         
     | 
| 
         @@ -225,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       225 
232 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       226 
233 
     | 
    
         
             
            requirements: []
         
     | 
| 
       227 
234 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       228 
     | 
    
         
            -
            rubygems_version: 2. 
     | 
| 
      
 235 
     | 
    
         
            +
            rubygems_version: 2.6.12
         
     | 
| 
       229 
236 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       230 
237 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       231 
238 
     | 
    
         
             
            summary: 'NistBib: retrive NIST standards.'
         
     |