openbd_api 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/lib/openbd/client.rb +27 -29
- data/lib/openbd/version.rb +1 -1
- data/openbd_api.gemspec +4 -0
- metadata +32 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7677573ec1279c4f8264add004da473f3a82b9c0
|
4
|
+
data.tar.gz: c4c9a33631c29b4930a4b39015ff8fd6cddcb506
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4b4a92fb6f95ef1fa03ab7b939cac8524dbc1afe23e50bf8d09439eef8db0a5346f1cce05d53ce1dd522bcb9c746ecfb7c9505a6dbad84b8bbdcf9015acae42
|
7
|
+
data.tar.gz: 3c6a6ede00bbdf0db98d23344e3932fc7471de927ca9651483ae7c0bde498dd4134c8a1ecd0483f05f5a69746013899613603784619db82a1fbb9a4fe31f1689
|
data/.travis.yml
CHANGED
data/lib/openbd/client.rb
CHANGED
@@ -1,51 +1,49 @@
|
|
1
|
-
require '
|
1
|
+
require 'faraday'
|
2
|
+
require 'faraday_middleware'
|
2
3
|
require 'json'
|
3
4
|
|
4
5
|
class OpenBD
|
5
|
-
API_BASE_URL = 'http://api.openbd.jp/
|
6
|
+
API_BASE_URL = 'http://api.openbd.jp/'.freeze
|
7
|
+
PATH_TO_GET = 'v1/get'
|
8
|
+
PATH_TO_COVERAGE = 'v1/coverage'
|
9
|
+
PATH_TO_SCHEMA = 'v1/schema'
|
6
10
|
|
7
11
|
class << self
|
8
12
|
def get(isbns)
|
9
|
-
|
10
|
-
response
|
11
|
-
create_body(response).select { |item| item != nil }
|
13
|
+
response = get_request(PATH_TO_GET, { isbn: normalize_isbns(isbns) })
|
14
|
+
response.body
|
12
15
|
end
|
13
16
|
|
14
17
|
def bulk_get(isbns)
|
15
|
-
|
16
|
-
response
|
17
|
-
create_body(response).select { |item| item != nil }
|
18
|
+
response = post_request(PATH_TO_GET, { isbn: isbns })
|
19
|
+
response.body
|
18
20
|
end
|
19
21
|
|
20
22
|
def coverage
|
21
|
-
|
22
|
-
response
|
23
|
-
create_body(response)
|
23
|
+
response = get_request(PATH_TO_COVERAGE)
|
24
|
+
response.body
|
24
25
|
end
|
25
26
|
|
26
27
|
def schema
|
27
|
-
|
28
|
-
response
|
29
|
-
create_body(response)
|
28
|
+
response = get_request(PATH_TO_SCHEMA)
|
29
|
+
response.body
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
33
|
-
|
32
|
+
def connection
|
33
|
+
Faraday::Connection.new(url: API_BASE_URL) do |connection|
|
34
|
+
connection.adapter :net_http
|
35
|
+
connection.response :json
|
36
|
+
end
|
34
37
|
end
|
35
38
|
|
36
|
-
def
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
"
|
44
|
-
when Array
|
45
|
-
params = normalize_isbns(isbns)
|
46
|
-
"#{API_BASE_URL}#{method}?isbn=#{params}"
|
47
|
-
else
|
48
|
-
"#{API_BASE_URL}#{method}"
|
39
|
+
def get_request(method, params = nil)
|
40
|
+
faraday_response = connection.get(method, params)
|
41
|
+
end
|
42
|
+
|
43
|
+
def post_request(method, params)
|
44
|
+
faraday_response = connection.post do |req|
|
45
|
+
req.url method
|
46
|
+
req.body = "isbn=#{normalize_isbns(params[:isbn])}"
|
49
47
|
end
|
50
48
|
end
|
51
49
|
|
data/lib/openbd/version.rb
CHANGED
data/openbd_api.gemspec
CHANGED
@@ -14,6 +14,8 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = "https://github.com/nasum/openbd"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
|
+
spec.required_ruby_version = '~> 2.2'
|
18
|
+
|
17
19
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
20
|
f.match(%r{^(test|spec|features)/})
|
19
21
|
end
|
@@ -25,4 +27,6 @@ Gem::Specification.new do |spec|
|
|
25
27
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
28
|
spec.add_development_dependency "rspec", "~> 3.0"
|
27
29
|
spec.add_runtime_dependency "slop", "~> 4.4"
|
30
|
+
spec.add_runtime_dependency "faraday", "~> 0.11"
|
31
|
+
spec.add_runtime_dependency "faraday_middleware", "~> 0.11"
|
28
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openbd_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nasum
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,34 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '4.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: faraday
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.11'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.11'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: faraday_middleware
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.11'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.11'
|
69
97
|
description: This gem wraps openBD Web API.
|
70
98
|
email:
|
71
99
|
- tomato.wonder.life@gmail.com
|
@@ -99,9 +127,9 @@ require_paths:
|
|
99
127
|
- lib
|
100
128
|
required_ruby_version: !ruby/object:Gem::Requirement
|
101
129
|
requirements:
|
102
|
-
- - "
|
130
|
+
- - "~>"
|
103
131
|
- !ruby/object:Gem::Version
|
104
|
-
version: '
|
132
|
+
version: '2.2'
|
105
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
134
|
requirements:
|
107
135
|
- - ">="
|