videawesome 0.0.3 → 0.0.4

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.
Files changed (2) hide show
  1. data/lib/videawesome.rb +10 -7
  2. metadata +3 -3
data/lib/videawesome.rb CHANGED
@@ -1,27 +1,30 @@
1
1
  module Videawesome
2
2
  class Convertor
3
+
4
+ URL = /(ht)tp\:\/\/[www.youtube||vimeo||youtu]+\.[com||be]/
5
+ YOUTUBE = /[a-zA-Z0-9]{3,12}/
6
+ VIMEO = /[0-9]{3,12}/
7
+
3
8
  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
9
+ url_ident =url.scan(YOUTUBE).to_s
6
10
  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>")
7
11
  end
8
12
 
9
13
  def self.vimeo_video(url, text, height, width)
10
- ident_regexp = /\/[0-9]{3,}/
11
- url_ident = url.scan(ident_regexp).to_s
14
+ url_ident = url.scan(VIMEO).to_s
12
15
  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>")
13
16
  end
14
17
 
15
18
  def self.parse_video(text, height, width)
16
- youtube_regexp = /(ht)tp\:\/\/[www.youtube||vimeo||youtu]+\.[com||be]/
17
- url = text.split.grep(youtube_regexp).to_s
19
+ url = text.split.grep(URL).to_s
18
20
 
19
- if url != "" && url.match("youtube.com") || url.match("http://youtu.be")
21
+ if url != "" && url.match("youtube.com") || url.match("youtu.be")
20
22
  text = youtube_video(url, text, height, width)
21
23
  elsif url != "" && url.match("vimeo.com")
22
24
  text = vimeo_video(url, text, height, width)
23
25
  end
24
26
  return text
25
27
  end
28
+
26
29
  end
27
30
  end
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: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Lee