alexandrite 0.0.1 → 0.1.1.pre.alpha
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 +4 -4
- data/.gitignore +1 -0
- data/README.md +21 -19
- data/bookshelf.dump +10 -0
- data/data.dump +0 -0
- data/lib/alexandrite/version.rb +1 -1
- data/lib/alexandrite.rb +23 -28
- data/lib/alexandrite_book_data.rb +57 -0
- data/lib/alexandrite_bookshelf.rb +42 -4
- data/lib/alexandrite_google.rb +7 -0
- data/lib/alexandrite_oclc.rb +7 -6
- data/lib/helpers/file_handler.rb +19 -0
- data/test_library.dump +0 -0
- metadata +10 -6
- data/lib/alexandrite_books.rb +0 -73
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b04594e2817421efbc7843faddd9ea5b6bee3ff093d52c4328d3fa1b76680905
|
4
|
+
data.tar.gz: 6ec96b26a30b7609dcdf2da25ce6ccaf38279d3fb232da07327e6699b39661ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b028aba504cc9e5f14deac610c81eb1c18066b90a563f0d9486cd6f06ca4b3a1be803333417fd0c06240be1db021842d334088695d512d06ea873dbd4f126b08
|
7
|
+
data.tar.gz: 66563405941ad6bd600b26466d229eb93929de988848547305322e878d3642df4da7cba555eafa3f22c055ea5c07314a85bc5028c70d352c5479a535324d8e06
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,18 @@
|
|
1
|
-
#
|
1
|
+
# Alexandrite GEM
|
2
|
+
[](https://badge.fury.io/rb/alexandrite)
|
2
3
|
|
3
|
-
|
4
|
+
Alexandrite is a gem that fetches book's data by ISBN number and other parameters from the [Google API](https://developers.google.com/books) and [OCLC API](http://classify.oclc.org/classify2/). It's intended to help librarians and bibliophiles to manage their bookshelves and classify their books.
|
4
5
|
|
5
|
-
|
6
|
-
- Structure data
|
6
|
+
With Alexandrite, it's
|
7
7
|
|
8
|
-
|
8
|
+
- Easy to get all information by ISBN and other parameters
|
9
|
+
- Structure data
|
10
|
+
|
11
|
+
## Features
|
9
12
|
|
13
|
+
- Retrieves Book data from Google API and OCLC API
|
14
|
+
- Suggest a Dewey Decimal Classification or a Library of Congress Classification with OCLC Data.
|
15
|
+
- Add data to a virtual collection
|
10
16
|
|
11
17
|
|
12
18
|
### Version
|
@@ -14,6 +20,7 @@ You don't have to call manually Google API with ISBN number. This gem will do ev
|
|
14
20
|
|
15
21
|
|
16
22
|
### Installation
|
23
|
+
|
17
24
|
Add this line to your application's Gemfile:
|
18
25
|
|
19
26
|
```ruby
|
@@ -32,9 +39,13 @@ Or install it yourself as globally:
|
|
32
39
|
gem install alexandrite
|
33
40
|
```
|
34
41
|
|
42
|
+
## Usage
|
43
|
+
|
44
|
+
Currently, Alexandrite is divided on four modules: Alexandrite, Alexandrite::Book, Alexandrite::GoogleAPI, and AlexandriteOCLCAPI. Require Alexandrite if you want to use an integration of all the modules, or use each module separately.
|
45
|
+
|
35
46
|
|
36
47
|
## Examples
|
37
|
-
book =
|
48
|
+
book = Alexandrite.create_book("0262033844")
|
38
49
|
|
39
50
|
book.title
|
40
51
|
#=> "Introduction to Algorithms"
|
@@ -52,17 +63,7 @@ gem install alexandrite
|
|
52
63
|
#=> 0262033844
|
53
64
|
|
54
65
|
book.isbn_13
|
55
|
-
#=>
|
56
|
-
|
57
|
-
book.thumbnail
|
58
|
-
#=> http://books.google.com/books/content?id=i-bUBQAAQBAJ&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api
|
59
|
-
|
60
|
-
book.preview
|
61
|
-
#=> http://books.google.ca/books?id=i-bUBQAAQBAJ&printsec=frontcover&dq=isbn:0262033844&hl=&cd=1&source=gbs_api
|
62
|
-
|
63
|
-
|
64
|
-
book.gisbn.isbn = 9780321573513
|
65
|
-
book.fetch.title => "Algorithms"
|
66
|
+
#=> 978026203384
|
66
67
|
|
67
68
|
|
68
69
|
|
@@ -100,11 +101,12 @@ Want to contribute? Great!
|
|
100
101
|
|
101
102
|
Author
|
102
103
|
-----------
|
103
|
-
[
|
104
|
+
[J. P. Pérez-Tejada](https://mx.linkedin.com/in/juanpaulopereztejada)
|
104
105
|
|
105
|
-
|
106
|
+
Gem inspired on GISBN. Special greetings to:
|
106
107
|
-----------
|
107
108
|
[Matt Seeberger](https://github.com/thebeardedgeek)
|
109
|
+
[Eftakhairul Islam](https://eftakhairul.com)
|
108
110
|
|
109
111
|
License
|
110
112
|
----
|
data/bookshelf.dump
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
o:Alexandrite::Bookshelf:@collection_nameI"Test Bookshelf:ET:@book_collection[
|
2
|
+
I"Google API;T;I"Pedro Páramo;T;[I"Juan Rulfo;TI"Josephine Sacabo;TI"Margaret Sayers Peden;T;
|
3
|
+
@;I".Todo queda en familia (All in the Family);T;[I"Dona Herweck Rice;T;
|
4
|
+
@;I"Todo queda en familia;T;[I"Cristina Padilla Dieste;T;
|
5
|
+
@ ;0;0;
|
6
|
+
o; ;
|
7
|
+
@ ;0;0;
|
8
|
+
o; ;
|
9
|
+
@;I" Cómo llegar a ser japonés;T;[I"Ramón Illán Bacca;T;
|
10
|
+
@ ;I"#Sociedad, naturaleza y turismo;T;I"�Seminario Internacional Nuevas Alternativas del Turismo (4th : 2010 : Universidad de Guadalajara. Centro Universitario de la Costa) | Arnáiz Burne, Stella Maris [Author] | Virgen Aguilar, Carlos Rogelio [Author];T;
|
data/data.dump
ADDED
Binary file
|
data/lib/alexandrite/version.rb
CHANGED
data/lib/alexandrite.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '
|
3
|
+
require_relative 'alexandrite_book_data'
|
4
4
|
require_relative 'alexandrite_google'
|
5
5
|
require_relative 'alexandrite_oclc'
|
6
6
|
require_relative 'error_type/errors'
|
@@ -8,37 +8,39 @@ require_relative 'error_type/errors'
|
|
8
8
|
# Main gem methods for creating books from ISBN
|
9
9
|
module Alexandrite
|
10
10
|
include ErrorType
|
11
|
+
include Alexandrite::BookData
|
11
12
|
|
12
13
|
# Get and Process data from Google API
|
13
14
|
class Google
|
15
|
+
include Alexandrite
|
14
16
|
extend Alexandrite::GoogleAPI
|
15
17
|
|
16
18
|
attr_reader :result
|
17
19
|
|
18
20
|
def initialize(key, query)
|
19
|
-
@result =
|
21
|
+
@result = search_with(key, query)
|
20
22
|
end
|
21
23
|
|
22
|
-
# @return [Alexandrite::
|
23
|
-
def self.
|
24
|
-
|
25
|
-
Alexandrite::Book.new(volume_info)
|
24
|
+
# @return [Alexandrite::BookData]
|
25
|
+
def self.create_from_google(key, query)
|
26
|
+
Alexandrite::BookData.create_data(get_volume_info(key, query))
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
29
30
|
# Get and Process data from OCLC API
|
30
31
|
class OCLC
|
32
|
+
include Alexandrite
|
31
33
|
extend Alexandrite::OCLCAPI
|
32
34
|
|
33
35
|
attr_reader :result
|
34
36
|
|
35
37
|
# return [Alexandrite::OCLC]
|
36
38
|
def initialize(key, query, api: :oclc)
|
37
|
-
@result =
|
39
|
+
@result = search_with(key, query, api: api)
|
38
40
|
end
|
39
41
|
|
40
|
-
# @return [Alexandrite::
|
41
|
-
def self.
|
42
|
+
# @return [Alexandrite::BookData]
|
43
|
+
def self.create_from_oclc(type, identifier)
|
42
44
|
query = Alexandrite::OCLC.new(type, identifier)
|
43
45
|
response_code = get_response_code(query.result)
|
44
46
|
|
@@ -51,34 +53,27 @@ module Alexandrite
|
|
51
53
|
oclc: Alexandrite::OCLC
|
52
54
|
}.freeze
|
53
55
|
|
54
|
-
def
|
56
|
+
def search_with(key, query, api: :google)
|
55
57
|
API[api].search_by(key, query)
|
56
58
|
end
|
57
59
|
|
58
60
|
def create_book(key, query)
|
59
|
-
book = API[:google].
|
60
|
-
return API[:oclc].
|
61
|
+
book = API[:google].create_from_google(key, query)
|
62
|
+
return API[:oclc].create_from_oclc(key, query) if book[:error_message]
|
61
63
|
|
62
64
|
book
|
63
65
|
end
|
64
66
|
|
65
|
-
# @param
|
66
|
-
# @
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
67
|
+
# @param key [String]
|
68
|
+
# @param data [Array<String>]
|
69
|
+
# @return [Array<Alexandrite::BookData]
|
70
|
+
def bulk_create(key, data)
|
71
|
+
bookshelf = []
|
72
|
+
data.each do |query|
|
73
|
+
book = create_book(key, query)
|
74
|
+
bookshelf << book
|
72
75
|
end
|
73
|
-
nil
|
74
|
-
end
|
75
|
-
|
76
|
-
private
|
77
|
-
|
78
|
-
def get_volume_info(isbn)
|
79
|
-
query = search_by(:isbn, isbn)
|
80
|
-
return query[:books].first[:volume_info] unless query[:error_message]
|
81
76
|
|
82
|
-
|
77
|
+
bookshelf
|
83
78
|
end
|
84
79
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'alexandrite'
|
4
|
+
require 'nokogiri'
|
5
|
+
|
6
|
+
module Alexandrite
|
7
|
+
# Create a book objects
|
8
|
+
module BookData
|
9
|
+
# @param volume_info [Hash]
|
10
|
+
# @return [Hash]
|
11
|
+
def self.create_data(volume_info)
|
12
|
+
data = add_basic_values(volume_info)
|
13
|
+
data[:data_source] = add_origin(volume_info)
|
14
|
+
data = add_industry_identifiers(volume_info, data)
|
15
|
+
data[:error_message] = volume_info[:error_message]
|
16
|
+
|
17
|
+
data
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.add_basic_values(volume_info)
|
21
|
+
{
|
22
|
+
title: volume_info['title'],
|
23
|
+
authors: volume_info['authors'],
|
24
|
+
published_date: volume_info['publisher'],
|
25
|
+
page_count: volume_info['pageCount'],
|
26
|
+
description: volume_info['description'],
|
27
|
+
categories: volume_info['categories'],
|
28
|
+
language: volume_info['language']
|
29
|
+
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# @param [Hash] volume_info
|
34
|
+
# @return [String]
|
35
|
+
def self.add_origin(volume_info) = volume_info['origin'] || 'Google API'
|
36
|
+
|
37
|
+
# @param [Hash] volume_info
|
38
|
+
# @param [Hash] data
|
39
|
+
# @return [NilClass]
|
40
|
+
def self.add_industry_identifiers(volume_info, data)
|
41
|
+
return data unless volume_info[:error_message].nil?
|
42
|
+
|
43
|
+
if data[:data_source] == 'OCLC API'
|
44
|
+
data[:isbn10] = volume_info['ISBN_10']
|
45
|
+
data[:isbn13] = volume_info['ISBN_13']
|
46
|
+
return data
|
47
|
+
end
|
48
|
+
|
49
|
+
volume_info['industryIdentifiers'].each do |identifier|
|
50
|
+
data[:isbn10] = identifier['identifier'] if identifier['type'] == 'ISBN_10'
|
51
|
+
data[:isbn13] = identifier['identifier'] if identifier['type'] == 'ISBN_13'
|
52
|
+
end
|
53
|
+
|
54
|
+
data
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -1,15 +1,53 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'alexandrite'
|
4
|
-
require_relative '
|
4
|
+
require_relative 'alexandrite_book_data'
|
5
|
+
require_relative 'helpers/file_handler'
|
5
6
|
|
6
7
|
# Create, Read, Update and Delete books in a book collection
|
7
8
|
module Alexandrite
|
8
9
|
# Create a collection of books
|
9
10
|
class Bookshelf
|
10
|
-
|
11
|
-
|
11
|
+
extend Alexandrite::Helpers::FileHandler
|
12
|
+
|
13
|
+
@@library = {}
|
14
|
+
|
15
|
+
attr_accessor :book_collection
|
16
|
+
|
17
|
+
attr_reader :collection_name
|
18
|
+
|
19
|
+
def initialize(collection_name, books = nil)
|
20
|
+
@collection_name = collection_name.to_sym
|
21
|
+
@book_collection = [books]
|
22
|
+
end
|
23
|
+
|
24
|
+
def save_bookshelf(file_path)
|
25
|
+
save(file_path, self)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.add_bookshelf(file_path)
|
29
|
+
bookshelf = open(file_path)
|
30
|
+
@@library[bookshelf.collection_name.to_sym] = bookshelf if bookshelf.instance_of?(Alexandrite::Bookshelf)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.charge_library(file_path)
|
34
|
+
bookshelves = open(file_path)
|
35
|
+
@@library = bookshelves if bookshelves.all?(Alexandrite::Bookshelf)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.save_library(file_path)
|
39
|
+
save(file_path, @@library)
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.show_library
|
43
|
+
@@library
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.find_bookshelf(bookshelf_name)
|
47
|
+
query = @@library[bookshelf_name.to_sym]
|
48
|
+
return "Bookshelf wasn't found. Check collection name" if query.nil?
|
49
|
+
|
50
|
+
query
|
12
51
|
end
|
13
52
|
end
|
14
|
-
def add_book(book) = @book_collection << book if book.instance_of?(Alexandrite::Book)
|
15
53
|
end
|
data/lib/alexandrite_google.rb
CHANGED
@@ -62,6 +62,13 @@ module Alexandrite
|
|
62
62
|
|
63
63
|
private
|
64
64
|
|
65
|
+
def get_volume_info(key, query)
|
66
|
+
query = search_by(key, query)
|
67
|
+
return query[:books].first['volumeInfo'] unless query[:error_message]
|
68
|
+
|
69
|
+
query
|
70
|
+
end
|
71
|
+
|
65
72
|
def zero_results?(response_body) = response_body['totalItems'].zero?
|
66
73
|
|
67
74
|
def process_response(response)
|
data/lib/alexandrite_oclc.rb
CHANGED
@@ -17,6 +17,7 @@ module Alexandrite
|
|
17
17
|
include Nokogiri
|
18
18
|
include Alexandrite::Helpers::Format
|
19
19
|
include Alexandrite::Helpers::Validation
|
20
|
+
include Alexandrite::BookData
|
20
21
|
|
21
22
|
BASE_URL = 'http://classify.oclc.org/classify2/Classify?'
|
22
23
|
|
@@ -50,6 +51,7 @@ module Alexandrite
|
|
50
51
|
|
51
52
|
private
|
52
53
|
|
54
|
+
# @return [Integer]
|
53
55
|
def get_response_code(result) = result.css('response').attribute('code').value.to_i
|
54
56
|
|
55
57
|
def get_owis(result, length)
|
@@ -82,21 +84,20 @@ module Alexandrite
|
|
82
84
|
end
|
83
85
|
|
84
86
|
def create_new_book(query)
|
85
|
-
|
86
|
-
Alexandrite::Book.new(volume_info)
|
87
|
+
Alexandrite::BookData.create_data(get_book_data(query.result))
|
87
88
|
end
|
88
89
|
|
89
90
|
def retry_create_new_book(query)
|
90
91
|
owi = get_owis(query.result, 1)[0]
|
91
92
|
new_query = Alexandrite::OCLC.new('owi', owi)
|
92
93
|
volume_info = get_book_data(new_query.result)
|
93
|
-
Alexandrite::
|
94
|
+
Alexandrite::BookData.create_data(volume_info)
|
94
95
|
end
|
95
96
|
|
96
97
|
def handle_error_creating_book(query)
|
97
|
-
raise ErrorType::DataNotFound, response_cases(query, 0, 'none')
|
98
|
+
raise ErrorType::DataNotFound, response_cases(query.result, 0, 'none')
|
98
99
|
rescue StandardError => e
|
99
|
-
Alexandrite::
|
100
|
+
Alexandrite::BookData.create_data({ :error_message => e.message, 'origin' => 'OCLC API' })
|
100
101
|
end
|
101
102
|
|
102
103
|
# @param [Nokogiri::XML] result
|
@@ -104,7 +105,7 @@ module Alexandrite
|
|
104
105
|
# @param [String] mode Possible: 'ddc' or 'lcc'
|
105
106
|
# @return [String]
|
106
107
|
def response_cases(result, length, mode)
|
107
|
-
code = get_response_code(result)
|
108
|
+
code = get_response_code(result)
|
108
109
|
case code
|
109
110
|
when 0
|
110
111
|
get_classification(result, mode)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Alexandrite
|
4
|
+
module Helpers
|
5
|
+
# Save files of books
|
6
|
+
module FileHandler
|
7
|
+
# @param [String] file_name
|
8
|
+
# @param [Array<Object>] data
|
9
|
+
def save(file_name, data)
|
10
|
+
File.open(file_name, 'w') { |f| f.write Marshal.dump(data) }
|
11
|
+
end
|
12
|
+
|
13
|
+
def open(file_name)
|
14
|
+
file = File.open(file_name)
|
15
|
+
Marshal.load(file)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/test_library.dump
ADDED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alexandrite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1.pre.alpha
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- J. P. Pérez-Tejada
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -152,13 +152,16 @@ files:
|
|
152
152
|
- README.md
|
153
153
|
- Rakefile
|
154
154
|
- alexandrite.gemspec
|
155
|
+
- bookshelf.dump
|
156
|
+
- data.dump
|
155
157
|
- lib/alexandrite.rb
|
156
158
|
- lib/alexandrite/version.rb
|
157
|
-
- lib/
|
159
|
+
- lib/alexandrite_book_data.rb
|
158
160
|
- lib/alexandrite_bookshelf.rb
|
159
161
|
- lib/alexandrite_google.rb
|
160
162
|
- lib/alexandrite_oclc.rb
|
161
163
|
- lib/error_type/errors.rb
|
164
|
+
- lib/helpers/file_handler.rb
|
162
165
|
- lib/helpers/format.rb
|
163
166
|
- lib/helpers/validation.rb
|
164
167
|
- spec/alexandrite_spec.rb
|
@@ -166,6 +169,7 @@ files:
|
|
166
169
|
- spec/helpers/format_spec.rb
|
167
170
|
- spec/spec_helper.rb
|
168
171
|
- spec/support/vcr_setup.rb
|
172
|
+
- test_library.dump
|
169
173
|
homepage: https://github.com/maclenn77/alexandrite
|
170
174
|
licenses:
|
171
175
|
- MIT
|
@@ -181,11 +185,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
181
185
|
version: '3.0'
|
182
186
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
183
187
|
requirements:
|
184
|
-
- - "
|
188
|
+
- - ">"
|
185
189
|
- !ruby/object:Gem::Version
|
186
|
-
version:
|
190
|
+
version: 1.3.1
|
187
191
|
requirements: []
|
188
|
-
rubygems_version: 3.3.
|
192
|
+
rubygems_version: 3.3.7
|
189
193
|
signing_key:
|
190
194
|
specification_version: 4
|
191
195
|
summary: Tools for fetching books data from Google and OCLC
|
data/lib/alexandrite_books.rb
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'alexandrite'
|
4
|
-
|
5
|
-
module Alexandrite
|
6
|
-
# Create a book objects
|
7
|
-
class Book
|
8
|
-
attr_accessor :title, :authors, :publisher, :published_date, :page_count, :description, :categories, :language,
|
9
|
-
:country, :isbn10, :isbn13, :error_message, :ddc, :lcc, :suggested_classifications
|
10
|
-
|
11
|
-
# @param volume_info [Hash]
|
12
|
-
# @return [Alexandrite::Books]
|
13
|
-
def initialize(volume_info)
|
14
|
-
add_origin(volume_info)
|
15
|
-
add_basic_values(volume_info)
|
16
|
-
add_industry_identifiers(volume_info, @origin)
|
17
|
-
@error_message = volume_info[:error_message]
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.collection = @@collection
|
21
|
-
|
22
|
-
def self.add_to_collection(book)
|
23
|
-
@@collection.push(book)
|
24
|
-
end
|
25
|
-
|
26
|
-
# @param [String] ddc_code
|
27
|
-
# @return [NilClass]
|
28
|
-
def add_ddc(ddc_code) = @ddc = ddc_code
|
29
|
-
|
30
|
-
# @param [String] lcc_code
|
31
|
-
# @return [NilClass]
|
32
|
-
def add_lcc(lcc_code) = @lcc = lcc_code
|
33
|
-
|
34
|
-
# @param [Array<String>] suggestions
|
35
|
-
# @return [NilClass]
|
36
|
-
def add_classification_suggested(suggestions) = @suggested_classifications = suggestions
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def add_basic_values(volume_info)
|
41
|
-
@title = volume_info['title']
|
42
|
-
@authors = volume_info['authors']
|
43
|
-
@publisher = volume_info['publisher']
|
44
|
-
@published_date = volume_info['publishedDate']
|
45
|
-
@page_count = volume_info['pageCount']
|
46
|
-
@description = volume_info['description']
|
47
|
-
@categories = volume_info['categories']
|
48
|
-
@language = volume_info['language']
|
49
|
-
end
|
50
|
-
|
51
|
-
# @param [Hash] volume_info
|
52
|
-
# @return [String]
|
53
|
-
def add_origin(volume_info) = @origin = volume_info['origin'] || 'Google API'
|
54
|
-
|
55
|
-
# @param [Hash] volume_info
|
56
|
-
# @param [String] origin
|
57
|
-
# @return [NilClass]
|
58
|
-
def add_industry_identifiers(volume_info, origin)
|
59
|
-
return nil unless volume_info[:error_message].nil?
|
60
|
-
|
61
|
-
if origin == 'OCLC API'
|
62
|
-
@isbn10 = volume_info['ISBN_10']
|
63
|
-
@isbn13 = volume_info['ISBN_13']
|
64
|
-
return
|
65
|
-
end
|
66
|
-
|
67
|
-
volume_info['industryIdentifiers'].each do |identifier|
|
68
|
-
@isbn10 = identifier['identifier'] if identifier['type'] == 'ISBN_10'
|
69
|
-
@isbn13 = identifier['identifier'] if identifier['type'] == 'ISBN_13'
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|