tinplate 2.1.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tinplate/errors.rb +25 -11
- data/lib/tinplate/tineye.rb +1 -1
- data/lib/tinplate/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c74f1bc36e6e016c34542b3ec3b489566d8f72a176945428ab7976cd9043524
|
4
|
+
data.tar.gz: 7b3c0d39b2332801d355b4b38ddc2c5cbdd96c5c99430e38700253d5c743f8fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '03899e5fbb07db090225c108c9c6a5db00ba4801819d405a174069e4a9a2dcfccc00ac344c42db806050dca3e124fbf9b29f9db57a8a741ef63700ed81fd72d2'
|
7
|
+
data.tar.gz: ac14fe344b6c537f8daacc3a9afe0d581e34c4a21bdd9188b02681c317126d233c4b33e6b06f7bb9186c18fd7d26cbcaf340f9cd83045532b03864cf70d8e442
|
data/lib/tinplate/errors.rb
CHANGED
@@ -1,20 +1,34 @@
|
|
1
1
|
module Tinplate
|
2
2
|
class Error < StandardError
|
3
|
-
def self.from_response(code,
|
4
|
-
|
5
|
-
when /503 Service Unavailable/ then Tinplate::ServiceUnavailableError
|
6
|
-
when /service is busy due to high load/ then Tinplate::ServiceUnavailableError
|
7
|
-
when /Image too simple/ then Tinplate::NoSignatureError
|
8
|
-
when /purchase another bundle/ then Tinplate::NoCreditsRemainingError
|
9
|
-
else
|
10
|
-
Tinplate::Error
|
11
|
-
end
|
3
|
+
def self.from_response(code, messages)
|
4
|
+
return UnauthorizedError.new(messages.first) if code == 403
|
12
5
|
|
13
|
-
|
6
|
+
messages.each do |message|
|
7
|
+
klass = class_from_message(message)
|
8
|
+
return klass.new(messages.join("\n")) if klass
|
9
|
+
end
|
10
|
+
|
11
|
+
Tinplate::Error.new(messages.join("\n"))
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.class_from_message(message)
|
15
|
+
case message
|
16
|
+
when /503 Service Unavailable/ then Tinplate::ServiceUnavailableError
|
17
|
+
when /service is busy due to high load/ then Tinplate::ServiceUnavailableError
|
18
|
+
when /Image too simple/ then Tinplate::NoSignatureError
|
19
|
+
when /purchase another bundle/ then Tinplate::NoCreditsRemainingError
|
20
|
+
when /Could not download/ then Tinplate::InaccessibleURLError
|
21
|
+
when /Please supply an image/ then Tinplate::InvalidSearchError
|
22
|
+
when /Error reading image data/ then Tinplate::InvalidImageDataError
|
23
|
+
end
|
14
24
|
end
|
15
25
|
end
|
16
26
|
|
17
27
|
class ServiceUnavailableError < Error; end
|
18
28
|
class NoSignatureError < Error; end
|
19
29
|
class NoCreditsRemainingError < Error; end
|
20
|
-
end
|
30
|
+
class UnauthorizedError < Error; end
|
31
|
+
class InaccessibleURLError < Error; end
|
32
|
+
class InvalidSearchError < Error; end
|
33
|
+
class InvalidImageDataError < Error; end
|
34
|
+
end
|
data/lib/tinplate/tineye.rb
CHANGED
@@ -55,7 +55,7 @@ module Tinplate
|
|
55
55
|
response = ::JSON.parse(response.body)
|
56
56
|
|
57
57
|
if response["code"] != 200
|
58
|
-
raise Tinplate::Error.from_response(response["code"], response["messages"]
|
58
|
+
raise Tinplate::Error.from_response(response["code"], response["messages"])
|
59
59
|
end
|
60
60
|
|
61
61
|
response
|
data/lib/tinplate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tinplate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Klaassen
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -86,7 +86,7 @@ dependencies:
|
|
86
86
|
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0'
|
89
|
-
description:
|
89
|
+
description:
|
90
90
|
email:
|
91
91
|
- aaron@unsplash.com
|
92
92
|
executables: []
|
@@ -113,7 +113,7 @@ homepage: https://github.com/unsplash/tinplate
|
|
113
113
|
licenses:
|
114
114
|
- MIT
|
115
115
|
metadata: {}
|
116
|
-
post_install_message:
|
116
|
+
post_install_message:
|
117
117
|
rdoc_options: []
|
118
118
|
require_paths:
|
119
119
|
- lib
|
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
129
|
version: '0'
|
130
130
|
requirements: []
|
131
131
|
rubygems_version: 3.1.4
|
132
|
-
signing_key:
|
132
|
+
signing_key:
|
133
133
|
specification_version: 4
|
134
134
|
summary: A wrapper around the TinEye API.
|
135
135
|
test_files: []
|