openbd_api 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/openbd/client.rb +14 -9
- data/lib/openbd/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d7dbb8431a3263434f2803c4d6ddfe812b45638
|
4
|
+
data.tar.gz: c8418e54012fef1faaed816df101b5d51d22633e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdb36dd3ebb4a0fb33daa50781a3b7199906740af32c60e7c24cb2dd700b8181139b9434cf298a521bd72366397ddca5b041bf2fdcd28afc1630b392cccef03b
|
7
|
+
data.tar.gz: 768c10f9b655a6f8c33b370979c14f54ba240751f7a8c8ff800834e09cf31165acddf785508c7d0065f3d788095709006ee31f66c76e4059d0ecbd16d232e5e5
|
data/README.md
CHANGED
@@ -31,14 +31,18 @@ Like this.
|
|
31
31
|
require 'openbd_api'
|
32
32
|
|
33
33
|
# get
|
34
|
+
OpenBD.get 9784309226712
|
34
35
|
OpenBD.get '9784309226712'
|
35
36
|
OpenBD.get '9784309226712,9784309226729'
|
36
37
|
OpenBD.get [9784309226712,9784309226729]
|
38
|
+
OpenBD.get ['9784309226712','9784309226729']
|
37
39
|
|
38
40
|
# bulk_get
|
41
|
+
OpenBD.bulk_get 9784309226712
|
39
42
|
OpenBD.bulk_get '9784309226712'
|
40
43
|
OpenBD.bulk_get '9784309226712,9784309226729'
|
41
44
|
OpenBD.bulk_get [9784309226712,9784309226729]
|
45
|
+
OpenBD.bulk_get ['9784309226712','9784309226729']
|
42
46
|
|
43
47
|
# coverage
|
44
48
|
OpenBD.coverage
|
data/lib/openbd/client.rb
CHANGED
@@ -34,10 +34,14 @@ class OpenBD
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def prepare_url(method, isbns = nil)
|
37
|
-
|
37
|
+
case isbns
|
38
|
+
when String
|
38
39
|
params = normalize_isbns(isbns)
|
39
40
|
"#{API_BASE_URL}#{method}?isbn=#{params}"
|
40
|
-
|
41
|
+
when Numeric
|
42
|
+
params = normalize_isbns(isbns)
|
43
|
+
"#{API_BASE_URL}#{method}?isbn=#{params}"
|
44
|
+
when Array
|
41
45
|
params = normalize_isbns(isbns)
|
42
46
|
"#{API_BASE_URL}#{method}?isbn=#{params}"
|
43
47
|
else
|
@@ -46,17 +50,18 @@ class OpenBD
|
|
46
50
|
end
|
47
51
|
|
48
52
|
def normalize_isbns(isbns)
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
+
case isbns
|
54
|
+
when String
|
55
|
+
isbns
|
56
|
+
when Numeric
|
57
|
+
isbns
|
58
|
+
when Array
|
59
|
+
params = ""
|
53
60
|
isbns.each do |isbn|
|
54
61
|
params << "#{isbn}, "
|
55
62
|
end
|
56
|
-
params.strip!.gsub
|
63
|
+
params.strip!.gsub(/,$/,'')
|
57
64
|
end
|
58
|
-
|
59
|
-
params
|
60
65
|
end
|
61
66
|
end
|
62
67
|
end
|
data/lib/openbd/version.rb
CHANGED