Take the 2008 Git User's Survey and help out! [ hide ]

public
Description: oEmbed for Ruby
Homepage: http://oembed.com/
Clone URL: git://github.com/judofyr/ruby-oembed.git
Search Repo:
Improving the error-system
judofyr (author)
Fri Jun 27 11:58:09 -0700 2008
commit  a283dfae5fba6f83ee7712b43fd65843e17bfb5e
tree    b02c91e1922f0a4d263693bee894a6d489cd6fcb
parent  8be532da66083b97cf8e0d26ca0eabf6eb65d49b
...
1
2
3
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
6
...
1
 
 
 
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
0
@@ -1,5 +1,19 @@
0
 module OEmbed
0
- NotFound = Class.new(StandardError)
0
- UnknownFormat = Class.new(StandardError)
0
- UnknownResponse = Class.new(StandardError)
0
+ class NotFound < StandardError
0
+ def to_s
0
+ "No embeddable content at '#{super}'"
0
+ end
0
+ end
0
+
0
+ class UnknownFormat < StandardError
0
+ def to_s
0
+ "The provider doesn't support the '#{super}' format"
0
+ end
0
+ end
0
+
0
+ class UnknownResponse < StandardError
0
+ def to_s
0
+ "Got unkown response (#{super}) from server"
0
+ end
0
+ end
0
 end
0
\ No newline at end of file
...
16
17
18
19
 
20
21
22
...
31
32
33
34
 
 
 
 
35
36
37
...
43
44
45
46
 
47
48
 
49
50
51
52
 
53
54
55
...
16
17
18
 
19
20
21
22
...
31
32
33
 
34
35
36
37
38
39
40
...
46
47
48
 
49
50
 
51
52
53
54
 
55
56
57
58
0
@@ -16,7 +16,7 @@ module OEmbed
0
     end
0
     
0
     def build(url, options = {})
0
- raise OEmbed::NotFound, "No embeddable content at '#{url}'" unless include?(url)
0
+ raise OEmbed::NotFound, url unless include?(url)
0
       query = options.merge({:url => url})
0
       endpoint = @endpoint.clone
0
       
0
@@ -31,7 +31,10 @@ module OEmbed
0
         "#{key}=#{value}&#{memo}"
0
       end.chop
0
       
0
- URI.parse(endpoint + query_string)
0
+ URI.parse(endpoint + query_string).instance_eval do
1
+ @format = format; def format; @format; end
0
+ self
0
+ end
0
     end
0
     
0
     def raw(url, options = {})
0
@@ -43,13 +46,13 @@ module OEmbed
0
       
0
       case res
0
       when Net::HTTPNotImplemented
0
- raise OEmbed::UnknownFormat, "The provider doesn't support the '#{format}' format"
0
+ raise OEmbed::UnknownFormat, uri.format
0
       when Net::HTTPNotFound
0
- raise OEmbed::NotFound, "No embeddable content at '#{url}'"
0
+ raise OEmbed::NotFound, url
0
       when Net::HTTPOK
0
         res.body
0
       else
0
- raise OEmbed::UnknownResponse, "Got unkown response (#{res.code}) from server"
0
+ raise OEmbed::UnknownResponse, res.code
0
       end
0
     end
0
     

Comments