imagize 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/imagize.gemspec +2 -2
- data/lib/imagize.rb +23 -7
- data/spec/imagize_spec.rb +23 -6
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/imagize.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{imagize}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Raymond van Dongelen"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-11-07}
|
13
13
|
s.description = %q{Retrieve images from a tweet}
|
14
14
|
s.email = %q{dongelen@nhl.nl}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/imagize.rb
CHANGED
@@ -28,7 +28,17 @@ module Imagize
|
|
28
28
|
:plixi => {
|
29
29
|
:url => "http://plixi.com/p/",
|
30
30
|
:convert => "http://api.plixi.com/api/tpapi.svc/imagefromurl?size=big&url=http://plixi.com/§ID§"
|
31
|
+
},
|
32
|
+
:twitgoo => {
|
33
|
+
:url => "http://twitgoo.com/",
|
34
|
+
:convert => "http://twitgoo.com/show/img/§ID§"
|
35
|
+
},
|
36
|
+
:imgly =>{
|
37
|
+
:url => "http://img.ly/",
|
38
|
+
:convert => "http://img.ly/show/full/§ID§"
|
31
39
|
}
|
40
|
+
|
41
|
+
|
32
42
|
|
33
43
|
}
|
34
44
|
SHORTENERS = {
|
@@ -40,6 +50,9 @@ module Imagize
|
|
40
50
|
},
|
41
51
|
:isgd =>{
|
42
52
|
:url=>"http://is.gd/"
|
53
|
+
},
|
54
|
+
:twitter=>{
|
55
|
+
:url=>"http://t.co/"
|
43
56
|
}
|
44
57
|
|
45
58
|
}
|
@@ -55,17 +68,20 @@ module Imagize
|
|
55
68
|
|
56
69
|
class Imagizer
|
57
70
|
|
58
|
-
def imagize(message)
|
71
|
+
def imagize(message, extract_shorteners=false)
|
59
72
|
tweet = message.clone
|
60
73
|
images = Array.new
|
61
74
|
|
75
|
+
|
62
76
|
#find shortened content
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
tweet
|
67
|
-
|
68
|
-
|
77
|
+
if extract_shorteners
|
78
|
+
SHORTENERS.each do |service, details|
|
79
|
+
currentService = details[:url]
|
80
|
+
tweet.scan /#{currentService}\w*/ do |current|
|
81
|
+
tweet = tweet.sub (current, extract_shortener(current))
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
69
85
|
|
70
86
|
#find image services
|
71
87
|
URL_DEFINITIONS.each do |service, details|
|
data/spec/imagize_spec.rb
CHANGED
@@ -33,6 +33,10 @@ describe "Imagize" do
|
|
33
33
|
|
34
34
|
urls = @imagizer.imagize("Hallo bnfgjfdgbfd http://www.youtube.com/watch?v=NPahxS10HkY Fiets")
|
35
35
|
urls.should include("http://img.youtube.com/vi/NPahxS10HkY/0.jpg")
|
36
|
+
|
37
|
+
urls = @imagizer.imagize("Hallo bnfgjfdgbfd http://www.youtube.com/watch?v=ogZ9WXNNdIc Fiets")
|
38
|
+
urls.should include("http://img.youtube.com/vi/ogZ9WXNNdIc/0.jpg")
|
39
|
+
|
36
40
|
end
|
37
41
|
|
38
42
|
it "should recognize tweetphoto" do
|
@@ -58,7 +62,20 @@ describe "Imagize" do
|
|
58
62
|
urls.size.should == 1
|
59
63
|
|
60
64
|
urls[0].should == "http://img.youtube.com/vi/1acVM7_rWw4/0.jpg"
|
61
|
-
end
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should extract twitgoo" do
|
68
|
+
urls= @imagizer.imagize "Komt toch bij mij over als een kippenoep met identiteitscrisis. http://twitgoo.com/1qg60x"
|
69
|
+
urls.size.should == 1
|
70
|
+
|
71
|
+
urls[0].should == "http://twitgoo.com/show/img/1qg60x"
|
72
|
+
end
|
73
|
+
it "should extract img.ly" do
|
74
|
+
urls= @imagizer.imagize "http://img.ly/2oii #porrauol Que falha é essa na página principal...?"
|
75
|
+
urls.size.should == 1
|
76
|
+
|
77
|
+
urls[0].should == "http://img.ly/show/full/2oii"
|
78
|
+
end
|
62
79
|
|
63
80
|
it "should create normal urls" do
|
64
81
|
@imagizer.make_url(:twitpic, "hi").should == "http://twitpic.com/show/large/hi"
|
@@ -72,8 +89,8 @@ describe "Imagize" do
|
|
72
89
|
@imagizer.extract_shortener("http://is.gd/bSCVo").should == "http://www.nu.nl"
|
73
90
|
end
|
74
91
|
|
75
|
-
it "should extract
|
76
|
-
@imagizer.imagize("http://bit.ly/92mRwT").should include("http://twitpic.com/show/large/h5uhc")
|
92
|
+
it "should extract image in shortened url" do
|
93
|
+
@imagizer.imagize("http://bit.ly/92mRwT", true).should include("http://twitpic.com/show/large/h5uhc")
|
77
94
|
end
|
78
95
|
|
79
96
|
|
@@ -81,9 +98,9 @@ describe "Imagize" do
|
|
81
98
|
@imagizer.imagize("This is some message http://www.hi.com/x.jpg").size.should ==1
|
82
99
|
@imagizer.imagize("This is some message http://www.hi.com/1/2/3/x.jpg").size.should ==1
|
83
100
|
@imagizer.imagize("This is some message http://www.hi.com/1/2/3/x.gif").should include "http://www.hi.com/1/2/3/x.gif"
|
84
|
-
@imagizer.imagize("This is some message http://bit.ly/bxjNbr but shortened").should include "http://www.hi.com/1/2/3/x.gif"
|
85
|
-
@imagizer.imagize("This is some message http://bit.ly/bxjNbr but shortened").should include "http://www.hi.com/1/2/3/x.gif"
|
86
|
-
@imagizer.imagize("This is some message http://is.gd/bSD5l but shortened").should include "http://www.hi.com/1/2/3/x.gif"
|
101
|
+
@imagizer.imagize("This is some message http://bit.ly/bxjNbr but shortened", true).should include "http://www.hi.com/1/2/3/x.gif"
|
102
|
+
@imagizer.imagize("This is some message http://bit.ly/bxjNbr but shortened", true).should include "http://www.hi.com/1/2/3/x.gif"
|
103
|
+
@imagizer.imagize("This is some message http://is.gd/bSD5l but shortened", true).should include "http://www.hi.com/1/2/3/x.gif"
|
87
104
|
end
|
88
105
|
|
89
106
|
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 3
|
8
|
+
- 0
|
9
|
+
version: 0.3.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Raymond van Dongelen
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-11-07 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|