relaton-isbn 1.18.0 → 1.19.0

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: a40299890b8c876a1397a66412981b29dd420e55f469b0d1d751f3ecfe76ad0a
4
- data.tar.gz: f6f18a46d654dc22fa0cdac813c023904b7a622b483f4ae9127c1e350a2f546b
3
+ metadata.gz: 06f70a5b69dd360292a5692cd5ea5f1228c9261bdc73fe2cb9e385f1d7683173
4
+ data.tar.gz: 729a5c5eb601e1ed36f93bf27e3dfce38f0cfcce2819f3a66838ffe6a3cc0ba3
5
5
  SHA512:
6
- metadata.gz: ebc9da4bc8e27e6a3b5c9f664dba1db1e878e7b059af03eae7c19de912ada3a31f82364327e886fae55da77ce60441fc5b07bd4d83a23189b68371892857ea41
7
- data.tar.gz: 557d400855efa4cb4ca264860ba525d1b0bbed5c2002788ad5d8bd41cbc70b4571431addf8c57f0e492d43969f4f7c606834afb77934b85258dce6440bb892ef
6
+ metadata.gz: 164de6cc7b1e1a2b5dedf3feeddb5cf92384206cfde6052fa20fd4d1798962fd3d8d9712062cea6f6b336fdec1568aa84f4d8887a0b085bfee7eb40b9e756734
7
+ data.tar.gz: b0ed039de5c4c242c2294adbe332389816d4776f9517ef6a274fd3ba69adeacf36868d548d1032ff8ba0624eda3b7782c4abba66c0e561eeee5deaf89dc7a4c7
data/README.adoc CHANGED
@@ -39,37 +39,26 @@ $ gem install relaton-isbn
39
39
 
40
40
  == Usage
41
41
 
42
- === Configuration
42
+ === Retrieving bibliographic items using OpenLibrary API
43
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 `RelatonIsbn.configure` block.
44
+ To retrieve bibliographic items, use `RelatonIsbn::OpenLibrary.get` method with ISBN-10 or ISBN-13 as an argument. Allowed prefixes are `ISBN`, `isbn:`. Prefix and hyphens are optional. The method returns `RelatonBib::BibliographicItem` object.
45
45
 
46
46
  [source,ruby]
47
47
  ----
48
48
  require 'relaton_isbn'
49
49
  => true
50
50
 
51
- RelatonIsbn.configure do |config|
52
- config.logger.level = Logger::DEBUG
53
- end
54
- ----
55
-
56
- === Retrieving bibliographic items using OpenLibrary API
57
-
58
- To retrieve bibliographic items, use `RelatonIsbn::OpenLibrary.get` method with ISBN-10 or ISBN-13 as an argument. Prefix `ISBN` and hyphens are optional. The method returns `RelatonBib::BibliographicItem` object.
59
-
60
- [source,ruby]
61
- ----
62
51
  # get document by ISBN-13
63
- > bibitem = RelatonIsbn::OpenLibrary.get "ISBN 978-0-12-064481-0"
52
+ > ibitem = RelatonIsbn::OpenLibrary.get "ISBN 978-0-12-064481-0"
64
53
  [relaton-isbn] (ISBN 9780120644810) Fetching from OpenLibrary ...
65
54
  [relaton-isbn] (ISBN 9780120644810) Found: `9780120644810`
66
55
  => #<RelatonBib::BibliographicItem:0x0000000113889258
67
56
  ...
68
57
 
69
58
  # get document by ISBN-10
70
- > RelatonIsbn::OpenLibrary.get "0120644819"
71
- [relaton-isbn] (ISBN 0120644819) Fetching from OpenLibrary ...
72
- [relaton-isbn] (ISBN 0120644819) Found: `9780120644810`
59
+ > RelatonIsbn::OpenLibrary.get "isbn:0120644819"
60
+ [relaton-isbn] (isbn:0120644819) Fetching from OpenLibrary ...
61
+ [relaton-isbn] (isbn:0120644819) Found: `9780120644810`
73
62
  => #<RelatonBib::BibliographicItem:0x00000001098ac960
74
63
  ...
75
64
  ----
@@ -129,6 +118,10 @@ To retrieve bibliographic items, use `RelatonIsbn::OpenLibrary.get` method with
129
118
  "place"=>[{"city"=>"Boston"}, {"city"=>"London"}]}
130
119
  ----
131
120
 
121
+ === Logging
122
+
123
+ RelatonIsbn uses the relaton-logger gem for logging. By default, it logs to STDOUT. To change the log levels and add other loggers, read the https://github.com/relaton/relaton-logger#usage[relaton-logger] documentation.
124
+
132
125
  == Development
133
126
 
134
127
  After checking out the repo, run `bin/setup` to install dependencies. Then, run
@@ -6,7 +6,7 @@ module RelatonIsbn
6
6
  # @param [String] isbn ISBN 13 number
7
7
  #
8
8
  def initialize(isbn)
9
- @isbn = isbn&.delete("-")&.sub(/^ISBN\s/, "")
9
+ @isbn = isbn&.delete("-")&.sub(/^ISBN[\s:]/i, "")
10
10
  end
11
11
 
12
12
  def parse
@@ -8,22 +8,22 @@ module RelatonIsbn
8
8
  ENDPOINT = "http://openlibrary.org/api/volumes/brief/isbn/".freeze
9
9
 
10
10
  def get(ref, _date = nil, _opts = {}) # rubocop:disable Metrics/MethodLength
11
- Util.warn "(#{ref}) Fetching from OpenLibrary ..."
11
+ Util.info "Fetching from OpenLibrary ...", key: ref
12
12
 
13
13
  isbn = Isbn.new(ref).parse
14
14
  unless isbn
15
- Util.warn "(#{ref}) Incorrect ISBN."
15
+ Util.info "Incorrect ISBN.", key: ref
16
16
  return
17
17
  end
18
18
 
19
19
  resp = request_api isbn
20
20
  unless resp
21
- Util.warn "(#{ref}) Not found."
21
+ Util.info "Not found.", key: ref
22
22
  return
23
23
  end
24
24
 
25
25
  bib = Parser.parse resp
26
- Util.warn "(#{ref}) Found: `#{bib.docidentifier.first.id}`"
26
+ Util.info "Found: `#{bib.docidentifier.first.id}`", key: ref
27
27
  bib
28
28
  end
29
29
 
@@ -1,9 +1,6 @@
1
1
  module RelatonIsbn
2
2
  module Util
3
3
  extend RelatonBib::Util
4
-
5
- def self.logger
6
- RelatonIsbn.configuration.logger
7
- end
4
+ PROGNAME = "relaton-isbn".freeze
8
5
  end
9
6
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonIsbn
2
- VERSION = "1.18.0".freeze
2
+ VERSION = "1.19.0".freeze
3
3
  end
data/lib/relaton_isbn.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require "net/http"
2
2
  require "relaton_bib"
3
3
  require_relative "relaton_isbn/version"
4
- require_relative "relaton_isbn/config"
5
4
  require_relative "relaton_isbn/util"
6
5
  require_relative "relaton_isbn/isbn"
7
6
  require_relative "relaton_isbn/parser"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-isbn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.0
4
+ version: 1.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-07 00:00:00.000000000 Z
11
+ date: 2024-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: relaton-bib
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.18.0
19
+ version: 1.19.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.18.0
26
+ version: 1.19.0
27
27
  description: 'RelatonIsbn: retrieve publications by ISBN for bibliographic use using
28
28
  the BibliographicItem model'
29
29
  email:
@@ -38,7 +38,6 @@ files:
38
38
  - README.adoc
39
39
  - Rakefile
40
40
  - lib/relaton_isbn.rb
41
- - lib/relaton_isbn/config.rb
42
41
  - lib/relaton_isbn/isbn.rb
43
42
  - lib/relaton_isbn/open_library.rb
44
43
  - lib/relaton_isbn/parser.rb
@@ -67,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
66
  - !ruby/object:Gem::Version
68
67
  version: '0'
69
68
  requirements: []
70
- rubygems_version: 3.3.26
69
+ rubygems_version: 3.3.27
71
70
  signing_key:
72
71
  specification_version: 4
73
72
  summary: 'RelatonIsbn: retrieve publications by ISBN for bibliographic use using the
@@ -1,10 +0,0 @@
1
- module RelatonIsbn
2
- module Config
3
- include RelatonBib::Config
4
- end
5
- extend Config
6
-
7
- class Configuration < RelatonBib::Configuration
8
- PROGNAME = "relaton-isbn".freeze
9
- end
10
- end