ruby-oembed 0.13.1 → 0.16.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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +5 -2
  3. data/CHANGELOG.rdoc +25 -1
  4. data/README.md +23 -5
  5. data/lib/oembed/provider.rb +54 -5
  6. data/lib/oembed/providers/{embedly_urls.yml → aggregators/embedly_urls.yml} +0 -0
  7. data/lib/oembed/providers/{noembed_urls.yml → aggregators/noembed_urls.yml} +0 -0
  8. data/lib/oembed/providers/{oohembed_urls.yml → aggregators/oohembed_urls.yml} +0 -0
  9. data/lib/oembed/providers/builtin_providers.rb +297 -0
  10. data/lib/oembed/providers/facebook_post.rb +35 -0
  11. data/lib/oembed/providers/facebook_video.rb +30 -0
  12. data/lib/oembed/providers/instagram.rb +45 -0
  13. data/lib/oembed/providers/tiktok.rb +13 -0
  14. data/lib/oembed/providers.rb +46 -322
  15. data/lib/oembed/version.rb +2 -2
  16. data/lib/oembed.rb +1 -0
  17. data/lib/tasks/oembed.rake +2 -2
  18. data/ruby-oembed.gemspec +1 -2
  19. metadata +16 -55
  20. data/integration_test/test.rb +0 -31
  21. data/integration_test/test_urls.csv +0 -502
  22. data/spec/cassettes/OEmbed_Provider.yml +0 -987
  23. data/spec/cassettes/OEmbed_ProviderDiscovery.yml +0 -27184
  24. data/spec/cassettes/OEmbed_Providers_Slideshare.yml +0 -1433
  25. data/spec/cassettes/OEmbed_Providers_Twitter.yml +0 -612
  26. data/spec/formatter/ducktype_backend_spec.rb +0 -94
  27. data/spec/formatter/json/.DS_Store +0 -0
  28. data/spec/formatter/json/jsongem_backend_spec.rb +0 -71
  29. data/spec/formatter/json/yaml_backend_spec.rb +0 -55
  30. data/spec/formatter/xml/nokogiri_backend_spec.rb +0 -59
  31. data/spec/formatter/xml/rexml_backend_spec.rb +0 -55
  32. data/spec/formatter/xml/xmlsimple_backend_spec.rb +0 -59
  33. data/spec/formatter_spec.rb +0 -37
  34. data/spec/provider_discovery_spec.rb +0 -141
  35. data/spec/provider_spec.rb +0 -366
  36. data/spec/providers/slideshare_spec.rb +0 -42
  37. data/spec/providers/twitter_spec.rb +0 -44
  38. data/spec/providers_spec.rb +0 -258
  39. data/spec/response_spec.rb +0 -230
  40. data/spec/spec_helper.rb +0 -111
  41. data/spec/spec_helper_examples.yml +0 -27
  42. data/spec/support/shared_examples_for_providers.rb +0 -39
@@ -9,6 +9,7 @@ module OEmbed
9
9
  @@urls = {}
10
10
  @@fallback = []
11
11
  @@to_register = {}
12
+ @@access_token_setters = {}
12
13
 
13
14
  # A Hash of all url schemes, where the keys represent schemes supported by
14
15
  # all registered Provider instances and values are an Array of Providers
@@ -44,11 +45,14 @@ module OEmbed
44
45
  # Register all Providers built into this gem.
45
46
  # The including_sub_type parameter should be one of the following values:
46
47
  # * :aggregators: also register provider aggregator endpoints, like Embedly
47
- def register_all(*including_sub_type)
48
+ # The access_tokens keys can be one of the following:
49
+ # * :facebook: See https://developers.facebook.com/docs/instagram/oembed#access-tokens
50
+ def register_all(*including_sub_type, access_tokens: {})
48
51
  register(*@@to_register[""])
49
52
  including_sub_type.each do |sub_type|
50
53
  register(*@@to_register[sub_type.to_s])
51
54
  end
55
+ set_access_tokens(access_tokens)
52
56
  end
53
57
 
54
58
  # Unregister all currently-registered Provider instances.
@@ -74,10 +78,19 @@ module OEmbed
74
78
  @@fallback
75
79
  end
76
80
 
77
- # Returns a Provider instance who's url scheme matches the given url.
81
+ # Returns a Provider instance whose url scheme matches the given url.
82
+ # Skips any Provider with missing required_query_params.
78
83
  def find(url)
79
- providers = @@urls[@@urls.keys.detect { |u| u =~ url }]
80
- Array(providers).first || nil
84
+ @@urls.keys.each do |url_regexp|
85
+ next unless url_regexp.match?(url)
86
+
87
+ matching_provider = @@urls[url_regexp].detect { |p| p.include?(url) }
88
+
89
+ # If we've found a matching provider, return it right away!
90
+ return matching_provider if matching_provider
91
+ end
92
+
93
+ nil
81
94
  end
82
95
 
83
96
  # Finds the appropriate Provider for this url and return the raw response.
@@ -111,335 +124,46 @@ module OEmbed
111
124
  private
112
125
 
113
126
  # Takes an OEmbed::Provider instance and registers it so that when we call
114
- # the register_all method, they all register. The sub_type can be be any value
127
+ # the register_all method, they all register.
128
+ # The sub_type can be be any value
115
129
  # used to uniquely group providers. Official sub_types are:
116
130
  # * nil: a normal provider
117
131
  # * :aggregators: an endpoint for an OEmbed aggregator
118
- def add_official_provider(provider_class, sub_type=nil)
132
+ # :access_token takes a Hash with the following required keys:
133
+ # * :name: A Symbol: the name of access token, to be used with `register_all`
134
+ # * :method: A Symbol: the name of the required_query_params for the access token.
135
+ def add_official_provider(provider_class, sub_type=nil, access_token: nil)
119
136
  raise TypeError, "Expected OEmbed::Provider instance but was #{provider_class.class}" \
120
137
  unless provider_class.is_a?(OEmbed::Provider)
121
138
 
122
139
  @@to_register[sub_type.to_s] ||= []
123
140
  @@to_register[sub_type.to_s] << provider_class
124
- end
125
- end
126
-
127
- # Custom providers:
128
-
129
- # Provider for youtube.com
130
- # http://apiblog.youtube.com/2009/10/oembed-support.html
131
- #
132
- # Options:
133
- # * To get the iframe embed code
134
- # OEmbed::Providers::Youtube.endpoint += "?iframe=1"
135
- # * To get the flash/object embed code
136
- # OEmbed::Providers::Youtube.endpoint += "?iframe=0"
137
- # * To require https embed code
138
- # OEmbed::Providers::Youtube.endpoint += "?scheme=https"
139
- Youtube = OEmbed::Provider.new("https://www.youtube.com/oembed?scheme=https")
140
- Youtube << "http://*.youtube.com/*"
141
- Youtube << "https://*.youtube.com/*"
142
- Youtube << "http://*.youtu.be/*"
143
- Youtube << "https://*.youtu.be/*"
144
- add_official_provider(Youtube)
145
-
146
- # Provider for codepen.io
147
- CodePen = OEmbed::Provider.new("https://codepen.io/api/oembed")
148
- CodePen << "http://codepen.io/*"
149
- CodePen << "https://codepen.io/*"
150
- add_official_provider(CodePen)
151
-
152
- # Provider for flickr.com
153
- Flickr = OEmbed::Provider.new("https://www.flickr.com/services/oembed/")
154
- Flickr << "http://*.flickr.com/*"
155
- Flickr << "https://*.flickr.com/*"
156
- Flickr << "http://flic.kr/*"
157
- Flickr << "https://flic.kr/*"
158
- add_official_provider(Flickr)
159
-
160
- # Provider for viddler.com
161
- # http://developers.viddler.com/documentation/services/oembed/
162
- Viddler = OEmbed::Provider.new("http://lab.viddler.com/services/oembed/")
163
- Viddler << "http://*.viddler.com/*"
164
- add_official_provider(Viddler)
165
-
166
- # Provider for qik.com
167
- # http://qik.com/blog/qik-embraces-oembed-for-embedding-videos/
168
- Qik = OEmbed::Provider.new("http://qik.com/api/oembed.{format}")
169
- Qik << "http://qik.com/*"
170
- Qik << "http://qik.com/video/*"
171
- add_official_provider(Qik)
172
-
173
- # Provider for revision3.com
174
- Revision3 = OEmbed::Provider.new("http://revision3.com/api/oembed/")
175
- Revision3 << "http://*.revision3.com/*"
176
- add_official_provider(Revision3)
177
-
178
- # Provider for hulu.com
179
- Hulu = OEmbed::Provider.new("https://www.hulu.com/api/oembed.{format}")
180
- Hulu << "http://www.hulu.com/watch/*"
181
- Hulu << "https://www.hulu.com/watch/*"
182
- add_official_provider(Hulu)
183
-
184
- # Provider for vimeo.com
185
- # https://developer.vimeo.com/apis/oembed
186
- Vimeo = OEmbed::Provider.new("https://vimeo.com/api/oembed.{format}")
187
- Vimeo << "http://*.vimeo.com/*"
188
- Vimeo << "https://*.vimeo.com/*"
189
- add_official_provider(Vimeo)
190
-
191
- # Provider for twitter.com
192
- # https://dev.twitter.com/rest/reference/get/statuses/oembed
193
- Twitter = OEmbed::Provider.new("https://publish.twitter.com/oembed", :json)
194
- Twitter << "https://*.twitter.com/*/status/*"
195
- add_official_provider(Twitter)
196
-
197
- # Provider for vine.co
198
- # https://dev.twitter.com/web/vine/oembed
199
- Vine = OEmbed::Provider.new("https://vine.co/oembed.{format}")
200
- Vine << "http://*.vine.co/v/*"
201
- Vine << "https://*.vine.co/v/*"
202
- add_official_provider(Vine)
203
-
204
- # Provider for instagram.com
205
- # https://instagr.am/developer/embedding/
206
- Instagram = OEmbed::Provider.new("https://api.instagram.com/oembed", :json)
207
- Instagram << "http://instagr.am/p/*"
208
- Instagram << "http://instagram.com/p/*"
209
- Instagram << "http://www.instagram.com/p/*"
210
- Instagram << "https://instagr.am/p/*"
211
- Instagram << "https://instagram.com/p/*"
212
- Instagram << "https://www.instagram.com/p/*"
213
- Instagram << "http://instagr.am/tv/*"
214
- Instagram << "http://instagram.com/tv/*"
215
- Instagram << "http://www.instagram.com/tv/*"
216
- Instagram << "https://instagr.am/tv/*"
217
- Instagram << "https://instagram.com/tv/*"
218
- Instagram << "https://www.instagram.com/tv/*"
219
- add_official_provider(Instagram)
220
-
221
- # Providers for Facebook Posts & Videos
222
- # https://developers.facebook.com/docs/plugins/oembed-endpoints
223
- FacebookPost = OEmbed::Provider.new('https://www.facebook.com/plugins/post/oembed.json/', :json)
224
- FacebookPost << 'https://www.facebook.com/*/posts/*'
225
- FacebookPost << 'https://www.facebook.com/*/activity/*'
226
- FacebookPost << 'https://www.facebook.com/photo*'
227
- FacebookPost << 'https://www.facebook.com/photos*'
228
- FacebookPost << 'https://www.facebook.com/*/photos*'
229
- FacebookPost << 'https://www.facebook.com/permalink*'
230
- FacebookPost << 'https://www.facebook.com/media*'
231
- FacebookPost << 'https://www.facebook.com/questions*'
232
- FacebookPost << 'https://www.facebook.com/notes*'
233
- add_official_provider(FacebookPost)
234
-
235
- FacebookVideo = OEmbed::Provider.new('https://www.facebook.com/plugins/video/oembed.json/', :json)
236
- FacebookVideo << 'https://www.facebook.com/*/videos/*'
237
- FacebookVideo << 'https://www.facebook.com/video*'
238
- add_official_provider(FacebookVideo)
239
-
240
- # Provider for slideshare.net
241
- # http://www.slideshare.net/developers/oembed
242
- Slideshare = OEmbed::Provider.new("https://www.slideshare.net/api/oembed/2")
243
- Slideshare << 'http://*.slideshare.net/*/*'
244
- Slideshare << 'https://*.slideshare.net/*/*'
245
- Slideshare << 'http://*.slideshare.net/mobile/*/*'
246
- Slideshare << 'https://*.slideshare.net/mobile/*/*'
247
- add_official_provider(Slideshare)
248
-
249
- # Provider for yfrog
250
- # http://code.google.com/p/imageshackapi/wiki/OEMBEDSupport
251
- Yfrog = OEmbed::Provider.new("https://www.yfrog.com/api/oembed", :json)
252
- Yfrog << "http://yfrog.com/*"
253
- add_official_provider(Yfrog)
254
-
255
- # Provider for Giphy
256
- Giphy = OEmbed::Provider.new("http://giphy.com/services/oembed")
257
- Giphy << "http://giphy.com/*"
258
- Giphy << "https://giphy.com/*"
259
- add_official_provider(Giphy)
260
-
261
- # Provider for imgur.com
262
- Imgur = OEmbed::Provider.new("https://api.imgur.com/oembed.{format}")
263
- Imgur << "https://*.imgur.com/gallery/*"
264
- Imgur << "http://*.imgur.com/gallery/*"
265
- add_official_provider(Imgur)
266
141
 
267
- # Provider for Kickstarter
268
- Kickstarter = OEmbed::Provider.new("https://www.kickstarter.com/services/oembed")
269
- Kickstarter << "http://www.kickstarter.com/projects/*"
270
- Kickstarter << "https://www.kickstarter.com/projects/*"
271
- add_official_provider(Kickstarter)
142
+ if access_token.is_a?(Hash) && access_token[:name] && access_token[:method]
143
+ setter_method = "#{access_token[:method]}="
144
+ raise TypeError, "Expected OEmbed::Provider instance to respond to the given access_token method #{setter_method}" \
145
+ unless provider_class.respond_to?(setter_method)
272
146
 
273
- # provider for mlg-tv
274
- # http://tv.majorleaguegaming.com/oembed
275
- MlgTv = OEmbed::Provider.new("http://tv.majorleaguegaming.com/oembed")
276
- MlgTv << "http://tv.majorleaguegaming.com/video/*"
277
- MlgTv << "http://mlg.tv/video/*"
278
- add_official_provider(MlgTv)
279
-
280
- # pownce.com closed in 2008
281
- #Pownce = OEmbed::Provider.new("http://api.pownce.com/2.1/oembed.{format}")
282
- #Pownce << "http://*.pownce.com/*"
283
- #add_official_provider(Pownce)
284
-
285
- # Provider for polleverywhere.com
286
- PollEverywhere = OEmbed::Provider.new("http://www.polleverywhere.com/services/oembed/")
287
- PollEverywhere << "http://www.polleverywhere.com/polls/*"
288
- PollEverywhere << "http://www.polleverywhere.com/multiple_choice_polls/*"
289
- PollEverywhere << "http://www.polleverywhere.com/free_text_polls/*"
290
- add_official_provider(PollEverywhere)
291
-
292
- # Provider for my.opera.com
293
- # http://my.opera.com/devblog/blog/2008/12/02/embedding-my-opera-content-oembed
294
- MyOpera = OEmbed::Provider.new("http://my.opera.com/service/oembed", :json)
295
- MyOpera << "http://my.opera.com/*"
296
- add_official_provider(MyOpera)
297
-
298
- # Provider for clearspring.com
299
- ClearspringWidgets = OEmbed::Provider.new("http://widgets.clearspring.com/widget/v1/oembed/")
300
- ClearspringWidgets << "http://www.clearspring.com/widgets/*"
301
- add_official_provider(ClearspringWidgets)
302
-
303
- # Provider for nfb.ca
304
- NFBCanada = OEmbed::Provider.new("http://www.nfb.ca/remote/services/oembed/")
305
- NFBCanada << "http://*.nfb.ca/film/*"
306
- add_official_provider(NFBCanada)
307
-
308
- # Provider for scribd.com
309
- Scribd = OEmbed::Provider.new("https://www.scribd.com/services/oembed")
310
- Scribd << "http://*.scribd.com/*"
311
- add_official_provider(Scribd)
312
-
313
- # Provider for speakerdeck.com
314
- # https://speakerdeck.com/faq#oembed
315
- SpeakerDeck = OEmbed::Provider.new("https://speakerdeck.com/oembed.json")
316
- SpeakerDeck << "http://speakerdeck.com/*/*"
317
- SpeakerDeck << "https://speakerdeck.com/*/*"
318
- add_official_provider(SpeakerDeck)
319
-
320
- # Provider for movieclips.com
321
- MovieClips = OEmbed::Provider.new("http://movieclips.com/services/oembed/")
322
- MovieClips << "http://movieclips.com/watch/*/*/"
323
- add_official_provider(MovieClips)
324
-
325
- # Provider for 23hq.com
326
- TwentyThree = OEmbed::Provider.new("http://www.23hq.com/23/oembed")
327
- TwentyThree << "http://www.23hq.com/*"
328
- add_official_provider(TwentyThree)
329
-
330
- # Provider for soundcloud.com
331
- # http://developers.soundcloud.com/docs/oembed
332
- SoundCloud = OEmbed::Provider.new("https://soundcloud.com/oembed", :json)
333
- SoundCloud << "http://*.soundcloud.com/*"
334
- SoundCloud << "https://*.soundcloud.com/*"
335
- add_official_provider(SoundCloud)
336
-
337
- # Provider for spotify.com
338
- # https://twitter.com/nicklas2k/status/330094611202723840
339
- # http://blog.embed.ly/post/45149936446/oembed-for-spotify
340
- Spotify = OEmbed::Provider.new("https://embed.spotify.com/oembed/")
341
- Spotify << "http://open.spotify.com/*"
342
- Spotify << "https://open.spotify.com/*"
343
- Spotify << "http://play.spotify.com/*"
344
- Spotify << "https://play.spotify.com/*"
345
- Spotify << /^spotify\:(.*?)/
346
- add_official_provider(Spotify)
347
-
348
- # Provider for skitch.com
349
- # http://skitch.com/oembed/%3C/endpoint
350
- Skitch = OEmbed::Provider.new("http://skitch.com/oembed")
351
- Skitch << "http://*.skitch.com/*"
352
- Skitch << "https://*.skitch.com/*"
353
- add_official_provider(Skitch)
354
-
355
- # Provider for TED
356
- Ted = OEmbed::Provider.new("https://www.ted.com/talks/oembed.{format}")
357
- Ted << "http://*.ted.com/talks/*"
358
- Ted << "https://*.ted.com/talks/*"
359
- add_official_provider(Ted)
360
-
361
- # Provider for tumblr.com
362
- Tumblr = OEmbed::Provider.new("http://www.tumblr.com/oembed/1.0/", :json)
363
- Tumblr << "http://*.tumblr.com/post/*"
364
- Tumblr << "https://*.tumblr.com/post/*"
365
- add_official_provider(Tumblr)
366
-
367
- ## Provider for clikthrough.com
368
- # http://corporate.clikthrough.com/wp/?p=275
369
- #Clickthrough = OEmbed::Provider.new("http://www.clikthrough.com/services/oembed/")
370
- #Clickthrough << "http://*.clikthrough.com/theater/video/*"
371
- #add_official_provider(Clickthrough)
372
-
373
- ## Provider for kinomap.com
374
- # http://www.kinomap.com/#!oEmbed
375
- #Kinomap = OEmbed::Provider.new("http://www.kinomap.com/oembed")
376
- #Kinomap << "http://www.kinomap.com/*"
377
- #add_official_provider(Kinomap)
378
-
379
- # Provider for oohembed.com, which is a provider aggregator. See
380
- # OEmbed::Providers::OohEmbed.urls for a full list of supported url schemas.
381
- # Embed.ly has taken over the oohembed.com domain and as of July 20 all oohEmbed
382
- # request will require you use an API key. For details on the transition see
383
- # http://blog.embed.ly/oohembed
384
- OohEmbed = OEmbed::Provider.new("http://oohembed.com/oohembed/", :json)
385
- OohEmbed << "http://*.5min.com/Video/*" # micro-video host
386
- OohEmbed << %r{http://(.*?).amazon.(com|co.uk|de|ca|jp)/(.*?)/(gp/product|o/ASIN|obidos/ASIN|dp)/(.*?)} # Online product shopping
387
- OohEmbed << "http://*.blip.tv/*"
388
- OohEmbed << "http://*.clikthrough.com/theater/video/*"
389
- OohEmbed << "http://*.collegehumor.com/video:*" # Comedic & original videos
390
- OohEmbed << "http://*.thedailyshow.com/video/*" # Syndicated show
391
- OohEmbed << "http://*.dailymotion.com/*"
392
- OohEmbed << "http://dotsub.com/view/*"
393
- OohEmbed << "http://*.flickr.com/photos/*"
394
- OohEmbed << "http://*.funnyordie.com/videos/*" # Comedy video host
395
- OohEmbed << "http://video.google.com/videoplay?*" # Video hosting
396
- OohEmbed << "http://www.hulu.com/watch/*"
397
- OohEmbed << "http://*.kinomap.com/*"
398
- OohEmbed << "http://*.livejournal.com/"
399
- OohEmbed << "http://*.metacafe.com/watch/*" # Video host
400
- OohEmbed << "http://*.nfb.ca/film/*"
401
- OohEmbed << "http://*.photobucket.com/albums/*"
402
- OohEmbed << "http://*.photobucket.com/groups/*"
403
- OohEmbed << "http://*.phodroid.com/*/*/*" # Photo host
404
- OohEmbed << "http://qik.com/*"
405
- OohEmbed << "http://*.revision3.com/*"
406
- OohEmbed << "http://*.scribd.com/*"
407
- OohEmbed << "http://*.slideshare.net/*" # Share presentations online
408
- OohEmbed << "http://*.twitpic.com/*" # Picture hosting for Twitter
409
- OohEmbed << "http://twitter.com/*/statuses/*" # Mirco-blogging network
410
- OohEmbed << "http://*.viddler.com/explore/*"
411
- OohEmbed << "http://www.vimeo.com/*"
412
- OohEmbed << "http://www.vimeo.com/groups/*/videos/*"
413
- OohEmbed << "http://*.wikipedia.org/wiki/*" # Online encyclopedia
414
- OohEmbed << "http://*.wordpress.com/*/*/*/*" # Blogging Engine & community
415
- OohEmbed << "http://*.xkcd.com/*" # A hilarious stick figure comic
416
- OohEmbed << %r{http://yfrog.(com|ru|com.tr|it|fr|co.il|co.uk|com.pl|pl|eu|us)/(.*?)} # image & video hosting
417
- OohEmbed << "http://*.youtube.com/watch*"
418
-
419
- # Provider for noembed.com, which is a provider aggregator. See
420
- # OEmbed::Providers::Noembed.urls for a full list of supported url schemas.
421
- # https://noembed.com/#supported-sites
422
- Noembed = OEmbed::Provider.new("https://noembed.com/embed")
423
- # Add all known URL regexps for Noembed.
424
- # To update this list run `rake oembed:update_noembed`
425
- YAML.load_file(File.join(File.dirname(__FILE__), "/providers/noembed_urls.yml")).each do |url|
426
- Noembed << Regexp.new(url)
427
- end
428
- add_official_provider(Noembed, :aggregators)
147
+ @@access_token_setters[access_token[:name]] ||= []
148
+ @@access_token_setters[access_token[:name]] << provider_class.method(setter_method)
149
+ end
150
+ end
429
151
 
430
- # Provider for Embedly.com, which is a provider aggregator. See
431
- # OEmbed::Providers::Embedly.urls for a full list of supported url schemas.
432
- # http://embed.ly/docs/endpoints/1/oembed
433
- #
434
- # You can append your Embed.ly API key to the provider so that all requests are signed
435
- # OEmbed::Providers::Embedly.endpoint += "?key=#{my_embedly_key}"
436
- #
437
- # If you don't yet have an API key you'll need to sign up here: http://embed.ly/pricing
438
- Embedly = OEmbed::Provider.new("http://api.embed.ly/1/oembed")
439
- # Add all known URL regexps for Embedly. To update this list run `rake oembed:update_embedly`
440
- YAML.load_file(File.join(File.dirname(__FILE__), "/providers/embedly_urls.yml")).each do |url|
441
- Embedly << url
152
+ # Takes a Hash of tokens, and calls the setter method
153
+ # for all providers that use the given tokens.
154
+ # Also supports "OEMBED_*_TOKEN" environment variables.
155
+ # Currently supported tokens:
156
+ # * facebook: See https://developers.facebook.com/docs/instagram/oembed#access-tokens
157
+ def set_access_tokens(access_tokens)
158
+ access_tokens.each do |token_name, token_value|
159
+ token_name = token_name.to_sym
160
+ next unless @@access_token_setters.has_key?(token_name)
161
+
162
+ @@access_token_setters[token_name].each do |token_setter_method|
163
+ token_setter_method.call(token_value)
164
+ end
165
+ end
166
+ end
442
167
  end
443
- add_official_provider(Embedly, :aggregators)
444
168
  end
445
169
  end
@@ -1,8 +1,8 @@
1
1
  module OEmbed
2
2
  class Version
3
3
  MAJOR = 0
4
- MINOR = 13
5
- PATCH = 1
4
+ MINOR = 16
5
+ PATCH = 0
6
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
 
8
8
  class << self
data/lib/oembed.rb CHANGED
@@ -8,6 +8,7 @@ require 'oembed/formatter'
8
8
  require 'oembed/provider'
9
9
  require 'oembed/provider_discovery'
10
10
  require 'oembed/providers'
11
+ require 'oembed/providers/builtin_providers'
11
12
  require 'oembed/response'
12
13
  require 'oembed/response/photo'
13
14
  require 'oembed/response/video'
@@ -8,7 +8,7 @@ begin
8
8
  task :update_noembed do
9
9
  # Details at http://api.embed.ly/docs/service
10
10
  json_uri = URI.parse("https://noembed.com/providers")
11
- yaml_path = File.join(File.dirname(__FILE__), "../oembed/providers/noembed_urls.yml")
11
+ yaml_path = File.join(File.dirname(__FILE__), "../oembed/providers/aggregators/noembed_urls.yml")
12
12
 
13
13
  services = JSON.parse(json_uri.read)
14
14
 
@@ -25,7 +25,7 @@ begin
25
25
  task :update_embedly do
26
26
  # Details at http://api.embed.ly/docs/service
27
27
  json_uri = URI.parse("http://api.embed.ly/1/services")
28
- yaml_path = File.join(File.dirname(__FILE__), "../oembed/providers/embedly_urls.yml")
28
+ yaml_path = File.join(File.dirname(__FILE__), "../oembed/providers/aggregators/embedly_urls.yml")
29
29
 
30
30
  services = JSON.parse(json_uri.read)
31
31
 
data/ruby-oembed.gemspec CHANGED
@@ -17,8 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.homepage = "https://github.com/ruby-oembed/ruby-oembed"
18
18
  s.licenses = ["MIT"]
19
19
 
20
- s.files = `git ls-files`.split("\n")
21
- s.test_files = s.files.grep(%r{^(test|spec|features,integration_test)/})
20
+ s.files = `git ls-files`.split("\n").reject { |f| f.start_with?('spec/') || f.start_with?('integration_test/') }
22
21
 
23
22
  s.rdoc_options = ["--main", "README.rdoc", "--title", "ruby-oembed-#{OEmbed::Version}", "--inline-source", "--exclude", "tasks", "CHANGELOG.rdoc"]
24
23
  s.extra_rdoc_files = s.files.grep(%r{\.rdoc$}) + %w{LICENSE}
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-oembed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.1
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Magnus Holm
8
8
  - Alex Kessinger
9
9
  - Aris Bartee
10
10
  - Marcos Wright Kuhns
11
- autorequire:
11
+ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2020-05-25 00:00:00.000000000 Z
14
+ date: 2022-01-08 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: xml-simple
@@ -61,8 +61,6 @@ files:
61
61
  - LICENSE
62
62
  - README.md
63
63
  - Rakefile
64
- - integration_test/test.rb
65
- - integration_test/test_urls.csv
66
64
  - lib/oembed.rb
67
65
  - lib/oembed/errors.rb
68
66
  - lib/oembed/formatter.rb
@@ -79,9 +77,14 @@ files:
79
77
  - lib/oembed/provider.rb
80
78
  - lib/oembed/provider_discovery.rb
81
79
  - lib/oembed/providers.rb
82
- - lib/oembed/providers/embedly_urls.yml
83
- - lib/oembed/providers/noembed_urls.yml
84
- - lib/oembed/providers/oohembed_urls.yml
80
+ - lib/oembed/providers/aggregators/embedly_urls.yml
81
+ - lib/oembed/providers/aggregators/noembed_urls.yml
82
+ - lib/oembed/providers/aggregators/oohembed_urls.yml
83
+ - lib/oembed/providers/builtin_providers.rb
84
+ - lib/oembed/providers/facebook_post.rb
85
+ - lib/oembed/providers/facebook_video.rb
86
+ - lib/oembed/providers/instagram.rb
87
+ - lib/oembed/providers/tiktok.rb
85
88
  - lib/oembed/response.rb
86
89
  - lib/oembed/response/link.rb
87
90
  - lib/oembed/response/photo.rb
@@ -91,37 +94,16 @@ files:
91
94
  - lib/tasks/oembed.rake
92
95
  - lib/tasks/rspec.rake
93
96
  - ruby-oembed.gemspec
94
- - spec/cassettes/OEmbed_Provider.yml
95
- - spec/cassettes/OEmbed_ProviderDiscovery.yml
96
- - spec/cassettes/OEmbed_Providers_Slideshare.yml
97
- - spec/cassettes/OEmbed_Providers_Twitter.yml
98
- - spec/formatter/ducktype_backend_spec.rb
99
- - spec/formatter/json/.DS_Store
100
- - spec/formatter/json/jsongem_backend_spec.rb
101
- - spec/formatter/json/yaml_backend_spec.rb
102
- - spec/formatter/xml/nokogiri_backend_spec.rb
103
- - spec/formatter/xml/rexml_backend_spec.rb
104
- - spec/formatter/xml/xmlsimple_backend_spec.rb
105
- - spec/formatter_spec.rb
106
- - spec/provider_discovery_spec.rb
107
- - spec/provider_spec.rb
108
- - spec/providers/slideshare_spec.rb
109
- - spec/providers/twitter_spec.rb
110
- - spec/providers_spec.rb
111
- - spec/response_spec.rb
112
- - spec/spec_helper.rb
113
- - spec/spec_helper_examples.yml
114
- - spec/support/shared_examples_for_providers.rb
115
97
  homepage: https://github.com/ruby-oembed/ruby-oembed
116
98
  licenses:
117
99
  - MIT
118
100
  metadata: {}
119
- post_install_message:
101
+ post_install_message:
120
102
  rdoc_options:
121
103
  - "--main"
122
104
  - README.rdoc
123
105
  - "--title"
124
- - ruby-oembed-0.13.1
106
+ - ruby-oembed-0.16.0
125
107
  - "--inline-source"
126
108
  - "--exclude"
127
109
  - tasks
@@ -139,29 +121,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
121
  - !ruby/object:Gem::Version
140
122
  version: '0'
141
123
  requirements: []
142
- rubygems_version: 3.0.3
143
- signing_key:
124
+ rubygems_version: 3.1.4
125
+ signing_key:
144
126
  specification_version: 4
145
127
  summary: oEmbed for Ruby
146
- test_files:
147
- - spec/cassettes/OEmbed_Provider.yml
148
- - spec/cassettes/OEmbed_ProviderDiscovery.yml
149
- - spec/cassettes/OEmbed_Providers_Slideshare.yml
150
- - spec/cassettes/OEmbed_Providers_Twitter.yml
151
- - spec/formatter/ducktype_backend_spec.rb
152
- - spec/formatter/json/.DS_Store
153
- - spec/formatter/json/jsongem_backend_spec.rb
154
- - spec/formatter/json/yaml_backend_spec.rb
155
- - spec/formatter/xml/nokogiri_backend_spec.rb
156
- - spec/formatter/xml/rexml_backend_spec.rb
157
- - spec/formatter/xml/xmlsimple_backend_spec.rb
158
- - spec/formatter_spec.rb
159
- - spec/provider_discovery_spec.rb
160
- - spec/provider_spec.rb
161
- - spec/providers/slideshare_spec.rb
162
- - spec/providers/twitter_spec.rb
163
- - spec/providers_spec.rb
164
- - spec/response_spec.rb
165
- - spec/spec_helper.rb
166
- - spec/spec_helper_examples.yml
167
- - spec/support/shared_examples_for_providers.rb
128
+ test_files: []
@@ -1,31 +0,0 @@
1
- require 'rubygems'
2
- require File.dirname(__FILE__) + '/../lib/oembed'
3
- OEmbed::Providers.register_all()
4
- OEmbed::Providers.register_fallback(OEmbed::ProviderDiscovery, OEmbed::Providers::Embedly, OEmbed::Providers::OohEmbed)
5
-
6
-
7
- passed = "passed"
8
- passed = "failed"
9
- File.open("test_urls.csv", "r") do |infile|
10
- while (line = infile.gets)
11
- begin
12
- res = OEmbed::Providers.raw(line, :format => :json)
13
- passed = "passed"
14
- rescue OEmbed::NotFound => e
15
- if e.message == "OEmbed::NotFound"
16
- puts "not a supported url: " + line
17
- else
18
- puts e.message
19
- end
20
- passed = "failed"
21
- rescue OEmbed::UnknownResponse => e
22
- puts "got a bad network response" + e.message
23
- passed = "failed"
24
- rescue Timeout::Error
25
- puts "timeout error"
26
- passed = "failed"
27
- end
28
-
29
- puts passed + ": " + line
30
- end
31
- end