acts_as_link 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,7 @@
1
1
  require 'net/http'
2
2
  require 'uri'
3
+ require 'rubygems'
4
+ require 'bitly'
3
5
 
4
6
  class Link
5
7
 
@@ -20,6 +22,10 @@ class Link
20
22
  verify_if_extension_is_an_image(extension)
21
23
  end
22
24
 
25
+ def shorten
26
+ shorten_link_with_bitly(@uri.to_s)
27
+ end
28
+
23
29
  private
24
30
 
25
31
  def response_code_is_not_valid?(code)
@@ -57,5 +63,11 @@ private
57
63
  end
58
64
  is_an_image
59
65
  end
66
+
67
+ def shorten_link_with_bitly(link)
68
+ Bitly.use_api_version_3
69
+ bitly = Bitly.new('actsaslink', 'R_fc70af6573e064c0f4081317bb592f18')
70
+ bitly.shorten(link).short_url
71
+ end
60
72
 
61
73
  end
@@ -63,4 +63,13 @@ describe Link do
63
63
  end
64
64
 
65
65
  end
66
+
67
+ describe 'shorten' do
68
+
69
+ it 'should return shortened link' do
70
+ link = Link.new('http://www.google.com')
71
+ link.shorten.include?('bit.ly').should be_true
72
+ end
73
+
74
+ end
66
75
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_link
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Fabr\xC3\xADcio Ferrari de Campos"
@@ -19,9 +19,25 @@ date: 2011-02-13 00:00:00 -02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: rspec
22
+ name: bitly
23
23
  prerelease: false
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - "="
28
+ - !ruby/object:Gem::Version
29
+ hash: 5
30
+ segments:
31
+ - 0
32
+ - 6
33
+ - 1
34
+ version: 0.6.1
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: rspec
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
25
41
  none: false
26
42
  requirements:
27
43
  - - ~>
@@ -33,8 +49,8 @@ dependencies:
33
49
  - 0
34
50
  version: 1.3.0
35
51
  type: :development
36
- version_requirements: *id001
37
- description: For now only verification if link is broken and if it is to an image
52
+ version_requirements: *id002
53
+ description: "ActsAsLink provides: verification if a link is broken; verification if a link is to an image; shortening links with bit.ly. Enjoy! ;)"
38
54
  email: fabricio@vizir.com.br
39
55
  executables: []
40
56