ruby-oembed 0.14.0 → 0.14.1
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 +4 -4
- data/CHANGELOG.rdoc +6 -2
- data/README.md +2 -2
- data/lib/oembed/providers.rb +1 -1
- data/lib/oembed/version.rb +1 -1
- data/spec/cassettes/OEmbed_Providers_Youtube.yml +211 -0
- data/spec/provider_spec.rb +58 -58
- data/spec/providers/slideshare_spec.rb +1 -1
- data/spec/providers/twitter_spec.rb +1 -1
- data/spec/providers/youtube_spec.rb +42 -0
- data/spec/support/shared_examples_for_providers.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 98b11115f745309211d4fdd9856ee88d281e22b15bfd86facf82caaff3e9b6e3
|
|
4
|
+
data.tar.gz: 83386c348c75465abc60fc57cb866355e7d07f65b5770090440d2a3512e4a3f1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a39256713d10577bca4888c6dbdb53c849cb4e9e6bd79b21c8692842091d634b71bd9f151eb46adbb71af6c5b4ae463d676a5e1b72da2ac8a72c0f933bc0ac40
|
|
7
|
+
data.tar.gz: f7d2ad213770c02f235925e234d89158ac3ec3cf6b94aa5e926eb539fd5cce67759a5a4a6ca56a8ae483fd0bb997d6ffe90f8884369238d2b9073b8e5fd95e7f
|
data/CHANGELOG.rdoc
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
= CHANGELOG
|
|
2
2
|
|
|
3
|
-
== Unreleased (0.14.
|
|
3
|
+
== Unreleased (0.14.2)
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
== 0.14.1 - 28 December 2020
|
|
7
|
+
|
|
8
|
+
* Fix the YouTube provider when given a private video; Issue #79 (Sebastian Schulze)
|
|
9
|
+
|
|
6
10
|
== 0.14.0 - 5 November 2020
|
|
7
11
|
|
|
8
|
-
* Add support for Facebook/
|
|
12
|
+
* Add support for Facebook/Instagram access tokens; Pull #75 (Inge Jørgensen)
|
|
9
13
|
|
|
10
14
|
== 0.13.1 - 25 May 2020
|
|
11
15
|
|
data/README.md
CHANGED
|
@@ -50,8 +50,8 @@ OEmbed::Providers.register_all
|
|
|
50
50
|
|
|
51
51
|
#### Currently supported access tokens
|
|
52
52
|
|
|
53
|
-
| access_token | environment variable |
|
|
54
|
-
|
|
53
|
+
| access_token | environment variable | Associated Providers |
|
|
54
|
+
|--------------|-------------------------|----------------------|
|
|
55
55
|
| `:facebook` | `OEMBED_FACEBOOK_TOKEN` | `FacebookPost`, `FacebookVideo`, `Instagram` |
|
|
56
56
|
|
|
57
57
|
## Custom Providers
|
data/lib/oembed/providers.rb
CHANGED
|
@@ -157,7 +157,7 @@ module OEmbed
|
|
|
157
157
|
# OEmbed::Providers::Youtube.endpoint += "?iframe=0"
|
|
158
158
|
# * To require https embed code
|
|
159
159
|
# OEmbed::Providers::Youtube.endpoint += "?scheme=https"
|
|
160
|
-
Youtube = OEmbed::Provider.new("https://www.youtube.com/oembed
|
|
160
|
+
Youtube = OEmbed::Provider.new("https://www.youtube.com/oembed/?scheme=https")
|
|
161
161
|
Youtube << "http://*.youtube.com/*"
|
|
162
162
|
Youtube << "https://*.youtube.com/*"
|
|
163
163
|
Youtube << "http://*.youtu.be/*"
|
data/lib/oembed/version.rb
CHANGED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: https://www.youtube.com/oembed/?format=json&scheme=https&url=https://www.youtube.com/watch?v=pO5L6vXtxsI
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Accept-Encoding:
|
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
12
|
+
Accept:
|
|
13
|
+
- "*/*"
|
|
14
|
+
User-Agent:
|
|
15
|
+
- Mozilla/5.0 (compatible; ruby-oembed/0.14.0)
|
|
16
|
+
response:
|
|
17
|
+
status:
|
|
18
|
+
code: 200
|
|
19
|
+
message: OK
|
|
20
|
+
headers:
|
|
21
|
+
Strict-Transport-Security:
|
|
22
|
+
- max-age=31536000
|
|
23
|
+
Cache-Control:
|
|
24
|
+
- no-cache
|
|
25
|
+
Content-Type:
|
|
26
|
+
- application/json
|
|
27
|
+
P3p:
|
|
28
|
+
- CP="This is not a P3P policy! See http://support.google.com/accounts/answer/151657?hl=en
|
|
29
|
+
for more info."
|
|
30
|
+
Expires:
|
|
31
|
+
- Tue, 27 Apr 1971 19:44:06 GMT
|
|
32
|
+
X-Content-Type-Options:
|
|
33
|
+
- nosniff
|
|
34
|
+
Date:
|
|
35
|
+
- Mon, 28 Dec 2020 15:32:04 GMT
|
|
36
|
+
Server:
|
|
37
|
+
- YouTube Frontend Proxy
|
|
38
|
+
X-Xss-Protection:
|
|
39
|
+
- '0'
|
|
40
|
+
Alt-Svc:
|
|
41
|
+
- h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443";
|
|
42
|
+
ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
|
|
43
|
+
Accept-Ranges:
|
|
44
|
+
- none
|
|
45
|
+
Vary:
|
|
46
|
+
- Accept-Encoding
|
|
47
|
+
Transfer-Encoding:
|
|
48
|
+
- chunked
|
|
49
|
+
body:
|
|
50
|
+
encoding: UTF-8
|
|
51
|
+
string: '{"title":"CKEditor 4.5 - Embedding Media Resources with oEmbed","author_name":"CKEditor
|
|
52
|
+
Ecosystem","author_url":"https://www.youtube.com/c/CKEditor","type":"video","height":270,"width":480,"version":"1.0","provider_name":"YouTube","provider_url":"https://www.youtube.com/","thumbnail_height":360,"thumbnail_width":480,"thumbnail_url":"https://i.ytimg.com/vi/pO5L6vXtxsI/hqdefault.jpg","html":"\u003ciframe
|
|
53
|
+
width=\u0022480\u0022 height=\u0022270\u0022 src=\u0022https://www.youtube.com/embed/pO5L6vXtxsI?feature=oembed\u0022
|
|
54
|
+
frameborder=\u00220\u0022 allow=\u0022accelerometer; autoplay; clipboard-write;
|
|
55
|
+
encrypted-media; gyroscope; picture-in-picture\u0022 allowfullscreen\u003e\u003c/iframe\u003e"}'
|
|
56
|
+
recorded_at: Mon, 28 Dec 2020 15:32:04 GMT
|
|
57
|
+
- request:
|
|
58
|
+
method: get
|
|
59
|
+
uri: https://www.youtube.com/oembed/?format=json&scheme=https&url=http://www.youtube.com/watch?v=pO5L6vXtxsI
|
|
60
|
+
body:
|
|
61
|
+
encoding: US-ASCII
|
|
62
|
+
string: ''
|
|
63
|
+
headers:
|
|
64
|
+
Accept-Encoding:
|
|
65
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
66
|
+
Accept:
|
|
67
|
+
- "*/*"
|
|
68
|
+
User-Agent:
|
|
69
|
+
- Mozilla/5.0 (compatible; ruby-oembed/0.14.0)
|
|
70
|
+
response:
|
|
71
|
+
status:
|
|
72
|
+
code: 200
|
|
73
|
+
message: OK
|
|
74
|
+
headers:
|
|
75
|
+
P3p:
|
|
76
|
+
- CP="This is not a P3P policy! See http://support.google.com/accounts/answer/151657?hl=en
|
|
77
|
+
for more info."
|
|
78
|
+
Cache-Control:
|
|
79
|
+
- no-cache
|
|
80
|
+
Content-Type:
|
|
81
|
+
- application/json
|
|
82
|
+
Strict-Transport-Security:
|
|
83
|
+
- max-age=31536000
|
|
84
|
+
Expires:
|
|
85
|
+
- Tue, 27 Apr 1971 19:44:06 GMT
|
|
86
|
+
X-Content-Type-Options:
|
|
87
|
+
- nosniff
|
|
88
|
+
Date:
|
|
89
|
+
- Mon, 28 Dec 2020 15:32:04 GMT
|
|
90
|
+
Server:
|
|
91
|
+
- YouTube Frontend Proxy
|
|
92
|
+
X-Xss-Protection:
|
|
93
|
+
- '0'
|
|
94
|
+
Alt-Svc:
|
|
95
|
+
- h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443";
|
|
96
|
+
ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
|
|
97
|
+
Accept-Ranges:
|
|
98
|
+
- none
|
|
99
|
+
Vary:
|
|
100
|
+
- Accept-Encoding
|
|
101
|
+
Transfer-Encoding:
|
|
102
|
+
- chunked
|
|
103
|
+
body:
|
|
104
|
+
encoding: UTF-8
|
|
105
|
+
string: '{"title":"CKEditor 4.5 - Embedding Media Resources with oEmbed","author_name":"CKEditor
|
|
106
|
+
Ecosystem","author_url":"https://www.youtube.com/c/CKEditor","type":"video","height":270,"width":480,"version":"1.0","provider_name":"YouTube","provider_url":"https://www.youtube.com/","thumbnail_height":360,"thumbnail_width":480,"thumbnail_url":"https://i.ytimg.com/vi/pO5L6vXtxsI/hqdefault.jpg","html":"\u003ciframe
|
|
107
|
+
width=\u0022480\u0022 height=\u0022270\u0022 src=\u0022https://www.youtube.com/embed/pO5L6vXtxsI?feature=oembed\u0022
|
|
108
|
+
frameborder=\u00220\u0022 allow=\u0022accelerometer; autoplay; clipboard-write;
|
|
109
|
+
encrypted-media; gyroscope; picture-in-picture\u0022 allowfullscreen\u003e\u003c/iframe\u003e"}'
|
|
110
|
+
recorded_at: Mon, 28 Dec 2020 15:32:04 GMT
|
|
111
|
+
- request:
|
|
112
|
+
method: get
|
|
113
|
+
uri: https://www.youtube.com/oembed/?format=json&scheme=https&url=https://youtu.be/pO5L6vXtxsI
|
|
114
|
+
body:
|
|
115
|
+
encoding: US-ASCII
|
|
116
|
+
string: ''
|
|
117
|
+
headers:
|
|
118
|
+
Accept-Encoding:
|
|
119
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
120
|
+
Accept:
|
|
121
|
+
- "*/*"
|
|
122
|
+
User-Agent:
|
|
123
|
+
- Mozilla/5.0 (compatible; ruby-oembed/0.14.0)
|
|
124
|
+
response:
|
|
125
|
+
status:
|
|
126
|
+
code: 200
|
|
127
|
+
message: OK
|
|
128
|
+
headers:
|
|
129
|
+
Expires:
|
|
130
|
+
- Tue, 27 Apr 1971 19:44:06 GMT
|
|
131
|
+
P3p:
|
|
132
|
+
- CP="This is not a P3P policy! See http://support.google.com/accounts/answer/151657?hl=en
|
|
133
|
+
for more info."
|
|
134
|
+
Content-Type:
|
|
135
|
+
- application/json
|
|
136
|
+
Cache-Control:
|
|
137
|
+
- no-cache
|
|
138
|
+
X-Content-Type-Options:
|
|
139
|
+
- nosniff
|
|
140
|
+
Strict-Transport-Security:
|
|
141
|
+
- max-age=31536000
|
|
142
|
+
Date:
|
|
143
|
+
- Mon, 28 Dec 2020 15:32:04 GMT
|
|
144
|
+
Server:
|
|
145
|
+
- YouTube Frontend Proxy
|
|
146
|
+
X-Xss-Protection:
|
|
147
|
+
- '0'
|
|
148
|
+
Alt-Svc:
|
|
149
|
+
- h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443";
|
|
150
|
+
ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
|
|
151
|
+
Accept-Ranges:
|
|
152
|
+
- none
|
|
153
|
+
Vary:
|
|
154
|
+
- Accept-Encoding
|
|
155
|
+
Transfer-Encoding:
|
|
156
|
+
- chunked
|
|
157
|
+
body:
|
|
158
|
+
encoding: UTF-8
|
|
159
|
+
string: '{"title":"CKEditor 4.5 - Embedding Media Resources with oEmbed","author_name":"CKEditor
|
|
160
|
+
Ecosystem","author_url":"https://www.youtube.com/c/CKEditor","type":"video","height":270,"width":480,"version":"1.0","provider_name":"YouTube","provider_url":"https://www.youtube.com/","thumbnail_height":360,"thumbnail_width":480,"thumbnail_url":"https://i.ytimg.com/vi/pO5L6vXtxsI/hqdefault.jpg","html":"\u003ciframe
|
|
161
|
+
width=\u0022480\u0022 height=\u0022270\u0022 src=\u0022https://www.youtube.com/embed/pO5L6vXtxsI?feature=oembed\u0022
|
|
162
|
+
frameborder=\u00220\u0022 allow=\u0022accelerometer; autoplay; clipboard-write;
|
|
163
|
+
encrypted-media; gyroscope; picture-in-picture\u0022 allowfullscreen\u003e\u003c/iframe\u003e"}'
|
|
164
|
+
recorded_at: Mon, 28 Dec 2020 15:32:04 GMT
|
|
165
|
+
- request:
|
|
166
|
+
method: get
|
|
167
|
+
uri: https://www.youtube.com/oembed/?format=json&scheme=https&url=https://youtu.be/NHriYTkvd0g
|
|
168
|
+
body:
|
|
169
|
+
encoding: US-ASCII
|
|
170
|
+
string: ''
|
|
171
|
+
headers:
|
|
172
|
+
Accept-Encoding:
|
|
173
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
174
|
+
Accept:
|
|
175
|
+
- "*/*"
|
|
176
|
+
User-Agent:
|
|
177
|
+
- Mozilla/5.0 (compatible; ruby-oembed/0.14.0)
|
|
178
|
+
response:
|
|
179
|
+
status:
|
|
180
|
+
code: 403
|
|
181
|
+
message: Forbidden
|
|
182
|
+
headers:
|
|
183
|
+
Strict-Transport-Security:
|
|
184
|
+
- max-age=31536000
|
|
185
|
+
Content-Length:
|
|
186
|
+
- '9'
|
|
187
|
+
X-Content-Type-Options:
|
|
188
|
+
- nosniff
|
|
189
|
+
Content-Type:
|
|
190
|
+
- text/html; charset=utf-8
|
|
191
|
+
Cache-Control:
|
|
192
|
+
- no-cache
|
|
193
|
+
P3p:
|
|
194
|
+
- CP="This is not a P3P policy! See http://support.google.com/accounts/answer/151657?hl=en
|
|
195
|
+
for more info."
|
|
196
|
+
Expires:
|
|
197
|
+
- Tue, 27 Apr 1971 19:44:06 GMT
|
|
198
|
+
Date:
|
|
199
|
+
- Mon, 28 Dec 2020 15:32:04 GMT
|
|
200
|
+
Server:
|
|
201
|
+
- YouTube Frontend Proxy
|
|
202
|
+
X-Xss-Protection:
|
|
203
|
+
- '0'
|
|
204
|
+
Alt-Svc:
|
|
205
|
+
- h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443";
|
|
206
|
+
ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
|
|
207
|
+
body:
|
|
208
|
+
encoding: UTF-8
|
|
209
|
+
string: Forbidden
|
|
210
|
+
recorded_at: Mon, 28 Dec 2020 15:32:04 GMT
|
|
211
|
+
recorded_with: VCR 6.0.0
|
data/spec/provider_spec.rb
CHANGED
|
@@ -49,108 +49,108 @@ describe OEmbed::Provider do
|
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
it "should allow no URI schema to be given" do
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
expect(
|
|
55
|
-
expect(
|
|
56
|
-
expect(
|
|
57
|
-
expect(
|
|
58
|
-
expect(
|
|
59
|
-
expect(
|
|
52
|
+
provider = OEmbed::Provider.new("http://foo.com/oembed")
|
|
53
|
+
|
|
54
|
+
expect(provider).to include("http://foo.com/1")
|
|
55
|
+
expect(provider).to include("http://bar.foo.com/1")
|
|
56
|
+
expect(provider).to include("http://bar.foo.com/show/1")
|
|
57
|
+
expect(provider).to include("https://bar.foo.com/1")
|
|
58
|
+
expect(provider).to include("http://asdf.com/1")
|
|
59
|
+
expect(provider).to include("asdf")
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
it "should allow a String as a URI schema" do
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
provider = OEmbed::Provider.new("http://foo.com/oembed")
|
|
64
|
+
provider << "http://bar.foo.com/*"
|
|
65
65
|
|
|
66
|
-
expect(
|
|
67
|
-
expect(
|
|
66
|
+
expect(provider).to include("http://bar.foo.com/1")
|
|
67
|
+
expect(provider).to include("http://bar.foo.com/show/1")
|
|
68
68
|
|
|
69
|
-
expect(
|
|
70
|
-
expect(
|
|
69
|
+
expect(provider).to_not include("https://bar.foo.com/1")
|
|
70
|
+
expect(provider).to_not include("http://foo.com/1")
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
it "should allow multiple path wildcards in a String URI schema" do
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
provider = OEmbed::Provider.new("http://foo.com/oembed")
|
|
75
|
+
provider << "http://bar.foo.com/*/show/*"
|
|
76
76
|
|
|
77
|
-
expect(
|
|
78
|
-
expect(
|
|
79
|
-
expect(
|
|
77
|
+
expect(provider).to include("http://bar.foo.com/photo/show/1")
|
|
78
|
+
expect(provider).to include("http://bar.foo.com/video/show/2")
|
|
79
|
+
expect(provider).to include("http://bar.foo.com/help/video/show/2")
|
|
80
80
|
|
|
81
|
-
expect(
|
|
82
|
-
expect(
|
|
83
|
-
expect(
|
|
84
|
-
expect(
|
|
81
|
+
expect(provider).to_not include("https://bar.foo.com/photo/show/1")
|
|
82
|
+
expect(provider).to_not include("http://foo.com/video/show/2")
|
|
83
|
+
expect(provider).to_not include("http://bar.foo.com/show/1")
|
|
84
|
+
expect(provider).to_not include("http://bar.foo.com/1")
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
it "should NOT allow multiple domain wildcards in a String URI schema", :pending => true do
|
|
88
|
-
|
|
88
|
+
provider = OEmbed::Provider.new("http://foo.com/oembed")
|
|
89
89
|
|
|
90
|
-
expect {
|
|
90
|
+
expect { provider << "http://*.com/*" }.
|
|
91
91
|
to raise_error(ArgumentError)
|
|
92
92
|
|
|
93
|
-
expect(
|
|
93
|
+
expect(provider).to_not include("http://foo.com/1")
|
|
94
94
|
end
|
|
95
95
|
|
|
96
96
|
it "should allow a sub-domain wildcard in String URI schema" do
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
provider = OEmbed::Provider.new("http://foo.com/oembed")
|
|
98
|
+
provider << "http://*.foo.com/*"
|
|
99
99
|
|
|
100
|
-
expect(
|
|
101
|
-
expect(
|
|
102
|
-
expect(
|
|
100
|
+
expect(provider).to include("http://bar.foo.com/1")
|
|
101
|
+
expect(provider).to include("http://foo.foo.com/2")
|
|
102
|
+
expect(provider).to include("http://foo.com/3")
|
|
103
103
|
|
|
104
|
-
expect(
|
|
105
|
-
expect(
|
|
104
|
+
expect(provider).to_not include("https://bar.foo.com/1")
|
|
105
|
+
expect(provider).to_not include("http://my.bar.foo.com/1")
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
provider << "http://my.*.foo.com/*"
|
|
108
108
|
end
|
|
109
109
|
|
|
110
110
|
it "should allow multiple sub-domain wildcards in a String URI schema" do
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
provider = OEmbed::Provider.new("http://foo.com/oembed")
|
|
112
|
+
provider << "http://*.my.*.foo.com/*"
|
|
113
113
|
|
|
114
|
-
expect(
|
|
115
|
-
expect(
|
|
116
|
-
expect(
|
|
114
|
+
expect(provider).to include("http://my.bar.foo.com/1")
|
|
115
|
+
expect(provider).to include("http://my.foo.com/2")
|
|
116
|
+
expect(provider).to include("http://bar.my.bar.foo.com/3")
|
|
117
117
|
|
|
118
|
-
expect(
|
|
119
|
-
expect(
|
|
118
|
+
expect(provider).to_not include("http://bar.foo.com/1")
|
|
119
|
+
expect(provider).to_not include("http://foo.bar.foo.com/1")
|
|
120
120
|
end
|
|
121
121
|
|
|
122
122
|
it "should NOT allow a scheme wildcard in a String URI schema", :pending => true do
|
|
123
|
-
|
|
123
|
+
provider = OEmbed::Provider.new("http://foo.com/oembed")
|
|
124
124
|
|
|
125
|
-
expect {
|
|
125
|
+
expect { provider << "*://foo.com/*" }.
|
|
126
126
|
to raise_error(ArgumentError)
|
|
127
127
|
|
|
128
|
-
expect(
|
|
128
|
+
expect(provider).to_not include("http://foo.com/1")
|
|
129
129
|
end
|
|
130
130
|
|
|
131
131
|
it "should allow a scheme other than http in a String URI schema" do
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
provider = OEmbed::Provider.new("http://foo.com/oembed")
|
|
133
|
+
provider << "https://foo.com/*"
|
|
134
134
|
|
|
135
|
-
expect(
|
|
135
|
+
expect(provider).to include("https://foo.com/1")
|
|
136
136
|
|
|
137
137
|
gopher_url = "gopher://foo.com/1"
|
|
138
|
-
expect(
|
|
139
|
-
|
|
140
|
-
expect(
|
|
138
|
+
expect(provider).to_not include(gopher_url)
|
|
139
|
+
provider << "gopher://foo.com/*"
|
|
140
|
+
expect(provider).to include(gopher_url)
|
|
141
141
|
end
|
|
142
142
|
|
|
143
143
|
it "should allow a Regexp as a URI schema" do
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
provider = OEmbed::Provider.new("http://foo.com/oembed")
|
|
145
|
+
provider << %r{^https?://([^\.]*\.)?foo.com/(show/)?\d+}
|
|
146
146
|
|
|
147
|
-
expect(
|
|
148
|
-
expect(
|
|
149
|
-
expect(
|
|
150
|
-
expect(
|
|
147
|
+
expect(provider).to include("http://bar.foo.com/1")
|
|
148
|
+
expect(provider).to include("http://bar.foo.com/show/1")
|
|
149
|
+
expect(provider).to include("http://foo.com/1")
|
|
150
|
+
expect(provider).to include("https://bar.foo.com/1")
|
|
151
151
|
|
|
152
|
-
expect(
|
|
153
|
-
expect(
|
|
152
|
+
expect(provider).to_not include("http://bar.foo.com/video/1")
|
|
153
|
+
expect(provider).to_not include("gopher://foo.com/1")
|
|
154
154
|
end
|
|
155
155
|
|
|
156
156
|
it "should by default use OEmbed::Formatter.default" do
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../spec_helper')
|
|
2
|
+
|
|
3
|
+
describe 'OEmbed::Providers::Youtube' do
|
|
4
|
+
before(:all) do
|
|
5
|
+
VCR.insert_cassette('OEmbed_Providers_Youtube')
|
|
6
|
+
end
|
|
7
|
+
after(:all) do
|
|
8
|
+
VCR.eject_cassette
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
include OEmbedSpecHelper
|
|
12
|
+
|
|
13
|
+
let(:provider_class) { OEmbed::Providers::Youtube }
|
|
14
|
+
|
|
15
|
+
expected_valid_urls = %w(
|
|
16
|
+
https://www.youtube.com/watch?v=pO5L6vXtxsI
|
|
17
|
+
http://www.youtube.com/watch?v=pO5L6vXtxsI
|
|
18
|
+
https://youtu.be/pO5L6vXtxsI
|
|
19
|
+
)
|
|
20
|
+
expected_invalid_urls = [
|
|
21
|
+
# Unrecognized hostname
|
|
22
|
+
'https://www.youtube.co.uk/watch?v=pO5L6vXtxsI',
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
it_should_behave_like(
|
|
26
|
+
"an OEmbed::Providers instance",
|
|
27
|
+
expected_valid_urls,
|
|
28
|
+
expected_invalid_urls
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
describe ".get" do
|
|
32
|
+
context 'given the URL of a private video' do
|
|
33
|
+
let(:invalid_url) { 'https://youtu.be/NHriYTkvd0g' }
|
|
34
|
+
|
|
35
|
+
it "should throw an UnknownResponse error" do
|
|
36
|
+
expect {
|
|
37
|
+
provider_class.get(invalid_url)
|
|
38
|
+
}.to raise_error(OEmbed::UnknownResponse, /403/)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
RSpec.shared_examples "an OEmbed::
|
|
1
|
+
RSpec.shared_examples "an OEmbed::Providers instance" do |expected_valid_urls, expected_invalid_urls|
|
|
2
2
|
expected_valid_urls.each do |valid_url|
|
|
3
3
|
context "given the valid URL #{valid_url}" do
|
|
4
4
|
describe ".include?" do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby-oembed
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.14.
|
|
4
|
+
version: 0.14.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Magnus Holm
|
|
@@ -11,7 +11,7 @@ authors:
|
|
|
11
11
|
autorequire:
|
|
12
12
|
bindir: bin
|
|
13
13
|
cert_chain: []
|
|
14
|
-
date: 2020-
|
|
14
|
+
date: 2020-12-28 00:00:00.000000000 Z
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
17
17
|
name: xml-simple
|
|
@@ -98,6 +98,7 @@ files:
|
|
|
98
98
|
- spec/cassettes/OEmbed_ProviderDiscovery.yml
|
|
99
99
|
- spec/cassettes/OEmbed_Providers_Slideshare.yml
|
|
100
100
|
- spec/cassettes/OEmbed_Providers_Twitter.yml
|
|
101
|
+
- spec/cassettes/OEmbed_Providers_Youtube.yml
|
|
101
102
|
- spec/formatter/ducktype_backend_spec.rb
|
|
102
103
|
- spec/formatter/json/.DS_Store
|
|
103
104
|
- spec/formatter/json/jsongem_backend_spec.rb
|
|
@@ -111,6 +112,7 @@ files:
|
|
|
111
112
|
- spec/providers/facebook_spec.rb
|
|
112
113
|
- spec/providers/slideshare_spec.rb
|
|
113
114
|
- spec/providers/twitter_spec.rb
|
|
115
|
+
- spec/providers/youtube_spec.rb
|
|
114
116
|
- spec/providers_spec.rb
|
|
115
117
|
- spec/response_spec.rb
|
|
116
118
|
- spec/spec_helper.rb
|
|
@@ -125,7 +127,7 @@ rdoc_options:
|
|
|
125
127
|
- "--main"
|
|
126
128
|
- README.rdoc
|
|
127
129
|
- "--title"
|
|
128
|
-
- ruby-oembed-0.14.
|
|
130
|
+
- ruby-oembed-0.14.1
|
|
129
131
|
- "--inline-source"
|
|
130
132
|
- "--exclude"
|
|
131
133
|
- tasks
|
|
@@ -152,6 +154,7 @@ test_files:
|
|
|
152
154
|
- spec/cassettes/OEmbed_ProviderDiscovery.yml
|
|
153
155
|
- spec/cassettes/OEmbed_Providers_Slideshare.yml
|
|
154
156
|
- spec/cassettes/OEmbed_Providers_Twitter.yml
|
|
157
|
+
- spec/cassettes/OEmbed_Providers_Youtube.yml
|
|
155
158
|
- spec/formatter/ducktype_backend_spec.rb
|
|
156
159
|
- spec/formatter/json/.DS_Store
|
|
157
160
|
- spec/formatter/json/jsongem_backend_spec.rb
|
|
@@ -165,6 +168,7 @@ test_files:
|
|
|
165
168
|
- spec/providers/facebook_spec.rb
|
|
166
169
|
- spec/providers/slideshare_spec.rb
|
|
167
170
|
- spec/providers/twitter_spec.rb
|
|
171
|
+
- spec/providers/youtube_spec.rb
|
|
168
172
|
- spec/providers_spec.rb
|
|
169
173
|
- spec/response_spec.rb
|
|
170
174
|
- spec/spec_helper.rb
|