micky 0.6.1 → 0.6.2

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
  SHA1:
3
- metadata.gz: c6659c9da05edb0382b1102b555ea80de00e40e9
4
- data.tar.gz: 7d4a1e4fe835550b6ef7a0baecf427b078b27712
3
+ metadata.gz: 564fb6538cc477e7c8774e406b318b557ad5c9cd
4
+ data.tar.gz: 32e4dfe50c966bbe85f36f8953ff9e0492bb8c61
5
5
  SHA512:
6
- metadata.gz: 975a69145cd13c6a15e3f2ae553b1bcbb307b33fc33dba764f23852e58e6e5fbd5fc11d0967f562adfd74ad06df0c3426e73da873c236da56cbce6fe180ba535
7
- data.tar.gz: fbda5e82a9c550a8bd7e21404ae5b23687dc4229eeddc360ad473bdf2df79305335ab53b6e6268a44af8dafc7a886c876ebbfe8c9d85d00ddee33e3ad0a50ae2
6
+ metadata.gz: 65b65ae98adec9f1066e44b0985a27c79f7fd5c4b1bf200d328b064acbffb952ec8b770f7c32fddaa3dd35bf16b5978ffcdeb244ec875dd6336ca5e4c46f6c4d
7
+ data.tar.gz: 52d30a340db566c8f0496109468659397474e9c77805591f3ac8cbc1d8342be88d106a9e71cf8900580a1ec05dd5c20d4e5314f97709383e471b55a34554fb7f
data/lib/micky/errors.rb CHANGED
@@ -1,36 +1,16 @@
1
1
  module Micky
2
2
  class Error < StandardError
3
- attr_reader :original_exception, :response
4
-
5
3
  def initialize(message = nil, original_exception: nil, response: nil)
6
- @original_exception = original_exception
7
- @response = response
8
- @message = message
9
- end
10
-
11
- def message
12
4
  if response
13
- "#{response_code} #{response_message} at #{request_uri}"
5
+ super "#{response.code} #{response.message} at #{response.uri}"
14
6
  elsif original_exception
15
- original_exception.inspect
16
- elsif @message
17
- @message
7
+ super original_exception.inspect
8
+ elsif message
9
+ super message
18
10
  else
19
11
  super
20
12
  end
21
13
  end
22
-
23
- def request_uri
24
- response.uri if response
25
- end
26
-
27
- def response_code
28
- response.code.to_i if response
29
- end
30
-
31
- def response_message
32
- response.message if response
33
- end
34
14
  end
35
15
 
36
16
  # Client errors
@@ -50,4 +30,6 @@ module Micky
50
30
  end
51
31
  class TooManyRedirects < ServerError
52
32
  end
33
+ class NoRedirectLocation < ServerError
34
+ end
53
35
  end
data/lib/micky/request.rb CHANGED
@@ -37,6 +37,12 @@ module Micky
37
37
  previous_uri = uri
38
38
  uri = response['Location']
39
39
 
40
+ if uri.nil?
41
+ raise Micky::NoRedirectLocation, response: response if @raise_errors
42
+ warn "Micky.#{@request_class_name.downcase}('#{previous_uri}'): No “Location” for #{response.code} response"
43
+ return nil
44
+ end
45
+
40
46
  if uri !~ Micky::HTTP_URI_REGEX
41
47
  if uri.start_with? '//'
42
48
  # Protocol-relative
data/lib/micky/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Micky
2
- VERSION = '0.6.1'
2
+ VERSION = '0.6.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: micky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafaël Blais Masson