ruby-oembed 0.11.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.
@@ -0,0 +1,50 @@
1
+ require File.join(File.dirname(__FILE__), '../spec_helper')
2
+
3
+ describe 'Facebook providers' do
4
+ let(:access_token) { 'my-fake-access-token' }
5
+
6
+ describe 'FacebookPost provider' do
7
+ let(:provider) { OEmbed::Providers::FacebookPost.new(access_token: access_token) }
8
+ let(:embed_url) { 'https://www.facebook.com/exampleuser/posts/1234567890' }
9
+
10
+ it 'sets the endpoint URL' do
11
+ expect(provider.endpoint).to(
12
+ eq("https://graph.facebook.com/v8.0/oembed_post?access_token=#{access_token}")
13
+ )
14
+ end
15
+
16
+ it 'recognizes embed URLs' do
17
+ expect(provider).to include(embed_url)
18
+ end
19
+ end
20
+
21
+ describe 'FacebookVideo provider' do
22
+ let(:provider) { OEmbed::Providers::FacebookVideo.new(access_token: access_token) }
23
+ let(:embed_url) { 'https://www.facebook.com/exampleuser/videos/1234567890' }
24
+
25
+ it 'sets the endpoint URL' do
26
+ expect(provider.endpoint).to(
27
+ eq("https://graph.facebook.com/v8.0/oembed_video?access_token=#{access_token}")
28
+ )
29
+ end
30
+
31
+ it 'recognizes embed URLs' do
32
+ expect(provider).to include(embed_url)
33
+ end
34
+ end
35
+
36
+ describe 'Instagram provider' do
37
+ let(:provider) { OEmbed::Providers::Instagram.new(access_token: access_token) }
38
+ let(:embed_url) { 'https://www.instagram.com/p/r4nd0m1mg/' }
39
+
40
+ it 'sets the endpoint URL' do
41
+ expect(provider.endpoint).to(
42
+ eq("https://graph.facebook.com/v8.0/instagram_oembed?access_token=#{access_token}")
43
+ )
44
+ end
45
+
46
+ it 'recognizes embed URLs' do
47
+ expect(provider).to include(embed_url)
48
+ end
49
+ end
50
+ end
@@ -35,7 +35,7 @@ describe 'OEmbed::Providers::Slideshare' do
35
35
  )
36
36
 
37
37
  it_should_behave_like(
38
- "an OEmbed::Proviers instance",
38
+ "an OEmbed::Providers instance",
39
39
  expected_valid_urls,
40
40
  expected_invalid_urls
41
41
  )
@@ -23,7 +23,7 @@ describe 'OEmbed::Providers::Twitter' do
23
23
  )
24
24
 
25
25
  it_should_behave_like(
26
- "an OEmbed::Proviers instance",
26
+ "an OEmbed::Providers instance",
27
27
  expected_valid_urls,
28
28
  expected_invalid_urls
29
29
  )
@@ -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
@@ -210,6 +210,54 @@ describe OEmbed::Providers do
210
210
  end
211
211
  end
212
212
 
213
+ describe 'register_access_token_providers' do
214
+ describe 'tokens[:facebook]' do
215
+ let(:access_token) { 'my-fake-access-token' }
216
+ let(:embed_url) { 'https://www.facebook.com/exampleuser/posts/1234567890' }
217
+
218
+ around(:each) do |each|
219
+ previous_value = ENV['OEMBED_FACEBOOK_TOKEN']
220
+ ENV['OEMBED_FACEBOOK_TOKEN'] = nil
221
+ each.run
222
+ ENV['OEMBED_FACEBOOK_TOKEN'] = previous_value
223
+ OEmbed::Providers.unregister_all
224
+ end
225
+
226
+ subject { OEmbed::Providers.find(embed_url) }
227
+
228
+ context 'when NO access token is provided' do
229
+ before do
230
+ OEmbed::Providers.register_all
231
+ end
232
+
233
+ it { is_expected.to_not be_a(OEmbed::Providers::FacebookPost) }
234
+ end
235
+
236
+ context 'when access token is provided to register_all' do
237
+ before do
238
+ OEmbed::Providers.register_all(access_tokens: { facebook: access_token })
239
+ end
240
+
241
+ it { is_expected.to be_a(OEmbed::Providers::FacebookPost) }
242
+ end
243
+
244
+ context 'when access token is set as an environment variable' do
245
+ before do
246
+ ENV['OEMBED_FACEBOOK_TOKEN'] = access_token
247
+ OEmbed::Providers.register_all
248
+ end
249
+
250
+ it { is_expected.to be_a(OEmbed::Providers::FacebookPost) }
251
+ end
252
+
253
+ context 'without access token' do
254
+ before { OEmbed::Providers.register_all }
255
+
256
+ it { is_expected.to eq(nil) }
257
+ end
258
+ end
259
+ end
260
+
213
261
  describe 'add_official_provider' do
214
262
  it "should register a new official provider" do
215
263
  expect(defined?(OEmbed::Providers::Fake)).to_not be
@@ -4,9 +4,10 @@ require 'vcr'
4
4
  VCR.config do |c|
5
5
  c.default_cassette_options = { :record => :new_episodes }
6
6
  c.cassette_library_dir = 'spec/cassettes'
7
- c.stub_with :fakeweb
7
+ c.hook_into :webmock
8
8
  end
9
9
 
10
+ require 'webmock/rspec'
10
11
  require 'coveralls'
11
12
  Coveralls.wear!
12
13
 
@@ -16,6 +17,7 @@ RSpec.configure do |config|
16
17
  config.raise_errors_for_deprecations!
17
18
  config.tty = true
18
19
  config.color = true
20
+ config.example_status_persistence_file_path = '.rspec-status'
19
21
  end
20
22
 
21
23
  module OEmbedSpecHelper
@@ -1,11 +1,9 @@
1
1
  ---
2
2
  :flickr:
3
3
  :url: "http://flickr.com/photos/bees/2362225867/"
4
- :body: !
5
- '{"version":"1.0","type":"photo","author_url":"http:\/\/www.flickr.com\/photos\/bees\/","cache_age":3600,"provider_name":"Flickr","provider_url":"http:\/\/www.flickr.com\/","title":"Bacon
6
- Lollys","author_name":"\u202e\u202d\u202cbees\u202c","width":"500","height":"375","url":"http:\/\/farm4.staticflickr.com\/3040\/2362225867_4a87ab8baf.jpg"}
4
+ :body: |
5
+ {"type":"photo","flickr_type":"photo","title":"Bacon Lollys","author_name":"\u202e\u202d\u202cbees\u202c","author_url":"https:\/\/www.flickr.com\/photos\/bees\/","width":1024,"height":768,"url":"https:\/\/live.staticflickr.com\/3040\/2362225867_4a87ab8baf_b.jpg","web_page":"https:\/\/www.flickr.com\/photos\/bees\/2362225867\/","thumbnail_url":"https:\/\/live.staticflickr.com\/3040\/2362225867_4a87ab8baf_q.jpg","thumbnail_width":150,"thumbnail_height":150,"web_page_short_url":"https:\/\/flic.kr\/p\/4AK2sc","license":"All Rights Reserved","license_id":0,"html":"<a data-flickr-embed=\"true\" href=\"https:\/\/www.flickr.com\/photos\/bees\/2362225867\/\" title=\"Bacon Lollys by \u202e\u202d\u202cbees\u202c, on Flickr\"><img src=\"https:\/\/live.staticflickr.com\/3040\/2362225867_4a87ab8baf_b.jpg\" width=\"1024\" height=\"768\" alt=\"Bacon Lollys\"><\/a><script async src=\"https:\/\/embedr.flickr.com\/assets\/client-code.js\" charset=\"utf-8\"><\/script>","version":"1.0","cache_age":3600,"provider_name":"Flickr","provider_url":"https:\/\/www.flickr.com\/"}
7
6
 
8
- '
9
7
  :skitch:
10
8
  :url: "http://skitch.com/sethferreira/nmbr8/the-kings-new-toy"
11
9
  :body: ! '{"type":"photo","version":"1.0","author_name":"sethferreira","author_url":"http:\/\/skitch.com\/sethferreira\/","provider_name":"Skitch.com","provider_url":"http:\/\/skitch.com\/","width":804,"height":804,"url":"https:\/\/img.skitch.com\/20091210-m9cq9r2e6cy1j1sn23acn38kx.jpg","thumbnail_width":337,"thumbnail_height":337,"thumbnail_url":"https:\/\/img.skitch.com\/20091210-m9cq9r2e6cy1j1sn23acn38kx.preview.jpg","cache_age":86400}'
@@ -15,20 +13,12 @@
15
13
  :url: "http://qik.com/video/49565"
16
14
  :vimeo:
17
15
  :url: "http://vimeo.com/3100878"
18
- :body: ! '{"type":"video","version":"1.0","provider_name":"Vimeo","provider_url":"http:\/\/vimeo.com\/","title":"Murmuration","author_name":"Sophie
19
- Windsor Clive","author_url":"http:\/\/vimeo.com\/user3069761","is_plus":"0","html":"<iframe
20
- src=\"https:\/\/player.vimeo.com\/video\/31158841\" width=\"640\" height=\"512\"
21
- frameborder=\"0\" webkitAllowFullScreen mozallowfullscreen allowFullScreen><\/iframe>","width":640,"height":512,"duration":120,"description":"A
22
- chance encounter and shared moment with one of natures greatest and most fleeting
23
- phenomena.","thumbnail_url":"https:\/\/secure-b.vimeocdn.com\/ts\/209\/801\/209801744_640.jpg","thumbnail_width":640,"thumbnail_height":512,"video_id":31158841}'
16
+ :body: |
17
+ {"type":"video","version":"1.0","provider_name":"Vimeo","provider_url":"https:\/\/vimeo.com\/","title":"Murmuration","author_name":"Islands & Rivers","author_url":"https:\/\/vimeo.com\/islandsandrivers","is_plus":"0","account_type":"basic","html":"<iframe src=\"https:\/\/player.vimeo.com\/video\/31158841?app_id=122963\" width=\"400\" height=\"320\" frameborder=\"0\" allow=\"autoplay; fullscreen\" allowfullscreen title=\"Murmuration\"><\/iframe>","width":400,"height":320,"duration":123,"description":"A chance encounter and shared moment with one of natures greatest and most fleeting phenomena.\n\nFacebook: Islands And Rivers\nFor licensing information contact Dale Dobson - dale@iconiclinx.com","thumbnail_url":"https:\/\/i.vimeocdn.com\/video\/448600816_295x166.jpg","thumbnail_width":295,"thumbnail_height":221,"thumbnail_url_with_play_button":"https:\/\/i.vimeocdn.com\/filter\/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F448600816_295x166.jpg&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png","upload_date":"2011-10-26 14:43:13","video_id":31158841,"uri":"\/videos\/31158841"}
24
18
  :vimeo_ssl:
25
19
  :url: "https://vimeo.com/31158841"
26
- :body: ! '{"type":"video","version":"1.0","provider_name":"Vimeo","provider_url":"http:\/\/vimeo.com\/","title":"Murmuration","author_name":"Sophie
27
- Windsor Clive","author_url":"http:\/\/vimeo.com\/user3069761","is_plus":"0","html":"<iframe
28
- src=\"https:\/\/player.vimeo.com\/video\/31158841\" width=\"640\" height=\"512\"
29
- frameborder=\"0\" webkitAllowFullScreen mozallowfullscreen allowFullScreen><\/iframe>","width":640,"height":512,"duration":120,"description":"A
30
- chance encounter and shared moment with one of natures greatest and most fleeting
31
- phenomena.","thumbnail_url":"https:\/\/secure-b.vimeocdn.com\/ts\/209\/801\/209801744_640.jpg","thumbnail_width":640,"thumbnail_height":512,"video_id":31158841}'
20
+ :body: |
21
+ {"type":"video","version":"1.0","provider_name":"Vimeo","provider_url":"https:\/\/vimeo.com\/","title":"Murmuration","author_name":"Islands & Rivers","author_url":"https:\/\/vimeo.com\/islandsandrivers","is_plus":"0","account_type":"basic","html":"<iframe src=\"https:\/\/player.vimeo.com\/video\/31158841?app_id=122963\" width=\"400\" height=\"320\" frameborder=\"0\" allow=\"autoplay; fullscreen\" allowfullscreen title=\"Murmuration\"><\/iframe>","width":400,"height":320,"duration":123,"description":"A chance encounter and shared moment with one of natures greatest and most fleeting phenomena.\n\nFacebook: Islands And Rivers\nFor licensing information contact Dale Dobson - dale@iconiclinx.com","thumbnail_url":"https:\/\/i.vimeocdn.com\/video\/448600816_295x166.jpg","thumbnail_width":295,"thumbnail_height":221,"thumbnail_url_with_play_button":"https:\/\/i.vimeocdn.com\/filter\/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F448600816_295x166.jpg&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png","upload_date":"2011-10-26 14:43:13","video_id":31158841,"uri":"\/videos\/31158841"}
32
22
  :rev3:
33
23
  :url: "http://revision3.com/diggnation/2008-04-17xsanned/"
34
24
  :hulu:
@@ -1,4 +1,4 @@
1
- RSpec.shared_examples "an OEmbed::Proviers instance" do |expected_valid_urls, expected_invalid_urls|
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.11.0
4
+ version: 0.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Magnus Holm
@@ -11,36 +11,8 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2017-03-26 00:00:00.000000000 Z
14
+ date: 2020-12-28 00:00:00.000000000 Z
15
15
  dependencies:
16
- - !ruby/object:Gem::Dependency
17
- name: rake
18
- requirement: !ruby/object:Gem::Requirement
19
- requirements:
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: '0'
23
- type: :development
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: json
32
- requirement: !ruby/object:Gem::Requirement
33
- requirements:
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- version: '0'
37
- type: :development
38
- prerelease: false
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: '0'
44
16
  - !ruby/object:Gem::Dependency
45
17
  name: xml-simple
46
18
  requirement: !ruby/object:Gem::Requirement
@@ -69,48 +41,6 @@ dependencies:
69
41
  - - ">="
70
42
  - !ruby/object:Gem::Version
71
43
  version: '0'
72
- - !ruby/object:Gem::Dependency
73
- name: rspec
74
- requirement: !ruby/object:Gem::Requirement
75
- requirements:
76
- - - "~>"
77
- - !ruby/object:Gem::Version
78
- version: '3.0'
79
- type: :development
80
- prerelease: false
81
- version_requirements: !ruby/object:Gem::Requirement
82
- requirements:
83
- - - "~>"
84
- - !ruby/object:Gem::Version
85
- version: '3.0'
86
- - !ruby/object:Gem::Dependency
87
- name: vcr
88
- requirement: !ruby/object:Gem::Requirement
89
- requirements:
90
- - - "~>"
91
- - !ruby/object:Gem::Version
92
- version: '1.0'
93
- type: :development
94
- prerelease: false
95
- version_requirements: !ruby/object:Gem::Requirement
96
- requirements:
97
- - - "~>"
98
- - !ruby/object:Gem::Version
99
- version: '1.0'
100
- - !ruby/object:Gem::Dependency
101
- name: fakeweb
102
- requirement: !ruby/object:Gem::Requirement
103
- requirements:
104
- - - ">="
105
- - !ruby/object:Gem::Version
106
- version: '0'
107
- type: :development
108
- prerelease: false
109
- version_requirements: !ruby/object:Gem::Requirement
110
- requirements:
111
- - - ">="
112
- - !ruby/object:Gem::Version
113
- version: '0'
114
44
  description: An oEmbed consumer library written in Ruby, letting you easily get embeddable
115
45
  HTML representations of supported web pages, based on their URLs. See http://oembed.com
116
46
  for more information about the protocol.
@@ -149,8 +79,12 @@ files:
149
79
  - lib/oembed/provider.rb
150
80
  - lib/oembed/provider_discovery.rb
151
81
  - lib/oembed/providers.rb
152
- - lib/oembed/providers/embedly_urls.yml
153
- - lib/oembed/providers/oohembed_urls.yml
82
+ - lib/oembed/providers/aggregators/embedly_urls.yml
83
+ - lib/oembed/providers/aggregators/noembed_urls.yml
84
+ - lib/oembed/providers/aggregators/oohembed_urls.yml
85
+ - lib/oembed/providers/facebook_post.rb
86
+ - lib/oembed/providers/facebook_video.rb
87
+ - lib/oembed/providers/instagram.rb
154
88
  - lib/oembed/response.rb
155
89
  - lib/oembed/response/link.rb
156
90
  - lib/oembed/response/photo.rb
@@ -164,6 +98,7 @@ files:
164
98
  - spec/cassettes/OEmbed_ProviderDiscovery.yml
165
99
  - spec/cassettes/OEmbed_Providers_Slideshare.yml
166
100
  - spec/cassettes/OEmbed_Providers_Twitter.yml
101
+ - spec/cassettes/OEmbed_Providers_Youtube.yml
167
102
  - spec/formatter/ducktype_backend_spec.rb
168
103
  - spec/formatter/json/.DS_Store
169
104
  - spec/formatter/json/jsongem_backend_spec.rb
@@ -174,8 +109,10 @@ files:
174
109
  - spec/formatter_spec.rb
175
110
  - spec/provider_discovery_spec.rb
176
111
  - spec/provider_spec.rb
112
+ - spec/providers/facebook_spec.rb
177
113
  - spec/providers/slideshare_spec.rb
178
114
  - spec/providers/twitter_spec.rb
115
+ - spec/providers/youtube_spec.rb
179
116
  - spec/providers_spec.rb
180
117
  - spec/response_spec.rb
181
118
  - spec/spec_helper.rb
@@ -190,7 +127,7 @@ rdoc_options:
190
127
  - "--main"
191
128
  - README.rdoc
192
129
  - "--title"
193
- - ruby-oembed-0.11.0
130
+ - ruby-oembed-0.14.1
194
131
  - "--inline-source"
195
132
  - "--exclude"
196
133
  - tasks
@@ -208,16 +145,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
145
  - !ruby/object:Gem::Version
209
146
  version: '0'
210
147
  requirements: []
211
- rubyforge_project:
212
- rubygems_version: 2.6.11
148
+ rubygems_version: 3.1.4
213
149
  signing_key:
214
- specification_version: 3
150
+ specification_version: 4
215
151
  summary: oEmbed for Ruby
216
152
  test_files:
217
153
  - spec/cassettes/OEmbed_Provider.yml
218
154
  - spec/cassettes/OEmbed_ProviderDiscovery.yml
219
155
  - spec/cassettes/OEmbed_Providers_Slideshare.yml
220
156
  - spec/cassettes/OEmbed_Providers_Twitter.yml
157
+ - spec/cassettes/OEmbed_Providers_Youtube.yml
221
158
  - spec/formatter/ducktype_backend_spec.rb
222
159
  - spec/formatter/json/.DS_Store
223
160
  - spec/formatter/json/jsongem_backend_spec.rb
@@ -228,8 +165,10 @@ test_files:
228
165
  - spec/formatter_spec.rb
229
166
  - spec/provider_discovery_spec.rb
230
167
  - spec/provider_spec.rb
168
+ - spec/providers/facebook_spec.rb
231
169
  - spec/providers/slideshare_spec.rb
232
170
  - spec/providers/twitter_spec.rb
171
+ - spec/providers/youtube_spec.rb
233
172
  - spec/providers_spec.rb
234
173
  - spec/response_spec.rb
235
174
  - spec/spec_helper.rb