film_snob 0.3.13 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.hound.yml +3 -0
- data/.rubocop.yml +61 -0
- data/.travis.yml +9 -1
- data/Gemfile +2 -1
- data/README.md +15 -3
- data/Rakefile +2 -2
- data/film_snob.gemspec +9 -6
- data/lib/film_snob/coub.rb +2 -3
- data/lib/film_snob/dailymotion.rb +3 -4
- data/lib/film_snob/deprecated.rb +13 -0
- data/lib/film_snob/exceptions.rb +1 -0
- data/lib/film_snob/funny_or_die.rb +1 -0
- data/lib/film_snob/hulu.rb +2 -3
- data/lib/film_snob/instagram.rb +13 -4
- data/lib/film_snob/url_to_video.rb +7 -8
- data/lib/film_snob/version.rb +2 -1
- data/lib/film_snob/video_site.rb +34 -35
- data/lib/film_snob/vimeo.rb +2 -3
- data/lib/film_snob/youtube.rb +6 -4
- data/lib/film_snob.rb +16 -12
- data/spec/cassettes/coub/.keep +0 -0
- data/spec/cassettes/dailymotion/.keep +0 -0
- data/spec/cassettes/funnyordie/.keep +0 -0
- data/spec/cassettes/hulu/.keep +0 -0
- data/spec/cassettes/instagram/.keep +0 -0
- data/spec/cassettes/vimeo/.keep +0 -0
- data/spec/cassettes/youtube/.keep +0 -0
- data/spec/deprecated_spec.rb +32 -0
- data/spec/film_snob_spec.rb +124 -111
- data/spec/spec_helper.rb +9 -4
- data/spec/youtube_spec.rb +24 -19
- metadata +50 -35
- data/spec/cassettes/coub/voodoo_people.yml +0 -53
- data/spec/cassettes/dailymotion/music.yml +0 -57
- data/spec/cassettes/dailymotion/music1.yml +0 -57
- data/spec/cassettes/dailymotion/music500.yml +0 -57
- data/spec/cassettes/funnyordie/space_jam.yml +0 -66
- data/spec/cassettes/hulu/harmon.yml +0 -47
- data/spec/cassettes/instagram/nothing.yml +0 -52
- data/spec/cassettes/instagram/sphynx_cat.yml +0 -53
- data/spec/cassettes/vimeo/murmuration.yml +0 -66
- data/spec/cassettes/vimeo/murmuration2.yml +0 -66
- data/spec/cassettes/vimeo/stephen.yml +0 -67
- data/spec/cassettes/youtube/bad_youtube_url.yml +0 -49
- data/spec/cassettes/youtube/billy.yml +0 -55
- data/spec/cassettes/youtube/dilla.yml +0 -54
- data/spec/cassettes/youtube/missing_video.yml +0 -49
- data/spec/cassettes/youtube/pete.yml +0 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1acb76c2c15e8ea0c82ec3aab3132d2b0e5b0f7c
|
4
|
+
data.tar.gz: 2a55b8d551947ceab6109a286110843d9cf6a6d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f2ec020294584d776de1787c3ddf01d968757a7ad335cb1599005fb68d59c2f7ee62091421cf13fa7c8cb7a76ab4478618252de353fb53afd2c448f6c3a8996
|
7
|
+
data.tar.gz: 863ced2514af6a67874e11de5e896dc49c17a08404c94c18bf600c96caacc5c0851eed56ea73960ba4a6a157171717adde78bd33085f5056c0b4f6a79fc6a262
|
data/.gitignore
CHANGED
data/.hound.yml
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
Style/CollectionMethods:
|
2
|
+
# Mapping from undesired method to desired_method
|
3
|
+
# e.g. to use `detect` over `find`:
|
4
|
+
#
|
5
|
+
# CollectionMethods:
|
6
|
+
# PreferredMethods:
|
7
|
+
# find: detect
|
8
|
+
PreferredMethods:
|
9
|
+
collect: 'map'
|
10
|
+
collect!: 'map!'
|
11
|
+
reduce: 'inject'
|
12
|
+
detect: 'find'
|
13
|
+
select: 'find_all'
|
14
|
+
|
15
|
+
# Disabling this because I don't love using the return keyword
|
16
|
+
# and sometimes lines get long and difficult to read that way
|
17
|
+
Style/GuardClause:
|
18
|
+
Description: "Check for conditionals that can be replaced with guard clauses"
|
19
|
+
StyleGuide: "https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals"
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
# I don't want to write documentation for every class
|
23
|
+
Style/Documentation:
|
24
|
+
Description: "Document classes and non-namespace modules."
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
# I will use the %r syntax even if there's only one slash
|
28
|
+
Style/RegexpLiteral:
|
29
|
+
Description: >-
|
30
|
+
Use %r for regular expressions matching more than
|
31
|
+
`MaxSlashes` "/" characters.
|
32
|
+
StyleGuide: "https://github.com/bbatsov/ruby-style-guide#percent-r"
|
33
|
+
MaxSlashes: 0
|
34
|
+
Enabled: true
|
35
|
+
|
36
|
+
# I prefer raise to fail, so I'm disabling this one
|
37
|
+
Style/SignalException:
|
38
|
+
Description: "Checks for proper usage of fail and raise."
|
39
|
+
StyleGuide: "https://github.com/bbatsov/ruby-style-guide#fail-method"
|
40
|
+
Enabled: false
|
41
|
+
|
42
|
+
# I prefer double quotes
|
43
|
+
Style/StringLiterals:
|
44
|
+
Description: "Checks if uses of quotes match the configured preference."
|
45
|
+
StyleGuide: "https://github.com/bbatsov/ruby-style-guide#consistent-string-literals"
|
46
|
+
Enabled: true
|
47
|
+
EnforcedStyle: double_quotes
|
48
|
+
|
49
|
+
# Expect a final blank line
|
50
|
+
Style/TrailingBlankLines:
|
51
|
+
Description: "Checks trailing blank lines and final newline."
|
52
|
+
StyleGuide: "https://github.com/bbatsov/ruby-style-guide#newline-eof"
|
53
|
+
Enabled: true
|
54
|
+
EnforcedStyle: final_blank_line
|
55
|
+
|
56
|
+
# I like to use assignment in conditions
|
57
|
+
Lint/AssignmentInCondition:
|
58
|
+
Description: "Don't use assignment in conditions."
|
59
|
+
StyleGuide: "https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition"
|
60
|
+
Enabled: false
|
61
|
+
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
[![Build Status](https://travis-ci.org/maxjacobson/film_snob.svg?branch=master)](https://travis-ci.org/maxjacobson/film_snob)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/film_snob.svg)](http://badge.fury.io/rb/film_snob)
|
5
5
|
[![Code Climate](https://codeclimate.com/github/maxjacobson/film_snob.png)](https://codeclimate.com/github/maxjacobson/film_snob)
|
6
|
+
[![Test Coverage](https://codeclimate.com/github/maxjacobson/film_snob/badges/coverage.svg)](https://codeclimate.com/github/maxjacobson/film_snob)
|
6
7
|
|
7
8
|
Helps parse URLs of web videos.
|
8
9
|
|
@@ -10,7 +11,7 @@ Helps parse URLs of web videos.
|
|
10
11
|
|
11
12
|
Add this line to your application's Gemfile:
|
12
13
|
|
13
|
-
gem
|
14
|
+
gem "film_snob"
|
14
15
|
|
15
16
|
And then execute:
|
16
17
|
|
@@ -24,7 +25,7 @@ Or install it yourself as:
|
|
24
25
|
|
25
26
|
```ruby
|
26
27
|
film = FilmSnob.new("https://www.youtube.com/watch?v=GwT3zH16w3s")
|
27
|
-
film.
|
28
|
+
film.embeddable? #=> true
|
28
29
|
film.site #=> :youtube
|
29
30
|
film.id #=> "GwT3zH16w3s"
|
30
31
|
film.title #=> "What Are You, The Coolest? With Robert Rodriguez"
|
@@ -57,10 +58,21 @@ The same methods work with all of these providers.
|
|
57
58
|
|
58
59
|
Run `rake` to run all of the rspecs.
|
59
60
|
|
61
|
+
## Code Style
|
62
|
+
|
63
|
+
Run `rubocop` and try to keep the cops happy.
|
64
|
+
|
65
|
+
## Questions?
|
66
|
+
|
67
|
+
[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/maxjacobson/film_snob?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
68
|
+
|
69
|
+
Ping me in [the Gitter chat room](https://gitter.im/maxjacobson/film_snob) or [create a GitHub issue](https://github.com/maxjacobson/film_snob/issues/new)
|
70
|
+
|
60
71
|
## Contributing
|
61
72
|
|
62
73
|
1. Fork it ( https://github.com/maxjacobson/film_snob/fork )
|
63
74
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
64
|
-
3. Commit your changes (`git commit -am
|
75
|
+
3. Commit your changes (`git commit -am "Add some feature"`)
|
65
76
|
4. Push to the branch (`git push origin my-new-feature`)
|
66
77
|
5. Create a new Pull Request
|
78
|
+
|
data/Rakefile
CHANGED
data/film_snob.gemspec
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
lib = File.expand_path(
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
4
|
+
require "film_snob/version"
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "film_snob"
|
8
8
|
spec.version = FilmSnob::VERSION
|
9
9
|
spec.authors = ["Max Jacobson"]
|
10
10
|
spec.email = ["max@hardscrabble.net"]
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
11
|
+
spec.summary = "Fetch embed codes for videos"
|
12
|
+
spec.description = "Find information about URLs from video sites, " \
|
13
|
+
"such as the title and embed code of the video"
|
13
14
|
spec.homepage = "https://github.com/maxjacobson/film_snob"
|
14
15
|
spec.license = "MIT"
|
15
16
|
|
@@ -24,6 +25,8 @@ Gem::Specification.new do |spec|
|
|
24
25
|
spec.add_development_dependency "webmock", "~> 1.17"
|
25
26
|
spec.add_development_dependency "vcr", "~> 2.9"
|
26
27
|
spec.add_development_dependency "pry", "~> 0.9"
|
27
|
-
|
28
|
-
spec.
|
28
|
+
spec.add_development_dependency "rubocop", "~> 0.26.1"
|
29
|
+
spec.add_development_dependency "codeclimate-test-reporter", "~> 0.4"
|
30
|
+
spec.required_ruby_version = ">= 1.9.3"
|
29
31
|
end
|
32
|
+
|
data/lib/film_snob/coub.rb
CHANGED
@@ -2,7 +2,6 @@ require "film_snob/video_site"
|
|
2
2
|
|
3
3
|
class FilmSnob
|
4
4
|
class Coub < VideoSite
|
5
|
-
|
6
5
|
def self.valid_url_patterns
|
7
6
|
[
|
8
7
|
%r{https?://coub.com/view/(\w*)}
|
@@ -14,8 +13,8 @@ class FilmSnob
|
|
14
13
|
end
|
15
14
|
|
16
15
|
def self.oembed_endpoint
|
17
|
-
|
16
|
+
"http://coub.com/api/oembed.json"
|
18
17
|
end
|
19
|
-
|
20
18
|
end
|
21
19
|
end
|
20
|
+
|
@@ -2,11 +2,10 @@ require "film_snob/video_site"
|
|
2
2
|
|
3
3
|
class FilmSnob
|
4
4
|
class Dailymotion < VideoSite
|
5
|
-
|
6
5
|
def self.valid_url_patterns
|
7
6
|
[
|
8
7
|
%r{https?://www.dailymotion.com/video/([\w\d\-_]+)},
|
9
|
-
%r{https?://touch.dailymotion.com/video/([\w\d\-_]+)}
|
8
|
+
%r{https?://touch.dailymotion.com/video/([\w\d\-_]+)}
|
10
9
|
]
|
11
10
|
end
|
12
11
|
|
@@ -15,8 +14,8 @@ class FilmSnob
|
|
15
14
|
end
|
16
15
|
|
17
16
|
def self.oembed_endpoint
|
18
|
-
|
17
|
+
"http://www.dailymotion.com/services/oembed"
|
19
18
|
end
|
20
|
-
|
21
19
|
end
|
22
20
|
end
|
21
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class FilmSnob
|
2
|
+
module Deprecated
|
3
|
+
def deprecated_alias(previous, replacement, options)
|
4
|
+
define_method(previous) do |*args, &block|
|
5
|
+
Kernel.warn "WARNING: ##{previous} is deprecated and " \
|
6
|
+
"will be removed in #{options[:removed_in]}. " \
|
7
|
+
"Please use ##{replacement} instead."
|
8
|
+
send(replacement, *args, &block)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
data/lib/film_snob/exceptions.rb
CHANGED
data/lib/film_snob/hulu.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
class FilmSnob
|
2
2
|
class Hulu < VideoSite
|
3
|
-
|
4
3
|
def self.valid_url_patterns
|
5
4
|
[
|
6
5
|
%r{https?://(?:(?:www).)?hulu.com/watch/(\d+)}
|
@@ -8,12 +7,12 @@ class FilmSnob
|
|
8
7
|
end
|
9
8
|
|
10
9
|
def self.oembed_endpoint
|
11
|
-
|
10
|
+
"http://www.hulu.com/api/oembed.json"
|
12
11
|
end
|
13
12
|
|
14
13
|
def clean_url
|
15
14
|
@clean_url ||= "http://www.hulu.com/watch/#{id}"
|
16
15
|
end
|
17
|
-
|
18
16
|
end
|
19
17
|
end
|
18
|
+
|
data/lib/film_snob/instagram.rb
CHANGED
@@ -10,7 +10,7 @@ class FilmSnob
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.oembed_endpoint
|
13
|
-
|
13
|
+
"http://api.instagram.com/oembed"
|
14
14
|
end
|
15
15
|
|
16
16
|
def clean_url
|
@@ -18,11 +18,20 @@ class FilmSnob
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def html
|
21
|
-
# instagram's oembed response does not include html,
|
21
|
+
# instagram's oembed response does not include html,
|
22
|
+
# so we need to construct it
|
22
23
|
# but first we need to ensure that the response was good
|
23
24
|
# which we do by checking for the presence of the title,
|
24
|
-
# which will raise an exception if it
|
25
|
-
title &&
|
25
|
+
# which will raise an exception if it"s not present
|
26
|
+
title && constructed_html
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def constructed_html
|
32
|
+
"<iframe src='//instagram.com/p/#{id}/embed/' width='612' height='710' " \
|
33
|
+
"frameborder='0' scrolling='no' allowtransparency='true'></iframe>"
|
26
34
|
end
|
27
35
|
end
|
28
36
|
end
|
37
|
+
|
@@ -8,7 +8,6 @@ require "film_snob/dailymotion"
|
|
8
8
|
|
9
9
|
class FilmSnob
|
10
10
|
class UrlToVideo
|
11
|
-
|
12
11
|
VIDEO_SITES = [
|
13
12
|
Vimeo,
|
14
13
|
YouTube,
|
@@ -27,18 +26,18 @@ class FilmSnob
|
|
27
26
|
end
|
28
27
|
|
29
28
|
def video
|
30
|
-
site.nil
|
29
|
+
site.nil? ? nil : site.new(url, options)
|
31
30
|
end
|
32
31
|
|
33
32
|
private
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
34
|
+
def site
|
35
|
+
@site ||= VIDEO_SITES.find do |site|
|
36
|
+
site.valid_url_patterns.any? do |pattern|
|
37
|
+
pattern.match(url)
|
40
38
|
end
|
41
39
|
end
|
42
|
-
|
40
|
+
end
|
43
41
|
end
|
44
42
|
end
|
43
|
+
|
data/lib/film_snob/version.rb
CHANGED
data/lib/film_snob/video_site.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "net/http"
|
2
|
+
require "json"
|
3
3
|
|
4
4
|
class FilmSnob
|
5
5
|
class VideoSite
|
6
6
|
attr_reader :url, :options
|
7
|
-
|
8
7
|
def initialize(url, options)
|
9
8
|
@url = url
|
10
9
|
@options = options
|
@@ -15,7 +14,7 @@ class FilmSnob
|
|
15
14
|
end
|
16
15
|
|
17
16
|
def site
|
18
|
-
@site ||= self.class.to_s.split(
|
17
|
+
@site ||= self.class.to_s.split("::").last.downcase.to_sym
|
19
18
|
end
|
20
19
|
|
21
20
|
def self.valid_url_patterns
|
@@ -23,7 +22,7 @@ class FilmSnob
|
|
23
22
|
end
|
24
23
|
|
25
24
|
def self.oembed_endpoint
|
26
|
-
|
25
|
+
""
|
27
26
|
end
|
28
27
|
|
29
28
|
def self.http
|
@@ -33,7 +32,7 @@ class FilmSnob
|
|
33
32
|
end
|
34
33
|
|
35
34
|
def self.use_ssl?
|
36
|
-
|
35
|
+
"https" == uri.scheme
|
37
36
|
end
|
38
37
|
|
39
38
|
def title
|
@@ -46,43 +45,43 @@ class FilmSnob
|
|
46
45
|
|
47
46
|
private
|
48
47
|
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
def not_embeddable!
|
49
|
+
raise NotEmbeddableError, "#{clean_url} is not embeddable"
|
50
|
+
end
|
52
51
|
|
53
|
-
|
54
|
-
|
55
|
-
|
52
|
+
def self.uri
|
53
|
+
URI.parse(oembed_endpoint)
|
54
|
+
end
|
56
55
|
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
def lookup(attribute)
|
57
|
+
oembed[attribute.to_s] || not_embeddable!
|
58
|
+
end
|
60
59
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
end
|
60
|
+
def matching_pattern
|
61
|
+
self.class.valid_url_patterns.find do |pattern|
|
62
|
+
pattern.match(url)
|
65
63
|
end
|
64
|
+
end
|
66
65
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
66
|
+
def oembed
|
67
|
+
@oembed ||= JSON.parse response.body
|
68
|
+
rescue
|
69
|
+
@oembed = {}
|
70
|
+
end
|
72
71
|
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
def response
|
73
|
+
self.class.http.request get
|
74
|
+
end
|
76
75
|
|
77
|
-
|
78
|
-
|
79
|
-
|
76
|
+
def get
|
77
|
+
Net::HTTP::Get.new uri.request_uri
|
78
|
+
end
|
80
79
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
end
|
80
|
+
def uri
|
81
|
+
URI(self.class.oembed_endpoint).tap do |uri|
|
82
|
+
uri.query = URI.encode_www_form({ url: clean_url }.merge(options))
|
85
83
|
end
|
86
|
-
|
84
|
+
end
|
87
85
|
end
|
88
86
|
end
|
87
|
+
|
data/lib/film_snob/vimeo.rb
CHANGED
@@ -2,7 +2,6 @@ require "film_snob/video_site"
|
|
2
2
|
|
3
3
|
class FilmSnob
|
4
4
|
class Vimeo < VideoSite
|
5
|
-
|
6
5
|
def self.valid_url_patterns
|
7
6
|
[
|
8
7
|
%r{https?://vimeo.com/(\d{1,})},
|
@@ -16,8 +15,8 @@ class FilmSnob
|
|
16
15
|
end
|
17
16
|
|
18
17
|
def self.oembed_endpoint
|
19
|
-
|
18
|
+
"http://vimeo.com/api/oembed.json"
|
20
19
|
end
|
21
|
-
|
22
20
|
end
|
23
21
|
end
|
22
|
+
|
data/lib/film_snob/youtube.rb
CHANGED
@@ -1,20 +1,22 @@
|
|
1
1
|
class FilmSnob
|
2
2
|
class YouTube < VideoSite
|
3
|
-
|
4
3
|
def self.valid_url_patterns
|
5
4
|
[
|
6
|
-
%r{
|
5
|
+
%r{
|
6
|
+
https?://(?:(?:www|m).)?youtube.com/watch\?
|
7
|
+
(?:feature=[\w\.]+&)?v=([\w\d\-_]+)
|
8
|
+
}x,
|
7
9
|
%r{https?://(?:(?:www|m).)?youtu.be/([\w\d\-_]+)}
|
8
10
|
]
|
9
11
|
end
|
10
12
|
|
11
13
|
def self.oembed_endpoint
|
12
|
-
|
14
|
+
"https://www.youtube.com/oembed"
|
13
15
|
end
|
14
16
|
|
15
17
|
def clean_url
|
16
18
|
@clean_url ||= "https://www.youtube.com/watch?v=#{id}"
|
17
19
|
end
|
18
|
-
|
19
20
|
end
|
20
21
|
end
|
22
|
+
|
data/lib/film_snob.rb
CHANGED
@@ -1,19 +1,24 @@
|
|
1
1
|
require "film_snob/version"
|
2
2
|
require "film_snob/url_to_video"
|
3
3
|
require "film_snob/exceptions"
|
4
|
+
require "film_snob/deprecated"
|
4
5
|
|
5
6
|
class FilmSnob
|
6
7
|
attr_reader :url
|
7
8
|
|
8
|
-
|
9
|
+
extend Deprecated
|
10
|
+
|
11
|
+
def initialize(url, options = {})
|
9
12
|
@url = url
|
10
13
|
@video = UrlToVideo.new(url, options).video
|
11
14
|
end
|
12
15
|
|
13
|
-
def
|
16
|
+
def embeddable?
|
14
17
|
!@video.nil?
|
15
18
|
end
|
16
19
|
|
20
|
+
deprecated_alias :watchable?, :embeddable?, removed_in: "v1.0.0"
|
21
|
+
|
17
22
|
def method_missing(message)
|
18
23
|
if delegated_video_methods.include?(message)
|
19
24
|
video.send(message)
|
@@ -24,17 +29,16 @@ class FilmSnob
|
|
24
29
|
|
25
30
|
private
|
26
31
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def delegated_video_methods
|
36
|
-
[:site, :id, :clean_url, :title, :html]
|
32
|
+
def video
|
33
|
+
if embeddable?
|
34
|
+
@video
|
35
|
+
else
|
36
|
+
raise NotSupportedURLError, "#{url} is not a supported URL"
|
37
37
|
end
|
38
|
+
end
|
38
39
|
|
40
|
+
def delegated_video_methods
|
41
|
+
[:site, :id, :clean_url, :title, :html]
|
42
|
+
end
|
39
43
|
end
|
40
44
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative "spec_helper"
|
2
|
+
|
3
|
+
class FilmSnob
|
4
|
+
describe Deprecated do
|
5
|
+
|
6
|
+
class Dog
|
7
|
+
extend Deprecated
|
8
|
+
|
9
|
+
deprecated_alias :woof, :bark, removed_in: "v4.0.0"
|
10
|
+
|
11
|
+
def bark
|
12
|
+
"bark"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:milo) { Dog.new }
|
17
|
+
|
18
|
+
describe "deprecated_alias" do
|
19
|
+
it "does not interfere with the current method" do
|
20
|
+
expect(Kernel).to_not receive(:warn)
|
21
|
+
milo.bark
|
22
|
+
end
|
23
|
+
|
24
|
+
it "creates an alias" do
|
25
|
+
expect(milo).to respond_to :woof
|
26
|
+
expect(Kernel).to receive(:warn)
|
27
|
+
expect(milo.woof).to eq "bark"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|