openbd 0.1.0 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8a76c497bf275a7eaa02bcfe162dbaed01b48cc3
4
- data.tar.gz: 294783f68230fbcee1ce7ae28b958589b551d29a
3
+ metadata.gz: e450c84ea7d9544bdd68f78d962d28f05e453a5d
4
+ data.tar.gz: 1cd6fa64ebe192a60767e7a5dec7f1020b9676b3
5
5
  SHA512:
6
- metadata.gz: fe5ec1b53affc92066e681f9901be317390f19eb33b0ab8bc9c83c51c6b1fe0a1e9b979d61930e3450f53693d67b04ac667309d03da059d341a18d816079b73e
7
- data.tar.gz: b8bd61c51ec5b32ae0ac761a83cbf1670cbf05e33314e2b800ddf82c32e174d9ec83b144e856749eed62802051f572f9197eb959fcb60b9d07f2d66e6b524dbd
6
+ metadata.gz: 5a65d8a420861ba67aa91e3d5f79cc1f0acd174930ebd9d0cce715194f3647a50f095a7a07b9ca0c7b9095990120a6e4690cf43612f966f4d777dcd998a308a4
7
+ data.tar.gz: 87e49b6ac04227fa1cda8f7de879168c97caf040923119840f6fa30d6bf585897835f99c76a8c185deb7bea909123c4038b2b1b58304d4b9bda39e9c2a50197d
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  /.bundle/
2
+ /vendor/bundle/
2
3
  /.idea/
3
4
  /.yardoc
4
5
  /Gemfile.lock
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
@@ -2,4 +2,9 @@ sudo: false
2
2
  language: ruby
3
3
  rvm:
4
4
  - 2.3.0
5
- before_install: gem install bundler -v 1.13.7
5
+ before_install:
6
+ - gem install bundler -v 1.13.7
7
+ - gem install rubocop
8
+ script:
9
+ - rubocop --fail-level=W
10
+ - bundle exec rspec
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gemspec
3
+ gemspec
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
@@ -3,4 +3,4 @@ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
@@ -1,3 +1,3 @@
1
1
  module Openbd
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
data/lib/openbd.rb CHANGED
@@ -1,9 +1,11 @@
1
1
  require 'openbd/version'
2
2
  require 'httpclient'
3
- require 'multi_json'
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
- MultiJson.load(resp.body)
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 = %q{openBD API}
12
- spec.description = %q{The library provides a wrapper to the openBD API}
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 = `git ls-files -z`.split("\x0").reject do |f|
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.1.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-05 00:00:00.000000000 Z
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: '0'
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: '0'
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: '0'
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: '0'
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: '0'
113
+ version: 2.3.0
128
114
  required_rubygems_version: !ruby/object:Gem::Requirement
129
115
  requirements:
130
116
  - - ">="