gus 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_DISABLE_SHARED_GEMS: "1"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gus (0.0.1)
4
+ gus (0.0.3)
5
5
  crack (>= 0.1.8)
6
6
 
7
7
  GEM
@@ -8,15 +8,15 @@ module Gus
8
8
  private
9
9
 
10
10
  def get_result(url)
11
- begin
12
- response = Net::HTTP.post_form(
13
- URI.parse('http://goo.gl/api/shorten'),
14
- {'url'=>url}
15
- )
16
- result = Crack::JSON.parse(response.body)
11
+ response = Net::HTTP.post_form(
12
+ URI.parse('http://goo.gl/api/shorten'),
13
+ {'url'=>url}
14
+ )
15
+ result = Crack::JSON.parse(response.body)
16
+ if response.code == "201"
17
17
  result['short_url']
18
- # rescue
19
- # raise "Goo.gl error: #{response.status_code}"
18
+ else
19
+ raise result['error_message']
20
20
  end
21
21
  end
22
22
 
@@ -1,3 +1,3 @@
1
1
  module Gus
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -12,8 +12,13 @@ describe Gus::Shortener do
12
12
  it 'should create a shortened url' do
13
13
  shortener.shorten(long_url).should_not be_nil
14
14
  end
15
+
15
16
  it 'should shorten the url' do
16
17
  short_url = shortener.shorten(long_url)
17
18
  (short_url.length < long_url.length).should be_true
18
19
  end
20
+
21
+ it 'should raise an error for a bad url' do
22
+ lambda{ shortener.shorten("eat more chicken") }.should raise_error( "Bad request" )
23
+ end
19
24
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
10
10
  platform: ruby
11
11
  authors: []
12
12
 
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-16 00:00:00 -05:00
17
+ date: 2010-12-23 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -59,6 +59,7 @@ extensions: []
59
59
  extra_rdoc_files: []
60
60
 
61
61
  files:
62
+ - .bundle/config
62
63
  - .gitignore
63
64
  - Gemfile
64
65
  - Gemfile.lock