videawesome 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/#videawesome.rb# +29 -0
  2. data/lib/videawesome.rb +3 -3
  3. metadata +5 -4
@@ -0,0 +1,29 @@
1
+ module Videawesome
2
+ class Convertor
3
+
4
+ URL = /http\:\/\/[www.youtube||a-z]+\.[a-z]{2,3}\/[a-zA-Z0-9*\D]{3,15}$/
5
+ IDENT = /\/[a-zA-Z0-9\D]{3,15}$/
6
+
7
+ def self.youtube_video(url, text, height, width)
8
+ url_ident =url.scan(IDENT).to_s
9
+ altered_text = text.gsub(url,"<iframe title='YouTube video player' class='youtube-player' type='text/html' width='#{width}' height='#{height}' src='http://www.youtube.com/v#{url_ident}' frameborder='0'></iframe><br /><small> dont have flash player installed? <a href=\"http://www.youtube.com/v#{url_ident}\" target=\"_blank\">click here</a></small>")
10
+ end
11
+
12
+ def self.vimeo_video(url, text, height, width)
13
+ url_ident = url.scan(IDENT).to_s
14
+ altered_text = text.gsub(url,"<iframe title='Vimeo Video Player' src='http://player.vimeo.com/video#{url_ident}' width='#{width}' height='#{height}' frameborder='0'></iframe><br /> <small>dont have flash player installed? <a href=\"http://player.vimeo.com/video#{url_ident}\" target=\"_blank\">click here</a></small>")
15
+ end
16
+
17
+ def self.parse_video(text, height, width)
18
+ url = text.split.grep(URL).to_s
19
+
20
+ if url != "" && url.match("youtube.com") || url.match("youtu.be")
21
+ text = youtube_video(url, text, height, width)
22
+ elsif url != "" && url.match("vimeo.com")
23
+ text = vimeo_video(url, text, height, width)
24
+ end
25
+ return text
26
+ end
27
+
28
+ end
29
+ end
data/lib/videawesome.rb CHANGED
@@ -1,12 +1,12 @@
1
1
  module Videawesome
2
2
  class Convertor
3
3
 
4
- URL = /http\:\/\/[www.youtube||a-z]+\.[a-z]{2,3}\/[a-zA-Z0-9*\/]{3,15}/
5
- IDENT = /[a-zA-Z0-9]{3,15}$/
4
+ URL = /http\:\/\/[www.youtube||a-z]+\.[a-z]{2,3}\/[a-zA-Z0-9*\D]{3,15}$/
5
+ IDENT = /\/[a-zA-Z0-9\D]{3,15}$/
6
6
 
7
7
  def self.youtube_video(url, text, height, width)
8
8
  url_ident =url.scan(IDENT).to_s
9
- altered_text = text.gsub(url,"<iframe title='YouTube video player' class='youtube-player' type='text/html' width='#{width}' height='#{height}' src='http://www.youtube.com/v/#{url_ident}' frameborder='0'></iframe><br /><small> dont have flash player installed? <a href=\"http://www.youtube.com/v/#{url_ident}\" target=\"_blank\">click here</a></small>")
9
+ altered_text = text.gsub(url,"<iframe title='YouTube video player' class='youtube-player' type='text/html' width='#{width}' height='#{height}' src='http://www.youtube.com/v/#{url_ident}' frameborder='0'></iframe><br /><small> dont have flash player installed? <a href=\"http://www.youtube.com/v#{url_ident}\" target=\"_blank\">click here</a></small>")
10
10
  end
11
11
 
12
12
  def self.vimeo_video(url, text, height, width)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: videawesome
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Lee
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-10 00:00:00 +01:00
18
+ date: 2011-05-13 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -28,6 +28,7 @@ extensions: []
28
28
  extra_rdoc_files: []
29
29
 
30
30
  files:
31
+ - lib/#videawesome.rb#
31
32
  - lib/videawesome.rb
32
33
  has_rdoc: true
33
34
  homepage: