resizing 0.1.0 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/resizing/carrier_wave/storage/file.rb +1 -1
- data/lib/resizing/client.rb +17 -5
- data/lib/resizing/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc0185b74fd4488a798b0a5da33379e54b9d95081ac7e1160a3d6e41aadc306e
|
4
|
+
data.tar.gz: b21eaae81ea5fc991ddec3fdefca7d73ec35b9c008057407547552c045b12c22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e13ddf3fdb99165d35d73bd580fd45c316e93bc1e25769fc9cb7c6f28ed98dfdce57b22c15ee12dabbaeff27bc0156c3833adb79857853f41974ec0773b5ca5
|
7
|
+
data.tar.gz: e4b7d41e6b4e58fba560a73876913564c532101dc54c777ea994adf529fbc76088bb5ecd13f7dfa178fc198553abc504b8451b91141dc900b335737169438d13
|
@@ -33,7 +33,7 @@ module Resizing
|
|
33
33
|
separted = Resizing.separate_public_id(public_id)
|
34
34
|
image_id = separted[:image_id]
|
35
35
|
resp = client.delete(image_id)
|
36
|
-
if resp
|
36
|
+
if resp['error'] == 'ActiveRecord::RecordNotFound' # 404 not found
|
37
37
|
model.send :write_attribute, serialization_column, nil
|
38
38
|
return
|
39
39
|
end
|
data/lib/resizing/client.rb
CHANGED
@@ -28,6 +28,7 @@ module Resizing
|
|
28
28
|
# to use standard constants
|
29
29
|
HTTP_STATUS_OK = 200
|
30
30
|
HTTP_STATUS_CREATED = 201
|
31
|
+
HTTP_STATUS_NOT_FOUND = 404
|
31
32
|
|
32
33
|
attr_reader :config
|
33
34
|
def initialize(*attrs)
|
@@ -58,7 +59,7 @@ module Resizing
|
|
58
59
|
request.headers['X-ResizingToken'] = config.generate_auth_header
|
59
60
|
end
|
60
61
|
|
61
|
-
result =
|
62
|
+
result = handle_create_response(response)
|
62
63
|
result
|
63
64
|
end
|
64
65
|
|
@@ -76,7 +77,7 @@ module Resizing
|
|
76
77
|
request.headers['X-ResizingToken'] = config.generate_auth_header
|
77
78
|
end
|
78
79
|
|
79
|
-
result =
|
80
|
+
result = handle_create_response(response)
|
80
81
|
result
|
81
82
|
end
|
82
83
|
|
@@ -87,7 +88,7 @@ module Resizing
|
|
87
88
|
request.headers['X-ResizingToken'] = config.generate_auth_header
|
88
89
|
end
|
89
90
|
|
90
|
-
result =
|
91
|
+
result = handle_delete_response(response)
|
91
92
|
result
|
92
93
|
end
|
93
94
|
|
@@ -134,14 +135,25 @@ module Resizing
|
|
134
135
|
raise ArgumentError, "need options[:content_type] for #{options.inspect}" unless options[:content_type]
|
135
136
|
end
|
136
137
|
|
137
|
-
def
|
138
|
+
def handle_create_response(response)
|
138
139
|
raise APIError, "no response is returned" if response.nil?
|
139
140
|
|
140
141
|
case response.status
|
141
142
|
when HTTP_STATUS_OK, HTTP_STATUS_CREATED
|
142
143
|
JSON.parse(response.body)
|
143
144
|
else
|
144
|
-
raise APIError, "invalid http status code #{
|
145
|
+
raise APIError, "invalid http status code #{response.status}"
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def handle_delete_response(response)
|
150
|
+
raise APIError, "no response is returned" if response.nil?
|
151
|
+
|
152
|
+
case response.status
|
153
|
+
when HTTP_STATUS_OK, HTTP_STATUS_CREATED, HTTP_STATUS_NOT_FOUND
|
154
|
+
JSON.parse(response.body)
|
155
|
+
else
|
156
|
+
raise APIError, "invalid http status code #{response.status}"
|
145
157
|
end
|
146
158
|
end
|
147
159
|
end
|
data/lib/resizing/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resizing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Junichiro Kasuya
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|