public
Description: Tinder is an Ruby API for interfacing with Campfire, the 37Signals chat application.
Homepage: http://tinder.rubyforge.org/
Clone URL: git://github.com/collectiveidea/tinder.git
Click here to lend your support to: tinder and make a donation at www.pledgie.com !
Added support for HTTP proxies
brandon (author)
Fri Apr 18 01:14:27 -0700 2008
commit  e99e0b698de2a66e7e7c08f9e4c9b8ffe83eacc8
tree    2b45afd3834cdd6a5540b4f913a51cc22e922ba3
parent  000a0432334d7660634d2031d0d25e6693303725
...
 
 
 
1
2
3
...
1
2
3
4
5
6
0
@@ -1,3 +1,6 @@
0
+0.1.7 - unreleased
0
+* Added support for HTTP proxies
0
+
0
 0.1.6 - 2008-03-07
0
 * Added Room#topic for getting the current topic [Even Weaver]
0
 * Trap INT in #listen(&block) [borrowed from Chris Shea's Pyre]
...
11
12
13
14
 
 
 
 
 
15
16
17
...
19
20
21
 
 
 
 
 
 
22
23
24
...
32
33
34
35
 
36
37
38
...
132
133
134
135
 
136
137
138
...
154
155
156
157
158
 
 
159
160
161
...
11
12
13
 
14
15
16
17
18
19
20
21
...
23
24
25
26
27
28
29
30
31
32
33
34
...
42
43
44
 
45
46
47
48
...
142
143
144
 
145
146
147
148
...
164
165
166
 
 
167
168
169
170
171
0
@@ -11,7 +11,11 @@ module Tinder
0
     attr_reader :subdomain, :uri
0
 
0
     # Create a new connection to the campfire account with the given +subdomain+.
0
-    # There's an +:ssl+ option to use SSL for the connection.
0
+    #
0
+    # == Options:
0
+    # * +:ssl+: use SSL for the connection, which is required if you have a Campfire SSL account.
0
+    #           Defaults to false
0
+    # * +:proxy+: a proxy URI. (e.g. :proxy => 'http://user:pass@example.com:8000')
0
     #
0
     #   c = Tinder::Campfire.new("mysubdomain", :ssl => true)
0
     def initialize(subdomain, options = {})
0
@@ -19,6 +23,12 @@ module Tinder
0
       @cookie = nil
0
       @subdomain = subdomain
0
       @uri = URI.parse("#{options[:ssl] ? 'https' : 'http' }://#{subdomain}.campfirenow.com")
0
+      if options[:proxy]
0
+        uri = URI.parse(options[:proxy])
0
+        @http = Net::HTTP::Proxy(uri.host, uri.port, uri.user, uri.password)
0
+      else
0
+        @http = Net::HTTP
0
+      end
0
       @logged_in = false
0
     end
0
     
0
@@ -32,7 +42,7 @@ module Tinder
0
     
0
     # Returns true when successfully logged in
0
     def logged_in?
0
-      @logged_in === true
0
+      @logged_in == true
0
     end
0
   
0
     def logout
0
@@ -132,7 +142,7 @@ module Tinder
0
     
0
     def perform_request(options = {}, &block)
0
       @request = prepare_request(yield, options)
0
-      http = Net::HTTP.new(uri.host, uri.port)
0
+      http = @http.new(uri.host, uri.port)
0
       http.use_ssl = ssl?
0
       http.verify_mode = OpenSSL::SSL::VERIFY_NONE if ssl?
0
       @response = returning http.request(@request) do |response|
0
@@ -154,8 +164,8 @@ module Tinder
0
     def verify_response(response, options = {})
0
       if options.is_a?(Symbol)
0
         codes = case options
0
-        when :success then [200]
0
-        when :redirect then 300..399
0
+        when :success; [200]
0
+        when :redirect; 300..399
0
         else raise ArgumentError.new("Unknown response #{options}")
0
         end
0
         codes.include?(response.code.to_i)

Comments