imagize 0.2.0 → 0.2.1

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{imagize}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
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"]
@@ -13,10 +13,14 @@ module Imagize
13
13
  :url => "http://yfrog.com/",
14
14
  :convert => "http://yfrog.com/§ID§:iphone"
15
15
  },
16
- :youtube => {
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
@@ -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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 0
9
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Raymond van Dongelen