isbndb-ruby 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +224 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/isbndb-ruby.gemspec +50 -0
- data/lib/isbndb.rb +19 -0
- data/lib/isbndb/api/author.rb +23 -0
- data/lib/isbndb/api/book.rb +23 -0
- data/lib/isbndb/api/publisher.rb +23 -0
- data/lib/isbndb/api/subject.rb +23 -0
- data/lib/isbndb/api_client.rb +71 -0
- data/lib/isbndb/version.rb +3 -0
- metadata +225 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 94484c0b78f93fd8ca655721ade1d7cf4bb8de2a
|
4
|
+
data.tar.gz: 2f74514daa98ee4408651ae68dc4238308c6d8ec
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cccceb7e3526e0cb4b379001ea2f64c482acca20767f4f9f52b1e4f9814eb3ac9acdd69bb83eeb91935c3565c14fb13dae37afb7580522ff95f609d31f123d94
|
7
|
+
data.tar.gz: bcb723b49293fce2e6ca3fc2e45e610dc5e720a40d7f4f7e02de0661179148887c26dbfe3b8312306febc7da88a4f4a1ce26047e233f4d22d684dc47d230f2ca
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at sampat.badhe@kiprosh.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2020 Sampat Badhe
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,224 @@
|
|
1
|
+
# Ruby library for ISBNdb API v2
|
2
|
+
|
3
|
+
[![Build Status](https://semaphoreci.com/api/v1/sampat-badhe/isbndb-ruby/branches/master/badge.svg)](https://semaphoreci.com/sampat-badhe/isbndb-ruby)
|
4
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/b3e523707c8cbaf73ea3/test_coverage)](https://codeclimate.com/github/sampatbadhe/isbndb-ruby/test_coverage)
|
5
|
+
|
6
|
+
* [Homepage](https://isbndb.com/)
|
7
|
+
* [API Documentation](https://isbndb.com/apidocs/v2)
|
8
|
+
* [Register](https://isbndb.com/isbn-database)
|
9
|
+
|
10
|
+
## Description
|
11
|
+
|
12
|
+
Provides a Ruby interface to [ISBNdb](https://isbndb.com/). This library is designed to help ruby applications consume the ISBNdb API v2.
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'isbndb-ruby'
|
20
|
+
```
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
|
24
|
+
$ bundle
|
25
|
+
|
26
|
+
Or install it yourself as:
|
27
|
+
|
28
|
+
$ gem install isbndb-ruby
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
### Setup
|
33
|
+
|
34
|
+
Register for your API KEY at https://isbndb.com/isbn-database
|
35
|
+
|
36
|
+
**Initialize**
|
37
|
+
```ruby
|
38
|
+
require 'isbndb-ruby'
|
39
|
+
|
40
|
+
isbndb_api_client = ISBNdb::ApiClient.new(api_key: api_key)
|
41
|
+
```
|
42
|
+
|
43
|
+
**Account Stats**
|
44
|
+
```ruby
|
45
|
+
#=> Returns a status object about the ISBNDB database.
|
46
|
+
isbndb_api_client.stats
|
47
|
+
```
|
48
|
+
|
49
|
+
**Author**
|
50
|
+
|
51
|
+
- Get single author details
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
#=> Returns the author name and a list of books by the author.
|
55
|
+
isbndb_api_client.author.find(name, options)
|
56
|
+
name = `The name of an author in the Author's database`
|
57
|
+
options = {
|
58
|
+
page: 1,
|
59
|
+
pageSize: 20
|
60
|
+
}
|
61
|
+
```
|
62
|
+
|
63
|
+
- Authors List
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
#=> This returns a list of authors who's name matches the given query.
|
67
|
+
isbndb_api_client.author.batch(query, options)
|
68
|
+
query = `A string to search for in the Author’s database`
|
69
|
+
options = {
|
70
|
+
page: 1, # for books
|
71
|
+
pageSize: 20 # for books
|
72
|
+
}
|
73
|
+
```
|
74
|
+
|
75
|
+
- Authors Search
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
#=> This returns a list of authors who's name matches the given query.
|
79
|
+
isbndb_api_client.author.search(options)
|
80
|
+
options = {
|
81
|
+
page: 1,
|
82
|
+
pageSize: 20,
|
83
|
+
author: `The name of an author in the Author's database`,
|
84
|
+
text: `A string to search for determinate author database`
|
85
|
+
}
|
86
|
+
```
|
87
|
+
|
88
|
+
**Book**
|
89
|
+
|
90
|
+
- Get single book details
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
#=> Returns the book details
|
94
|
+
isbndb_api_client.book.find(isbn)
|
95
|
+
isbn = `an ISBN 10 or ISBN 13 in the Books database`
|
96
|
+
```
|
97
|
+
|
98
|
+
- Books List
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
#=> This returns a list of books that match the query
|
102
|
+
isbndb_api_client.book.batch(query, options)
|
103
|
+
query = `A string to search for in the Book’s database`
|
104
|
+
options = {
|
105
|
+
page: 1,
|
106
|
+
pageSize: 20,
|
107
|
+
column: specify the column to search
|
108
|
+
- '' - Empty value search in every column
|
109
|
+
- title - Only searches in Books Title
|
110
|
+
- author - Only searches books by the given Author
|
111
|
+
- Available values : , title, author,
|
112
|
+
beta: A integer (1 or 0) for enable or disable beta searching.
|
113
|
+
Default value : 0 (disabled)
|
114
|
+
```
|
115
|
+
|
116
|
+
- Books Search
|
117
|
+
|
118
|
+
```ruby
|
119
|
+
#=> This returns a list of authors who's name matches the given query.
|
120
|
+
isbndb_api_client.author.search(options)
|
121
|
+
options = {
|
122
|
+
page: 1,
|
123
|
+
pageSize: 20,
|
124
|
+
isbn: `an ISBN 10 in the Books database`,
|
125
|
+
isbn13: `an ISBN 13 in the Books database`,
|
126
|
+
text: `A string to search for determinate author database`
|
127
|
+
}
|
128
|
+
```
|
129
|
+
|
130
|
+
**Publisher**
|
131
|
+
|
132
|
+
- Get single publisher details
|
133
|
+
|
134
|
+
```ruby
|
135
|
+
#=> Returns the publisher name and a list of books by the publisher.
|
136
|
+
isbndb_api_client.publisher.find(name, options)
|
137
|
+
name = `The name of a publisher in the Publisher's database`
|
138
|
+
options = {
|
139
|
+
page: 1,
|
140
|
+
pageSize: 20
|
141
|
+
}
|
142
|
+
```
|
143
|
+
|
144
|
+
- Publishers List
|
145
|
+
|
146
|
+
```ruby
|
147
|
+
#=> This returns a list of publishers who's name matches the given query.
|
148
|
+
isbndb_api_client.publisher.batch(query, options)
|
149
|
+
query = `A string to search for in the Publisher’s database`
|
150
|
+
options = {
|
151
|
+
page: 1, # for books
|
152
|
+
pageSize: 20 # for books
|
153
|
+
}
|
154
|
+
```
|
155
|
+
|
156
|
+
- Publishers Search
|
157
|
+
|
158
|
+
```ruby
|
159
|
+
#=> This returns a list of publishers who's name matches the given query.
|
160
|
+
isbndb_api_client.publisher.search(options)
|
161
|
+
options = {
|
162
|
+
page: 1,
|
163
|
+
pageSize: 20,
|
164
|
+
publisher: `The name of an publisher in the publisher's database`,
|
165
|
+
text: `A string to search for determinate publisher database`
|
166
|
+
}
|
167
|
+
```
|
168
|
+
|
169
|
+
**Subject**
|
170
|
+
|
171
|
+
- Get single subject details
|
172
|
+
|
173
|
+
```ruby
|
174
|
+
#=> Returns the subject name and a list of books by the subject.
|
175
|
+
isbndb_api_client.subject.find(name, options)
|
176
|
+
name = `A subject in the Subject's database`
|
177
|
+
options = {
|
178
|
+
page: 1,
|
179
|
+
pageSize: 20
|
180
|
+
}
|
181
|
+
```
|
182
|
+
|
183
|
+
- Subjects List
|
184
|
+
|
185
|
+
```ruby
|
186
|
+
#=> This returns a list of subjects matches the given query.
|
187
|
+
isbndb_api_client.subject.batch(query, options)
|
188
|
+
query = `A string to search for in the Subject’s database`
|
189
|
+
options = {
|
190
|
+
page: 1, # for books
|
191
|
+
pageSize: 20 # for books
|
192
|
+
}
|
193
|
+
```
|
194
|
+
|
195
|
+
- Subjects Search
|
196
|
+
|
197
|
+
```ruby
|
198
|
+
#=> This returns a list of subjects who's name matches the given query.
|
199
|
+
isbndb_api_client.subject.search(options)
|
200
|
+
options = {
|
201
|
+
page: 1,
|
202
|
+
pageSize: 20,
|
203
|
+
subject: `A subject in the Subject's database`,
|
204
|
+
text: `A string to search for determinate subject database`
|
205
|
+
}
|
206
|
+
```
|
207
|
+
|
208
|
+
## Development
|
209
|
+
|
210
|
+
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.
|
211
|
+
|
212
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
213
|
+
|
214
|
+
## Contributing
|
215
|
+
|
216
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/isbndb-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
217
|
+
|
218
|
+
## License
|
219
|
+
|
220
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
221
|
+
|
222
|
+
## Code of Conduct
|
223
|
+
|
224
|
+
Everyone interacting in the ISBNdb project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/isbndb-ruby/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "isbndb"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/isbndb-ruby.gemspec
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "isbndb/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "isbndb-ruby"
|
7
|
+
spec.version = ISBNdb::VERSION
|
8
|
+
spec.authors = ["sampatbadhe"]
|
9
|
+
spec.email = ["sampat.badhe@kiprosh.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{Library for communicating with the ISBNdb.com's v2 API}
|
12
|
+
spec.description = %q{Library for communicating with the ISBNdb.com's v2 API}
|
13
|
+
spec.homepage = "https://github.com/sampatbadhe/isbndb-ruby"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
20
|
+
|
21
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
22
|
+
spec.metadata["source_code_uri"] = "https://github.com/sampatbadhe/isbndb-ruby"
|
23
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
24
|
+
else
|
25
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
26
|
+
"public gem pushes."
|
27
|
+
end
|
28
|
+
|
29
|
+
# Specify which files should be added to the gem when it is released.
|
30
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
31
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
32
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
33
|
+
end
|
34
|
+
spec.bindir = "exe"
|
35
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
36
|
+
spec.require_paths = ["lib"]
|
37
|
+
|
38
|
+
spec.add_runtime_dependency 'httparty', '~> 0.13'
|
39
|
+
spec.add_runtime_dependency 'plissken', '~> 1.2'
|
40
|
+
|
41
|
+
spec.add_development_dependency "bundler"
|
42
|
+
spec.add_development_dependency "rake", '~> 12.3', '>= 12.3.3'
|
43
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
44
|
+
spec.add_development_dependency 'simplecov'
|
45
|
+
spec.add_development_dependency 'coveralls'
|
46
|
+
spec.add_development_dependency 'pry', '~> 0.12'
|
47
|
+
spec.add_development_dependency 'rubocop', '~> 0.49.0'
|
48
|
+
spec.add_development_dependency 'webmock', '~> 2.1'
|
49
|
+
spec.add_development_dependency 'travis', '~> 1.8'
|
50
|
+
end
|
data/lib/isbndb.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# vendors
|
2
|
+
require 'httparty'
|
3
|
+
require 'plissken'
|
4
|
+
|
5
|
+
# helpers w/o dependencies
|
6
|
+
require "isbndb/version"
|
7
|
+
|
8
|
+
# auth classes
|
9
|
+
require 'isbndb/api_client'
|
10
|
+
|
11
|
+
# isbndb endpoints
|
12
|
+
require 'isbndb/api/author'
|
13
|
+
require 'isbndb/api/book'
|
14
|
+
require 'isbndb/api/publisher'
|
15
|
+
require 'isbndb/api/subject'
|
16
|
+
|
17
|
+
module ISBNdb
|
18
|
+
class RequestError < StandardError; end
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ISBNdb
|
2
|
+
module Api
|
3
|
+
class Author
|
4
|
+
attr_reader :client
|
5
|
+
|
6
|
+
def initialize(client:)
|
7
|
+
@client = client
|
8
|
+
end
|
9
|
+
|
10
|
+
def find(name, options = {})
|
11
|
+
@client.request("/author/#{name}", options)
|
12
|
+
end
|
13
|
+
|
14
|
+
def batch(query, options = {})
|
15
|
+
@client.request("/authors/#{query}", options)
|
16
|
+
end
|
17
|
+
|
18
|
+
def search(options = {})
|
19
|
+
@client.request("/search/authors/", options)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ISBNdb
|
2
|
+
module Api
|
3
|
+
class Book
|
4
|
+
attr_reader :client
|
5
|
+
|
6
|
+
def initialize(client:)
|
7
|
+
@client = client
|
8
|
+
end
|
9
|
+
|
10
|
+
def find(isbn)
|
11
|
+
@client.request("/book/#{isbn}")
|
12
|
+
end
|
13
|
+
|
14
|
+
def batch(query, options = {})
|
15
|
+
@client.request("/books/#{query}", options)
|
16
|
+
end
|
17
|
+
|
18
|
+
def search(options = {})
|
19
|
+
@client.request("/search/books/", options)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ISBNdb
|
2
|
+
module Api
|
3
|
+
class Publisher
|
4
|
+
attr_reader :client
|
5
|
+
|
6
|
+
def initialize(client:)
|
7
|
+
@client = client
|
8
|
+
end
|
9
|
+
|
10
|
+
def find(name)
|
11
|
+
@client.request("/publisher/#{name}")
|
12
|
+
end
|
13
|
+
|
14
|
+
def batch(query, options = {})
|
15
|
+
@client.request("/publishers/#{query}", options)
|
16
|
+
end
|
17
|
+
|
18
|
+
def search(options = {})
|
19
|
+
@client.request("/search/publishers/", options)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ISBNdb
|
2
|
+
module Api
|
3
|
+
class Subject
|
4
|
+
attr_reader :client
|
5
|
+
|
6
|
+
def initialize(client:)
|
7
|
+
@client = client
|
8
|
+
end
|
9
|
+
|
10
|
+
def find(name)
|
11
|
+
@client.request("/subject/#{name}")
|
12
|
+
end
|
13
|
+
|
14
|
+
def batch(query, options = {})
|
15
|
+
@client.request("/subjects/#{query}", options)
|
16
|
+
end
|
17
|
+
|
18
|
+
def search(options = {})
|
19
|
+
@client.request("/search/subjects/", options)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module ISBNdb
|
2
|
+
class ApiClient
|
3
|
+
include HTTParty
|
4
|
+
base_uri 'https://api2.isbndb.com/'
|
5
|
+
|
6
|
+
attr_accessor :api_key
|
7
|
+
|
8
|
+
def initialize(api_key: nil)
|
9
|
+
raise ArgumentError, 'API key is required.' unless api_key.is_a?(String)
|
10
|
+
@api_key = api_key
|
11
|
+
end
|
12
|
+
|
13
|
+
def request(page, params = {})
|
14
|
+
response = self.class.get(URI.escape(page), query: params, headers: headers, timeout: 60)
|
15
|
+
raise ISBNdb::RequestError.new "HTTP Response: #{response.code}" if response.code != 200
|
16
|
+
begin
|
17
|
+
self.class.snakify(response.parsed_response)
|
18
|
+
rescue JSON::ParserError
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def stats
|
24
|
+
request('/stats')
|
25
|
+
end
|
26
|
+
|
27
|
+
def author
|
28
|
+
@author ||= ISBNdb::Api::Author.new(client: self)
|
29
|
+
end
|
30
|
+
|
31
|
+
def book
|
32
|
+
@book ||= ISBNdb::Api::Book.new(client: self)
|
33
|
+
end
|
34
|
+
|
35
|
+
def publisher
|
36
|
+
@publisher ||= ISBNdb::Api::Publisher.new(client: self)
|
37
|
+
end
|
38
|
+
|
39
|
+
def subject
|
40
|
+
@subject ||= ISBNdb::Api::Subject.new(client: self)
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.snakify(hash)
|
44
|
+
if hash.is_a? Array
|
45
|
+
hash.map{ |item| symbolize(item.to_snake_keys) }
|
46
|
+
else
|
47
|
+
symbolize(hash.to_snake_keys)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def headers
|
54
|
+
{
|
55
|
+
'Authorization' => api_key,
|
56
|
+
'Content-Type' => 'application/json',
|
57
|
+
'Accept' => '*/*'
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.symbolize(obj)
|
62
|
+
return obj.reduce({}) do |memo, (k, v)|
|
63
|
+
memo.tap { |m| m[k.to_sym] = symbolize(v) }
|
64
|
+
end if obj.is_a? Hash
|
65
|
+
return obj.reduce([]) do |memo, v|
|
66
|
+
memo << symbolize(v); memo
|
67
|
+
end if obj.is_a? Array
|
68
|
+
obj
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
metadata
ADDED
@@ -0,0 +1,225 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: isbndb-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- sampatbadhe
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-03-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.13'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: plissken
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '12.3'
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 12.3.3
|
65
|
+
type: :development
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - "~>"
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '12.3'
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 12.3.3
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rspec
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '3.0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '3.0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: simplecov
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: coveralls
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: pry
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0.12'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0.12'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: rubocop
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: 0.49.0
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - "~>"
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: 0.49.0
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
name: webmock
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - "~>"
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '2.1'
|
152
|
+
type: :development
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - "~>"
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '2.1'
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
name: travis
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - "~>"
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '1.8'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - "~>"
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '1.8'
|
173
|
+
description: Library for communicating with the ISBNdb.com's v2 API
|
174
|
+
email:
|
175
|
+
- sampat.badhe@kiprosh.com
|
176
|
+
executables: []
|
177
|
+
extensions: []
|
178
|
+
extra_rdoc_files: []
|
179
|
+
files:
|
180
|
+
- ".gitignore"
|
181
|
+
- ".rspec"
|
182
|
+
- ".travis.yml"
|
183
|
+
- CODE_OF_CONDUCT.md
|
184
|
+
- Gemfile
|
185
|
+
- LICENSE
|
186
|
+
- README.md
|
187
|
+
- Rakefile
|
188
|
+
- bin/console
|
189
|
+
- bin/setup
|
190
|
+
- isbndb-ruby.gemspec
|
191
|
+
- lib/isbndb.rb
|
192
|
+
- lib/isbndb/api/author.rb
|
193
|
+
- lib/isbndb/api/book.rb
|
194
|
+
- lib/isbndb/api/publisher.rb
|
195
|
+
- lib/isbndb/api/subject.rb
|
196
|
+
- lib/isbndb/api_client.rb
|
197
|
+
- lib/isbndb/version.rb
|
198
|
+
homepage: https://github.com/sampatbadhe/isbndb-ruby
|
199
|
+
licenses:
|
200
|
+
- MIT
|
201
|
+
metadata:
|
202
|
+
allowed_push_host: https://rubygems.org
|
203
|
+
homepage_uri: https://github.com/sampatbadhe/isbndb-ruby
|
204
|
+
source_code_uri: https://github.com/sampatbadhe/isbndb-ruby
|
205
|
+
post_install_message:
|
206
|
+
rdoc_options: []
|
207
|
+
require_paths:
|
208
|
+
- lib
|
209
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
210
|
+
requirements:
|
211
|
+
- - ">="
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: '0'
|
214
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
|
+
requirements:
|
216
|
+
- - ">="
|
217
|
+
- !ruby/object:Gem::Version
|
218
|
+
version: '0'
|
219
|
+
requirements: []
|
220
|
+
rubyforge_project:
|
221
|
+
rubygems_version: 2.4.5.5
|
222
|
+
signing_key:
|
223
|
+
specification_version: 4
|
224
|
+
summary: Library for communicating with the ISBNdb.com's v2 API
|
225
|
+
test_files: []
|