hosted_video 0.0.2 → 0.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7de6ddafdc048c125a565f8c3af73ee3ac0a980f
4
- data.tar.gz: ba024b1e762357a3b6790409d56b6820d959e49b
3
+ metadata.gz: bef8edd4d844122f99a4cc256e84471dc4a83f1c
4
+ data.tar.gz: e5013dd01daa32477e6375d82481675cf8f17787
5
5
  SHA512:
6
- metadata.gz: 3d681ba4a1e99802556b93d05de4f08fd683af6fd5e20504dd2f57b9c53666cf42a8485bfacf714c3d6177362fb9d4964ca293a812a37e67b7363b1a7f80185a
7
- data.tar.gz: 1c6d1bf026fe4e71632daddab92ed569c58789f5388e8c1d4989787030c076e6f3c156dc1f07fdc76637f9b2eebe06266d1a0eb674d73d2e90ec432492040074
6
+ metadata.gz: 9b3c2b28397ce608bdb3cf3881e2ef28dd1e0d098a8ef24e2fd6894ee97225e900f34214bb546b132e24e137b6152816e540b684739f042abeed7c2502214329
7
+ data.tar.gz: 5e8e85f1fb3dcbe4ab67cf9151d75d563365f7af585f2f6252b0e15e30485b54ecef5e19896adeee8222fff98a05a510904d68b2517827e47d53131ee40548f9
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
+ sudo: false
2
3
  rvm:
3
4
  - 2.1.0
4
5
  - 2.0.0
data/README.md CHANGED
@@ -28,6 +28,37 @@ video.preview # => "http://img.youtube.com/vi/TBKN7_vx2xo/hqdefault.jpg"
28
28
  video.iframe_code # => "<iframe width='420' height='315' frameborder='0' src='http://www.youtube.com/embed/TBKN7_vx2xo?wmode=transparent'></iframe>"
29
29
  ```
30
30
 
31
+ You can create your own video service providers by inheriting from HostedVideo::Providers::Base and implementing parsing functions:
32
+ ```ruby
33
+ class MyProvider < HostedVideo::Providers::Base
34
+ # logic to determine your service
35
+ def self.can_parse?(url)
36
+ url =~ /myprovider\.com\/\d{3}.*/
37
+ end
38
+
39
+ # how to get preview image
40
+ def preview
41
+ "http://myprovider.ru/api/video/#{vid}/?preview=true")
42
+ end
43
+
44
+ def url_for_iframe
45
+ "http://rutube.ru/video/embed/#{vid}"
46
+ end
47
+
48
+ private
49
+ # regular expression for getting video id from link
50
+ def vid_regex
51
+ /(https?:\/\/)?(www\.)?rutube\.ru\/video\/(?<id>\w{32}|\w{7}).*/
52
+ end
53
+ end
54
+
55
+ HostedVideo.configure do |c|
56
+ c.additional_providers += [MyProvider]
57
+ end
58
+ ```
59
+ Please send me pull-requests with your providers or write an issue with pasted code.
60
+
61
+
31
62
  ## Contributing
32
63
 
33
64
  1. Fork it
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "rspec"
24
24
  spec.add_development_dependency "webmock"
25
+
25
26
  end
@@ -1,18 +1,10 @@
1
1
  module HostedVideo
2
2
  module Providers
3
- class RutubeByIframe < Base
3
+ class RutubeByIframe < Rutube
4
4
  def self.can_parse?(url)
5
5
  url =~ /rutube\.ru\/video\/embed\/(\w{32}|\w{7}).*/
6
6
  end
7
7
 
8
- def preview
9
- JSON.load(open("http://rutube.ru/api/video/#{vid}/?format=json"))['thumbnail_url']
10
- end
11
-
12
- def url_for_iframe
13
- "http://rutube.ru/video/embed/#{vid}"
14
- end
15
-
16
8
  private
17
9
 
18
10
  def vid_regex
@@ -1,18 +1,10 @@
1
1
  module HostedVideo
2
2
  module Providers
3
- class VimeoByIframe < Base
3
+ class VimeoByIframe < Vimeo
4
4
  def self.can_parse?(url)
5
5
  url =~ /player\.vimeo\.com\/video\/\d{7,8}.*/
6
6
  end
7
7
 
8
- def preview
9
- JSON.load(open("http://vimeo.com/api/v2/video/#{vid}.json")).first['thumbnail_large']
10
- end
11
-
12
- def url_for_iframe
13
- "http://player.vimeo.com/video/#{vid}?api=0"
14
- end
15
-
16
8
  private
17
9
 
18
10
  def vid_regex
@@ -1,19 +1,11 @@
1
1
  module HostedVideo
2
2
  module Providers
3
- class YoutubeByIframe < Base
3
+ class YoutubeByIframe < Youtube
4
4
 
5
5
  def self.can_parse?(url)
6
6
  url =~ /youtube\.com\/embed\/[\w,-]{11}(\?.*)?/
7
7
  end
8
8
 
9
- def preview
10
- "http://img.youtube.com/vi/#{vid}/hqdefault.jpg"
11
- end
12
-
13
- def url_for_iframe
14
- "http://www.youtube.com/embed/#{vid}?wmode=transparent"
15
- end
16
-
17
9
  private
18
10
 
19
11
  def vid_regex
@@ -1,3 +1,3 @@
1
1
  module HostedVideo
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,7 +1,3 @@
1
1
  require 'rspec'
2
2
  require 'webmock/rspec'
3
3
  require 'hosted_video'
4
-
5
- RSpec.configure do |config|
6
- config.color_enabled = true
7
- end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hosted_video
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vadim Alekseev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-26 00:00:00.000000000 Z
11
+ date: 2015-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler