longurl 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 1
4
- :patch: 2
4
+ :patch: 3
@@ -85,14 +85,28 @@ module LongURL
85
85
 
86
86
  def handle_response(response)
87
87
  parsed = JSON.parse(response.body)
88
+ parsed = parsed.first if parsed.is_a?(Array)
88
89
  if parsed['long_url']
89
90
  parsed['long_url']
90
91
  elsif parsed['message'] # Error
91
- raise LongURL::UnsupportedService if parsed['messages']['message'] == 'Unsupported service.'
92
+ raise exception_regarding_message(parsed['message'])
92
93
  else
93
94
  raise LongURL::UnknownError
94
95
  end
95
96
  end
97
+
98
+ def exception_class_regarding_message(message)
99
+ case message
100
+ when 'Unsupported service.'
101
+ LongURL::UnsupportedService
102
+ when 'Connection timeout'
103
+ LongURL::NetworkError
104
+ when 'Could not expand URL. Please check that you have submitted a valid URL.'
105
+ LongURL::InvalidURL
106
+ else
107
+ LongURL::UnknownError
108
+ end
109
+ end
96
110
 
97
111
  end
98
112
 
data/longurl.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{longurl}
5
- s.version = "0.1.2"
5
+ s.version = "0.1.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Fabien Jakimowicz"]
9
- s.date = %q{2009-05-19}
9
+ s.date = %q{2009-05-26}
10
10
  s.default_executable = %q{longurl}
11
11
  s.description = %q{LongURL expands short urls (tinyurl, is.gd, ...) to original ones, using on LongURL.org, internal resolution or direct resolution}
12
12
  s.email = %q{fabien@jakimowicz.com}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: longurl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabien Jakimowicz
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-19 00:00:00 +02:00
12
+ date: 2009-05-26 00:00:00 +02:00
13
13
  default_executable: longurl
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency