relaton-nist 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 860bed641e26ef2dd9e431c754d38d0dffb81a69
4
- data.tar.gz: e7a3cddcdab9e27866ff220374bd73d6f3253b0f
3
+ metadata.gz: 147749e057ac3bdfed497ab88ba83931df9a6f01
4
+ data.tar.gz: 913e28a5f496a8aa48b21e8fb81d8107eb629d6b
5
5
  SHA512:
6
- metadata.gz: 8afdc827eaa9d984bf344138f7965099fbb7ec717cb283f2ab5d5cfa2feb910432f26fd1d22608c9de3e3364d8706acbb0d55419382808610e050c40a35065e9
7
- data.tar.gz: 01e02e9dfd1b33d0ed24ae1b7f8181637c77ed7694fc725092882ca327044219bc8871a70999808bcd4c93890994cf39705ea43d9b48059357265b3099e1c88e
6
+ metadata.gz: 6037679e600a3656512514dcad74adcab91eaa9bfa85e87f39e564f1c7f80007e4598693fd80654e6ef44fa6e1b913b2b0f0c266dd381940dad1288eeb692fea
7
+ data.tar.gz: bb8d3ec45f4eb94e647dc747a16bad03b2d4349a5b0519ecbf8eb7b639791c7b5d4a2c4836c5251428ff774ec579a402f6aeb818722b6feaa6393dd17bcec33c
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- relaton-nist (0.3.0)
4
+ relaton-nist (0.3.1)
5
5
  relaton-bib (~> 0.3.0)
6
6
  rubyzip
7
7
 
@@ -35,7 +35,7 @@ GEM
35
35
  pry (~> 0.10)
36
36
  public_suffix (3.1.1)
37
37
  rake (10.5.0)
38
- relaton-bib (0.3.0)
38
+ relaton-bib (0.3.2)
39
39
  addressable
40
40
  nokogiri (~> 1.10)
41
41
  rspec (3.8.0)
@@ -113,6 +113,22 @@ fetching 8200...
113
113
  ...
114
114
  ----
115
115
 
116
+ === Create bibliographic item form YAML
117
+ [source,ruby]
118
+ ----
119
+ hash = YAML.load_file 'spec/examples/nist_bib_item.yml'
120
+ => {"id"=>"NISTIR 8011 Vol. 3",
121
+ ...
122
+
123
+ bib_hash = RelatonNist::HashConverter.hash_to_bib hash
124
+ => {:id=>"NISTIR 8011 Vol. 3",
125
+ ...
126
+
127
+ RelatonNist::NistBibliographicItem.new bib_hash
128
+ => #<RelatonNist::NistBibliographicItem:0x007f8b708505b8
129
+ ...
130
+ ----
131
+
116
132
  == Development
117
133
 
118
134
  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.
@@ -12,7 +12,7 @@ module RelatonNist
12
12
  # @param from [Date]
13
13
  # @param to [Date, NilClass]
14
14
  # @param extended [Date, NilClass]
15
- def initialize(from, to = nil, extended = nil)
15
+ def initialize(from:, to: nil, extended: nil)
16
16
  @from = from
17
17
  @to = to
18
18
  @extended = extended
@@ -0,0 +1,30 @@
1
+ module RelatonNist
2
+ class HashConverter < RelatonBib::HashConverter
3
+ class << self
4
+ # @override RelatonBib::HashConverter.hash_to_bib
5
+ # @param args [Hash]
6
+ # @param nested [TrueClass, FalseClass]
7
+ # @return [Hash]
8
+ def hash_to_bib(args, nested = false)
9
+ ret = super
10
+ return if ret.nil?
11
+
12
+ keyword_hash_to_bib(ret)
13
+ commentperiod_hash_to_bib(ret)
14
+ ret
15
+ end
16
+
17
+ private
18
+
19
+ def keyword_hash_to_bib(ret)
20
+ ret[:keyword]&.map! { |kw| Keyword.new kw }
21
+ end
22
+
23
+ def commentperiod_hash_to_bib(ret)
24
+ return unless ret[:commentperiod]
25
+
26
+ ret[:commentperiod] = CommentPeriod.new ret[:commentperiod]
27
+ end
28
+ end
29
+ end
30
+ end
@@ -6,6 +6,7 @@ require "relaton_nist/xml_parser"
6
6
  require "relaton_nist/keyword"
7
7
  require "relaton_nist/comment_period"
8
8
  require "relaton_nist/document_status"
9
+ require "relaton_nist/hash_converter"
9
10
 
10
11
  module RelatonNist
11
12
  class NistBibliography
@@ -208,7 +208,7 @@ module RelatonNist
208
208
  org = RelatonBib::Organization.new(
209
209
  name: name, url: "www.nist.gov", abbreviation: "NIST",
210
210
  )
211
- contribs << RelatonBib::ContributionInfo.new(entity: org, role: ["publisher"])
211
+ contribs << RelatonBib::ContributionInfo.new(entity: org, role: [type: "publisher"])
212
212
  authors = doc.at('//h4[.="Author(s)"]/following-sibling::p')
213
213
  contribs += contributors(authors, "author")
214
214
  editors = doc.at('//h4[.="Editor(s)"]/following-sibling::p')
@@ -237,7 +237,7 @@ module RelatonNist
237
237
  else
238
238
  entity = org
239
239
  end
240
- RelatonBib::ContributionInfo.new entity: entity, role: [role]
240
+ RelatonBib::ContributionInfo.new entity: entity, role: [type: role]
241
241
  end
242
242
  end
243
243
 
@@ -273,7 +273,7 @@ module RelatonNist
273
273
  else
274
274
  entity = RelatonBib::Organization.new name: an, abbreviation: abbrev
275
275
  end
276
- RelatonBib::ContributionInfo.new entity: entity, role: [role]
276
+ RelatonBib::ContributionInfo.new entity: entity, role: [type: role]
277
277
  end
278
278
  end
279
279
  # rubocop:enable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength
@@ -455,13 +455,15 @@ module RelatonNist
455
455
  ex = doc.at "//strong[contains(.,'The comment closing date has been extended to')]"
456
456
  ext = ex&.text&.match(/\w+\s\d{2},\s\d{4}/).to_s
457
457
  extended = ext.empty? ? nil : Date.strptime(ext, "%B %d, %Y")
458
- CommentPeriod.new from, to, extended
458
+ CommentPeriod.new from: from, to: to, extended: extended
459
459
  end
460
460
 
461
461
  # @param json [Hash]
462
462
  # @return [RelatonNist::CommentPeriod, NilClass]
463
463
  def fetch_commentperiod_json(json)
464
- CommentPeriod.new json["comment-from"], json["comment-to"] if json["comment-from"]
464
+ return unless json["comment-from"]
465
+
466
+ CommentPeriod.new from: json["comment-from"], to: json["comment-to"]
465
467
  end
466
468
  end
467
469
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonNist
2
- VERSION = "0.3.0".freeze
2
+ VERSION = "0.3.1".freeze
3
3
  end
@@ -34,7 +34,10 @@ module RelatonNist
34
34
  cp = item.at "./commentperiod"
35
35
  return unless cp
36
36
 
37
- CommentPeriod.new cp.at("from").text, cp.at("to")&.text, cp.at("extended")&.text
37
+ CommentPeriod.new(
38
+ from: cp.at("from").text, to: cp.at("to")&.text,
39
+ extended: cp.at("extended")&.text
40
+ )
38
41
  end
39
42
 
40
43
  def fetch_keyword(item)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-nist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-07-25 00:00:00.000000000 Z
11
+ date: 2019-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -216,6 +216,7 @@ files:
216
216
  - lib/relaton_nist/comment_period.rb
217
217
  - lib/relaton_nist/data/pubs-export.zip
218
218
  - lib/relaton_nist/document_status.rb
219
+ - lib/relaton_nist/hash_converter.rb
219
220
  - lib/relaton_nist/hit.rb
220
221
  - lib/relaton_nist/hit_collection.rb
221
222
  - lib/relaton_nist/keyword.rb