ruby-oembed 0.10.1 → 0.14.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.
@@ -24,8 +24,8 @@ describe OEmbed::ProviderDiscovery do
24
24
  :json,
25
25
  ],
26
26
  'vimeo' => [
27
- 'http://vimeo.com/27953845',
28
- {:json=>'http://vimeo.com/api/oembed.json', :xml=>'http://vimeo.com/api/oembed.xml'},
27
+ 'https://vimeo.com/27953845',
28
+ {:json=>'https://vimeo.com/api/oembed.json', :xml=>'https://vimeo.com/api/oembed.xml'},
29
29
  :json,
30
30
  ],
31
31
  'facebook-photo' => [
@@ -38,11 +38,6 @@ describe OEmbed::ProviderDiscovery do
38
38
  'https://www.tumblr.com/oembed/1.0',
39
39
  :json
40
40
  ],
41
- 'noteflight' => [
42
- 'http://www.noteflight.com/scores/view/09665392c94475f65dfaf5f30aadb6ed0921939d',
43
- {:json=>'http://www.noteflight.com/services/oembed', :xml=>'http://www.noteflight.com/services/oembed'},
44
- :json,
45
- ],
46
41
  # TODO: Enhance ProviderDiscovery to support arbitrary query parameters. See https://github.com/ruby-oembed/ruby-oembed/issues/15
47
42
  #'wordpress' => [
48
43
  # 'http://sweetandweak.wordpress.com/2011/09/23/nothing-starts-the-morning-like-a-good-dose-of-panic/',
@@ -267,37 +267,30 @@ describe OEmbed::Provider do
267
267
  @vimeo_ssl << "http://*.vimeo.com/*"
268
268
  @vimeo_ssl << "https://*.vimeo.com/*"
269
269
 
270
- expect {
271
- res = @vimeo_ssl.send(:raw, example_url(:vimeo_ssl))
272
- expect(res).to eq(example_body(:vimeo_ssl))
273
- }.not_to raise_error
270
+ res = @vimeo_ssl.send(:raw, example_url(:vimeo_ssl))
271
+ expect(res).to eq(example_body(:vimeo_ssl).strip)
274
272
  end
275
273
 
276
274
  it "should raise an UnknownFormat error on 501" do
277
- # Note: This test relies on a custom-written VCR response in the
278
- # cassettes/OEmbed_Provider.yml file.
275
+ stub_request(:get, /flickr/).to_return(status: 501)
279
276
 
280
277
  expect {
281
- @flickr.send(:raw, File.join(example_url(:flickr), '501'))
278
+ result = @flickr.send(:raw, File.join(example_url(:flickr), '501'))
282
279
  }.to raise_error(OEmbed::UnknownFormat)
283
280
  end
284
281
 
285
282
  it "should raise a NotFound error on 404" do
286
- # Note: This test relies on a custom-written VCR response in the
287
- # cassettes/OEmbed_Provider.yml file.
283
+ stub_request(:get, /flickr/).to_return(status: 404)
288
284
 
289
285
  expect {
290
286
  @flickr.send(:raw, File.join(example_url(:flickr), '404'))
291
287
  }.to raise_error(OEmbed::NotFound)
292
288
  end
293
289
 
294
- it "should raise an UnknownResponse error on other responses" do
295
- # Note: This test relies on a custom-written VCR response in the
296
- # cassettes/OEmbed_Provider.yml file.
297
-
298
- statuses_to_check = ['405', '500']
290
+ ['405', '500'].each do |status|
291
+ it "should raise an UnknownResponse error on other responses (#{status})" do
292
+ stub_request(:get, /flickr/).to_return(status: status)
299
293
 
300
- statuses_to_check.each do |status|
301
294
  expect {
302
295
  @flickr.send(:raw, File.join(example_url(:flickr), status))
303
296
  }.to raise_error(OEmbed::UnknownResponse)
@@ -364,7 +357,7 @@ describe OEmbed::Provider do
364
357
  @viddler.get(example_url(:viddler))
365
358
  end
366
359
 
367
- it "handles the :timeout option" do
360
+ it "handles the :timeout option", pending: true do
368
361
  expect_any_instance_of(Net::HTTP).to receive(:open_timeout=).with(5)
369
362
  expect_any_instance_of(Net::HTTP).to receive(:read_timeout=).with(5)
370
363
  @flickr.get(example_url(:flickr), :timeout => 5)
@@ -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
@@ -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:
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.10.1
4
+ version: 0.14.0
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: 2016-05-21 00:00:00.000000000 Z
14
+ date: 2020-11-05 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
@@ -174,6 +108,7 @@ files:
174
108
  - spec/formatter_spec.rb
175
109
  - spec/provider_discovery_spec.rb
176
110
  - spec/provider_spec.rb
111
+ - spec/providers/facebook_spec.rb
177
112
  - spec/providers/slideshare_spec.rb
178
113
  - spec/providers/twitter_spec.rb
179
114
  - spec/providers_spec.rb
@@ -190,7 +125,7 @@ rdoc_options:
190
125
  - "--main"
191
126
  - README.rdoc
192
127
  - "--title"
193
- - ruby-oembed-0.10.1
128
+ - ruby-oembed-0.14.0
194
129
  - "--inline-source"
195
130
  - "--exclude"
196
131
  - tasks
@@ -208,10 +143,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
143
  - !ruby/object:Gem::Version
209
144
  version: '0'
210
145
  requirements: []
211
- rubyforge_project:
212
- rubygems_version: 2.5.1
146
+ rubygems_version: 3.1.4
213
147
  signing_key:
214
- specification_version: 3
148
+ specification_version: 4
215
149
  summary: oEmbed for Ruby
216
150
  test_files:
217
151
  - spec/cassettes/OEmbed_Provider.yml
@@ -228,6 +162,7 @@ test_files:
228
162
  - spec/formatter_spec.rb
229
163
  - spec/provider_discovery_spec.rb
230
164
  - spec/provider_spec.rb
165
+ - spec/providers/facebook_spec.rb
231
166
  - spec/providers/slideshare_spec.rb
232
167
  - spec/providers/twitter_spec.rb
233
168
  - spec/providers_spec.rb