conred 0.1.2 → 0.1.3
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/lib/conred.rb +1 -4
- data/lib/conred/version.rb +1 -1
- data/lib/conred/video.rb +10 -16
- data/lib/views/video/vimeo_iframe.html.haml +1 -1
- data/lib/views/video/youtube_iframe.html.haml +1 -1
- data/spec/conred_spec/video_spec.rb +7 -19
- metadata +1 -1
data/lib/conred.rb
CHANGED
data/lib/conred/version.rb
CHANGED
data/lib/conred/video.rb
CHANGED
@@ -32,12 +32,8 @@ module Conred
|
|
32
32
|
if @video_url[/vimeo\.com\/([0-9]*)/]
|
33
33
|
@vimeo_id = $1
|
34
34
|
end
|
35
|
-
vimeo_file =
|
36
|
-
|
37
|
-
'..', 'views',
|
38
|
-
'video', 'vimeo_iframe.html.haml'
|
39
|
-
)
|
40
|
-
render_file(vimeo_file).html_safe
|
35
|
+
vimeo_file = "../views/video/vimeo_iframe"
|
36
|
+
render(vimeo_file, :vimeo_id => @vimeo_id, :height => @height, :width => @width).html_safe
|
41
37
|
end
|
42
38
|
|
43
39
|
def video_from_youtube_url
|
@@ -46,19 +42,17 @@ module Conred
|
|
46
42
|
else
|
47
43
|
@video_url[/(v=([A-Za-z0-9_]*))/]
|
48
44
|
@youtube_id = $2
|
49
|
-
|
50
45
|
end
|
51
|
-
youtube_file =
|
52
|
-
|
53
|
-
'..', 'views',
|
54
|
-
'video', 'youtube_iframe.html.haml'
|
55
|
-
)
|
56
|
-
render_file(youtube_file).html_safe
|
46
|
+
youtube_file = "../views/video/youtube_iframe"
|
47
|
+
render(youtube_file, :youtube_id => @youtube_id, :height => @height, :width => @width).html_safe
|
57
48
|
end
|
58
49
|
|
59
|
-
def
|
60
|
-
|
61
|
-
|
50
|
+
def render(path_to_partial, locals = {})
|
51
|
+
path = File.join(
|
52
|
+
File.dirname(__FILE__),
|
53
|
+
path_to_partial.split("/")
|
54
|
+
)
|
55
|
+
Haml::Engine.new(File.read("#{path}.html.haml")).render(Object.new, locals)
|
62
56
|
end
|
63
57
|
|
64
58
|
end
|
@@ -1 +1 @@
|
|
1
|
-
%iframe{:allowFullScreen => "", :frameborder => "0", :height =>
|
1
|
+
%iframe{:allowFullScreen => "", :frameborder => "0", :height => height, :mozallowfullscreen => "", :src => "http://player.vimeo.com/video/#{vimeo_id}", :webkitAllowFullScreen => "", :width => width}
|
@@ -1 +1 @@
|
|
1
|
-
%iframe{:allowfullscreen => "", :frameborder => "0", :height =>
|
1
|
+
%iframe{:allowfullscreen => "", :frameborder => "0", :height => height, :src => "http://www.youtube.com/embed/#{youtube_id}?wmode=transparent", :title => "YouTube video player", :width => width}
|
@@ -4,22 +4,6 @@ describe Conred do
|
|
4
4
|
describe Conred::Video do
|
5
5
|
before do
|
6
6
|
|
7
|
-
@vimeo_code = "49556689"
|
8
|
-
vimeo_file = File.join(
|
9
|
-
File.dirname(__FILE__),
|
10
|
-
'..', '..', 'lib', 'views',
|
11
|
-
'video', 'vimeo_iframe.html.haml'
|
12
|
-
)
|
13
|
-
@vimeo_embed_code = Conred.render_file(vimeo_file).html_safe
|
14
|
-
|
15
|
-
@youtube_id = "Lrj5Kxdzouc"
|
16
|
-
youtube_file = File.join(
|
17
|
-
File.dirname(__FILE__),
|
18
|
-
'..', '..', 'lib', 'views',
|
19
|
-
'video', 'youtube_iframe.html.haml'
|
20
|
-
)
|
21
|
-
@youtube_embed_code = Conred.render_file(youtube_file).html_safe
|
22
|
-
|
23
7
|
end
|
24
8
|
it "should match youtube video" do
|
25
9
|
Conred::Video.new("http://www.youtube.com/watch?v=SZt5RFzqEfY&feature=g-all-fbc").should be_youtube_video
|
@@ -39,9 +23,13 @@ describe Conred do
|
|
39
23
|
Conred::Video.new("eeevil vimeo www.vimeo.com/12311233").youtube_video? == false
|
40
24
|
end
|
41
25
|
it "should return correct embed code" do
|
42
|
-
Conred::Video.new("http://www.youtube.com/watch?NR=1&feature=endscreen&v=Lrj5Kxdzouc", 450, 300).code.should
|
43
|
-
Conred::Video.new("http://www.youtube.com/watch?v=Lrj5Kxdzouc", 450, 300).code.should
|
44
|
-
Conred::Video.new("http://
|
26
|
+
Conred::Video.new("http://www.youtube.com/watch?NR=1&feature=endscreen&v=Lrj5Kxdzouc", 450, 300).code.should match(/Lrj5Kxdzouc/)
|
27
|
+
Conred::Video.new("http://www.youtube.com/watch?v=Lrj5Kxdzouc", 450, 300).code.should match(/Lrj5Kxdzouc/)
|
28
|
+
Conred::Video.new("http://www.youtube.com/watch?v=Lrj5Kxdzouc", 450, 300).code.should match(/width='450'/)
|
29
|
+
Conred::Video.new("http://www.youtube.com/watch?v=Lrj5Kxdzouc", 450, 300).code.should match(/height='300'/)
|
30
|
+
Conred::Video.new("http://vimeo.com/49556689", 450, 300).code.should match(/49556689/)
|
31
|
+
Conred::Video.new("http://vimeo.com/49556689", 450, 300).code.should match(/width='450'/)
|
32
|
+
Conred::Video.new("http://vimeo.com/49556689", 450, 300).code.should match(/height='300'/)
|
45
33
|
Conred::Video.new("http://google.com/12311233", 450, 300, "Some mistake in url").code.should == "Some mistake in url"
|
46
34
|
end
|
47
35
|
end
|