videawesome 0.0.1

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# +27 -0
  2. data/lib/videawesome.rb +27 -0
  3. metadata +68 -0
@@ -0,0 +1,27 @@
1
+ module Videawesome
2
+ class Convertor
3
+ def self.youtube_video(url, text, height, width)
4
+ ident_regexp = /[a-zA-Z0-9]{11}/
5
+ url_ident =url.scan(ident_regexp).to_s
6
+ altered_text = text.gsub(url,"<p><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></p>")
7
+ end
8
+
9
+ def self.vimeo_video(url, text, height, width)
10
+ ident_regexp = /\/[0-9]{3,}/
11
+ url_ident = url.scan(ident_regexp).to_s
12
+ altered_text = text.gsub(url,"<p><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></p>")
13
+ end
14
+
15
+ def self.parse_video(text, height, width)
16
+ youtube_regexp = /(ht)tp\:\/\/[www.youtube||vimeo]+\.(com)/
17
+ url = text.split.grep(youtube_regexp).to_s
18
+
19
+ if url != "" && url.match("youtube.com")
20
+ text = youtube_video(url, text, height, width)
21
+ elsif url != "" && url.match("vimeo.com")
22
+ text = vimeo_video(url, text, height, width)
23
+ end
24
+ return text
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ module Videawesome
2
+ class Convertor
3
+ def self.youtube_video(url, text, height, width)
4
+ ident_regexp = /[a-zA-Z0-9]{11}/
5
+ url_ident =url.scan(ident_regexp).to_s
6
+ altered_text = text.gsub(url,"<p><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></p>")
7
+ end
8
+
9
+ def self.vimeo_video(url, text, height, width)
10
+ ident_regexp = /\/[0-9]{3,}/
11
+ url_ident = url.scan(ident_regexp).to_s
12
+ altered_text = text.gsub(url,"<p><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></p>")
13
+ end
14
+
15
+ def self.parse_video(text, height, width)
16
+ youtube_regexp = /(ht)tp\:\/\/[www.youtube||vimeo]+\.(com)/
17
+ url = text.split.grep(youtube_regexp).to_s
18
+
19
+ if url != "" && url.match("youtube.com")
20
+ text = youtube_video(url, text, height, width)
21
+ elsif url != "" && url.match("vimeo.com")
22
+ text = vimeo_video(url, text, height, width)
23
+ end
24
+ return text
25
+ end
26
+ end
27
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: videawesome
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Lee
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-03-24 00:00:00 +00:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description:
23
+ email: lee@stealthygecko.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - lib/#videawesome.rb#
32
+ - lib/videawesome.rb
33
+ has_rdoc: true
34
+ homepage:
35
+ licenses: []
36
+
37
+ post_install_message:
38
+ rdoc_options: []
39
+
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ hash: 3
48
+ segments:
49
+ - 0
50
+ version: "0"
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ requirements: []
61
+
62
+ rubyforge_project:
63
+ rubygems_version: 1.3.7
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: An awesome video helper for Rails apps
67
+ test_files: []
68
+