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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46b4c727294bdd92f33e9fa5cf32ee2cd320987a1b2d65dccba240a5a776f0b4
4
- data.tar.gz: c9c7b2a9b568c216804afb3f6108e9190644df0ed241eee73a600fe228982eca
3
+ metadata.gz: dc0185b74fd4488a798b0a5da33379e54b9d95081ac7e1160a3d6e41aadc306e
4
+ data.tar.gz: b21eaae81ea5fc991ddec3fdefca7d73ec35b9c008057407547552c045b12c22
5
5
  SHA512:
6
- metadata.gz: d8fc3430aef73a2b20adbc4d6c649c62ff467944e03db06b977d1dc517205644573e5ab87eb891a3539ae9776e1f4adbb3b9fded9eb782b203c244892ad3e2be
7
- data.tar.gz: e5f0122b6a5d06f04b55ef79f9da102f603cd397941135787ff1d121afedcbc4d18f6d72f472e4552daa7f11099c9dd493a175ef1763145c0828b72073d215b3
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.nil? # 404 not found
36
+ if resp['error'] == 'ActiveRecord::RecordNotFound' # 404 not found
37
37
  model.send :write_attribute, serialization_column, nil
38
38
  return
39
39
  end
@@ -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 = handle_response(response)
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 = handle_response(response)
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 = handle_response(response)
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 handle_response(response)
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 #{resp.status}"
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Resizing
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.3'
5
5
  end
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.0
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-09 00:00:00.000000000 Z
11
+ date: 2020-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday