imagize 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/imagize.gemspec +1 -1
- data/lib/imagize.rb +15 -4
- data/spec/imagize_spec.rb +3 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/imagize.gemspec
CHANGED
data/lib/imagize.rb
CHANGED
@@ -13,10 +13,14 @@ module Imagize
|
|
13
13
|
:url => "http://yfrog.com/",
|
14
14
|
:convert => "http://yfrog.com/§ID§:iphone"
|
15
15
|
},
|
16
|
-
:
|
16
|
+
:youtube_short => {
|
17
17
|
:url => "http://youtu.be/",
|
18
18
|
:convert => "http://img.youtube.com/vi/§ID§/0.jpg"
|
19
|
-
},
|
19
|
+
},
|
20
|
+
:youtube_long => {
|
21
|
+
:url => "http://www.youtube.com/watch",
|
22
|
+
:convert => "http://img.youtube.com/vi/§ID§/0.jpg"
|
23
|
+
},
|
20
24
|
:tweetphoto => {
|
21
25
|
:url => "http://tweetphoto.com/",
|
22
26
|
:convert => "http://tweetphotoapi.com/api/TPAPI.svc/imagefromurl?size=big&url=http://tweetphoto.com/§ID§"
|
@@ -47,6 +51,7 @@ module Imagize
|
|
47
51
|
PNG_FINDER = /#{IMAGE_URL}.png/
|
48
52
|
|
49
53
|
IMAGE_FINDERS = [JPG_FINDER, GIF_FINDER, PNG_FINDER]
|
54
|
+
YOUTUBE_LONG_URL="http://www.youtube.com/watch"
|
50
55
|
|
51
56
|
class Imagizer
|
52
57
|
|
@@ -64,13 +69,19 @@ module Imagize
|
|
64
69
|
|
65
70
|
#find image services
|
66
71
|
URL_DEFINITIONS.each do |service, details|
|
67
|
-
currentService = details[:url]
|
68
|
-
tweet.scan /#{currentService}\w*/ do |current|
|
72
|
+
currentService = details[:url]
|
73
|
+
tweet.scan /#{currentService}\w*/ do |current|
|
69
74
|
code = current.sub(currentService, "")
|
70
75
|
images << make_url (service, code)
|
71
76
|
end
|
72
77
|
end
|
73
78
|
|
79
|
+
# long youtube
|
80
|
+
tweet.scan /#{YOUTUBE_LONG_URL}\?v=\w*/ do |current|
|
81
|
+
code = current.sub(YOUTUBE_LONG_URL+"?v=", "")
|
82
|
+
images << make_url (:youtube_long, code)
|
83
|
+
end
|
84
|
+
|
74
85
|
IMAGE_FINDERS.each do |finder|
|
75
86
|
images += tweet.scan(finder)
|
76
87
|
end
|
data/spec/imagize_spec.rb
CHANGED
@@ -30,6 +30,9 @@ describe "Imagize" do
|
|
30
30
|
it "should recognize youtube" do
|
31
31
|
urls= @imagizer.imagize("Hallo bnfgjfdgbfd http://youtu.be/B5IgPI9Dc7A?a\n Fiets")
|
32
32
|
urls.should include("http://img.youtube.com/vi/B5IgPI9Dc7A/0.jpg")
|
33
|
+
|
34
|
+
urls = @imagizer.imagize("Hallo bnfgjfdgbfd http://www.youtube.com/watch?v=NPahxS10HkY Fiets")
|
35
|
+
urls.should include("http://img.youtube.com/vi/NPahxS10HkY/0.jpg")
|
33
36
|
end
|
34
37
|
|
35
38
|
it "should recognize tweetphoto" do
|