acts_as_unvlogable 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.markdown +3 -1
- data/acts_as_unvlogable.gemspec +2 -1
- data/lib/acts_as_unvlogable/version.rb +1 -1
- data/lib/acts_as_unvlogable/vg_metacafe.rb +1 -1
- data/lib/acts_as_unvlogable/vg_youtube.rb +10 -7
- data/lib/acts_as_unvlogable.rb +1 -1
- data/spec/acts_as_unvlogable_spec.rb +5 -5
- data/unvlogable_sample.yml +3 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 119b6b929d2bfebafa60364c69adde19040c728c
|
4
|
+
data.tar.gz: 100ce17b9848f5e24ef0da99e2a9c8eaa554094b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d3460ba785a20703192566dfd8ade5d6363c8e9dd8ab6925b9dce5c08964464ed82d0360efc20826246c6221e41be94156a9da7cb5c120f79807bbb6cd956eb
|
7
|
+
data.tar.gz: 85cbe903a240835ef4ac54c4abfb7c7aa550d3c71b5c9423f046a9f0b1451e3696f5d6c2cc479c24d8c179dd6286c9c593cac2ee1e3cdec88ad48de7e7850a00
|
data/README.markdown
CHANGED
@@ -33,7 +33,9 @@ Install it!
|
|
33
33
|
|
34
34
|
gem "acts_as_unvlogable"
|
35
35
|
|
36
|
-
2. Optionally you can create the `config/unvlogable.yml` to store keys for the different services. You have in the plugin a [sample file](http://github.com/mamuso/acts_as_unvlogable/tree/master/unvlogable_sample.yml).
|
36
|
+
2. Optionally you can create the `config/unvlogable.yml` to store keys for the different services. You have in the plugin a [sample file](http://github.com/mamuso/acts_as_unvlogable/tree/master/unvlogable_sample.yml).
|
37
|
+
|
38
|
+
2.1. 'yt' gem will need an API key from google in order to get the youtube video information properly, without dealing with API limits. They explain it better than me [here](https://github.com/Fullscreen/yt#apps-that-do-not-require-user-interactions)
|
37
39
|
|
38
40
|
Use it!
|
39
41
|
-------
|
data/acts_as_unvlogable.gemspec
CHANGED
@@ -6,6 +6,7 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.name = "acts_as_unvlogable"
|
7
7
|
s.version = ActsAsUnvlogable::VERSION
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
|
+
s.required_ruby_version = '>= 1.9.3'
|
9
10
|
s.authors = ["Manuel Muñoz", "Fernando Blat", "Alberto Romero"]
|
10
11
|
s.email = ["mamuso@mamuso.net", "ferblape@gmail.com", "denegro@gmail.com"]
|
11
12
|
s.homepage = "https://github.com/mamuso/acts_as_unvlogable"
|
@@ -24,5 +25,5 @@ Gem::Specification.new do |s|
|
|
24
25
|
s.add_development_dependency 'rspec'
|
25
26
|
s.add_runtime_dependency("nokogiri")
|
26
27
|
s.add_runtime_dependency("xml-simple")
|
27
|
-
s.add_runtime_dependency("
|
28
|
+
s.add_runtime_dependency("yt")
|
28
29
|
end
|
@@ -10,7 +10,7 @@ class VgMetacafe
|
|
10
10
|
@url = url
|
11
11
|
@args = parse_url(url)
|
12
12
|
@youtubed = @args[1].index("yt-").nil? ? false : true
|
13
|
-
@yt = @youtubed ? VgYoutube.new("http://www.youtube.com/watch?v=#{@args[1].sub('yt-', '')}") : nil
|
13
|
+
@yt = @youtubed ? VgYoutube.new("http://www.youtube.com/watch?v=#{@args[1].sub('yt-', '')}", options) : nil
|
14
14
|
end
|
15
15
|
|
16
16
|
def title
|
@@ -6,13 +6,16 @@
|
|
6
6
|
class VgYoutube
|
7
7
|
|
8
8
|
def initialize(url=nil, options={})
|
9
|
-
|
9
|
+
settings ||= YAML.load_file(RAILS_ROOT + '/config/unvlogable.yml') rescue {}
|
10
|
+
Yt.configure do |config|
|
11
|
+
config.api_key = options.nil? || options[:key].nil? ? settings['youtube_key'] : options[:key]
|
12
|
+
end
|
13
|
+
|
10
14
|
@url = url
|
11
15
|
@video_id = @url.query_param('v')
|
12
16
|
begin
|
13
|
-
@details =
|
14
|
-
raise if @details.blank?
|
15
|
-
@details.instance_variable_set(:@noembed, false) unless !@details.embeddable?
|
17
|
+
@details = Yt::Video.new id: @video_id
|
18
|
+
raise if @details.blank? || !@details.embeddable?
|
16
19
|
rescue
|
17
20
|
raise ArgumentError, "Unsuported url or service"
|
18
21
|
end
|
@@ -23,7 +26,7 @@ class VgYoutube
|
|
23
26
|
end
|
24
27
|
|
25
28
|
def thumbnail
|
26
|
-
@details.
|
29
|
+
@details.thumbnail_url
|
27
30
|
end
|
28
31
|
|
29
32
|
def duration
|
@@ -31,12 +34,12 @@ class VgYoutube
|
|
31
34
|
end
|
32
35
|
|
33
36
|
def embed_url
|
34
|
-
|
37
|
+
"http://www.youtube.com/embed/#{@video_id}" if @details.embeddable?
|
35
38
|
end
|
36
39
|
|
37
40
|
# iframe embed — https://developers.google.com/youtube/player_parameters#Manual_IFrame_Embeds
|
38
41
|
def embed_html(width=425, height=344, options={}, params={})
|
39
|
-
"<iframe id='ytplayer' type='text/html' width='#{width}' height='#{height}' src='#{embed_url}#{options.map {|k,v| "&#{k}=#{v}"}}' frameborder='0'/>" if @details.
|
42
|
+
"<iframe id='ytplayer' type='text/html' width='#{width}' height='#{height}' src='#{embed_url}#{options.map {|k,v| "&#{k}=#{v}"}}' frameborder='0'/>" if @details.embeddable?
|
40
43
|
end
|
41
44
|
|
42
45
|
def service
|
data/lib/acts_as_unvlogable.rb
CHANGED
@@ -19,7 +19,7 @@ describe UnvlogIt do
|
|
19
19
|
# ----------------------------------------------------------
|
20
20
|
|
21
21
|
context "with an existent youtube url" do
|
22
|
-
let(:videotron) { UnvlogIt.new("http://www.youtube.com/watch?v=MVa4q-YVjD8") } # => Keith Moon´s drum kit explodes
|
22
|
+
let(:videotron) { UnvlogIt.new("http://www.youtube.com/watch?v=MVa4q-YVjD8", {:key => "AIzaSyCWdV1zQpyD1X1OdheU6UqfV3JR6JQXY9A" }) } # => Keith Moon´s drum kit explodes
|
23
23
|
|
24
24
|
it "initialize a VgYoutube instance" do
|
25
25
|
expect(VgYoutube).to eq(videotron.instance_values['object'].class)
|
@@ -35,18 +35,18 @@ describe UnvlogIt do
|
|
35
35
|
|
36
36
|
context "with an existent youtube url that can not be embedded" do
|
37
37
|
it {
|
38
|
-
expect { UnvlogIt.new("https://www.youtube.com/watch?v=-PZYZ6fJbr4") }.to raise_error(ArgumentError, "
|
38
|
+
expect { UnvlogIt.new("https://www.youtube.com/watch?v=-PZYZ6fJbr4", {:key => "AIzaSyCWdV1zQpyD1X1OdheU6UqfV3JR6JQXY9A" }) }.to raise_error(ArgumentError, "Unsuported url or service")
|
39
39
|
}
|
40
40
|
end
|
41
41
|
|
42
42
|
context "with an inexistent youtube url" do
|
43
43
|
it {
|
44
|
-
expect { UnvlogIt.new("http://www.youtube.com/watch?v=inexistente") }.to raise_error(ArgumentError, "Unsuported url or service")
|
44
|
+
expect { UnvlogIt.new("http://www.youtube.com/watch?v=inexistente", {:key => "AIzaSyCWdV1zQpyD1X1OdheU6UqfV3JR6JQXY9A" }) }.to raise_error(ArgumentError, "Unsuported url or service")
|
45
45
|
}
|
46
46
|
end
|
47
47
|
|
48
48
|
context "with a shortened youtube URL" do
|
49
|
-
let(:videotron) { UnvlogIt.new("http://youtu.be/4pzMBtPMUq8") } # => Keith Moon´s drum kit explodes
|
49
|
+
let(:videotron) { UnvlogIt.new("http://youtu.be/4pzMBtPMUq8", {:key => "AIzaSyCWdV1zQpyD1X1OdheU6UqfV3JR6JQXY9A" }) } # => Keith Moon´s drum kit explodes
|
50
50
|
|
51
51
|
it "initialize a VgYoutube instance" do
|
52
52
|
expect(VgYoutu).to eq(videotron.instance_values['object'].class)
|
@@ -81,7 +81,7 @@ describe UnvlogIt do
|
|
81
81
|
end
|
82
82
|
|
83
83
|
context "with an existent 'youtubed' metacafe url" do
|
84
|
-
let(:videotron) { UnvlogIt.new("http://www.metacafe.com/watch/yt-r07zdVLOWBA/pop_rocks_and_coke_myth/") } # => Pop Rocks and Coke Myth
|
84
|
+
let(:videotron) { UnvlogIt.new("http://www.metacafe.com/watch/yt-r07zdVLOWBA/pop_rocks_and_coke_myth/", {:key => "AIzaSyCWdV1zQpyD1X1OdheU6UqfV3JR6JQXY9A" }) } # => Pop Rocks and Coke Myth
|
85
85
|
|
86
86
|
it "initialize a VgMetacafe instance" do
|
87
87
|
expect(VgMetacafe).to eq(videotron.instance_values['object'].class)
|
data/unvlogable_sample.yml
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_unvlogable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manuel Muñoz
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-05-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -83,7 +83,7 @@ dependencies:
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
|
-
name:
|
86
|
+
name: yt
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
89
|
- - ">="
|
@@ -150,7 +150,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
150
150
|
requirements:
|
151
151
|
- - ">="
|
152
152
|
- !ruby/object:Gem::Version
|
153
|
-
version:
|
153
|
+
version: 1.9.3
|
154
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
155
|
requirements:
|
156
156
|
- - ">="
|