relaton-doi 1.16.0 → 1.16.2

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
  SHA256:
3
- metadata.gz: 36fbec3dfe6ed0635449ed79967ab8f78e8ea10569de97b144926de8ea64b330
4
- data.tar.gz: 766e94778c9a4a5d4a5a949d3329409604a1d4fe87079f31c1ce71280049c33c
3
+ metadata.gz: 1fc8ca041ddc95e57f5cc9ed9a92c82f2084d6d6c85bb388fe6517eb735c13a2
4
+ data.tar.gz: 76b59b80620b074a1612989d8235c4de08a3871eb0719193a87bdbb6c769e4bc
5
5
  SHA512:
6
- metadata.gz: 7921e6e71d1526bc2d26240616200ad832a0e228772336764a0ac9484de5427382141c89dc8718a30f12819696304746dc5ddfe060719a034a73fcf0d4f6c6a6
7
- data.tar.gz: fdb1f361f3b6cd14bb07401fc3594de0222c4d1d76fcac1f216198075b4827d35d317af30d7f3d372896a163b8fb32335d96ec90931b1eb6cd4cd85c970d4206
6
+ metadata.gz: 0d030e88dda6f574255c2f74c650490d3abc3d1b2885dc087e4b8a8e618362b36e56d4170fe4fa9ee9825f7b38212b995ddf35bf1d00a10aa4932866a6339d62
7
+ data.tar.gz: 0204b1fd7fd912c7c49ccb83a4f62ef370f529f34a136edc077e1aacb3c71247442c6d9a8194b3591d38b9e858ce2058e50fde8d02f3d1217e941c32029a5ac2
data/README.adoc CHANGED
@@ -39,6 +39,20 @@ $ gem install relaton-doi
39
39
 
40
40
  == Usage
41
41
 
42
+ === Configuration
43
+
44
+ Configuration is optional. The available option is `logger` which is a `Logger` instance. By default, the logger is `Logger.new($stderr)` with `Logger::WARN` level. To change the logger level, use `RelatonDoi.configure` block.
45
+
46
+ [source,ruby]
47
+ ----
48
+ require 'relaton_doi'
49
+ => true
50
+
51
+ RelatonDoi.configure do |config|
52
+ config.logger.level = Logger::DEBUG
53
+ end
54
+ ----
55
+
42
56
  === Retrieving items of known type using DOI
43
57
 
44
58
  If the resulting bibliographic item returned from CrossRef is a known Relaton
@@ -52,30 +66,30 @@ require 'relaton_doi'
52
66
 
53
67
  # get NIST standard
54
68
  RelatonDoi::Crossref.get "doi:10.6028/nist.ir.8245"
55
- [relaton-doi] ["doi:10.6028/nist.ir.8245"] fetching...
56
- [relaton-doi] ["doi:10.6028/nist.ir.8245"] found 10.6028/nist.ir.8245
69
+ [relaton-doi] (doi:10.6028/nist.ir.8245) Fetching from search.crossref.org ...
70
+ [relaton-doi] (doi:10.6028/nist.ir.8245) Found: `10.6028/nist.ir.8245`
57
71
  => #<RelatonNist::NistBibliographicItem:0x00007ff22420d820
58
72
  ...
59
73
 
60
74
  # get RFC standard
61
75
  RelatonDoi::Crossref.get "doi:10.17487/RFC0001"
62
- [relaton-doi] ["doi:10.17487/RFC0001"] fetching...
63
- [relaton-doi] ["doi:10.17487/RFC0001"] found 10.17487/rfc0001
64
- [relaton-ietf] WARNING: invalid doctype report
76
+ [relaton-doi] (doi:10.17487/RFC0001) Fetching from search.crossref.org ...
77
+ [relaton-doi] (doi:10.17487/RFC0001) Found: `10.17487/rfc0001`
78
+ [relaton-ietf] WARNING: Invalid doctype report
65
79
  => #<RelatonIetf::IetfBibliographicItem:0x00007ff2241be6d0
66
80
  ...
67
81
 
68
82
  # get BIPM standard
69
83
  RelatonDoi::Crossref.get "doi:10.1088/0026-1394/29/6/001"
70
- [relaton-doi] ["doi:10.1088/0026-1394/29/6/001"] fetching...
71
- [relaton-doi] ["doi:10.1088/0026-1394/29/6/001"] found 10.1088/0026-1394/29/6/001
84
+ [relaton-doi] (doi:10.1088/0026-1394/29/6/001) Fetching from search.crossref.org ...
85
+ [relaton-doi] (doi:10.1088/0026-1394/29/6/001) Found: `10.1088/0026-1394/29/6/001`
72
86
  => #<RelatonBipm::BipmBibliographicItem:0x00007f9c846f0a68
73
87
  ...
74
88
 
75
89
  # get IEEE standard
76
90
  RelatonDoi::Crossref.get "doi:10.1109/ieeestd.2014.6835311"
77
- [relaton-doi] ["doi:10.1109/ieeestd.2014.6835311"] fetching...
78
- [relaton-doi] ["doi:10.1109/ieeestd.2014.6835311"] found 10.1109/ieeestd.2014.6835311
91
+ [relaton-doi] (doi:10.1109/ieeestd.2014.6835311) Fetching from search.crossref.org ...
92
+ [relaton-doi] (doi:10.1109/ieeestd.2014.6835311) Found: `10.1109/ieeestd.2014.6835311`
79
93
  => #<RelatonIeee::IeeeBibliographicItem:0x00007f9cb46db688
80
94
  ...
81
95
  ----
@@ -88,8 +102,8 @@ to Relaton, an instance of RelatonBib::BibliographicItem will be returned.
88
102
  [source,ruby]
89
103
  ----
90
104
  RelatonDoi::Crossref.get "doi:10.1109/ACCESS.2017.2739804"
91
- [relaton-doi] ["doi:10.1109/ACCESS.2017.2739804"] fetching...
92
- [relaton-doi] ["doi:10.1109/ACCESS.2017.2739804"] found 10.1109/access.2017.2739804
105
+ [relaton-doi] (doi:10.1109/ACCESS.2017.2739804) Fetching from search.crossref.org ...
106
+ [relaton-doi] (doi:10.1109/ACCESS.2017.2739804) Found: `10.1109/access.2017.2739804`
93
107
  => #<RelatonBib::BibliographicItem:0x00007ff22435e490
94
108
  ...
95
109
  ----
@@ -0,0 +1,10 @@
1
+ module RelatonDoi
2
+ module Config
3
+ include RelatonBib::Config
4
+ end
5
+ extend Config
6
+
7
+ class Configuration < RelatonBib::Configuration
8
+ PROGNAME = "relaton-doi".freeze
9
+ end
10
+ end
@@ -12,11 +12,14 @@ module RelatonDoi
12
12
  # RelatonNist::NistBibliographicItem] The bibitem.
13
13
  #
14
14
  def get(doi)
15
- warn "[relaton-doi] [\"#{doi}\"] fetching..."
15
+ Util.warn "(#{doi}) Fetching from search.crossref.org ..."
16
16
  id = doi.sub(%r{^doi:}, "")
17
17
  message = get_by_id id
18
- warn "[relaton-doi] [\"#{doi}\"] found #{message['DOI']}"
18
+ Util.warn "(#{doi}) Found: `#{message['DOI']}`"
19
19
  Parser.parse message
20
+ rescue Serrano::NotFound
21
+ Util.warn "(#{doi}) Not found."
22
+ nil
20
23
  end
21
24
 
22
25
  #
@@ -45,7 +45,7 @@ module RelatonDoi
45
45
  # Returns hash of XML grammar
46
46
  # @return [String]
47
47
  def grammar_hash
48
- @grammar_hash ||= ::RelatonBib.grammar_hash
48
+ @grammar_hash ||= ::RelatonDoi.grammar_hash
49
49
  end
50
50
  end
51
51
  end
@@ -0,0 +1,9 @@
1
+ module RelatonDoi
2
+ module Util
3
+ extend RelatonBib::Util
4
+
5
+ def self.logger
6
+ RelatonDoi.configuration.logger
7
+ end
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelatonDoi
4
- VERSION = "1.16.0"
4
+ VERSION = "1.16.2"
5
5
  end
data/lib/relaton_doi.rb CHANGED
@@ -8,6 +8,8 @@ require "relaton_ietf"
8
8
  require "relaton_ieee"
9
9
  require "relaton_nist"
10
10
  require_relative "relaton_doi/version"
11
+ require_relative "relaton_doi/config"
12
+ require_relative "relaton_doi/util"
11
13
  require_relative "relaton_doi/parser"
12
14
  require_relative "relaton_doi/crossref"
13
15
 
@@ -16,4 +18,11 @@ Serrano.configuration do |config|
16
18
  end
17
19
 
18
20
  module RelatonDoi
21
+ extend self
22
+
23
+ def grammar_hash
24
+ Digest::MD5.hexdigest(
25
+ RelatonNist::VERSION + RelatonIetf::VERSION + RelatonIeee::VERSION + RelatonBipm::VERSION + RelatonBib::VERSION,
26
+ )
27
+ end
19
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-doi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.16.0
4
+ version: 1.16.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-03 00:00:00.000000000 Z
11
+ date: 2023-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: relaton-bib
@@ -115,9 +115,11 @@ files:
115
115
  - bin/rspec
116
116
  - bin/setup
117
117
  - lib/relaton_doi.rb
118
+ - lib/relaton_doi/config.rb
118
119
  - lib/relaton_doi/crossref.rb
119
120
  - lib/relaton_doi/parser.rb
120
121
  - lib/relaton_doi/processor.rb
122
+ - lib/relaton_doi/util.rb
121
123
  - lib/relaton_doi/version.rb
122
124
  - relaton-doi.gemspec
123
125
  homepage: https://github.com/relaton/relaton-doi