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.
- data/lib/acts_as_link/link.rb +12 -0
- data/spec/acts_as_link/link_spec.rb +9 -0
- metadata +22 -6
data/lib/acts_as_link/link.rb
CHANGED
@@ -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
|
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:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
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:
|
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: *
|
37
|
-
description:
|
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
|
|