tinplate 2.1.0 → 2.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/tinplate/errors.rb +27 -11
- data/lib/tinplate/tineye.rb +1 -1
- data/lib/tinplate/version.rb +1 -1
- data/lib/tinplate.rb +0 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c1ace4f94bd8263a1891dfb2f30e01a43562e3f1e9bf62cc9ea5bb470d6c05c9
|
4
|
+
data.tar.gz: 245d673949dee9932b2b41f35251c781576398cccf8b89b067278b8e6530346b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb5c81720a9d1809323ccb83a4a93c245a2bfb9bccca3b905e1c73748d1292a9afaa1fcd31dd0453aa2bc92fc11dc50ed7e61ae19ac86563337134660fb8f261
|
7
|
+
data.tar.gz: 2b4ab575b33057c1b4342ea633bd6931494d25ff3e662eba751036bab315d6b277dd1df6aff126875e44bc50e750dbabaf590f9b953c27991b532139da6a2946
|
data/lib/tinplate/errors.rb
CHANGED
@@ -1,20 +1,36 @@
|
|
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
|
+
when /Too many concurrent requests/ then Tinplate::TooManyRequestsError
|
24
|
+
end
|
14
25
|
end
|
15
26
|
end
|
16
27
|
|
17
28
|
class ServiceUnavailableError < Error; end
|
18
29
|
class NoSignatureError < Error; end
|
19
30
|
class NoCreditsRemainingError < Error; end
|
20
|
-
end
|
31
|
+
class UnauthorizedError < Error; end
|
32
|
+
class InaccessibleURLError < Error; end
|
33
|
+
class InvalidSearchError < Error; end
|
34
|
+
class InvalidImageDataError < Error; end
|
35
|
+
class TooManyRequestsError < Error; end
|
36
|
+
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
data/lib/tinplate.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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Klaassen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -128,8 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
- !ruby/object:Gem::Version
|
129
129
|
version: '0'
|
130
130
|
requirements: []
|
131
|
-
|
132
|
-
rubygems_version: 2.4.8
|
131
|
+
rubygems_version: 3.1.4
|
133
132
|
signing_key:
|
134
133
|
specification_version: 4
|
135
134
|
summary: A wrapper around the TinEye API.
|