openbd 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +10 -2
- data/.travis.yml +6 -1
- data/Gemfile +1 -1
- data/README.md +16 -0
- data/Rakefile +1 -1
- data/lib/openbd/version.rb +1 -1
- data/lib/openbd.rb +18 -4
- data/openbd.gemspec +6 -6
- metadata +11 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e450c84ea7d9544bdd68f78d962d28f05e453a5d
|
4
|
+
data.tar.gz: 1cd6fa64ebe192a60767e7a5dec7f1020b9676b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a65d8a420861ba67aa91e3d5f79cc1f0acd174930ebd9d0cce715194f3647a50f095a7a07b9ca0c7b9095990120a6e4690cf43612f966f4d777dcd998a308a4
|
7
|
+
data.tar.gz: 87e49b6ac04227fa1cda8f7de879168c97caf040923119840f6fa30d6bf585897835f99c76a8c185deb7bea909123c4038b2b1b58304d4b9bda39e9c2a50197d
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,2 +1,10 @@
|
|
1
|
-
Style/MutableConstant
|
2
|
-
Enabled: false
|
1
|
+
Style/MutableConstant:
|
2
|
+
Enabled: false
|
3
|
+
Style/Documentation:
|
4
|
+
Enabled: false
|
5
|
+
Style/EmptyLinesAroundModuleBody:
|
6
|
+
Enabled: false
|
7
|
+
Style/EmptyLinesAroundClassBody:
|
8
|
+
Enabled: false
|
9
|
+
Style/NumericLiterals:
|
10
|
+
Enabled: false
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Openbd
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/openbd.svg)](https://badge.fury.io/rb/openbd) [![Build Status](https://travis-ci.org/kyoshidajp/openbd.svg?branch=master)](https://travis-ci.org/kyoshidajp/openbd)
|
4
|
+
|
5
|
+
The Ruby library provides a wrapper to the [openBD API](https://openbd.jp/).
|
6
|
+
|
3
7
|
## Installation
|
4
8
|
|
5
9
|
Add this line to your application's Gemfile:
|
@@ -32,6 +36,18 @@ client.get('978-4-7808-0204-7')
|
|
32
36
|
client.coverage
|
33
37
|
```
|
34
38
|
|
39
|
+
Set `HTTP_SERVER` or `http_server` as Environment Variable if you'd like to access via proxy server.
|
40
|
+
|
41
|
+
```
|
42
|
+
export HTTP_PROXY=http://user:pass@host:port
|
43
|
+
# or
|
44
|
+
export http_proxy=http://user:pass@host:port
|
45
|
+
```
|
46
|
+
|
47
|
+
## Requirements
|
48
|
+
|
49
|
+
- Ruby(MRI) 2.3.0 or higher
|
50
|
+
|
35
51
|
## License
|
36
52
|
|
37
53
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
data/lib/openbd/version.rb
CHANGED
data/lib/openbd.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
require 'openbd/version'
|
2
2
|
require 'httpclient'
|
3
|
-
require '
|
3
|
+
require 'json'
|
4
4
|
|
5
5
|
module Openbd
|
6
6
|
|
7
|
+
class RequestError < StandardError; end
|
8
|
+
|
7
9
|
END_POINT = 'https://api.openbd.jp/v1'
|
8
10
|
|
9
11
|
class Client
|
@@ -29,16 +31,28 @@ module Openbd
|
|
29
31
|
end
|
30
32
|
|
31
33
|
def body(resp)
|
32
|
-
|
34
|
+
JSON.parse(resp.body)
|
33
35
|
end
|
34
36
|
|
35
37
|
def _get(isbn, method)
|
36
38
|
return unless [:get, :post].include?(method)
|
37
39
|
|
38
40
|
url = "#{END_POINT}/get"
|
39
|
-
q = { isbn: isbn}
|
41
|
+
q = { isbn: isbn_param(isbn) }
|
40
42
|
resp = client.send(method, url, q)
|
41
43
|
body(resp)
|
42
44
|
end
|
45
|
+
|
46
|
+
def isbn_param(value)
|
47
|
+
isbns = if value.instance_of?(String)
|
48
|
+
value.split(',')
|
49
|
+
elsif value.instance_of?(Array)
|
50
|
+
value
|
51
|
+
else
|
52
|
+
raise Openbd::RequestError,
|
53
|
+
"Invalid type of param: #{value.class}(#{value})"
|
54
|
+
end
|
55
|
+
isbns.join(',')
|
56
|
+
end
|
43
57
|
end
|
44
|
-
end
|
58
|
+
end
|
data/openbd.gemspec
CHANGED
@@ -8,12 +8,13 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ['kyoshidajp']
|
9
9
|
spec.email = ['claddvd@gmail.com']
|
10
10
|
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
11
|
+
spec.summary = 'openBD API'
|
12
|
+
spec.description = 'The library provides a wrapper to the openBD API'
|
13
13
|
spec.homepage = 'http://github.com/kyoshidajp/openbd'
|
14
14
|
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = '>= 2.3.0'
|
15
16
|
|
16
|
-
spec.files
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
18
|
f.match(%r{^(test|spec|features)/})
|
18
19
|
end
|
19
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
@@ -22,7 +23,6 @@ Gem::Specification.new do |spec|
|
|
22
23
|
spec.add_development_dependency 'bundler', '~> 1.13'
|
23
24
|
spec.add_development_dependency 'rake', '~> 10.0'
|
24
25
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
25
|
-
spec.add_development_dependency 'webmock'
|
26
|
-
spec.add_runtime_dependency 'httpclient'
|
27
|
-
spec.add_runtime_dependency 'multi_json'
|
26
|
+
spec.add_development_dependency 'webmock', '~> 2.3.0'
|
27
|
+
spec.add_runtime_dependency 'httpclient', '~> 2.8.3'
|
28
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openbd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kyoshidajp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -56,44 +56,30 @@ dependencies:
|
|
56
56
|
name: webmock
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 2.3.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 2.3.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: httpclient
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: multi_json
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
73
|
+
- - "~>"
|
88
74
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
75
|
+
version: 2.8.3
|
90
76
|
type: :runtime
|
91
77
|
prerelease: false
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
|
-
- - "
|
80
|
+
- - "~>"
|
95
81
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
82
|
+
version: 2.8.3
|
97
83
|
description: The library provides a wrapper to the openBD API
|
98
84
|
email:
|
99
85
|
- claddvd@gmail.com
|
@@ -124,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
124
110
|
requirements:
|
125
111
|
- - ">="
|
126
112
|
- !ruby/object:Gem::Version
|
127
|
-
version:
|
113
|
+
version: 2.3.0
|
128
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
115
|
requirements:
|
130
116
|
- - ">="
|