video_info 1.0.1 → 1.1.0

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.
@@ -16,10 +16,6 @@ module VideoInfo
16
16
  get_info unless @video_id == url || @video_id.nil? || @video_id.empty?
17
17
  end
18
18
 
19
- def valid?
20
- !@video_id.nil? && !['', nil].include?(@title)
21
- end
22
-
23
19
  private
24
20
 
25
21
  def get_info
@@ -26,10 +26,6 @@ module VideoInfo
26
26
  end
27
27
  end
28
28
 
29
- def valid?
30
- !@video_id.nil? && !['', nil].include?(@title)
31
- end
32
-
33
29
  private
34
30
 
35
31
  def get_info
data/lib/video_info.rb CHANGED
@@ -1,11 +1,32 @@
1
1
  require 'open-uri'
2
2
  require 'multi_json'
3
- require 'video_info/version'
4
3
  require 'providers/vimeo'
5
4
  require 'providers/youtube'
6
5
 
7
6
  module VideoInfo
7
+
8
8
  def self.get(url, options = {})
9
+ options = clean_options(options)
10
+ video = get_video(url, options)
11
+ valid?(video) ? video : nil
12
+ end
13
+
14
+ private
15
+
16
+ def self.get_video(url, options)
17
+ case url
18
+ when /vimeo\.com/
19
+ Vimeo.new(url, options)
20
+ when /(youtube\.com)|(youtu\.be)/
21
+ Youtube.new(url, options)
22
+ end
23
+ end
24
+
25
+ def self.valid?(video)
26
+ !video.nil? && !video.video_id.nil? && !['', nil].include?(video.title)
27
+ end
28
+
29
+ def self.clean_options(options)
9
30
  options = { "User-Agent" => "VideoInfo/#{VideoInfo::VERSION}" }.merge options
10
31
  options.dup.each do |key, value|
11
32
  unless OpenURI::Options.keys.include?(key) || options[:iframe_attributes]
@@ -15,17 +36,7 @@ module VideoInfo
15
36
  end
16
37
  end
17
38
  end
18
-
19
- case url
20
- when /vimeo\.com/
21
- @video = Vimeo.new(url, options)
22
- when /(youtube\.com)|(youtu\.be)/
23
- @video = Youtube.new(url, options)
24
- end
25
- end
26
-
27
- def self.method_missing(sym, *args, &block)
28
- @video.send sym, *args, &block
39
+ options
29
40
  end
30
41
 
31
42
  def self.hash_to_attributes(hash)
@@ -1,3 +1,3 @@
1
1
  module VideoInfo
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: video_info
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
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-12-10 00:00:00.000000000 Z
12
+ date: 2012-12-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json