ruby-oembed 0.7.0 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ /pkg
2
+ /.bundle
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm ree-1.8.7@oembed
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ # A sample Gemfile
2
+ source "http://rubygems.org"
3
+ gem 'jeweler'
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,32 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ruby-oembed (0.7.0)
5
+ json
6
+ xml-simple
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ gemcutter (0.6.1)
12
+ git (1.2.5)
13
+ jeweler (1.4.0)
14
+ gemcutter (>= 0.1.0)
15
+ git (>= 1.2.5)
16
+ rubyforge (>= 2.0.0)
17
+ json (1.4.6)
18
+ json_pure (1.4.6)
19
+ rspec (1.3.0)
20
+ rubyforge (2.0.4)
21
+ json_pure (>= 1.1.7)
22
+ xml-simple (1.0.12)
23
+
24
+ PLATFORMS
25
+ ruby
26
+
27
+ DEPENDENCIES
28
+ jeweler
29
+ json
30
+ rspec
31
+ ruby-oembed!
32
+ xml-simple
data/README.md CHANGED
@@ -1,17 +1,36 @@
1
- Changed From The Original
2
- =========================
3
- This is defenitly the "embedly" fork. I replaced everything I could from oohembed.com with embedly. oohembed.com has been running into rate issued with google app engine, so I am just trying to relive the pressure.
1
+ # ruby-oembed
4
2
 
5
- All the supported embedly urls are built from the embeddly json file of simple regexps, which can be found at [http://api.embed.ly/static/data/embedly_regex.json](http://api.embed.ly/static/data/embedly_regex.json)
3
+ An oEmbed client written in Ruby, letting you easily get embeddable HTML representations of a supported web pages, based on their URLs. See [oembed.com][oembed] for more about the protocol.
6
4
 
7
- Adding a folder for testing all the possible urls. I am not sure what the best way to do this is, if some one who is more familiar with ruby can explain a better way of doing that I would be much appreciated.
5
+ # Installation
8
6
 
9
- I also included a url file, provided by embedlly as well, so that the library can check for urls that work or not.
7
+ gem install ruby-oembed
10
8
 
11
- There should probably two types of url checks, one for wellformedness, that doesn't make an HTTP call, and then one to see if the actual url works.
9
+ # Getting Started
12
10
 
13
- Also, Net:HTTP doesn't automatically look for redirectes, so I replaced the main fetch with a loop that checks for a location:header, and if so it does a fetch again. I have hardcoded the max redirects too 4.
11
+ Get embedable resources via an OEmbed::Provider. This gem comes with many Providers built right in, to help you get started.
14
12
 
13
+ resource = OEmbed::Providers::YouTube.get("http://www.youtube.com/watch?v=2BYXBC8WQ5k")
14
+ resource.video? #=> true
15
+ resource.thumbnail_url #=> "http://i3.ytimg.com/vi/2BYXBC8WQ5k/hqdefault.jpg"
16
+ resource.html #=> '<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/2BYXBC8WQ5k?fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/2BYXBC8WQ5k?fs=1" type="application/x-shockwave-flash" width="425" height="344" allowscriptaccess="always" allowfullscreen="true"></embed></object>'
15
17
 
18
+ If you'd like to use a provider that isn't included in the library, it's easy to add one, pointing at your own oEmbed API endpoint and providing the relevant URL schemes.
16
19
 
20
+ my_provider = OEmbed::Provider.new("http://my.cool-service.com/api/oembed_endpoint.{format}"
21
+ my_provider << "http://*.cool-service.com/image/*"
22
+ my_provider << "http://*.cool-service.com/video/*"
23
+ resource = my_provider.get("http://a.cool-service.com/video/1") #=> OEmbed::Response
17
24
 
25
+ To use multiple Providers at once, simply register them.
26
+
27
+ OEmbed::Providers.register(OEmbed::Providers::YouTube, my_provider)
28
+ resource = OEmbed::Providers.get("http://www.youtube.com/watch?v=2BYXBC8WQ5k") #=> OEmbed::Response
29
+ resource.type #=> "video"
30
+ resource.provider.name #=> "YouTube"
31
+
32
+ Last but not least, ruby-oembed supports both [oohEmbed][oohembed] and [Embedly][embedly]. These services are provider aggregators. Each supports a wide array of websites ranging from [Amazon.com](http://www.amazon.com) to [xkcd](http://www.xkcd.com).
33
+
34
+ [oembed]: http://oembed.com "The oembed protocol"
35
+ [oohembed]: http://oohembed.com
36
+ [embedly]: http://embed.ly
data/Rakefile CHANGED
@@ -11,6 +11,7 @@ begin
11
11
  gemspec.add_dependency("xml-simple")
12
12
  gemspec.add_development_dependency("rspec")
13
13
  end
14
+ Jeweler::GemcutterTasks.new
14
15
  rescue LoadError
15
16
  puts "Jeweler not available. Install it with: gem install jeweler"
16
17
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.0
1
+ 0.7.5
@@ -1,143 +1,227 @@
1
1
  [
2
- "http://*youtube.com/watch*",
3
- "http://*.youtube.com/v/*",
4
- "http://youtu.be/*",
5
- "http://*.youtube.com/user/*#*",
6
- "http://*.youtube.com/*#*/*",
7
- "http://www.veoh.com/*/watch/*",
8
- "http://*justin.tv/*",
9
- "http://*justin.tv/*/b/*",
10
- "http://www.ustream.tv/recorded/*",
11
- "http://www.ustream.tv/channel/*",
12
- "http://qik.com/video/*",
13
- "http://qik.com/*",
14
- "http://*revision3.com/*",
15
- "http://*.dailymotion.com/video/*",
16
- "http://*.dailymotion.com/*/video/*",
17
- "http://www.collegehumor.com/video:*",
18
- "http://*twitvid.com/*",
19
- "http://www.break.com/*/*",
20
- "http://vids.myspace.com/index.cfm?fuseaction=vids.individual&videoid*",
21
- "http://www.myspace.com/index.cfm?fuseaction=*&videoid*",
22
- "http://www.metacafe.com/watch/*",
23
- "http://blip.tv/file/*",
24
- "http://*.blip.tv/file/*",
25
- "http://video.google.com/videoplay?*",
26
- "http://*revver.com/video/*",
27
- "http://video.yahoo.com/watch/*/*",
28
- "http://video.yahoo.com/network/*",
29
- "http://*viddler.com/explore/*/videos/*",
30
- "http://liveleak.com/view?*",
31
- "http://www.liveleak.com/view?*",
32
- "http://animoto.com/play/*",
33
- "http://dotsub.com/view/*",
34
- "http://www.overstream.net/view.php?oid=*",
35
- "http://*yfrog.*/*",
36
- "http://tweetphoto.com/*",
37
- "http://www.flickr.com/photos/*",
38
- "http://*twitpic.com/*",
39
- "http://*imgur.com/*",
40
- "http://*.posterous.com/*",
41
- "http://post.ly/*",
42
- "http://twitgoo.com/*",
43
- "http://i*.photobucket.com/albums/*",
44
- "http://gi*.photobucket.com/groups/*",
45
- "http://phodroid.com/*/*/*",
46
- "http://www.mobypicture.com/user/*/view/*",
47
- "http://moby.to/*",
48
- "http://xkcd.com/*",
49
- "http://www.xkcd.com/*",
50
- "http://www.asofterworld.com/index.php?id=*",
51
- "http://www.qwantz.com/index.php?comic=*",
52
- "http://23hq.com/*/photo/*",
53
- "http://www.23hq.com/*/photo/*",
54
- "http://*dribbble.com/shots/*",
55
- "http://drbl.in/*",
56
- "http://*.smugmug.com/*",
57
- "http://*.smugmug.com/*#*",
58
- "http://emberapp.com/*/images/*",
59
- "http://emberapp.com/*/images/*/sizes/*",
60
- "http://emberapp.com/*/collections/*/*",
61
- "http://emberapp.com/*/categories/*/*/*",
62
- "http://embr.it/*",
63
- "http://picasaweb.google.com*/*/*#*",
64
- "http://picasaweb.google.com*/lh/photo/*",
65
- "http://picasaweb.google.com*/*/*",
66
- "http://www.whitehouse.gov/photos-and-video/video/*",
67
- "http://www.whitehouse.gov/video/*",
68
- "http://wh.gov/photos-and-video/video/*",
69
- "http://wh.gov/video/*",
70
- "http://www.hulu.com/watch*",
71
- "http://www.hulu.com/w/*",
72
- "http://hulu.com/watch*",
73
- "http://hulu.com/w/*",
74
- "http://movieclips.com/watch/*/*/",
75
- "http://movieclips.com/watch/*/*/*/*",
76
- "http://*crackle.com/c/*",
77
- "http://www.fancast.com/*/videos",
78
- "http://www.funnyordie.com/videos/*",
79
- "http://www.vimeo.com/groups/*/videos/*",
80
- "http://www.vimeo.com/*",
81
- "http://vimeo.com/groups/*/videos/*",
82
- "http://vimeo.com/*",
83
- "http://www.ted.com/talks/*.html*",
84
- "http://www.ted.com/talks/lang/*/*.html*",
85
- "http://www.ted.com/index.php/talks/*.html*",
86
- "http://www.ted.com/index.php/talks/lang/*/*.html*",
87
- "http://*omnisio.com/*",
88
- "http://*nfb.ca/film/*",
89
- "http://www.thedailyshow.com/watch/*",
90
- "http://www.thedailyshow.com/full-episodes/*",
91
- "http://www.thedailyshow.com/collection/*/*/*",
92
- "http://movies.yahoo.com/movie/*/video/*",
93
- "http://movies.yahoo.com/movie/*/info",
94
- "http://movies.yahoo.com/movie/*/trailer",
95
- "http://www.colbertnation.com/the-colbert-report-collections/*",
96
- "http://www.colbertnation.com/full-episodes/*",
97
- "http://www.colbertnation.com/the-colbert-report-videos/*",
98
- "http://www.comedycentral.com/videos/index.jhtml?*",
99
- "http://www.theonion.com/video/*",
100
- "http://theonion.com/video/*",
101
- "http://wordpress.tv/*/*/*/*/",
102
- "http://www.traileraddict.com/trailer/*",
103
- "http://www.traileraddict.com/clip/*",
104
- "http://www.traileraddict.com/poster/*",
105
- "http://www.escapistmagazine.com/videos/*",
106
- "http://www.trailerspy.com/trailer/*/*",
107
- "http://www.trailerspy.com/trailer/*",
108
- "http://www.trailerspy.com/view_video.php*",
109
- "http://soundcloud.com/*",
110
- "http://soundcloud.com/*/*",
111
- "http://soundcloud.com/*/sets/*",
112
- "http://soundcloud.com/groups/*",
113
- "http://www.lala.com/#album/*",
114
- "http://www.lala.com/album/*",
115
- "http://www.lala.com/#song/*",
116
- "http://www.lala.com/song/*",
117
- "http://www.mixcloud.com/*/*/",
118
- "http://*amazon.*/gp/product/*",
119
- "http://*amazon.*/*/dp/*",
120
- "http://*amazon.*/dp/*",
121
- "http://*amazon.*/o/ASIN/*",
122
- "http://*amazon.*/gp/offer-listing/*",
123
- "http://*amazon.*/*/ASIN/*",
124
- "http://*amazon.*/gp/product/images/*",
125
- "http://www.amzn.com/*",
126
- "http://amzn.com/*",
127
- "http://twitter.com/*/status/*",
128
- "http://twitter.com/*/statuses/*",
129
- "http://www.slideshare.net/*/*",
130
- "http://*.scribd.com/doc/*",
131
- "http://screenr.com/*",
132
- "http://www.5min.com/Video/*",
133
- "http://www.howcast.com/videos/*",
134
- "http://www.screencast.com/*/media/*",
135
- "http://screencast.com/*/media/*",
136
- "http://www.screencast.com/t/*",
137
- "http://screencast.com/t/*",
138
- "http://www.clearspring.com/widgets/*",
139
- "http://my.opera.com/*/albums/show.dml?id=*",
140
- "http://my.opera.com/*/albums/showpic.dml?album=*&picture=*",
141
- "http://tumblr.com/*",
142
- "http://*.tumblr.com/post/*"
2
+ "http://*youtube.com/watch*",
3
+ "http://*.youtube.com/v/*",
4
+ "http://youtu.be/*",
5
+ "http://*.youtube.com/user/*#*",
6
+ "http://*.youtube.com/*#*/*",
7
+ "http://*justin.tv/*",
8
+ "http://*justin.tv/*/b/*",
9
+ "http://www.ustream.tv/recorded/*",
10
+ "http://www.ustream.tv/channel/*",
11
+ "http://www.ustream.tv/*",
12
+ "http://qik.com/video/*",
13
+ "http://qik.com/*",
14
+ "http://*revision3.com/*",
15
+ "http://*.dailymotion.com/video/*",
16
+ "http://*.dailymotion.com/*/video/*",
17
+ "http://www.collegehumor.com/video:*",
18
+ "http://*twitvid.com/*",
19
+ "http://www.break.com/*/*",
20
+ "http://vids.myspace.com/index.cfm?fuseaction=vids.individual&videoid*",
21
+ "http://www.myspace.com/index.cfm?fuseaction=*&videoid*",
22
+ "http://www.metacafe.com/watch/*",
23
+ "http://blip.tv/file/*",
24
+ "http://*.blip.tv/file/*",
25
+ "http://video.google.com/videoplay?*",
26
+ "http://*revver.com/video/*",
27
+ "http://video.yahoo.com/watch/*/*",
28
+ "http://video.yahoo.com/network/*",
29
+ "http://*viddler.com/explore/*/videos/*",
30
+ "http://liveleak.com/view?*",
31
+ "http://www.liveleak.com/view?*",
32
+ "http://animoto.com/play/*",
33
+ "http://dotsub.com/view/*",
34
+ "http://www.overstream.net/view.php?oid=*",
35
+ "http://www.livestream.com/*",
36
+ "http://www.worldstarhiphop.com/videos/video*.php?v=*",
37
+ "http://worldstarhiphop.com/videos/video*.php?v=*",
38
+ "http://teachertube.com/viewVideo.php*",
39
+ "http://teachertube.com/viewVideo.php*",
40
+ "http://bambuser.com/v/*",
41
+ "http://bambuser.com/channel/*",
42
+ "http://bambuser.com/channel/*/broadcast/*",
43
+ "http://www.schooltube.com/video/*/*",
44
+ "http://*yfrog.*/*",
45
+ "http://tweetphoto.com/*",
46
+ "http://www.flickr.com/photos/*",
47
+ "http://flic.kr/*",
48
+ "http://*twitpic.com/*",
49
+ "http://*imgur.com/*",
50
+ "http://*.posterous.com/*",
51
+ "http://post.ly/*",
52
+ "http://twitgoo.com/*",
53
+ "http://i*.photobucket.com/albums/*",
54
+ "http://gi*.photobucket.com/groups/*",
55
+ "http://phodroid.com/*/*/*",
56
+ "http://www.mobypicture.com/user/*/view/*",
57
+ "http://moby.to/*",
58
+ "http://xkcd.com/*",
59
+ "http://www.xkcd.com/*",
60
+ "http://www.asofterworld.com/index.php?id=*",
61
+ "http://www.qwantz.com/index.php?comic=*",
62
+ "http://23hq.com/*/photo/*",
63
+ "http://www.23hq.com/*/photo/*",
64
+ "http://*dribbble.com/shots/*",
65
+ "http://drbl.in/*",
66
+ "http://*.smugmug.com/*",
67
+ "http://*.smugmug.com/*#*",
68
+ "http://emberapp.com/*/images/*",
69
+ "http://emberapp.com/*/images/*/sizes/*",
70
+ "http://emberapp.com/*/collections/*/*",
71
+ "http://emberapp.com/*/categories/*/*/*",
72
+ "http://embr.it/*",
73
+ "http://picasaweb.google.com*/*/*#*",
74
+ "http://picasaweb.google.com*/lh/photo/*",
75
+ "http://picasaweb.google.com*/*/*",
76
+ "http://dailybooth.com/*/*",
77
+ "http://brizzly.com/pic/*",
78
+ "http://pics.brizzly.com/*.jpg",
79
+ "http://img.ly/*",
80
+ "http://www.facebook.com/photo.php*",
81
+ "http://www.tinypic.com/view.php*",
82
+ "http://tinypic.com/view.php*",
83
+ "http://www.tinypic.com/player.php*",
84
+ "http://tinypic.com/player.php*",
85
+ "http://www.tinypic.com/r/*/*",
86
+ "http://tinypic.com/r/*/*",
87
+ "http://*.tinypic.com/*.jpg",
88
+ "http://*.tinypic.com/*.png",
89
+ "http://meadd.com/*/*",
90
+ "http://meadd.com/*",
91
+ "http://*.deviantart.com/art/*",
92
+ "http://*.deviantart.com/gallery/*",
93
+ "http://*.deviantart.com/#/*",
94
+ "http://fav.me/*",
95
+ "http://*.deviantart.com",
96
+ "http://*.deviantart.com/gallery",
97
+ "http://*.deviantart.com/*/*.jpg",
98
+ "http://*.deviantart.com/*/*.gif",
99
+ "http://*.deviantart.net/*/*.jpg",
100
+ "http://*.deviantart.net/*/*.gif",
101
+ "http://www.whitehouse.gov/photos-and-video/video/*",
102
+ "http://www.whitehouse.gov/video/*",
103
+ "http://wh.gov/photos-and-video/video/*",
104
+ "http://wh.gov/video/*",
105
+ "http://www.hulu.com/watch*",
106
+ "http://www.hulu.com/w/*",
107
+ "http://hulu.com/watch*",
108
+ "http://hulu.com/w/*",
109
+ "http://movieclips.com/watch/*/*/",
110
+ "http://movieclips.com/watch/*/*/*/*",
111
+ "http://*crackle.com/c/*",
112
+ "http://www.fancast.com/*/videos",
113
+ "http://www.funnyordie.com/videos/*",
114
+ "http://www.vimeo.com/groups/*/videos/*",
115
+ "http://www.vimeo.com/*",
116
+ "http://vimeo.com/groups/*/videos/*",
117
+ "http://vimeo.com/*",
118
+ "http://www.ted.com/talks/*.html*",
119
+ "http://www.ted.com/talks/lang/*/*.html*",
120
+ "http://www.ted.com/index.php/talks/*.html*",
121
+ "http://www.ted.com/index.php/talks/lang/*/*.html*",
122
+ "http://*omnisio.com/*",
123
+ "http://*nfb.ca/film/*",
124
+ "http://www.thedailyshow.com/watch/*",
125
+ "http://www.thedailyshow.com/full-episodes/*",
126
+ "http://www.thedailyshow.com/collection/*/*/*",
127
+ "http://movies.yahoo.com/movie/*/video/*",
128
+ "http://movies.yahoo.com/movie/*/info",
129
+ "http://movies.yahoo.com/movie/*/trailer",
130
+ "http://www.colbertnation.com/the-colbert-report-collections/*",
131
+ "http://www.colbertnation.com/full-episodes/*",
132
+ "http://www.colbertnation.com/the-colbert-report-videos/*",
133
+ "http://www.comedycentral.com/videos/index.jhtml?*",
134
+ "http://www.theonion.com/video/*",
135
+ "http://theonion.com/video/*",
136
+ "http://wordpress.tv/*/*/*/*/",
137
+ "http://www.traileraddict.com/trailer/*",
138
+ "http://www.traileraddict.com/clip/*",
139
+ "http://www.traileraddict.com/poster/*",
140
+ "http://www.escapistmagazine.com/videos/*",
141
+ "http://www.trailerspy.com/trailer/*/*",
142
+ "http://www.trailerspy.com/trailer/*",
143
+ "http://www.trailerspy.com/view_video.php*",
144
+ "http://www.atom.com/*/*/",
145
+ "http://fora.tv/*/*/*/*",
146
+ "http://www.spike.com/video/*",
147
+ "http://www.gametrailers.com/video/*",
148
+ "http://gametrailers.com/video/*",
149
+ "http://www.koldcast.tv/video/*",
150
+ "http://www.koldcast.tv/#video:*",
151
+ "http://techcrunch.tv/watch*",
152
+ "http://techcrunch.tv/*/watch*",
153
+ "http://www.godtube.com/featured/video/*",
154
+ "http://www.tangle.com/view_video*",
155
+ "http://soundcloud.com/*",
156
+ "http://soundcloud.com/*/*",
157
+ "http://soundcloud.com/*/sets/*",
158
+ "http://soundcloud.com/groups/*",
159
+ "http://www.last.fm/music/*",
160
+ "http://www.last.fm/music/+videos/*",
161
+ "http://www.last.fm/music/+images/*",
162
+ "http://www.last.fm/music/*/_/*",
163
+ "http://www.last.fm/music/*/*",
164
+ "http://www.mixcloud.com/*/*/",
165
+ "http://espn.go.com/video/clip*",
166
+ "http://espn.go.com/*/story*",
167
+ "http://cnbc.com/id/*",
168
+ "http://cbsnews.com/video/watch/*",
169
+ "http://www.cnn.com/video/*",
170
+ "http://edition.cnn.com/video/*",
171
+ "http://money.cnn.com/video/*",
172
+ "http://today.msnbc.msn.com/id/*/vp/*",
173
+ "http://www.msnbc.msn.com/id/*/vp/*",
174
+ "http://www.msnbc.msn.com/id/*/ns/*",
175
+ "http://today.msnbc.msn.com/id/*/ns/*",
176
+ "http://multimedia.foxsports.com/m/video/*/*",
177
+ "http://msn.foxsports.com/video*",
178
+ "http://*amazon.*/gp/product/*",
179
+ "http://*amazon.*/*/dp/*",
180
+ "http://*amazon.*/dp/*",
181
+ "http://*amazon.*/o/ASIN/*",
182
+ "http://*amazon.*/gp/offer-listing/*",
183
+ "http://*amazon.*/*/ASIN/*",
184
+ "http://*amazon.*/gp/product/images/*",
185
+ "http://www.amzn.com/*",
186
+ "http://amzn.com/*",
187
+ "http://www.shopstyle.com/browse*",
188
+ "http://www.shopstyle.com/action/apiVisitRetailer*",
189
+ "http://www.shopstyle.com/action/viewLook*",
190
+ "http://gist.github.com/*",
191
+ "http://twitter.com/*/status/*",
192
+ "http://twitter.com/*/statuses/*",
193
+ "http://www.crunchbase.com/*/*",
194
+ "http://crunchbase.com/*/*",
195
+ "http://www.slideshare.net/*/*",
196
+ "http://*.scribd.com/doc/*",
197
+ "http://screenr.com/*",
198
+ "http://polldaddy.com/community/poll/*",
199
+ "http://polldaddy.com/poll/*",
200
+ "http://answers.polldaddy.com/poll/*",
201
+ "http://www.5min.com/Video/*",
202
+ "http://www.howcast.com/videos/*",
203
+ "http://www.screencast.com/*/media/*",
204
+ "http://screencast.com/*/media/*",
205
+ "http://www.screencast.com/t/*",
206
+ "http://screencast.com/t/*",
207
+ "http://issuu.com/*/docs/*",
208
+ "http://www.kickstarter.com/projects/*/*",
209
+ "http://www.scrapblog.com/viewer/viewer.aspx*",
210
+ "http://my.opera.com/*/albums/show.dml?id=*",
211
+ "http://my.opera.com/*/albums/showpic.dml?album=*&picture=*",
212
+ "http://tumblr.com/*",
213
+ "http://*.tumblr.com/post/*",
214
+ "http://www.polleverywhere.com/polls/*",
215
+ "http://www.polleverywhere.com/multiple_choice_polls/*",
216
+ "http://www.polleverywhere.com/free_text_polls/*",
217
+ "http://www.quantcast.com/wd:*",
218
+ "http://www.quantcast.com/*",
219
+ "http://siteanalytics.compete.com/*",
220
+ "http://statsheet.com/statplot/charts/*/*/*/*",
221
+ "http://statsheet.com/statplot/charts/e/*",
222
+ "http://statsheet.com/*/teams/*/*",
223
+ "http://statsheet.com/tools/chartlets?chart=*",
224
+ "http://*.status.net/notice/*",
225
+ "http://identi.ca/notice/*",
226
+ "http://shitmydadsays.com/notice/*"
143
227
  ]
@@ -5,14 +5,25 @@ module OEmbed
5
5
  # Load XML
6
6
  begin
7
7
  require 'xmlsimple'
8
- FORMATS[:xml] = proc { |r| XmlSimple.xml_in(r, 'ForceArray' => false)}
8
+ FORMATS[:xml] = proc do |r|
9
+ begin
10
+ XmlSimple.xml_in(StringIO.new(r), 'ForceArray' => false)
11
+ rescue
12
+ case $!
13
+ when ::ArgumentError
14
+ raise $!
15
+ else
16
+ raise ::ArgumentError, "Couldn't parse the given document."
17
+ end
18
+ end
19
+ end
9
20
  rescue LoadError
10
21
  end
11
22
 
12
23
  # Load JSON
13
24
  begin
14
25
  require 'json'
15
- FORMATS[:json] = proc { |r| ::JSON.load(r) }
26
+ FORMATS[:json] = proc { |r| ::JSON.load(r.to_s) }
16
27
  rescue LoadError
17
28
  end
18
29
 
@@ -66,13 +66,24 @@ module OEmbed
66
66
  when Net::HTTPOK
67
67
  res.body
68
68
  else
69
- raise OEmbed::UnknownResponse, res.code
69
+ raise OEmbed::UnknownResponse, res && res.respond_to?(:code) ? res.code : 'Error'
70
+ end
71
+ rescue StandardError
72
+ # Convert known errors into OEmbed::UnknownResponse for easy catching
73
+ # up the line. This is important if given a URL that doesn't support
74
+ # OEmbed. The following are known errors:
75
+ # * Net::* errors like Net::HTTPBadResponse
76
+ # * JSON::JSONError errors like JSON::ParserError
77
+ if $!.is_a?(JSON::JSONError) || $!.class.to_s =~ /\ANet::/
78
+ raise OEmbed::UnknownResponse, res && res.respond_to?(:code) ? res.code : 'Error'
79
+ else
80
+ raise $!
70
81
  end
71
82
  end
72
83
 
73
84
  def get(url, options = {})
74
85
  options[:format] ||= @format if @format
75
- OEmbed::Response.create_for(raw(url, options), self, options[:format])
86
+ OEmbed::Response.create_for(raw(url, options), self, url, options[:format])
76
87
  end
77
88
 
78
89
  def format_in_url?
@@ -14,7 +14,8 @@ module OEmbed
14
14
  def register(*providers)
15
15
  providers.each do |provider|
16
16
  provider.urls.each do |url|
17
- @@urls[url] = provider
17
+ @@urls[url] ||= []
18
+ @@urls[url] << provider
18
19
  end
19
20
  end
20
21
  end
@@ -22,13 +23,16 @@ module OEmbed
22
23
  def unregister(*providers)
23
24
  providers.each do |provider|
24
25
  provider.urls.each do |url|
25
- @@urls.delete(url)
26
+ if @@urls[url].is_a?(Array)
27
+ @@urls[url].delete(provider)
28
+ @@urls.delete(url) if @@urls[url].empty?
29
+ end
26
30
  end
27
31
  end
28
32
  end
29
33
 
30
34
  def register_all
31
- register(Youtube, Flickr, Viddler, Qik, Pownce, Revision3, Hulu, Vimeo, PollEverywhere, MyOpera, ClearspringWidgets, MovieClips, TwentyThree)
35
+ register(Youtube, Flickr, Viddler, Qik, Pownce, Revision3, Hulu, Vimeo)
32
36
  end
33
37
 
34
38
  # Takes an array of OEmbed::Provider instances or OEmbed::ProviderDiscovery
@@ -49,7 +53,8 @@ module OEmbed
49
53
  end
50
54
 
51
55
  def find(url)
52
- @@urls[@@urls.keys.detect { |u| u =~ url }] || false
56
+ providers = @@urls[@@urls.keys.detect { |u| u =~ url }]
57
+ Array(providers).first || nil
53
58
  end
54
59
 
55
60
  def raw(url, options = {})
@@ -78,7 +83,7 @@ module OEmbed
78
83
  end
79
84
 
80
85
  # Custom providers:
81
- Youtube = OEmbed::Provider.new("http://www.youtube.com/oembed/")
86
+ Youtube = OEmbed::Provider.new("http://www.youtube.com/oembed")
82
87
  Youtube << "http://*.youtube.com/*"
83
88
 
84
89
  Flickr = OEmbed::Provider.new("http://www.flickr.com/services/oembed/")
@@ -105,28 +110,42 @@ module OEmbed
105
110
  Pownce << "http://*.pownce.com/*"
106
111
 
107
112
  # A general end point, which then calls other APIs and returns OEmbed info
108
- OohEmbed = OEmbed::Provider.new("http://oohembed.com/oohembed/")
109
- #OohEmbed << %r{http://yfrog.(com|ru|com.tr|it|fr|co.il|co.uk|com.pl|pl|eu|us)/(.*?)} # image & video hosting
110
- #OohEmbed << "http://*.xkcd.com/*" # A hilarious stick figure comic
111
- OohEmbed << "http://*.wordpress.com/*/*/*/*" # Blogging Engine & community
113
+ OohEmbed = OEmbed::Provider.new("http://oohembed.com/oohembed/", :json)
114
+ OohEmbed << "http://*.5min.com/Video/*" # micro-video host
115
+ OohEmbed << %r{http://(.*?).amazon.(com|co.uk|de|ca|jp)/(.*?)/(gp/product|o/ASIN|obidos/ASIN|dp)/(.*?)} # Online product shopping
116
+ OohEmbed << "http://*.blip.tv/*"
117
+ OohEmbed << "http://*.collegehumor.com/video:*" # Comedic & original videos
118
+ OohEmbed << "http://*.thedailyshow.com/video/*" # Syndicated show
119
+ OohEmbed << "http://*.dailymotion.com/*"
120
+ OohEmbed << "http://dotsub.com/view/*"
121
+ OohEmbed << "http://*.flickr.com/photos/*"
122
+ OohEmbed << "http://*.funnyordie.com/videos/*" # Comedy video host
123
+ OohEmbed << "http://video.google.com/videoplay?*" # Video hosting
124
+ OohEmbed << "http://www.hulu.com/watch/*"
125
+ OohEmbed << "http://*.livejournal.com/"
126
+ OohEmbed << "http://*.metacafe.com/watch/*" # Video host
127
+ OohEmbed << "http://*.nfb.ca/film/*"
128
+ OohEmbed << "http://*.phodroid.com/*/*/*" # Photo host
129
+ OohEmbed << "http://qik.com/*"
130
+ OohEmbed << "http://*.revision3.com/*"
131
+ OohEmbed << "http://*.scribd.com/*"
132
+ OohEmbed << "http://*.slideshare.net/*" # Share presentations online
133
+ OohEmbed << "http://*.twitpic.com/*" # Picture hosting for Twitter
134
+ OohEmbed << "http://twitter.com/*/statuses/*" # Mirco-blogging network
135
+ OohEmbed << "http://*.viddler.com/explore/*"
136
+ OohEmbed << "http://www.vimeo.com/*"
137
+ OohEmbed << "http://www.vimeo.com/groups/*/videos/*"
112
138
  OohEmbed << "http://*.wikipedia.org/wiki/*" # Online encyclopedia
113
- #OohEmbed << "http://*.twitpic.com/*" # Picture hosting for Twitter
114
- #OohEmbed << "http://twitter.com/*/statuses/*" # Mirco-blogging network
115
- #OohEmbed << "http://*.slideshare.net/*" # Share presentations online
116
- #OohEmbed << "http://*.phodroid.com/*/*/*" # Photo host
117
- #OohEmbed << "http://*.metacafe.com/watch/*" # Video host
118
- #OohEmbed << "http://video.google.com/videoplay?*" # Video hosting
119
- #OohEmbed << "http://*.funnyordie.com/videos/*" # Comedy video host
120
- #OohEmbed << "http://*.thedailyshow.com/video/*" # Syndicated show
121
- #OohEmbed << "http://*.collegehumor.com/video:*" # Comedic & original videos
122
- #OohEmbed << %r{http://(.*?).amazon.(com|co.uk|de|ca|jp)/(.*?)/(gp/product|o/ASIN|obidos/ASIN|dp)/(.*?)} # Online product shopping
123
- #OohEmbed << "http://*.5min.com/Video/*" # micro-video host
139
+ OohEmbed << "http://*.wordpress.com/*/*/*/*" # Blogging Engine & community
140
+ OohEmbed << "http://*.xkcd.com/*" # A hilarious stick figure comic
141
+ OohEmbed << %r{http://yfrog.(com|ru|com.tr|it|fr|co.il|co.uk|com.pl|pl|eu|us)/(.*?)} # image & video hosting
142
+ OohEmbed << "http://*.youtube.com/watch*"
124
143
 
125
144
  # A general end point, which then calls other APIs and returns OEmbed info
126
145
  Embedly = OEmbed::Provider.new("http://api.embed.ly/v1/api/oembed")
127
- urls = JSON.parse(File.open(File.dirname(__FILE__) + "/embedly_urls.json", "r").read)
128
- urls.each do |url|
129
- Embedly << url
146
+ # An up-to-date version of this json file is available here: (http://api.embed.ly/static/data/embedly_regex.json
147
+ JSON.parse(File.open(File.dirname(__FILE__) + "/embedly_urls.json", "r").read).each do |url|
148
+ Embedly << url
130
149
  end
131
150
 
132
151
  PollEverywhere = OEmbed::Provider.new("http://www.polleverywhere.com/services/oembed/")
@@ -1,9 +1,9 @@
1
1
  module OEmbed
2
2
  class Response
3
3
  METHODS = [:define_methods!, :provider, :field, :fields]
4
- attr_reader :fields, :provider, :format
4
+ attr_reader :fields, :provider, :format, :url
5
5
 
6
- def self.create_for(raw, provider, format = :json)
6
+ def self.create_for(raw, provider, url, format = :json)
7
7
  fields = OEmbed::Formatters.convert(format, raw)
8
8
 
9
9
  resp_type = case fields['type']
@@ -14,10 +14,10 @@ module OEmbed
14
14
  else self
15
15
  end
16
16
 
17
- resp_type.new(fields, provider)
17
+ resp_type.new(fields, provider, url)
18
18
  end
19
19
 
20
- def initialize(fields, provider)
20
+ def initialize(fields, provider, url = nil)
21
21
  @fields = fields
22
22
  @provider = provider
23
23
  define_methods!
data/ruby-oembed.gemspec CHANGED
@@ -5,18 +5,22 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ruby-oembed}
8
- s.version = "0.7.0"
8
+ s.version = "0.7.5"
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"]
12
- s.date = %q{2010-08-19}
12
+ s.date = %q{2010-09-29}
13
13
  s.description = %q{A fork of a fork. @github[voidfiles,judofyr]. judufyr created the project and voidfiles added support for Embedly. This is just the gem}
14
14
  s.email = %q{arisbartee@gmail.com}
15
15
  s.extra_rdoc_files = [
16
16
  "README.md"
17
17
  ]
18
18
  s.files = [
19
- "README.md",
19
+ ".gitignore",
20
+ ".rvmrc",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "README.md",
20
24
  "Rakefile",
21
25
  "VERSION",
22
26
  "idea.rb",
@@ -44,7 +48,7 @@ Gem::Specification.new do |s|
44
48
  s.homepage = %q{http://github.com/arisbartee/ruby-oembed}
45
49
  s.rdoc_options = ["--charset=UTF-8"]
46
50
  s.require_paths = ["lib"]
47
- s.rubygems_version = %q{1.3.6}
51
+ s.rubygems_version = %q{1.3.7}
48
52
  s.summary = %q{oEmbed for Ruby}
49
53
  s.test_files = [
50
54
  "spec/provider_spec.rb",
@@ -57,7 +61,7 @@ Gem::Specification.new do |s|
57
61
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
58
62
  s.specification_version = 3
59
63
 
60
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
64
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
61
65
  s.add_runtime_dependency(%q<json>, [">= 0"])
62
66
  s.add_runtime_dependency(%q<xml-simple>, [">= 0"])
63
67
  s.add_development_dependency(%q<rspec>, [">= 0"])
@@ -14,17 +14,18 @@ describe OEmbed::Providers do
14
14
 
15
15
  it "should register providers" do
16
16
  OEmbed::Providers.register(@flickr, @qik)
17
- urls = OEmbed::Providers.urls.dup
17
+
18
+ OEmbed::Providers.urls.keys.should == @flickr.urls + @qik.urls
18
19
 
19
20
  @flickr.urls.each do |regexp|
20
- urls.delete(regexp).should == @flickr
21
+ OEmbed::Providers.urls.should have_key(regexp)
22
+ OEmbed::Providers.urls[regexp].should include(@flickr)
21
23
  end
22
24
 
23
- @qik.urls.each do |regexp|
24
- urls.delete(regexp).should == @qik
25
+ @qik.urls.each do |regexp|
26
+ OEmbed::Providers.urls.should have_key(regexp)
27
+ OEmbed::Providers.urls[regexp].should include(@qik)
25
28
  end
26
-
27
- urls.length.should == 0
28
29
  end
29
30
 
30
31
  it "should find by URLs" do
@@ -34,40 +35,79 @@ describe OEmbed::Providers do
34
35
 
35
36
  it "should unregister providers" do
36
37
  OEmbed::Providers.unregister(@flickr)
37
- urls = OEmbed::Providers.urls.dup
38
+
39
+ @flickr.urls.each do |regexp|
40
+ OEmbed::Providers.urls.should_not have_key(regexp)
41
+ end
42
+
43
+ OEmbed::Providers.urls.keys.should == @qik.urls
38
44
 
39
45
  @qik.urls.each do |regexp|
40
- urls.delete(regexp).should == @qik
46
+ OEmbed::Providers.urls.should have_key(regexp)
47
+ OEmbed::Providers.urls[regexp].should include(@qik)
41
48
  end
42
-
43
- urls.length.should == 0
44
49
  end
45
50
 
46
- it "should use the OEmbed::ProviderDiscovery fallback provider correctly" do
47
-
48
-
49
- # None of the registered providers should match
50
- # all_example_urls.each do |url|
51
- provider = OEmbed::Providers.find('http://www.mobypicture.com/user/IadoreChrisette/view/7275748')
52
- provider.should_not_receive(:raw)
53
- provider.should_not_receive(:get)
54
- # end
55
-
56
- # Register the fallback
57
- # OEmbed::Providers.register_fallback(OEmbed::ProviderDiscovery)
58
-
59
- # provider = OEmbed::ProviderDiscovery
60
- # provider.should_receive(:raw).
61
- # with(url, {}).
62
- # and_return(valid_response(:raw))
63
- # provider.should_receive(:get).
64
- # with(url, {}).
65
- # and_return(valid_response(:object))
66
- #asdf
67
-
51
+ it "should not unregister duplicate provider urls at first" do
52
+ @qik_mirror = OEmbed::Provider.new("http://mirror.qik.com/api/oembed.{format}")
53
+ @qik_mirror << "http://qik.com/*"
54
+
55
+ @qik_mirror.urls.each do |regexp|
56
+ @qik.urls.should include(regexp)
57
+ end
58
+
59
+ OEmbed::Providers.register(@qik_mirror)
60
+
61
+ OEmbed::Providers.urls.keys.should == @qik.urls
62
+
63
+ @qik_mirror.urls.each do |regexp|
64
+ OEmbed::Providers.urls[regexp].should include(@qik_mirror)
65
+ OEmbed::Providers.urls[regexp].should include(@qik)
66
+ end
67
+
68
+ OEmbed::Providers.find(example_url(:qik)).should == @qik
69
+
70
+ OEmbed::Providers.unregister(@qik)
71
+
72
+ urls = OEmbed::Providers.urls.dup
68
73
 
74
+ @qik_mirror.urls.each do |regexp|
75
+ OEmbed::Providers.urls[regexp].should include(@qik_mirror)
76
+ end
77
+
78
+ OEmbed::Providers.find(example_url(:qik)).should == @qik_mirror
79
+
80
+ OEmbed::Providers.unregister(@qik_mirror)
81
+
82
+ @qik_mirror.urls.each do |regexp|
83
+ OEmbed::Providers.urls.should_not have_key(regexp)
84
+ end
69
85
  end
70
86
 
87
+ #it "should use the OEmbed::ProviderDiscovery fallback provider correctly" do
88
+ # url = example_url(:vimeo)
89
+ #
90
+ # # None of the registered providers should match
91
+ # all_example_urls.each do |url|
92
+ # provider = OEmbed::Providers.find(url)
93
+ # if provider
94
+ # provider.should_not_receive(:raw)
95
+ # provider.should_not_receive(:get)
96
+ # end
97
+ # end
98
+ #
99
+ # # Register the fallback
100
+ # OEmbed::Providers.register_fallback(OEmbed::ProviderDiscovery)
101
+ #
102
+ # provider = OEmbed::ProviderDiscovery
103
+ # provider.should_receive(:raw).
104
+ # with(url, {}).
105
+ # and_return(valid_response(:raw))
106
+ # provider.should_receive(:get).
107
+ # with(url, {}).
108
+ # and_return(valid_response(:object))
109
+ #end
110
+
71
111
  it "should bridge #get and #raw to the right provider" do
72
112
  OEmbed::Providers.register_all
73
113
  all_example_urls.each do |url|
@@ -15,9 +15,9 @@ describe OEmbed::Response do
15
15
 
16
16
  @new_res = OEmbed::Response.new(valid_response(:object), OEmbed::Providers::OohEmbed)
17
17
 
18
- @default_res = OEmbed::Response.create_for(valid_response(:json), @flickr)
19
- @xml_res = OEmbed::Response.create_for(valid_response(:xml), @qik, :xml)
20
- @json_res = OEmbed::Response.create_for(valid_response(:json), @viddler, :json)
18
+ @default_res = OEmbed::Response.create_for(valid_response(:json), @flickr, example_url(:flickr))
19
+ @xml_res = OEmbed::Response.create_for(valid_response(:xml), @qik, example_url(:qik), :xml)
20
+ @json_res = OEmbed::Response.create_for(valid_response(:json), @viddler, example_url(:viddler), :json)
21
21
  end
22
22
 
23
23
  it "should set the provider" do
@@ -38,29 +38,29 @@ describe OEmbed::Response do
38
38
 
39
39
  it "should only allow JSON or XML" do
40
40
  lambda do
41
- OEmbed::Response.create_for(valid_response(:json), @flickr, :json)
41
+ OEmbed::Response.create_for(valid_response(:json), @flickr, example_url(:flickr), :json)
42
42
  end.should_not raise_error(OEmbed::FormatNotSupported)
43
43
 
44
44
  lambda do
45
- OEmbed::Response.create_for(valid_response(:xml), @flickr, :xml)
45
+ OEmbed::Response.create_for(valid_response(:xml), @flickr, example_url(:flickr), :xml)
46
46
  end.should_not raise_error(OEmbed::FormatNotSupported)
47
47
 
48
48
  lambda do
49
- OEmbed::Response.create_for(valid_response(:yml), @flickr, :yml)
49
+ OEmbed::Response.create_for(valid_response(:yml), @flickr, example_url(:flickr), :yml)
50
50
  end.should raise_error(OEmbed::FormatNotSupported)
51
51
  end
52
52
 
53
53
  it "should not parse the incorrect format" do
54
54
  lambda do
55
- OEmbed::Response.create_for(valid_response(:xml), @flickr)
55
+ OEmbed::Response.create_for(valid_response(:xml), example_url(:flickr), @flickr)
56
56
  end.should raise_error(JSON::ParserError)
57
57
 
58
58
  lambda do
59
- OEmbed::Response.create_for(valid_response(:xml), @viddler, :json)
59
+ OEmbed::Response.create_for(valid_response(:xml), example_url(:flickr), @viddler, :json)
60
60
  end.should raise_error(JSON::ParserError)
61
61
 
62
62
  lambda do
63
- OEmbed::Response.create_for(valid_response(:json), @viddler, :xml)
63
+ OEmbed::Response.create_for(valid_response(:json), example_url(:flickr), @viddler, :xml)
64
64
  end.should raise_error(ArgumentError)
65
65
  end
66
66
 
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-oembed
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 9
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 7
8
- - 0
9
- version: 0.7.0
9
+ - 5
10
+ version: 0.7.5
10
11
  platform: ruby
11
12
  authors:
12
13
  - Magnus Holm
@@ -16,16 +17,18 @@ autorequire:
16
17
  bindir: bin
17
18
  cert_chain: []
18
19
 
19
- date: 2010-08-19 00:00:00 -05:00
20
+ date: 2010-09-29 00:00:00 -05:00
20
21
  default_executable:
21
22
  dependencies:
22
23
  - !ruby/object:Gem::Dependency
23
24
  name: json
24
25
  prerelease: false
25
26
  requirement: &id001 !ruby/object:Gem::Requirement
27
+ none: false
26
28
  requirements:
27
29
  - - ">="
28
30
  - !ruby/object:Gem::Version
31
+ hash: 3
29
32
  segments:
30
33
  - 0
31
34
  version: "0"
@@ -35,9 +38,11 @@ dependencies:
35
38
  name: xml-simple
36
39
  prerelease: false
37
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
38
42
  requirements:
39
43
  - - ">="
40
44
  - !ruby/object:Gem::Version
45
+ hash: 3
41
46
  segments:
42
47
  - 0
43
48
  version: "0"
@@ -47,9 +52,11 @@ dependencies:
47
52
  name: rspec
48
53
  prerelease: false
49
54
  requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
50
56
  requirements:
51
57
  - - ">="
52
58
  - !ruby/object:Gem::Version
59
+ hash: 3
53
60
  segments:
54
61
  - 0
55
62
  version: "0"
@@ -64,6 +71,10 @@ extensions: []
64
71
  extra_rdoc_files:
65
72
  - README.md
66
73
  files:
74
+ - .gitignore
75
+ - .rvmrc
76
+ - Gemfile
77
+ - Gemfile.lock
67
78
  - README.md
68
79
  - Rakefile
69
80
  - VERSION
@@ -98,23 +109,27 @@ rdoc_options:
98
109
  require_paths:
99
110
  - lib
100
111
  required_ruby_version: !ruby/object:Gem::Requirement
112
+ none: false
101
113
  requirements:
102
114
  - - ">="
103
115
  - !ruby/object:Gem::Version
116
+ hash: 3
104
117
  segments:
105
118
  - 0
106
119
  version: "0"
107
120
  required_rubygems_version: !ruby/object:Gem::Requirement
121
+ none: false
108
122
  requirements:
109
123
  - - ">="
110
124
  - !ruby/object:Gem::Version
125
+ hash: 3
111
126
  segments:
112
127
  - 0
113
128
  version: "0"
114
129
  requirements: []
115
130
 
116
131
  rubyforge_project:
117
- rubygems_version: 1.3.6
132
+ rubygems_version: 1.3.7
118
133
  signing_key:
119
134
  specification_version: 3
120
135
  summary: oEmbed for Ruby