alexandrite 0.1.3.pre.alpha → 0.1.4.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/Gemfile +3 -1
- data/lib/alexandrite/version.rb +1 -1
- data/lib/alexandrite.rb +3 -1
- data/lib/alexandrite_book_data.rb +25 -8
- data/sig/alexandrite/alexandrite.rbs +10 -0
- data/sig/alexandrite/book_data.rbs +16 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43a1742c1305de531ba2b4c3b7c68b28763fc0c3193a1e2ab74d47c35a44b260
|
4
|
+
data.tar.gz: 9b3e16191969c872fa000ca8e9fc4c44e9c028b141da68f7d7e54cd911abf2c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2461c44fc9d3324db7bcf84bc060112094f7a17412b3dcf4c339030b08b1b2c8cd5cee52e70e35aa7cb1339a1c6a8d9300cfe5d36a85f64286acb1cb6943f14
|
7
|
+
data.tar.gz: c2bf54e156474abf8a5424b7e953f8e60e646a2ad56fd4f1e33a42fb69775444df92ab90e81bc3c05b8d486df755f0a02be9467f2a17169847b09c4bd82672d7
|
data/Gemfile
CHANGED
data/lib/alexandrite/version.rb
CHANGED
data/lib/alexandrite.rb
CHANGED
@@ -21,6 +21,8 @@ module Alexandrite
|
|
21
21
|
@result = search_with(key, query)
|
22
22
|
end
|
23
23
|
|
24
|
+
# @param [String] key
|
25
|
+
# @param [String] query
|
24
26
|
# @return [nil]
|
25
27
|
def self.create_from_google(key, query)
|
26
28
|
Alexandrite::BookData.create_data(get_volume_info(key, query))
|
@@ -74,7 +76,7 @@ module Alexandrite
|
|
74
76
|
|
75
77
|
# @param key [String]
|
76
78
|
# @param data [Array<String>]
|
77
|
-
# @return [Array<Alexandrite::BookData]
|
79
|
+
# @return [Array<Alexandrite::BookData>]
|
78
80
|
def bulk_create(key, data)
|
79
81
|
bookshelf = []
|
80
82
|
log = Logger.new(STDOUT)
|
@@ -40,20 +40,37 @@ module Alexandrite
|
|
40
40
|
def self.add_industry_identifiers(volume_info, data)
|
41
41
|
return data unless volume_info[:error_message].nil?
|
42
42
|
|
43
|
-
|
43
|
+
assign_isbn(data, volume_info)
|
44
|
+
|
45
|
+
data
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def assign_isbn(data, volume_info)
|
51
|
+
case data[:data_source]
|
52
|
+
when 'OCLC API'
|
44
53
|
data[:isbn10] = volume_info['ISBN_10']
|
45
54
|
data[:isbn13] = volume_info['ISBN_13']
|
46
|
-
|
55
|
+
else
|
56
|
+
select_identifiers(data, volume_info)
|
47
57
|
end
|
48
|
-
begin
|
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
|
-
rescue NoMethodError
|
54
58
|
data
|
59
|
+
end
|
60
|
+
|
61
|
+
def select_identifiers(data, volume_info)
|
62
|
+
return data unless volume_info['industryIdentifiers']
|
63
|
+
|
64
|
+
volume_info['industryIdentifiers'].each do |identifier|
|
65
|
+
data[:isbn10] = identifier['identifier'] if isbn10?(identifier)
|
66
|
+
data[:isbn13] = identifier['identifier'] if isbn13?(identifier)
|
55
67
|
end
|
68
|
+
|
56
69
|
data
|
57
70
|
end
|
71
|
+
|
72
|
+
def isbn10?(identifier) = identifier['type'] == 'ISBN_10'
|
73
|
+
|
74
|
+
def isbn13?(identifier) = identifier['type'] == 'ISBN_13'
|
58
75
|
end
|
59
76
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Alexandrite
|
2
|
+
VERSION: String
|
3
|
+
API: {google: singleton(Google), oclc: singleton(OCLC)}
|
4
|
+
include BookData
|
5
|
+
include ErrorType
|
6
|
+
|
7
|
+
def search_with: (String key, String query, ?api: :google | :oclc) -> (Nokogiri::XML::Document | {error_message: String, results_size: Integer, books: untyped})
|
8
|
+
def create_book: (String key, String query) -> {title: String?, authors: String?, published_date: String?, page_count: String?, description: String?, categories: String?, language: String?, data_source: String, isbn10: String?, isbn13: String?, error_message: String?}
|
9
|
+
def bulk_create: (String key, Array[String] data) -> Array[Hash[Symbol,Object]]
|
10
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Alexandrite
|
2
|
+
module BookData
|
3
|
+
def self.create_data: (Hash[:books | :error_message | :results_size | String, String?] volume_info) -> {title: String?, authors: String?, published_date: String?, page_count: String?, description: String?, categories: String?, language: String?, data_source: String, isbn10: String?, isbn13: String?, error_message: String?}
|
4
|
+
def self.add_basic_values: (Hash[:books | :error_message | :results_size | String, String?] volume_info) -> {title: String?, authors: String?, published_date: String?, page_count: String?, description: String?, categories: String?, language: String?}
|
5
|
+
def self.add_origin: (Hash[:books | :error_message | :results_size | String, String?] volume_info) -> String
|
6
|
+
def self.add_industry_identifiers: (Hash[:books | :error_message | :results_size | String, String?] volume_info, {title: String?, authors: String?, published_date: String?, page_count: String?, description: String?, categories: String?, language: String?, data_source: String} data) -> {title: String?, authors: String?, published_date: String?, page_count: String?, description: String?, categories: String?, language: String?, data_source: String, isbn10: String?, isbn13: String?}
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def assign_isbn: (Hash[Symbol,Object] data, Hash[Symbol,Object] volume_info) -> Hash[Symbol,Object]
|
11
|
+
def select_identifiers: (Hash[Symbol,Object] data, Hash[Symbol,Object] volume_info) -> Hash[Symbol,Object]
|
12
|
+
def isbn10?: (Hash[String, String] identifier)-> bool
|
13
|
+
def isbn13?: -> (Hash[String, String] identifier)-> bool
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
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.1.
|
4
|
+
version: 0.1.4.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-
|
11
|
+
date: 2023-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -164,6 +164,8 @@ files:
|
|
164
164
|
- lib/helpers/file_handler.rb
|
165
165
|
- lib/helpers/format.rb
|
166
166
|
- lib/helpers/validation.rb
|
167
|
+
- sig/alexandrite/alexandrite.rbs
|
168
|
+
- sig/alexandrite/book_data.rbs
|
167
169
|
- spec/alexandrite_spec.rb
|
168
170
|
- spec/factories/book.rb
|
169
171
|
- spec/helpers/format_spec.rb
|
@@ -189,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
191
|
- !ruby/object:Gem::Version
|
190
192
|
version: 1.3.1
|
191
193
|
requirements: []
|
192
|
-
rubygems_version: 3.
|
194
|
+
rubygems_version: 3.3.7
|
193
195
|
signing_key:
|
194
196
|
specification_version: 4
|
195
197
|
summary: Tools for fetching books data from Google and OCLC
|