relaton-nist 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b6d99784844761b6cde3c399bc02e8b34308c562
4
+ data.tar.gz: 1a267971e69723396eabb57fc8f49d745a5eb014
5
+ SHA512:
6
+ metadata.gz: d5d9ebf4cb69757b72bb32a12144e7512cde10de1d0fcd9ad6bc2422f095a07f45f5a3ddf3e4e68e980acf63bc359e9d87ee495f3f637f2a6e61ef5d63fbde1d
7
+ data.tar.gz: 7d478dbb6e7721ae6e018a3765f3b2e19f3fb803fe9581efb25472010d6bc650db2dd5def983782508d0b3fd659a6924e017e3b7dec7b078356ae8c52daff587
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ .vscode/
10
+ .rubocop-https---raw-githubusercontent-com-riboseinc-oss-guides-master-ci-rubocop-yml
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
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/.travis.yml ADDED
@@ -0,0 +1,17 @@
1
+ # Auto-generated !!! Do not edit it manually
2
+ # use ci-master https://github.com/metanorma/metanorma-build-scripts
3
+ language: ruby
4
+ cache: bundler
5
+ os:
6
+ - linux
7
+ - osx
8
+ rvm:
9
+ - 2.5
10
+ - 2.4
11
+ - ruby-head
12
+ before_install:
13
+ - gem install bundler -v 2.0.1
14
+ - bundle update
15
+ matrix:
16
+ allow_failures:
17
+ - rvm: ruby-head
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ Encoding.default_external = Encoding::UTF_8
2
+ Encoding.default_internal = Encoding::UTF_8
3
+
4
+ source "https://rubygems.org"
5
+
6
+ # Specify your gem's dependencies in relaton_nist.gemspec
7
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,85 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ relaton-nist (0.1.0)
5
+ relaton-bib (~> 0.1.6)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.6.0)
11
+ public_suffix (>= 2.0.2, < 4.0)
12
+ byebug (11.0.1)
13
+ coderay (1.1.2)
14
+ crack (0.4.3)
15
+ safe_yaml (~> 1.0.0)
16
+ debase (0.2.2)
17
+ debase-ruby_core_source (>= 0.10.2)
18
+ debase-ruby_core_source (0.10.4)
19
+ diff-lcs (1.3)
20
+ docile (1.3.1)
21
+ equivalent-xml (0.6.0)
22
+ nokogiri (>= 1.4.3)
23
+ hashdiff (0.4.0)
24
+ json (2.2.0)
25
+ method_source (0.9.2)
26
+ mini_portile2 (2.3.0)
27
+ nokogiri (1.8.5)
28
+ mini_portile2 (~> 2.3.0)
29
+ pry (0.12.2)
30
+ coderay (~> 1.1.0)
31
+ method_source (~> 0.9.0)
32
+ pry-byebug (3.7.0)
33
+ byebug (~> 11.0)
34
+ pry (~> 0.10)
35
+ public_suffix (3.1.0)
36
+ rake (10.5.0)
37
+ relaton-bib (0.1.6)
38
+ addressable
39
+ nokogiri (~> 1.8.4)
40
+ rspec (3.8.0)
41
+ rspec-core (~> 3.8.0)
42
+ rspec-expectations (~> 3.8.0)
43
+ rspec-mocks (~> 3.8.0)
44
+ rspec-core (3.8.0)
45
+ rspec-support (~> 3.8.0)
46
+ rspec-expectations (3.8.3)
47
+ diff-lcs (>= 1.2.0, < 2.0)
48
+ rspec-support (~> 3.8.0)
49
+ rspec-mocks (3.8.0)
50
+ diff-lcs (>= 1.2.0, < 2.0)
51
+ rspec-support (~> 3.8.0)
52
+ rspec-support (3.8.0)
53
+ ruby-debug-ide (0.6.1)
54
+ rake (>= 0.8.1)
55
+ safe_yaml (1.0.5)
56
+ simplecov (0.16.1)
57
+ docile (~> 1.1)
58
+ json (>= 1.8, < 3)
59
+ simplecov-html (~> 0.10.0)
60
+ simplecov-html (0.10.2)
61
+ vcr (5.0.0)
62
+ webmock (3.5.1)
63
+ addressable (>= 2.3.6)
64
+ crack (>= 0.3.2)
65
+ hashdiff
66
+
67
+ PLATFORMS
68
+ ruby
69
+
70
+ DEPENDENCIES
71
+ bundler (~> 2.0)
72
+ byebug
73
+ debase
74
+ equivalent-xml (~> 0.6)
75
+ pry-byebug
76
+ rake (~> 10.0)
77
+ relaton-nist!
78
+ rspec (~> 3.0)
79
+ ruby-debug-ide
80
+ simplecov
81
+ vcr
82
+ webmock
83
+
84
+ BUNDLED WITH
85
+ 2.0.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Andrei Kislichenko
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.adoc ADDED
@@ -0,0 +1,128 @@
1
+ = RelatonNist: retrieve NIST Standards for bibliographic use using the BibliographicItem model
2
+
3
+ image:https://img.shields.io/gem/v/relaton-nist.svg["Gem Version", link="https://rubygems.org/gems/relaton-nist"]
4
+ image:https://img.shields.io/travis/metanorma/relaton-nist/master.svg["Build Status", link="https://travis-ci.com/metanorma/relaton-nist"]
5
+ image:https://ci.appveyor.com/api/projects/status/vk85u3df4f3kertr?svg=true["Appveyor Build Status", link="https://ci.appveyor.com/project/ribose/relaton-nist"]
6
+ image:https://codeclimate.com/github/metanorma/relaton-nist/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/relaton-nist"]
7
+
8
+
9
+ RelatonNist is a Ruby gem that implements the https://github.com/metanorma/metanorma-model-iso#iso-bibliographic-item[IsoBibliographicItem model].
10
+
11
+ You can use it to retrieve metadata of NIST Standards from https://csrc.nist.gov, and access such metadata through the `IsoBibliographicItem` object.
12
+
13
+ == Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ [source,ruby]
18
+ ----
19
+ gem 'relaton_nist'
20
+ ----
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install relaton_nist
29
+
30
+ == Usage
31
+
32
+ === Search for a standard using keywords
33
+
34
+ [source,ruby]
35
+ ----
36
+ require 'relaton_nist'
37
+
38
+ hit_collection = RelatonNist::NistBibliography.search("8200")
39
+ => [<RelatonNist::Hit:0x007f82b9b2b298 @text="8200" @fetched="false" @fullIdentifier="" @title="8200">,
40
+ <RelatonNist::Hit:0x007f82b9b2a1e0 @text="8200" @fetched="false" @fullIdentifier="" @title="8200">]
41
+
42
+ item = hit_collection[1].fetch
43
+ => #<RelatonNist::NistBibliographicItem:0x007f82b986e668
44
+ ...
45
+ ----
46
+
47
+ === XML serialization
48
+ [source,ruby]
49
+ ----
50
+ item.to_xml
51
+ => "<bibitem id="NISTIR8200(DRAFT)" type="standard">
52
+ <fetched>2019-05-03</fetched>
53
+ <title format="text/plain" language="en" script="Latn">
54
+ Interagency Report on Status of International Cybersecurity Standardization for the Internet of Things (IoT)
55
+ </title>
56
+ ...
57
+ <bibitem>"
58
+ ----
59
+ With argument `bibdata: true` it ouputs XML wrapped by `bibdata` element and adds flavour `ext` element.
60
+ [source,ruby]
61
+ ----
62
+ item.to_xml bibdata: true
63
+ => "<bibdata type="standard">
64
+ <fetched>2019-05-17</fetched>
65
+ <title format="text/plain" language="en" script="Latn">
66
+ Interagency Report on Status of International Cybersecurity Standardization for the Internet of Things (IoT)
67
+ </title>
68
+ ...
69
+ <ext>
70
+ <doctype>stadard</doctype>
71
+ <keyword>cybersecurity</keyword>
72
+ <keyword>cybersecurity objectives</keyword>
73
+ ...
74
+ <commentperiod>
75
+ <from>2018-02-01</from>
76
+ <to>2018-04-18</to>
77
+ </commentperiod>
78
+ </ext>
79
+ </bibdata>"
80
+ ----
81
+
82
+ === Get code, and year
83
+ [source,ruby]
84
+ ----
85
+ RelatonNist::NistBibliography.get("8200", "2018", {})
86
+ fetching 8200...
87
+ => #<RelatonNist::NistBibliographicItem:0x007f82bb3370a8
88
+ ...
89
+ ----
90
+
91
+ === Get short citation
92
+ Short citation is a convetion about a citation's format. The format for NIST publications is:
93
+ ----
94
+ NIST {abbrev(series)} {docnumber} {(edition), optional} {(stage), optioal}
95
+ # or
96
+ {abbrev(series)} {docnumber} {(edition), optional} {(stage), optioal}
97
+ ----
98
+ - `(stage)` is empty if the state is "final" (published)
99
+ - `(edition)` is the date of publication or update
100
+ - `docnumber` is the full NIST number, including revision, e.g., 800-52
101
+
102
+ The format for FIPS publications is:
103
+ ----
104
+ FIPS {docnumber}
105
+ # or
106
+ NIST FIPS {docnumber}
107
+ ----
108
+ [source,ruby]
109
+ ----
110
+ RelatonNist::NistBibliography.get("8200", "2018", {})
111
+ fetching 8200...
112
+ => #<RelatonNist::NistBibliographicItem:0x007f82bb3370a8
113
+ ...
114
+ ----
115
+
116
+ == Development
117
+
118
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
119
+
120
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
121
+
122
+ == Contributing
123
+
124
+ Bug reports and pull requests are welcome on GitHub at https://github.com/metanorma/relaton-nist.
125
+
126
+ == License
127
+
128
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/appveyor.yml ADDED
@@ -0,0 +1,30 @@
1
+ version: '{build}'
2
+
3
+ environment:
4
+ matrix:
5
+ - RUBY_VERSION: 25
6
+ - RUBY_VERSION: 24
7
+ - RUBY_VERSION: 23
8
+ - RUBY_VERSION: _trunk
9
+
10
+ matrix:
11
+ allow_failures:
12
+ - RUBY_VERSION: _trunk
13
+
14
+ install:
15
+ - ps: . { iwr -useb https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/appveyor.ps1 } | iex
16
+ - refreshenv
17
+
18
+ build_script:
19
+ - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
20
+ - bundle update
21
+ - bundle install
22
+
23
+ before_test:
24
+ - ruby -v
25
+ - gem -v
26
+ - bundle -v
27
+
28
+ test_script:
29
+ - bundle exec rake
30
+
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "relaton_nist"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,23 @@
1
+ require "relaton/processor"
2
+
3
+ module Relaton
4
+ module RelatonNist
5
+ class Processor < Relaton::Processor
6
+
7
+ def initialize
8
+ @short = :relaton_nist
9
+ @prefix = "NIST"
10
+ @defaultprefix = %r{^(NIST|NISTGCR|ITL Bulletin|JPCRD|NISTIR|CSRC)[ /]}
11
+ @idtype = "NIST"
12
+ end
13
+
14
+ def get(code, date = nil, opts = {})
15
+ ::RelatonNist::NistBibliography.get(code, date, opts)
16
+ end
17
+
18
+ def from_xml(xml)
19
+ ::RelatonNist::XMLParser.from_xml xml
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,30 @@
1
+ module RelatonNist
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,24 @@
1
+ module RelatonNist
2
+ class DocumentStatus < RelatonBib::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
+ # @param stage [String]
10
+ # @param substage [String, NilClass]
11
+ # @param iteration [String, NilClass]
12
+ def initialize(stage:, substage: nil, iteration: nil)
13
+ # unless STAGES.include? stage
14
+ # raise ArgumentError, "invalid argument: stage (#{stage})"
15
+ # end
16
+
17
+ # if substage && !SUBSTAGES.include?(substage)
18
+ # raise ArgumentError, "invalid argument: substage (#{substage})"
19
+ # end
20
+
21
+ super
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RelatonNist
4
+ # Hit.
5
+ class Hit
6
+ # @return [RelatonNist::HitCollection]
7
+ attr_reader :hit_collection
8
+
9
+ # @return [Array<Hash>]
10
+ attr_reader :hit
11
+
12
+ # @param hit [Hash]
13
+ # @param hit_collection [RelatonNist:HitCollection]
14
+ def initialize(hit, hit_collection = nil)
15
+ @hit = hit
16
+ @hit_collection = hit_collection
17
+ end
18
+
19
+ # Parse page.
20
+ # @return [RelatonNist::NistBliographicItem]
21
+ def fetch
22
+ @fetch ||= Scrapper.parse_page @hit
23
+ end
24
+
25
+ # @return [String]
26
+ def to_s
27
+ inspect
28
+ end
29
+
30
+ # @return [String]
31
+ def inspect
32
+ "<#{self.class}:#{format('%#.14x', object_id << 1)} "\
33
+ "@text=\"#{@hit_collection&.text}\" "\
34
+ "@fetched=\"#{!@fetch.nil?}\" "\
35
+ "@fullIdentifier=\"#{@fetch&.shortref(nil)}\" "\
36
+ "@title=\"#{@hit[:code]}\">"
37
+ end
38
+
39
+ # @return [String]
40
+ def to_xml(**opts)
41
+ fetch.to_xml **opts
42
+ end
43
+
44
+ # @return [Iteger]
45
+ def sort_value
46
+ case hit[:status]
47
+ when "final" then 1
48
+ when "withdrawn" then 2
49
+ when "draft (withdrawn)" then 3
50
+ else 4
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "relaton_nist/hit"
4
+ require "addressable/uri"
5
+ require "open-uri"
6
+
7
+ module RelatonNist
8
+ # Page of hit collection.
9
+ class HitCollection < Array
10
+
11
+ DOMAIN = "https://csrc.nist.gov"
12
+
13
+ # @return [TrueClass, FalseClass]
14
+ attr_reader :fetched
15
+
16
+ # @return [String]
17
+ attr_reader :text
18
+
19
+ # @return [String]
20
+ attr_reader :year
21
+
22
+ # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
23
+
24
+ # @param ref_nbr [String]
25
+ # @param year [String]
26
+ # @param opts [Hash]
27
+ # @option opts [String] :stage
28
+ def initialize(ref_nbr, year = nil, opts = {})
29
+ @text = ref_nbr
30
+ @year = year
31
+ from, to = nil
32
+ if year
33
+ d = Date.strptime year, "%Y"
34
+ from = d.strftime "%m/%d/%Y"
35
+ to = d.next_year.prev_day.strftime "%m/%d/%Y"
36
+ end
37
+ url = "#{DOMAIN}/publications/search?keywords-lg=#{ref_nbr}"
38
+ url += "&dateFrom-lg=#{from}" if from
39
+ url += "&dateTo-lg=#{to}" if to
40
+ url += if /PD/ =~ opts[:stage]
41
+ "&status-lg=Draft,Retired Draft,Withdrawn"
42
+ else
43
+ "&status-lg=Final,Withdrawn"
44
+ end
45
+
46
+ doc = Nokogiri::HTML OpenURI.open_uri(::Addressable::URI.parse(url).normalize)
47
+ hits = doc.css("table.publications-table > tbody > tr").map do |h|
48
+ link = h.at("td/div/strong/a")
49
+ serie = h.at("td[1]").text.strip
50
+ code = h.at("td[2]").text.strip
51
+ title = link.text
52
+ url = DOMAIN + link[:href]
53
+ status = h.at("td[4]").text.strip.downcase
54
+ release_date = Date.strptime h.at("td[5]").text.strip, "%m/%d/%Y"
55
+ Hit.new(
56
+ {
57
+ code: code, serie: serie, title: title, url: url, status: status,
58
+ release_date: release_date
59
+ }, self
60
+ )
61
+ end
62
+ concat(hits.sort { |a, b| a.sort_value - b.sort_value })
63
+ # concat(hits.map { |h| Hit.new(h, self) })
64
+ @fetched = false
65
+ # @hit_pages = hit_pages
66
+ end
67
+ # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
68
+
69
+ # @return [Iecbib::HitCollection]
70
+ def fetch
71
+ workers = RelatonBib::WorkersPool.new 4
72
+ workers.worker(&:fetch)
73
+ each do |hit|
74
+ workers << hit
75
+ end
76
+ workers.end
77
+ workers.result
78
+ @fetched = true
79
+ self
80
+ end
81
+
82
+ def to_s
83
+ inspect
84
+ end
85
+
86
+ def inspect
87
+ "<#{self.class}:#{format('%#.14x', object_id << 1)} @fetched=#{@fetched}>"
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,16 @@
1
+ module RelatonNist
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,78 @@
1
+ module RelatonNist
2
+ class NistBibliographicItem < RelatonBib::BibliographicItem
3
+ # @return [String]
4
+ attr_reader :doctype
5
+
6
+ # @return [Array<RelatonNist::Keyword>]
7
+ attr_reader :keyword
8
+
9
+ # @return [RelatonNist::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 [RelatonNist::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 doctype [String]
33
+ # @param keyword [Array<RelatonNist::Keyword>]
34
+ # @param commentperiod [RelatonNist::CommentPeriod]
35
+ #
36
+ # @param dates [Array<Hash>]
37
+ # @option dates [String] :type
38
+ # @option dates [String] :from
39
+ # @option dates [String] :to
40
+ #
41
+ # @param contributors [Array<Hash>]
42
+ # @option contributors [String] :type
43
+ # @option contributors [String] :from
44
+ # @option contributirs [String] :to
45
+ # @option contributors [String] :abbreviation
46
+ # @option contributors [Array<String>] :roles
47
+ #
48
+ # @param abstract [Array<Hash>]
49
+ # @option abstract [String] :content
50
+ # @option abstract [String] :language
51
+ # @option abstract [String] :script
52
+ # @option abstract [String] :type
53
+ #
54
+ # @param relations [Array<Hash>]
55
+ # @option relations [String] :type
56
+ # @option relations [RelatonBib::BibliographicItem] :bibitem
57
+ # @option relations [Array<RelatonBib::BibItemLocality>] :bib_locality
58
+ def initialize(**args)
59
+ @doctype = args.delete(:doctype) || "standard"
60
+ @keyword = args.delete(:keyword) || []
61
+ @commentperiod = args.delete :commentperiod
62
+ super
63
+ end
64
+
65
+ # @param builder [Nokogiri::XML::Builder]
66
+ def to_xml(builder = nil, **opts)
67
+ super builder, date_format: :short, **opts do |b|
68
+ if opts[:bibdata]
69
+ b.ext do
70
+ b.doctype doctype
71
+ keyword.each { |kw| kw.to_xml b }
72
+ commentperiod&.to_xml b
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end