ruby-oembed 0.8.5 → 0.8.7

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.
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm default@oembed
1
+ rvm --create use default@oembed
data/CHANGELOG.rdoc CHANGED
@@ -1,10 +1,18 @@
1
1
  = CHANGELOG
2
2
 
3
+ == 0.8.7 - 11 March 2012
4
+
5
+ * Support for https provider endpoints; Issue #16 (Marcos Wright Kuhns)
6
+ * OEmbed::Providers.register_all now actually registers all bundled providers; Issue #18 (Marcos Wright Kuhns)
7
+ * Added built-in provider for SoundCloud (Hendrik Mans)
8
+ * Updated the list of {Embedly}[http://embed.ly] URL schemes. (Marcos Wright Kuhns)
9
+ * For developers who work on this gem, the rvmrc now automatically creates an oembed gemset; Issue #20 (Florian Staudacher)
10
+
3
11
  == 0.8.5 - 14 November 2011
4
12
 
5
13
  * Fixed problems ProviderDiscovery and some xml endpoints. Also added much better test coverage. (Marcos Wright Kuhns)
6
14
  * Added support for XML parsing using {Nokogiri}[http://nokogiri.org/] (Marcos Wright Kuhns)
7
- * Added built-in providers for MLG.TV (Matt Wilson)
15
+ * Added built-in provider for MLG.TV (Matt Wilson)
8
16
  * Added https support to the built-in YouTube provider (Marcos Wright Kuhns)
9
17
  * Updated the list of {Embedly}[http://embed.ly] URL schemes. (Marcos Wright Kuhns)
10
18
 
@@ -125,13 +125,20 @@ module OEmbed
125
125
  found = false
126
126
  max_redirects = 4
127
127
  until found
128
- host, port = uri.host, uri.port if uri.host && uri.port
129
- res = Net::HTTP.start(uri.host, uri.port) {|http| http.get(uri.request_uri) }
128
+ http = Net::HTTP.new(uri.host, uri.port)
129
+ http.use_ssl = uri.scheme == 'https'
130
+ http.verify_mode = OpenSSL::SSL::VERIFY_PEER
131
+
132
+ %w{scheme userinfo host port registry}.each { |method| uri.send("#{method}=", nil) }
133
+ res = http.request(Net::HTTP::Get.new(uri.to_s))
134
+
135
+ #res = Net::HTTP.start(uri.host, uri.port) {|http| http.get(uri.request_uri) }
136
+
130
137
  res.header['location'] ? uri = URI.parse(res.header['location']) : found = true
131
138
  if max_redirects == 0
132
- found = true
139
+ found = true
133
140
  else
134
- max_redirects = max_redirects - 1
141
+ max_redirects -= 1
135
142
  end
136
143
  end
137
144
 
@@ -8,6 +8,7 @@ module OEmbed
8
8
  class << self
9
9
  @@urls = {}
10
10
  @@fallback = []
11
+ @@to_register = {}
11
12
 
12
13
  # A Hash of all url schemes, where the keys represent schemes supported by
13
14
  # all registered Provider instances and values are an Array of Providers
@@ -40,16 +41,14 @@ module OEmbed
40
41
  end
41
42
  end
42
43
 
43
- # Register a standard set of common Provider instances, including:
44
- # * Flickr
45
- # * Hulu
46
- # * Qik
47
- # * Revision3
48
- # * Viddler
49
- # * Vimeo
50
- # * Youtube
51
- def register_all
52
- register(Youtube, Flickr, Viddler, Qik, Revision3, Hulu, Vimeo)
44
+ # Register all Providers built into this gem.
45
+ # The including_sub_type parameter should be one of the following values:
46
+ # * :aggregators: also register provider agregator endpoints, like Embedly
47
+ def register_all(*including_sub_type)
48
+ register(*@@to_register[""])
49
+ including_sub_type.each do |sub_type|
50
+ register(*@@to_register[sub_type.to_s])
51
+ end
53
52
  end
54
53
 
55
54
  # Unregister all currently-registered Provider instances.
@@ -108,6 +107,21 @@ module OEmbed
108
107
  raise(OEmbed::NotFound)
109
108
  end
110
109
  end
110
+
111
+ private
112
+
113
+ # 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
115
+ # used to uniquely group providers. Official sub_types are:
116
+ # * nil: a normal provider
117
+ # * :aggregators: an endpoint for an OEmbed aggregator
118
+ def add_official_provider(provider_class, sub_type=nil)
119
+ raise TypeError, "Expected OEmbed::Provider instance but was #{provider_class.class}" \
120
+ unless provider_class.is_a?(OEmbed::Provider)
121
+
122
+ @@to_register[sub_type.to_s] ||= []
123
+ @@to_register[sub_type.to_s] << provider_class
124
+ end
111
125
  end
112
126
 
113
127
  # Custom providers:
@@ -121,63 +135,131 @@ module OEmbed
121
135
  Youtube << "https://*.youtube.com/*"
122
136
  Youtube << "http://*.youtu.be/*"
123
137
  Youtube << "https://*.youtu.be/*"
138
+ add_official_provider(Youtube)
124
139
 
125
140
  # Provider for flickr.com
126
141
  # http://developer.yahoo.com/blogs/ydn/posts/2008/05/oembed_embeddin/
127
142
  Flickr = OEmbed::Provider.new("http://www.flickr.com/services/oembed/")
128
143
  Flickr << "http://*.flickr.com/*"
144
+ add_official_provider(Flickr)
129
145
 
130
146
  # Provider for viddler.com
131
147
  # http://developers.viddler.com/documentation/services/oembed/
132
148
  Viddler = OEmbed::Provider.new("http://lab.viddler.com/services/oembed/")
133
149
  Viddler << "http://*.viddler.com/*"
150
+ add_official_provider(Viddler)
134
151
 
135
152
  # Provider for qik.com
136
153
  # http://qik.com/blog/qik-embraces-oembed-for-embedding-videos/
137
154
  Qik = OEmbed::Provider.new("http://qik.com/api/oembed.{format}")
138
155
  Qik << "http://qik.com/*"
139
156
  Qik << "http://qik.com/video/*"
157
+ add_official_provider(Qik)
140
158
 
141
159
  # Provider for revision3.com
142
160
  Revision3 = OEmbed::Provider.new("http://revision3.com/api/oembed/")
143
161
  Revision3 << "http://*.revision3.com/*"
162
+ add_official_provider(Revision3)
144
163
 
145
164
  # Provider for hulu.com
146
165
  Hulu = OEmbed::Provider.new("http://www.hulu.com/api/oembed.{format}")
147
166
  Hulu << "http://www.hulu.com/watch/*"
167
+ add_official_provider(Hulu)
148
168
 
149
169
  # Provider for vimeo.com
150
170
  # http://vimeo.com/api/docs/oEmbed
151
171
  Vimeo = OEmbed::Provider.new("http://www.vimeo.com/api/oembed.{format}")
152
172
  Vimeo << "http://*.vimeo.com/*"
153
- Vimeo << "http://*.vimeo.com/groups/*/videos/*"
173
+ Vimeo << "https://*.vimeo.com/*"
174
+ add_official_provider(Vimeo)
154
175
 
155
176
  # Provider for instagram.com
156
177
  # http://instagr.am/developer/embedding/
157
178
  Instagram = OEmbed::Provider.new("http://api.instagram.com/oembed", :json)
158
179
  Instagram << "http://instagr.am/p/*"
159
180
  Instagram << "http://instagram.com/p/*"
181
+ add_official_provider(Instagram)
160
182
 
161
183
  # Provider for slideshare.net
162
184
  # http://www.slideshare.net/developers/oembed
163
185
  Slideshare = OEmbed::Provider.new("http://www.slideshare.net/api/oembed/2")
164
186
  Slideshare << "http://www.slideshare.net/*/*"
165
187
  Slideshare << "http://www.slideshare.net/mobile/*/*"
188
+ add_official_provider(Slideshare)
166
189
 
167
190
  # Provider for yfrog
168
191
  # http://code.google.com/p/imageshackapi/wiki/OEMBEDSupport
169
192
  Yfrog = OEmbed::Provider.new("http://www.yfrog.com/api/oembed", :json)
170
193
  Yfrog << "http://yfrog.com/*"
194
+ add_official_provider(Yfrog)
171
195
 
172
196
  # provider for mlg-tv
173
197
  # http://tv.majorleaguegaming.com/oembed
174
198
  MlgTv = OEmbed::Provider.new("http://tv.majorleaguegaming.com/oembed")
175
199
  MlgTv << "http://tv.majorleaguegaming.com/video/*"
176
200
  MlgTv << "http://mlg.tv/video/*"
201
+ add_official_provider(MlgTv)
177
202
 
178
203
  # pownce.com closed in 2008
179
204
  #Pownce = OEmbed::Provider.new("http://api.pownce.com/2.1/oembed.{format}")
180
205
  #Pownce << "http://*.pownce.com/*"
206
+ #add_official_provider(Pownce)
207
+
208
+ # Provider for polleverywhere.com
209
+ PollEverywhere = OEmbed::Provider.new("http://www.polleverywhere.com/services/oembed/")
210
+ PollEverywhere << "http://www.polleverywhere.com/polls/*"
211
+ PollEverywhere << "http://www.polleverywhere.com/multiple_choice_polls/*"
212
+ PollEverywhere << "http://www.polleverywhere.com/free_text_polls/*"
213
+ add_official_provider(PollEverywhere)
214
+
215
+ # Provider for my.opera.com
216
+ # http://my.opera.com/devblog/blog/2008/12/02/embedding-my-opera-content-oembed
217
+ MyOpera = OEmbed::Provider.new("http://my.opera.com/service/oembed", :json)
218
+ MyOpera << "http://my.opera.com/*"
219
+ add_official_provider(MyOpera)
220
+
221
+ # Provider for clearspring.com
222
+ ClearspringWidgets = OEmbed::Provider.new("http://widgets.clearspring.com/widget/v1/oembed/")
223
+ ClearspringWidgets << "http://www.clearspring.com/widgets/*"
224
+ add_official_provider(ClearspringWidgets)
225
+
226
+ # Provider for nfb.ca
227
+ NFBCanada = OEmbed::Provider.new("http://www.nfb.ca/remote/services/oembed/")
228
+ NFBCanada << "http://*.nfb.ca/film/*"
229
+ add_official_provider(NFBCanada)
230
+
231
+ # Provider for scribd.com
232
+ Scribd = OEmbed::Provider.new("http://www.scribd.com/services/oembed")
233
+ Scribd << "http://*.scribd.com/*"
234
+ add_official_provider(Scribd)
235
+
236
+ # Provider for movieclips.com
237
+ MovieClips = OEmbed::Provider.new("http://movieclips.com/services/oembed/")
238
+ MovieClips << "http://movieclips.com/watch/*/*/"
239
+ add_official_provider(MovieClips)
240
+
241
+ # Provider for 23hq.com
242
+ TwentyThree = OEmbed::Provider.new("http://www.23hq.com/23/oembed")
243
+ TwentyThree << "http://www.23hq.com/*"
244
+ add_official_provider(TwentyThree)
245
+
246
+ # Provider for soundcloud.com
247
+ # http://developers.soundcloud.com/docs/oembed
248
+ SoundCloud = OEmbed::Provider.new("http://soundcloud.com/oembed", :json)
249
+ SoundCloud << "http://*.soundcloud.com/*"
250
+ add_official_provider(SoundCloud)
251
+
252
+ ## Provider for clikthrough.com
253
+ # http://corporate.clikthrough.com/wp/?p=275
254
+ #Clickthrough = OEmbed::Provider.new("http://www.clikthrough.com/services/oembed/")
255
+ #Clickthrough << "http://*.clikthrough.com/theater/video/*"
256
+ #add_official_provider(Clickthrough)
257
+
258
+ ## Provider for kinomap.com
259
+ # http://www.kinomap.com/#!oEmbed
260
+ #Kinomap = OEmbed::Provider.new("http://www.kinomap.com/oembed")
261
+ #Kinomap << "http://www.kinomap.com/*"
262
+ #add_official_provider(Kinomap)
181
263
 
182
264
  # Provider for oohembed.com, which is a provider agregator. See
183
265
  # OEmbed::Providers::OohEmbed.urls for a full list of supported url schemas.
@@ -229,44 +311,6 @@ module OEmbed
229
311
  YAML.load_file(File.join(File.dirname(__FILE__), "/providers/embedly_urls.yml")).each do |url|
230
312
  Embedly << url
231
313
  end
232
-
233
- # Provider for polleverywhere.com
234
- PollEverywhere = OEmbed::Provider.new("http://www.polleverywhere.com/services/oembed/")
235
- PollEverywhere << "http://www.polleverywhere.com/polls/*"
236
- PollEverywhere << "http://www.polleverywhere.com/multiple_choice_polls/*"
237
- PollEverywhere << "http://www.polleverywhere.com/free_text_polls/*"
238
-
239
- # Provider for my.opera.com
240
- # http://my.opera.com/devblog/blog/2008/12/02/embedding-my-opera-content-oembed
241
- MyOpera = OEmbed::Provider.new("http://my.opera.com/service/oembed", :json)
242
- MyOpera << "http://my.opera.com/*"
243
-
244
- # Provider for clearspring.com
245
- ClearspringWidgets = OEmbed::Provider.new("http://widgets.clearspring.com/widget/v1/oembed/")
246
- ClearspringWidgets << "http://www.clearspring.com/widgets/*"
247
-
248
- # Provider for nfb.ca
249
- NFBCanada = OEmbed::Provider.new("http://www.nfb.ca/remote/services/oembed/")
250
- NFBCanada << "http://*.nfb.ca/film/*"
251
-
252
- # Provider for scribd.com
253
- Scribd = OEmbed::Provider.new("http://www.scribd.com/services/oembed")
254
- Scribd << "http://*.scribd.com/*"
255
-
256
- # Provider for movieclips.com
257
- MovieClips = OEmbed::Provider.new("http://movieclips.com/services/oembed/")
258
- MovieClips << "http://movieclips.com/watch/*/*/"
259
-
260
- # Provider for 23hq.com
261
- TwentyThree = OEmbed::Provider.new("http://www.23hq.com/23/oembed")
262
- TwentyThree << "http://www.23hq.com/*"
263
-
264
- # Provider for clikthrough.com
265
- #Clickthrough = OEmbed::Provider.new("http://www.clikthrough.com/services/oembed/")
266
- #Clickthrough << "http://*.clikthrough.com/theater/video/*"
267
- #
268
- ## Provider for kinomap.com
269
- #Kinomap = OEmbed::Provider.new("http://www.kinomap.com/oembed")
270
- #Kinomap << "http://www.kinomap.com/*"
314
+ add_official_provider(Embedly, :aggregators)
271
315
  end
272
316
  end
@@ -72,7 +72,6 @@
72
72
  - http://aniboom.com/animation-video/*
73
73
  - http://animal.discovery.com/videos/*
74
74
  - http://animoto.com/play/*
75
- - http://answers.polldaddy.com/poll/*
76
75
  - http://api.shopstyle.com/action/apiVisitRetailer*
77
76
  - http://app.wistia.com/embed/medias/*
78
77
  - http://asofterworld.com/*.jpg
@@ -215,10 +214,9 @@
215
214
  - http://pics.brizzly.com/*.jpg
216
215
  - http://pikchur.com/*
217
216
  - http://ping.fm/p/*
217
+ - http://pinterest.com/pin/*
218
218
  - http://pixorial.com/watch/*
219
219
  - http://planetgreen.discovery.com/videos/*
220
- - http://polldaddy.com/community/poll/*
221
- - http://polldaddy.com/poll/*
222
220
  - http://post.ly/*
223
221
  - http://prezi.com/*/*
224
222
  - http://qik.com/*
@@ -2,7 +2,7 @@ module OEmbed
2
2
  class Version
3
3
  MAJOR = 0
4
4
  MINOR = 8
5
- PATCH = 5
5
+ PATCH = 7
6
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
 
8
8
  class << self
@@ -1,4 +1,5 @@
1
1
  begin
2
+ require 'yaml'
2
3
  require 'json'
3
4
  require 'open-uri'
4
5
 
data/ruby-oembed.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "ruby-oembed"
8
- s.version = "0.8.5"
8
+ s.version = "0.8.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Magnus Holm", "Alex Kessinger", "Aris Bartee", "Marcos Wright Kuhns"]
12
- s.date = "2011-11-15"
12
+ s.date = "2012-03-12"
13
13
  s.description = "An oEmbed consumer library written in Ruby, letting you easily get embeddable HTML representations of supported web pages, based on their URLs. See http://oembed.com for more information about the protocol."
14
14
  s.email = "arisbartee@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -54,6 +54,7 @@ Gem::Specification.new do |s|
54
54
  "lib/tasks/oembed.rake",
55
55
  "lib/tasks/rspec.rake",
56
56
  "ruby-oembed.gemspec",
57
+ "spec/cassettes/OEmbed_Provider.yml",
57
58
  "spec/cassettes/OEmbed_ProviderDiscovery.yml",
58
59
  "spec/formatter/ducktype_backend_spec.rb",
59
60
  "spec/formatter/json/.DS_Store",
@@ -67,11 +68,12 @@ Gem::Specification.new do |s|
67
68
  "spec/provider_spec.rb",
68
69
  "spec/providers_spec.rb",
69
70
  "spec/response_spec.rb",
70
- "spec/spec_helper.rb"
71
+ "spec/spec_helper.rb",
72
+ "spec/spec_helper_examples.yml"
71
73
  ]
72
74
  s.homepage = "http://github.com/judofyr/ruby-oembed"
73
75
  s.licenses = ["MIT"]
74
- s.rdoc_options = ["--main", "README.rdoc", "--title", "ruby-oembed-0.8.5", "--inline-source", "--exclude", "tasks", "CHANGELOG.rdoc"]
76
+ s.rdoc_options = ["--main", "README.rdoc", "--title", "ruby-oembed-0.8.7", "--inline-source", "--exclude", "tasks", "CHANGELOG.rdoc"]
75
77
  s.require_paths = ["lib"]
76
78
  s.rubygems_version = "1.8.10"
77
79
  s.summary = "oEmbed for Ruby"
@@ -0,0 +1,224 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :get
5
+ uri: http://www.flickr.com:80/services/oembed/?format=json&url=http://flickr.com/photos/bees/2362225867/
6
+ body: !!null
7
+ headers: !!null
8
+ response: !ruby/struct:VCR::Response
9
+ status: !ruby/struct:VCR::ResponseStatus
10
+ code: 200
11
+ message: OK
12
+ headers:
13
+ date:
14
+ - Sat, 26 Nov 2011 01:53:45 GMT
15
+ p3p:
16
+ - policyref="http://p3p.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV
17
+ TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY
18
+ ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV"
19
+ set-cookie:
20
+ - localization=en-us%3Bus%3Bus; expires=Sat, 23-Nov-2013 01:53:45 GMT; path=/;
21
+ domain=.flickr.com
22
+ cache-control:
23
+ - private
24
+ x-served-by:
25
+ - www129.flickr.mud.yahoo.com
26
+ vary:
27
+ - Accept-Encoding
28
+ content-type:
29
+ - application/json
30
+ age:
31
+ - '0'
32
+ via:
33
+ - HTTP/1.1 r08.ycpi.ne1.yahoo.net (YahooTrafficServer/1.20.9 [cMsSf ]), HTTP/1.1
34
+ r22.ycpi.sp2.yahoo.net (YahooTrafficServer/1.20.9 [cMsSf ])
35
+ server:
36
+ - YTS/1.20.9
37
+ body: ! '{"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
38
+ Lollys","author_name":"\u202e\u202d\u202cbees\u202c","width":"500","height":"375","url":"http:\/\/farm4.staticflickr.com\/3040\/2362225867_4a87ab8baf.jpg"}
39
+
40
+ '
41
+ http_version: '1.1'
42
+ - !ruby/struct:VCR::HTTPInteraction
43
+ request: !ruby/struct:VCR::Request
44
+ method: :get
45
+ uri: http://www.flickr.com:80/services/oembed/?format=json&url=http://flickr.com/photos/bees/2362225867/404
46
+ body: !!null
47
+ headers: !!null
48
+ response: !ruby/struct:VCR::Response
49
+ status: !ruby/struct:VCR::ResponseStatus
50
+ code: 404
51
+ message: Not Found
52
+ headers:
53
+ date:
54
+ - Sat, 26 Nov 2011 01:53:45 GMT
55
+ p3p:
56
+ - policyref="http://p3p.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV
57
+ TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY
58
+ ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV"
59
+ set-cookie:
60
+ - localization=en-us%3Bus%3Bus; expires=Sat, 23-Nov-2013 01:53:45 GMT; path=/;
61
+ domain=.flickr.com
62
+ cache-control:
63
+ - private
64
+ x-served-by:
65
+ - www129.flickr.mud.yahoo.com
66
+ vary:
67
+ - Accept-Encoding
68
+ content-type:
69
+ - application/json
70
+ age:
71
+ - '0'
72
+ via:
73
+ - HTTP/1.1 r08.ycpi.ne1.yahoo.net (YahooTrafficServer/1.20.9 [cMsSf ]), HTTP/1.1
74
+ r22.ycpi.sp2.yahoo.net (YahooTrafficServer/1.20.9 [cMsSf ])
75
+ server:
76
+ - YTS/1.20.9
77
+ body: ! ' '
78
+ http_version: '1.1'
79
+ - !ruby/struct:VCR::HTTPInteraction
80
+ request: !ruby/struct:VCR::Request
81
+ method: :get
82
+ uri: http://www.flickr.com:80/services/oembed/?format=json&url=http://flickr.com/photos/bees/2362225867/405
83
+ body: !!null
84
+ headers: !!null
85
+ response: !ruby/struct:VCR::Response
86
+ status: !ruby/struct:VCR::ResponseStatus
87
+ code: 405
88
+ message: Method Not Allowed
89
+ headers:
90
+ date:
91
+ - Sat, 26 Nov 2011 01:53:45 GMT
92
+ p3p:
93
+ - policyref="http://p3p.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV
94
+ TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY
95
+ ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV"
96
+ set-cookie:
97
+ - localization=en-us%3Bus%3Bus; expires=Sat, 23-Nov-2013 01:53:45 GMT; path=/;
98
+ domain=.flickr.com
99
+ cache-control:
100
+ - private
101
+ x-served-by:
102
+ - www129.flickr.mud.yahoo.com
103
+ vary:
104
+ - Accept-Encoding
105
+ content-type:
106
+ - application/json
107
+ age:
108
+ - '0'
109
+ via:
110
+ - HTTP/1.1 r08.ycpi.ne1.yahoo.net (YahooTrafficServer/1.20.9 [cMsSf ]), HTTP/1.1
111
+ r22.ycpi.sp2.yahoo.net (YahooTrafficServer/1.20.9 [cMsSf ])
112
+ server:
113
+ - YTS/1.20.9
114
+ body: ! ' '
115
+ http_version: '1.1'
116
+ - !ruby/struct:VCR::HTTPInteraction
117
+ request: !ruby/struct:VCR::Request
118
+ method: :get
119
+ uri: http://www.flickr.com:80/services/oembed/?format=json&url=http://flickr.com/photos/bees/2362225867/500
120
+ body: !!null
121
+ headers: !!null
122
+ response: !ruby/struct:VCR::Response
123
+ status: !ruby/struct:VCR::ResponseStatus
124
+ code: 500
125
+ message: Internal Server Error
126
+ headers:
127
+ date:
128
+ - Sat, 26 Nov 2011 01:53:45 GMT
129
+ p3p:
130
+ - policyref="http://p3p.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV
131
+ TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY
132
+ ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV"
133
+ set-cookie:
134
+ - localization=en-us%3Bus%3Bus; expires=Sat, 23-Nov-2013 01:53:45 GMT; path=/;
135
+ domain=.flickr.com
136
+ cache-control:
137
+ - private
138
+ x-served-by:
139
+ - www129.flickr.mud.yahoo.com
140
+ vary:
141
+ - Accept-Encoding
142
+ content-type:
143
+ - application/json
144
+ age:
145
+ - '0'
146
+ via:
147
+ - HTTP/1.1 r08.ycpi.ne1.yahoo.net (YahooTrafficServer/1.20.9 [cMsSf ]), HTTP/1.1
148
+ r22.ycpi.sp2.yahoo.net (YahooTrafficServer/1.20.9 [cMsSf ])
149
+ server:
150
+ - YTS/1.20.9
151
+ body: ! ' '
152
+ http_version: '1.1'
153
+ - !ruby/struct:VCR::HTTPInteraction
154
+ request: !ruby/struct:VCR::Request
155
+ method: :get
156
+ uri: http://www.flickr.com:80/services/oembed/?format=json&url=http://flickr.com/photos/bees/2362225867/501
157
+ body: !!null
158
+ headers: !!null
159
+ response: !ruby/struct:VCR::Response
160
+ status: !ruby/struct:VCR::ResponseStatus
161
+ code: 501
162
+ message: Not Implemented
163
+ headers:
164
+ date:
165
+ - Sat, 26 Nov 2011 01:53:45 GMT
166
+ p3p:
167
+ - policyref="http://p3p.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV
168
+ TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY
169
+ ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV"
170
+ set-cookie:
171
+ - localization=en-us%3Bus%3Bus; expires=Sat, 23-Nov-2013 01:53:45 GMT; path=/;
172
+ domain=.flickr.com
173
+ cache-control:
174
+ - private
175
+ x-served-by:
176
+ - www129.flickr.mud.yahoo.com
177
+ vary:
178
+ - Accept-Encoding
179
+ content-type:
180
+ - application/json
181
+ age:
182
+ - '0'
183
+ via:
184
+ - HTTP/1.1 r08.ycpi.ne1.yahoo.net (YahooTrafficServer/1.20.9 [cMsSf ]), HTTP/1.1
185
+ r22.ycpi.sp2.yahoo.net (YahooTrafficServer/1.20.9 [cMsSf ])
186
+ server:
187
+ - YTS/1.20.9
188
+ body: ! ' '
189
+ http_version: '1.1'
190
+ - !ruby/struct:VCR::HTTPInteraction
191
+ request: !ruby/struct:VCR::Request
192
+ method: :get
193
+ uri: https://vimeo.com:443/api/oembed.json?url=https://vimeo.com/31158841
194
+ body: !!null
195
+ headers: !!null
196
+ response: !ruby/struct:VCR::Response
197
+ status: !ruby/struct:VCR::ResponseStatus
198
+ code: 200
199
+ message: OK
200
+ headers:
201
+ date:
202
+ - Sat, 26 Nov 2011 02:02:58 GMT
203
+ server:
204
+ - Apache
205
+ x-powered-by:
206
+ - PHP/5.3.5-0.dotdeb.0
207
+ expires:
208
+ - Fri, 25 Nov 2011 14:02:58 GMT
209
+ cache-control:
210
+ - no-store, no-cache, must-revalidate
211
+ - post-check=0, pre-check=0
212
+ vary:
213
+ - Accept-Encoding
214
+ content-length:
215
+ - '697'
216
+ content-type:
217
+ - application/json
218
+ body: ! '{"type":"video","version":"1.0","provider_name":"Vimeo","provider_url":"http:\/\/vimeo.com\/","title":"Murmuration","author_name":"Sophie
219
+ Windsor Clive","author_url":"http:\/\/vimeo.com\/user3069761","is_plus":"0","html":"<iframe
220
+ src=\"https:\/\/player.vimeo.com\/video\/31158841\" width=\"640\" height=\"512\"
221
+ frameborder=\"0\" webkitAllowFullScreen mozallowfullscreen allowFullScreen><\/iframe>","width":640,"height":512,"duration":120,"description":"A
222
+ chance encounter and shared moment with one of natures greatest and most fleeting
223
+ phenomena.","thumbnail_url":"https:\/\/secure-b.vimeocdn.com\/ts\/209\/801\/209801744_640.jpg","thumbnail_width":640,"thumbnail_height":512,"video_id":31158841}'
224
+ http_version: '1.1'
@@ -1,6 +1,20 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
+ require 'vcr'
3
+
4
+ VCR.config do |c|
5
+ c.default_cassette_options = { :record => :new_episodes }
6
+ c.cassette_library_dir = 'spec/cassettes'
7
+ c.stub_with :fakeweb
8
+ end
2
9
 
3
10
  describe OEmbed::Provider do
11
+ before(:all) do
12
+ VCR.insert_cassette('OEmbed_Provider')
13
+ end
14
+ after(:all) do
15
+ VCR.eject_cassette
16
+ end
17
+
4
18
  include OEmbedSpecHelper
5
19
 
6
20
  before(:all) do
@@ -36,7 +50,6 @@ describe OEmbed::Provider do
36
50
  "http://not a uri",
37
51
  nil, 1,
38
52
  ].each do |endpoint|
39
- #puts "given a endpoint of #{endpoint.inspect}"
40
53
  proc { OEmbed::Provider.new(endpoint) }.
41
54
  should raise_error(ArgumentError)
42
55
  end
@@ -236,44 +249,55 @@ describe OEmbed::Provider do
236
249
 
237
250
  describe "#raw" do
238
251
  it "should return the body on 200" do
239
- res = Net::HTTPOK.new("1.1", 200, "OK").instance_eval do
240
- @body = "raw content"
241
- @read = true
242
- self
243
- end
244
- Net::HTTP.stub!(:start).and_return(res)
245
-
246
- @flickr.send(:raw, example_url(:flickr)).should == "raw content"
252
+ res = @flickr.send(:raw, example_url(:flickr))
253
+ res.should == example_body(:flickr)
247
254
  end
255
+
256
+ it "should return the body on 200 even over https" do
257
+ @vimeo_ssl = OEmbed::Provider.new("https://vimeo.com/api/oembed.{format}")
258
+ @vimeo_ssl << "http://*.vimeo.com/*"
259
+ @vimeo_ssl << "https://*.vimeo.com/*"
248
260
 
249
- it "should raise error on 501" do
250
- res = Net::HTTPNotImplemented.new("1.1", 501, "Not Implemented")
251
- Net::HTTP.stub!(:start).and_return(res)
261
+ proc do
262
+ @vimeo_ssl.send(:raw, example_url(:vimeo_ssl)).should == example_body(:vimeo_ssl)
263
+ end.should_not raise_error
264
+ end
252
265
 
266
+ it "should raise an UnknownFormat error on 501" do
267
+ # Note: This test relies on a custom-written VCR response in the
268
+ # cassettes/OEmbed_Provider.yml file.
269
+
253
270
  proc do
254
- @flickr.send(:raw, example_url(:flickr))
271
+ @flickr.send(:raw, File.join(example_url(:flickr), '501'))
255
272
  end.should raise_error(OEmbed::UnknownFormat)
256
273
  end
257
274
 
258
- it "should raise error on 404" do
259
- res = Net::HTTPNotFound.new("1.1", 404, "Not Found")
260
- Net::HTTP.stub!(:start).and_return(res)
261
-
275
+ it "should raise a NotFound error on 404" do
276
+ # Note: This test relies on a custom-written VCR response in the
277
+ # cassettes/OEmbed_Provider.yml file.
278
+
262
279
  proc do
263
- @flickr.send(:raw, example_url(:flickr))
280
+ @flickr.send(:raw, File.join(example_url(:flickr), '404'))
264
281
  end.should raise_error(OEmbed::NotFound)
265
282
  end
266
283
 
267
- it "should raise error on all other responses" do
268
- Net::HTTPResponse::CODE_TO_OBJ.delete_if do |code, res|
269
- ("200".."299").include?(code) ||
270
- ["404", "501"].include?(code)
271
- end.each do |code, res|
272
- r = res.new("1.1", code, "Message")
273
- Net::HTTP.stub!(:start).and_return(r)
274
-
284
+ it "should raise an UnknownResponse error on other responses" do
285
+ # Note: This test relies on a custom-written VCR response in the
286
+ # cassettes/OEmbed_Provider.yml file.
287
+
288
+ statuses_to_check = ['405', '500']
289
+
290
+ statuses_to_check.each do |status|
291
+ proc do
292
+ proc do
293
+ @flickr.send(:raw, File.join(example_url(:flickr), status))
294
+ end.should_not raise_error(OEmbed::NotFound)
295
+ end.should_not raise_error(OEmbed::UnknownResponse)
296
+ end
297
+
298
+ statuses_to_check.each do |status|
275
299
  proc do
276
- @flickr.send(:raw, example_url(:flickr))
300
+ @flickr.send(:raw, File.join(example_url(:flickr), status))
277
301
  end.should raise_error(OEmbed::UnknownResponse)
278
302
  end
279
303
  end
@@ -16,81 +16,85 @@ describe OEmbed::Providers do
16
16
  OEmbed::Providers.unregister_all
17
17
  end
18
18
 
19
- it "should register providers" do
20
- OEmbed::Providers.urls.should be_empty
19
+ describe ".register" do
20
+ it "should register providers" do
21
+ OEmbed::Providers.urls.should be_empty
21
22
 
22
- OEmbed::Providers.register(@flickr, @qik)
23
+ OEmbed::Providers.register(@flickr, @qik)
23
24
 
24
- OEmbed::Providers.urls.keys.should == @flickr.urls + @qik.urls
25
+ OEmbed::Providers.urls.keys.should == @flickr.urls + @qik.urls
25
26
 
26
- @flickr.urls.each do |regexp|
27
- OEmbed::Providers.urls.should have_key(regexp)
28
- OEmbed::Providers.urls[regexp].should include(@flickr)
29
- end
27
+ @flickr.urls.each do |regexp|
28
+ OEmbed::Providers.urls.should have_key(regexp)
29
+ OEmbed::Providers.urls[regexp].should include(@flickr)
30
+ end
30
31
 
31
- @qik.urls.each do |regexp|
32
- OEmbed::Providers.urls.should have_key(regexp)
33
- OEmbed::Providers.urls[regexp].should include(@qik)
32
+ @qik.urls.each do |regexp|
33
+ OEmbed::Providers.urls.should have_key(regexp)
34
+ OEmbed::Providers.urls[regexp].should include(@qik)
35
+ end
34
36
  end
35
- end
36
37
 
37
- it "should find by URLs" do
38
- OEmbed::Providers.register(@flickr, @qik) # tested in "should register providers"
38
+ it "should find by URLs" do
39
+ OEmbed::Providers.register(@flickr, @qik) # tested in "should register providers"
39
40
 
40
- OEmbed::Providers.find(example_url(:flickr)).should == @flickr
41
- OEmbed::Providers.find(example_url(:qik)).should == @qik
41
+ OEmbed::Providers.find(example_url(:flickr)).should == @flickr
42
+ OEmbed::Providers.find(example_url(:qik)).should == @qik
43
+ end
42
44
  end
43
45
 
44
- it "should unregister providers" do
45
- OEmbed::Providers.register(@flickr, @qik) # tested in "should register providers"
46
+ describe ".unregister" do
47
+ it "should unregister providers" do
48
+ OEmbed::Providers.register(@flickr, @qik) # tested in "should register providers"
46
49
 
47
- OEmbed::Providers.unregister(@flickr)
50
+ OEmbed::Providers.unregister(@flickr)
48
51
 
49
- @flickr.urls.each do |regexp|
50
- OEmbed::Providers.urls.should_not have_key(regexp)
51
- end
52
+ @flickr.urls.each do |regexp|
53
+ OEmbed::Providers.urls.should_not have_key(regexp)
54
+ end
52
55
 
53
- OEmbed::Providers.urls.keys.should == @qik.urls
56
+ OEmbed::Providers.urls.keys.should == @qik.urls
54
57
 
55
- @qik.urls.each do |regexp|
56
- OEmbed::Providers.urls.should have_key(regexp)
57
- OEmbed::Providers.urls[regexp].should include(@qik)
58
+ @qik.urls.each do |regexp|
59
+ OEmbed::Providers.urls.should have_key(regexp)
60
+ OEmbed::Providers.urls[regexp].should include(@qik)
61
+ end
58
62
  end
59
- end
60
63
 
61
- it "should not unregister duplicate provider urls at first" do
62
- @qik_mirror = OEmbed::Provider.new("http://mirror.qik.com/api/oembed.{format}")
63
- @qik_mirror << "http://qik.com/*"
64
+ it "should not unregister duplicate provider urls at first" do
65
+ @qik_mirror = OEmbed::Provider.new("http://mirror.qik.com/api/oembed.{format}")
66
+ @qik_mirror << "http://qik.com/*"
64
67
 
65
- @qik_mirror.urls.each do |regexp|
66
- @qik.urls.should include(regexp)
67
- end
68
+ @qik_mirror.urls.each do |regexp|
69
+ @qik.urls.should include(regexp)
70
+ end
68
71
 
69
- OEmbed::Providers.register(@qik, @qik_mirror)
72
+ OEmbed::Providers.register(@qik, @qik_mirror)
70
73
 
71
- OEmbed::Providers.urls.keys.should == @qik.urls
74
+ OEmbed::Providers.urls.keys.should == @qik.urls
72
75
 
73
- @qik_mirror.urls.each do |regexp|
74
- OEmbed::Providers.urls[regexp].should include(@qik_mirror)
75
- OEmbed::Providers.urls[regexp].should include(@qik)
76
- end
76
+ @qik_mirror.urls.each do |regexp|
77
+ OEmbed::Providers.urls[regexp].should include(@qik_mirror)
78
+ OEmbed::Providers.urls[regexp].should include(@qik)
79
+ end
77
80
 
78
- OEmbed::Providers.find(example_url(:qik)).should == @qik
81
+ OEmbed::Providers.find(example_url(:qik)).should == @qik
79
82
 
80
- OEmbed::Providers.unregister(@qik)
83
+ OEmbed::Providers.unregister(@qik)
81
84
 
82
- urls = OEmbed::Providers.urls.dup
85
+ urls = OEmbed::Providers.urls.dup
83
86
 
84
- @qik_mirror.urls.each do |regexp|
85
- OEmbed::Providers.urls[regexp].should include(@qik_mirror)
86
- end
87
+ @qik_mirror.urls.each do |regexp|
88
+ OEmbed::Providers.urls[regexp].should include(@qik_mirror)
89
+ end
87
90
 
88
- OEmbed::Providers.find(example_url(:qik)).should == @qik_mirror
91
+ OEmbed::Providers.find(example_url(:qik)).should == @qik_mirror
89
92
 
90
- OEmbed::Providers.unregister(@qik_mirror)
93
+ OEmbed::Providers.unregister(@qik_mirror)
91
94
 
92
- @qik_mirror.urls.each do |regexp|
93
- OEmbed::Providers.urls.should_not have_key(regexp)
95
+ @qik_mirror.urls.each do |regexp|
96
+ OEmbed::Providers.urls.should_not have_key(regexp)
97
+ end
94
98
  end
95
99
  end
96
100
 
@@ -118,67 +122,137 @@ describe OEmbed::Providers do
118
122
  # and_return(valid_response(:object))
119
123
  #end
120
124
 
121
- it "should bridge #get and #raw to the right provider" do
122
- OEmbed::Providers.register_all
123
- all_example_urls.each do |url|
124
- provider = OEmbed::Providers.find(url)
125
- provider.should_receive(:raw).
126
- with(url, {})
127
- provider.should_receive(:get).
128
- with(url, {})
129
- OEmbed::Providers.raw(url)
130
- OEmbed::Providers.get(url)
125
+ describe "#raw and #get" do
126
+ it "should bridge #get and #raw to the right provider" do
127
+ OEmbed::Providers.register_all
128
+ all_example_urls.each do |url|
129
+ provider = OEmbed::Providers.find(url)
130
+ provider.should_receive(:raw).
131
+ with(url, {})
132
+ provider.should_receive(:get).
133
+ with(url, {})
134
+ OEmbed::Providers.raw(url)
135
+ OEmbed::Providers.get(url)
136
+ end
131
137
  end
132
- end
133
138
 
134
- it "should raise an error if no embeddable content is found" do
135
- OEmbed::Providers.register_all
136
- ["http://fake.com/", example_url(:google_video)].each do |url|
137
- proc { OEmbed::Providers.get(url) }.should raise_error(OEmbed::NotFound)
138
- proc { OEmbed::Providers.raw(url) }.should raise_error(OEmbed::NotFound)
139
+ it "should raise an error if no embeddable content is found" do
140
+ OEmbed::Providers.register_all
141
+ ["http://fake.com/", example_url(:google_video)].each do |url|
142
+ proc { OEmbed::Providers.get(url) }.should raise_error(OEmbed::NotFound)
143
+ proc { OEmbed::Providers.raw(url) }.should raise_error(OEmbed::NotFound)
144
+ end
139
145
  end
140
146
  end
141
147
 
142
- it "should register fallback providers" do
143
- OEmbed::Providers.register_fallback(OEmbed::Providers::Hulu)
144
- OEmbed::Providers.register_fallback(OEmbed::Providers::OohEmbed)
148
+ describe ".register_fallback" do
149
+ it "should register fallback providers" do
150
+ OEmbed::Providers.register_fallback(OEmbed::Providers::Hulu)
151
+ OEmbed::Providers.register_fallback(OEmbed::Providers::OohEmbed)
145
152
 
146
- OEmbed::Providers.fallback.should == [ OEmbed::Providers::Hulu, OEmbed::Providers::OohEmbed]
147
- end
153
+ OEmbed::Providers.fallback.should == [ OEmbed::Providers::Hulu, OEmbed::Providers::OohEmbed]
154
+ end
148
155
 
149
- it "should fallback to the appropriate provider when URL isn't found" do
150
- OEmbed::Providers.register_all
151
- OEmbed::Providers.register_fallback(OEmbed::Providers::Hulu)
152
- OEmbed::Providers.register_fallback(OEmbed::Providers::OohEmbed)
153
-
154
- url = example_url(:google_video)
155
-
156
- provider = OEmbed::Providers.fallback.last
157
- provider.should_receive(:raw).
158
- with(url, {}).
159
- and_return(valid_response(:raw))
160
- provider.should_receive(:get).
161
- with(url, {}).
162
- and_return(valid_response(:object))
163
-
164
- OEmbed::Providers.fallback.each do |p|
165
- next if p == provider
166
- p.should_receive(:raw).and_raise(OEmbed::NotFound)
167
- p.should_receive(:get).and_raise(OEmbed::NotFound)
156
+ it "should fallback to the appropriate provider when URL isn't found" do
157
+ OEmbed::Providers.register_all
158
+ OEmbed::Providers.register_fallback(OEmbed::Providers::Hulu)
159
+ OEmbed::Providers.register_fallback(OEmbed::Providers::OohEmbed)
160
+
161
+ url = example_url(:google_video)
162
+
163
+ provider = OEmbed::Providers.fallback.last
164
+ provider.should_receive(:raw).
165
+ with(url, {}).
166
+ and_return(valid_response(:raw))
167
+ provider.should_receive(:get).
168
+ with(url, {}).
169
+ and_return(valid_response(:object))
170
+
171
+ OEmbed::Providers.fallback.each do |p|
172
+ next if p == provider
173
+ p.should_receive(:raw).and_raise(OEmbed::NotFound)
174
+ p.should_receive(:get).and_raise(OEmbed::NotFound)
175
+ end
176
+
177
+ OEmbed::Providers.raw(url)
178
+ OEmbed::Providers.get(url)
168
179
  end
169
180
 
170
- OEmbed::Providers.raw(url)
171
- OEmbed::Providers.get(url)
181
+ it "should still raise an error if no embeddable content is found" do
182
+ OEmbed::Providers.register_all
183
+ OEmbed::Providers.register_fallback(OEmbed::Providers::Hulu)
184
+ OEmbed::Providers.register_fallback(OEmbed::Providers::OohEmbed)
185
+
186
+ ["http://fa.ke/"].each do |url|
187
+ proc { OEmbed::Providers.get(url) }.should raise_error(OEmbed::NotFound)
188
+ proc { OEmbed::Providers.raw(url) }.should raise_error(OEmbed::NotFound)
189
+ end
190
+ end
172
191
  end
173
192
 
174
- it "should still raise an error if no embeddable content is found" do
175
- OEmbed::Providers.register_all
176
- OEmbed::Providers.register_fallback(OEmbed::Providers::Hulu)
177
- OEmbed::Providers.register_fallback(OEmbed::Providers::OohEmbed)
193
+ describe ".register_all" do
194
+ after(:each) do
195
+ OEmbed::Providers.send(:remove_const, :Fake) if defined?(OEmbed::Providers::Fake)
196
+ end
197
+
198
+ it "should not register a provider that is not marked as official" do
199
+ defined?(OEmbed::Providers::Fake).should_not be
200
+
201
+ class OEmbed::Providers
202
+ Fake = OEmbed::Provider.new("http://new.fa.ke/oembed/")
203
+ Fake << "http://new.fa.ke/*"
204
+ end
205
+
206
+ OEmbed::Providers.register_all
207
+ ["http://new.fa.ke/20C285E0"].each do |url|
208
+ provider = OEmbed::Providers.find(url)
209
+ provider.should be_nil
210
+ end
211
+ end
178
212
 
179
- ["http://fake.com/"].each do |url|
180
- proc { OEmbed::Providers.get(url) }.should raise_error(OEmbed::NotFound)
181
- proc { OEmbed::Providers.raw(url) }.should raise_error(OEmbed::NotFound)
213
+ describe 'add_official_provider' do
214
+ it "should register a new official provider" do
215
+ defined?(OEmbed::Providers::Fake).should_not be
216
+
217
+ class OEmbed::Providers
218
+ Fake = OEmbed::Provider.new("http://official.fa.ke/oembed/")
219
+ Fake << "http://official.fa.ke/*"
220
+ add_official_provider(Fake)
221
+ end
222
+
223
+ ["http://official.fa.ke/20C285E0"].each do |url|
224
+ provider = OEmbed::Providers.find(url)
225
+ provider.should_not be_a(OEmbed::Provider)
226
+ end
227
+
228
+ OEmbed::Providers.register_all
229
+ ["http://official.fa.ke/20C285E0"].each do |url|
230
+ provider = OEmbed::Providers.find(url)
231
+ provider.should be_a(OEmbed::Provider)
232
+ end
233
+ end
234
+
235
+ it "should register an official sub_type provider separately" do
236
+ defined?(OEmbed::Providers::Fake).should_not be
237
+
238
+ class OEmbed::Providers
239
+ Fake = OEmbed::Provider.new("http://sub.fa.ke/oembed/")
240
+ Fake << "http://sub.fa.ke/*"
241
+ add_official_provider(Fake, :fakes)
242
+ end
243
+
244
+ OEmbed::Providers.register_all
245
+ ["http://sub.fa.ke/20C285E0"].each do |url|
246
+ provider = OEmbed::Providers.find(url)
247
+ provider.should_not be_a(OEmbed::Provider)
248
+ end
249
+
250
+ OEmbed::Providers.register_all(:fakes)
251
+ ["http://sub.fa.ke/20C285E0"].each do |url|
252
+ provider = OEmbed::Providers.find(url)
253
+ provider.should be_a(OEmbed::Provider)
254
+ end
255
+ end
182
256
  end
183
257
  end
184
258
  end
data/spec/spec_helper.rb CHANGED
@@ -3,23 +3,15 @@ require 'vcr'
3
3
  require File.dirname(__FILE__) + '/../lib/oembed'
4
4
 
5
5
  module OEmbedSpecHelper
6
- EXAMPLE = {
7
- :flickr => "http://flickr.com/photos/bees/2362225867/",
8
- :viddler => "http://www.viddler.com/explore/cdevroe/videos/424/",
9
- :qik => "http://qik.com/video/49565",
10
- :vimeo => "http://vimeo.com/3100878",
11
- :rev3 => "http://revision3.com/diggnation/2008-04-17xsanned/",
12
- :hulu => "http://www.hulu.com/watch/4569/firefly-serenity#x-0,vepisode,1",
13
- :google_video => "http://video.google.com/videoplay?docid=8372603330420559198",
14
- } unless defined?(EXAMPLE)
6
+ EXAMPLE = YAML.load_file(File.expand_path(File.join(__FILE__, '../spec_helper_examples.yml'))) unless defined?(EXAMPLE)
15
7
 
16
8
  def example_url(site)
17
9
  return "http://fake.com/" if site == :fake
18
- EXAMPLE[site]
10
+ EXAMPLE[site][:url]
19
11
  end
20
12
 
21
13
  def all_example_urls(*fallback)
22
- results = EXAMPLE.values
14
+ results = EXAMPLE.values.map{ |v| v[:url] }
23
15
 
24
16
  # By default don't return example_urls that won't be recognized by
25
17
  # the included default providers
@@ -35,6 +27,10 @@ module OEmbedSpecHelper
35
27
 
36
28
  results
37
29
  end
30
+
31
+ def example_body(site)
32
+ EXAMPLE[site][:body]
33
+ end
38
34
 
39
35
  def valid_response(format)
40
36
  case format.to_s
@@ -0,0 +1,34 @@
1
+ ---
2
+ :flickr:
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"}
7
+
8
+ '
9
+ :viddler:
10
+ :url: "http://www.viddler.com/explore/cdevroe/videos/424/"
11
+ :qik:
12
+ :url: "http://qik.com/video/49565"
13
+ :vimeo:
14
+ :url: "http://vimeo.com/3100878"
15
+ :body: ! '{"type":"video","version":"1.0","provider_name":"Vimeo","provider_url":"http:\/\/vimeo.com\/","title":"Murmuration","author_name":"Sophie
16
+ Windsor Clive","author_url":"http:\/\/vimeo.com\/user3069761","is_plus":"0","html":"<iframe
17
+ src=\"https:\/\/player.vimeo.com\/video\/31158841\" width=\"640\" height=\"512\"
18
+ frameborder=\"0\" webkitAllowFullScreen mozallowfullscreen allowFullScreen><\/iframe>","width":640,"height":512,"duration":120,"description":"A
19
+ chance encounter and shared moment with one of natures greatest and most fleeting
20
+ phenomena.","thumbnail_url":"https:\/\/secure-b.vimeocdn.com\/ts\/209\/801\/209801744_640.jpg","thumbnail_width":640,"thumbnail_height":512,"video_id":31158841}'
21
+ :vimeo_ssl:
22
+ :url: "https://vimeo.com/31158841"
23
+ :body: ! '{"type":"video","version":"1.0","provider_name":"Vimeo","provider_url":"http:\/\/vimeo.com\/","title":"Murmuration","author_name":"Sophie
24
+ Windsor Clive","author_url":"http:\/\/vimeo.com\/user3069761","is_plus":"0","html":"<iframe
25
+ src=\"https:\/\/player.vimeo.com\/video\/31158841\" width=\"640\" height=\"512\"
26
+ frameborder=\"0\" webkitAllowFullScreen mozallowfullscreen allowFullScreen><\/iframe>","width":640,"height":512,"duration":120,"description":"A
27
+ chance encounter and shared moment with one of natures greatest and most fleeting
28
+ phenomena.","thumbnail_url":"https:\/\/secure-b.vimeocdn.com\/ts\/209\/801\/209801744_640.jpg","thumbnail_width":640,"thumbnail_height":512,"video_id":31158841}'
29
+ :rev3:
30
+ :url: "http://revision3.com/diggnation/2008-04-17xsanned/"
31
+ :hulu:
32
+ :url: "http://www.hulu.com/watch/4569/firefly-serenity#x-0,vepisode,1"
33
+ :google_video:
34
+ :url: "http://video.google.com/videoplay?docid=8372603330420559198"
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.8.5
4
+ version: 0.8.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,11 +12,11 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2011-11-15 00:00:00.000000000Z
15
+ date: 2012-03-12 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: jeweler
19
- requirement: &2170353860 !ruby/object:Gem::Requirement
19
+ requirement: &70130727181160 !ruby/object:Gem::Requirement
20
20
  none: false
21
21
  requirements:
22
22
  - - ! '>='
@@ -24,10 +24,10 @@ dependencies:
24
24
  version: '0'
25
25
  type: :development
26
26
  prerelease: false
27
- version_requirements: *2170353860
27
+ version_requirements: *70130727181160
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
- requirement: &2170353280 !ruby/object:Gem::Requirement
30
+ requirement: &70130727180620 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
33
  - - ! '>='
@@ -35,10 +35,10 @@ dependencies:
35
35
  version: '0'
36
36
  type: :development
37
37
  prerelease: false
38
- version_requirements: *2170353280
38
+ version_requirements: *70130727180620
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: json
41
- requirement: &2170352700 !ruby/object:Gem::Requirement
41
+ requirement: &70130727179960 !ruby/object:Gem::Requirement
42
42
  none: false
43
43
  requirements:
44
44
  - - ! '>='
@@ -46,10 +46,10 @@ dependencies:
46
46
  version: '0'
47
47
  type: :development
48
48
  prerelease: false
49
- version_requirements: *2170352700
49
+ version_requirements: *70130727179960
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: xml-simple
52
- requirement: &2170352120 !ruby/object:Gem::Requirement
52
+ requirement: &70130727179260 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
55
55
  - - ! '>='
@@ -57,10 +57,10 @@ dependencies:
57
57
  version: '0'
58
58
  type: :development
59
59
  prerelease: false
60
- version_requirements: *2170352120
60
+ version_requirements: *70130727179260
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: nokogiri
63
- requirement: &2170351480 !ruby/object:Gem::Requirement
63
+ requirement: &70130727178760 !ruby/object:Gem::Requirement
64
64
  none: false
65
65
  requirements:
66
66
  - - ! '>='
@@ -68,10 +68,10 @@ dependencies:
68
68
  version: '0'
69
69
  type: :development
70
70
  prerelease: false
71
- version_requirements: *2170351480
71
+ version_requirements: *70130727178760
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: rspec
74
- requirement: &2170350980 !ruby/object:Gem::Requirement
74
+ requirement: &70130727178240 !ruby/object:Gem::Requirement
75
75
  none: false
76
76
  requirements:
77
77
  - - ! '>='
@@ -79,10 +79,10 @@ dependencies:
79
79
  version: '2.0'
80
80
  type: :development
81
81
  prerelease: false
82
- version_requirements: *2170350980
82
+ version_requirements: *70130727178240
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: vcr
85
- requirement: &2170350500 !ruby/object:Gem::Requirement
85
+ requirement: &70130727177700 !ruby/object:Gem::Requirement
86
86
  none: false
87
87
  requirements:
88
88
  - - ~>
@@ -90,10 +90,10 @@ dependencies:
90
90
  version: '1.0'
91
91
  type: :development
92
92
  prerelease: false
93
- version_requirements: *2170350500
93
+ version_requirements: *70130727177700
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: fakeweb
96
- requirement: &2170350020 !ruby/object:Gem::Requirement
96
+ requirement: &70130727177160 !ruby/object:Gem::Requirement
97
97
  none: false
98
98
  requirements:
99
99
  - - ! '>='
@@ -101,7 +101,7 @@ dependencies:
101
101
  version: '0'
102
102
  type: :development
103
103
  prerelease: false
104
- version_requirements: *2170350020
104
+ version_requirements: *70130727177160
105
105
  description: An oEmbed consumer library written in Ruby, letting you easily get embeddable
106
106
  HTML representations of supported web pages, based on their URLs. See http://oembed.com
107
107
  for more information about the protocol.
@@ -149,6 +149,7 @@ files:
149
149
  - lib/tasks/oembed.rake
150
150
  - lib/tasks/rspec.rake
151
151
  - ruby-oembed.gemspec
152
+ - spec/cassettes/OEmbed_Provider.yml
152
153
  - spec/cassettes/OEmbed_ProviderDiscovery.yml
153
154
  - spec/formatter/ducktype_backend_spec.rb
154
155
  - spec/formatter/json/.DS_Store
@@ -163,6 +164,7 @@ files:
163
164
  - spec/providers_spec.rb
164
165
  - spec/response_spec.rb
165
166
  - spec/spec_helper.rb
167
+ - spec/spec_helper_examples.yml
166
168
  homepage: http://github.com/judofyr/ruby-oembed
167
169
  licenses:
168
170
  - MIT
@@ -171,7 +173,7 @@ rdoc_options:
171
173
  - --main
172
174
  - README.rdoc
173
175
  - --title
174
- - ruby-oembed-0.8.5
176
+ - ruby-oembed-0.8.7
175
177
  - --inline-source
176
178
  - --exclude
177
179
  - tasks