video 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +12 -4
- data/lib/video.rb +12 -1
- data/lib/video/version.rb +1 -1
- data/spec/video_spec.rb +20 -4
- metadata +2 -2
data/README.md
CHANGED
@@ -10,14 +10,22 @@ Only youtube links are supported so far
|
|
10
10
|
|
11
11
|
link = GC::Video.new "http://www.youtube.com/watch?v=t9LMOydfc4k&feature=related"
|
12
12
|
|
13
|
-
link.id
|
14
|
-
=> "t9LMOydfc4k"
|
13
|
+
link.id => "t9LMOydfc4k"
|
15
14
|
|
16
|
-
link.provider
|
17
|
-
|
15
|
+
link.provider => :youtube
|
16
|
+
|
17
|
+
link.thumbnail => "//img.youtube.com/vi/t9LMOydfc4k/default.jpg"
|
18
|
+
link.thumbnail(:full) => "//img.youtube.com/vi/t9LMOydfc4k/0.jpg"
|
18
19
|
|
19
20
|
link.embed('560x315')
|
20
21
|
=> <iframe width="560" height="315"
|
21
22
|
src="http://www.youtube.com/embed/t9LMOydfc4k&html5=1"
|
22
23
|
frameborder="0" allowfullscreen>
|
23
24
|
</iframe>
|
25
|
+
|
26
|
+
link.embed('560x315', load: false, attr1: 'value1')
|
27
|
+
=> <iframe width="560" height="315"
|
28
|
+
data-src="http://www.youtube.com/embed/t9LMOydfc4k&html5=1"
|
29
|
+
data-attr1="value1"
|
30
|
+
frameborder="0" allowfullscreen>
|
31
|
+
</iframe>
|
data/lib/video.rb
CHANGED
@@ -25,7 +25,18 @@ module GC
|
|
25
25
|
def embed dim='560x315', options={}
|
26
26
|
options[:load] = true if options[:load].nil?
|
27
27
|
h,w = dim.split('x')
|
28
|
-
|
28
|
+
if youtube?
|
29
|
+
@embed = %(<iframe width="#{h}" height="#{w}" #{options[:load] ? 'src' : 'data-src'}="http://www.youtube.com/embed/#{id}?html5=1")
|
30
|
+
options.each do | k,v|
|
31
|
+
next if k == :load
|
32
|
+
@embed += %( data-#{k}="#{v}")
|
33
|
+
end
|
34
|
+
@embed += %( frameborder="0" allowfullscreen></iframe>)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def thumbnail size=:default
|
39
|
+
"//img.youtube.com/vi/#{id}/#{size == :full ? '0' : 'default'}.jpg" if youtube?
|
29
40
|
end
|
30
41
|
end
|
31
42
|
end
|
data/lib/video/version.rb
CHANGED
data/spec/video_spec.rb
CHANGED
@@ -23,12 +23,28 @@ describe GC::Video do
|
|
23
23
|
video.id.should == 't9LMOydfc4k'
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
describe '#embed' do
|
27
|
+
it 'outputs provider recommended code to embed' do
|
28
|
+
video.embed('1024x768').should == %(<iframe width="1024" height="768" src="http://www.youtube.com/embed/t9LMOydfc4k?html5=1" frameborder="0" allowfullscreen></iframe>)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'outputs provider recommended code without the src attribute' do
|
32
|
+
video.embed('1024x768', load: false).should == %(<iframe width="1024" height="768" data-src="http://www.youtube.com/embed/t9LMOydfc4k?html5=1" frameborder="0" allowfullscreen></iframe>)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'outputs a hash of options as data attributes' do
|
36
|
+
video.embed('1024x768', attr1: 'value1', attr2: 'value2').should == %(<iframe width="1024" height="768" src="http://www.youtube.com/embed/t9LMOydfc4k?html5=1" data-attr1="value1" data-attr2="value2" frameborder="0" allowfullscreen></iframe>)
|
37
|
+
end
|
28
38
|
end
|
29
39
|
|
30
|
-
|
31
|
-
|
40
|
+
describe '#thumbnail' do
|
41
|
+
it 'provides the default thuwbnail' do
|
42
|
+
video.thumbnail.should == "//img.youtube.com/vi/t9LMOydfc4k/default.jpg"
|
43
|
+
end
|
44
|
+
it 'provides the full thuwbnail' do
|
45
|
+
video.thumbnail(:full).should == "//img.youtube.com/vi/t9LMOydfc4k/0.jpg"
|
46
|
+
end
|
32
47
|
end
|
48
|
+
|
33
49
|
end
|
34
50
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: video
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|