tinder 1.7.0 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/faraday/response/raise_on_authentication_failure.rb +1 -1
- data/lib/tinder.rb +1 -0
- data/lib/tinder/campfire.rb +2 -2
- data/lib/tinder/connection.rb +14 -11
- data/lib/tinder/version.rb +1 -1
- data/spec/tinder/connection_spec.rb +25 -0
- data/tinder.gemspec +1 -1
- metadata +193 -114
@@ -4,7 +4,7 @@ require 'faraday'
|
|
4
4
|
module Faraday
|
5
5
|
class Response::RaiseOnAuthenticationFailure < Response::Middleware
|
6
6
|
def on_complete(response)
|
7
|
-
raise Tinder::AuthenticationFailed if response[:status]
|
7
|
+
raise Tinder::AuthenticationFailed if [401, 404].include?(response[:status])
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
data/lib/tinder.rb
CHANGED
data/lib/tinder/campfire.rb
CHANGED
@@ -19,8 +19,8 @@ module Tinder
|
|
19
19
|
# == Options:
|
20
20
|
# * +:ssl+: use SSL for the connection, which is required if you have a Campfire SSL account.
|
21
21
|
# Defaults to true
|
22
|
-
# * +:
|
23
|
-
# Defaults to true
|
22
|
+
# * +:ssl_options+: SSL options passed to the underlaying Faraday connection. Allows to specify if the SSL certificate should be verified (:verify => true|false) and to specify the path to the ssl certs directory (:ca_path => "path/certs")
|
23
|
+
# Defaults to {:verify => true}
|
24
24
|
# * +:proxy+: a proxy URI. (e.g. :proxy => 'http://user:pass@example.com:8000')
|
25
25
|
#
|
26
26
|
# c = Tinder::Campfire.new("mysubdomain", :ssl => true)
|
data/lib/tinder/connection.rb
CHANGED
@@ -35,7 +35,9 @@ module Tinder
|
|
35
35
|
|
36
36
|
def initialize(subdomain, options = {})
|
37
37
|
@subdomain = subdomain
|
38
|
-
@options = {:ssl => true, :
|
38
|
+
@options = {:ssl => true, :ssl_options => {:verify => true}, :proxy => ENV['HTTP_PROXY']}
|
39
|
+
@options[:ssl_options][:verify] = options.delete(:ssl_verify) unless options[:ssl_verify].nil?
|
40
|
+
@options.merge!(options)
|
39
41
|
@uri = URI.parse("#{@options[:ssl] ? 'https' : 'http' }://#{subdomain}.#{HOST}")
|
40
42
|
@token = options[:token]
|
41
43
|
|
@@ -50,11 +52,7 @@ module Tinder
|
|
50
52
|
def connection
|
51
53
|
@connection ||= begin
|
52
54
|
conn = self.class.connection.dup
|
53
|
-
conn
|
54
|
-
conn.proxy options[:proxy]
|
55
|
-
if options[:ssl_verify] == false
|
56
|
-
conn.ssl[:verify] = false
|
57
|
-
end
|
55
|
+
set_connection_options(conn)
|
58
56
|
conn
|
59
57
|
end
|
60
58
|
end
|
@@ -62,11 +60,7 @@ module Tinder
|
|
62
60
|
def raw_connection
|
63
61
|
@raw_connection ||= begin
|
64
62
|
conn = self.class.raw_connection.dup
|
65
|
-
conn
|
66
|
-
conn.proxy options[:proxy]
|
67
|
-
if options[:ssl_verify] == false
|
68
|
-
conn.ssl[:verify] = false
|
69
|
-
end
|
63
|
+
set_connection_options(conn)
|
70
64
|
conn
|
71
65
|
end
|
72
66
|
end
|
@@ -101,5 +95,14 @@ module Tinder
|
|
101
95
|
def ssl?
|
102
96
|
uri.scheme == 'https'
|
103
97
|
end
|
98
|
+
|
99
|
+
private
|
100
|
+
def set_connection_options(conn)
|
101
|
+
conn.url_prefix = @uri.to_s
|
102
|
+
conn.proxy options[:proxy]
|
103
|
+
if options[:ssl_options]
|
104
|
+
conn.ssl.merge!(options[:ssl_options])
|
105
|
+
end
|
106
|
+
end
|
104
107
|
end
|
105
108
|
end
|
data/lib/tinder/version.rb
CHANGED
@@ -12,6 +12,15 @@ describe Tinder::Connection do
|
|
12
12
|
lambda { connection.get('/rooms.json') }.should raise_error(Tinder::AuthenticationFailed)
|
13
13
|
end
|
14
14
|
|
15
|
+
it "should raise an exception when an invalid subdomain is specified" do
|
16
|
+
stub_connection(Tinder::Connection) do |stub|
|
17
|
+
stub.get("/rooms.json") {[404, {}, "Not found"]}
|
18
|
+
end
|
19
|
+
|
20
|
+
connection = Tinder::Connection.new('test', :token => 'foo')
|
21
|
+
lambda { connection.get('/rooms.json') }.should raise_error(Tinder::AuthenticationFailed)
|
22
|
+
end
|
23
|
+
|
15
24
|
it "should lookup token when username/password provided" do
|
16
25
|
stub_connection(Tinder::Connection) do |stub|
|
17
26
|
stub.get("/users/me.json") {[200, {}, fixture('users/me.json')]}
|
@@ -48,5 +57,21 @@ describe Tinder::Connection do
|
|
48
57
|
connection = Tinder::Connection.new('test', :username => 'user', :password => 'pass', :ssl_verify => false)
|
49
58
|
connection.connection.ssl[:verify].should be == false
|
50
59
|
end
|
60
|
+
|
61
|
+
it "should allow passing any ssl_options to Faraday" do
|
62
|
+
stub_connection(Tinder::Connection) do |stub|
|
63
|
+
stub.get("/users/me.json") {[200, {}, fixture('users/me.json')]}
|
64
|
+
end
|
65
|
+
connection = Tinder::Connection.new('test',
|
66
|
+
:username => 'user',
|
67
|
+
:password => 'pass',
|
68
|
+
:ssl_options => {
|
69
|
+
:verify => false,
|
70
|
+
:ca_path => "/usr/lib/ssl/certs",
|
71
|
+
:ca_file => "/etc/ssl/custom"
|
72
|
+
}
|
73
|
+
)
|
74
|
+
connection.connection.ssl.should eql(:verify => false, :ca_path => "/usr/lib/ssl/certs", :ca_file => "/etc/ssl/custom")
|
75
|
+
end
|
51
76
|
end
|
52
77
|
end
|
data/tinder.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.add_runtime_dependency 'multipart-post', '~> 1.1'
|
17
17
|
gem.add_runtime_dependency 'twitter-stream', '~> 0.1'
|
18
18
|
|
19
|
-
gem.authors = ["Brandon Keepers"]
|
19
|
+
gem.authors = ["Brandon Keepers", "Brian Ryckbost"]
|
20
20
|
gem.description = %q{A Ruby API for interfacing with Campfire, the 37Signals chat application.}
|
21
21
|
gem.email = ['brandon@opensoul.org']
|
22
22
|
gem.extra_rdoc_files = ['README.markdown']
|
metadata
CHANGED
@@ -1,165 +1,233 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: tinder
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 55
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 8
|
9
|
+
- 0
|
10
|
+
version: 1.8.0
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Brandon Keepers
|
14
|
+
- Brian Ryckbost
|
9
15
|
autorequire:
|
10
16
|
bindir: bin
|
11
17
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
18
|
+
|
19
|
+
date: 2011-11-16 00:00:00 Z
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
15
22
|
name: fakeweb
|
16
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
25
|
none: false
|
18
|
-
requirements:
|
26
|
+
requirements:
|
19
27
|
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 9
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 3
|
33
|
+
version: "1.3"
|
22
34
|
type: :development
|
23
|
-
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
26
37
|
name: rake
|
27
|
-
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
40
|
none: false
|
29
|
-
requirements:
|
41
|
+
requirements:
|
30
42
|
- - ~>
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 27
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
- 8
|
48
|
+
version: "0.8"
|
33
49
|
type: :development
|
34
|
-
|
35
|
-
|
36
|
-
- !ruby/object:Gem::Dependency
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
37
52
|
name: rspec
|
38
|
-
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
39
55
|
none: false
|
40
|
-
requirements:
|
56
|
+
requirements:
|
41
57
|
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 15
|
60
|
+
segments:
|
61
|
+
- 2
|
62
|
+
- 6
|
63
|
+
version: "2.6"
|
44
64
|
type: :development
|
45
|
-
|
46
|
-
|
47
|
-
- !ruby/object:Gem::Dependency
|
65
|
+
version_requirements: *id003
|
66
|
+
- !ruby/object:Gem::Dependency
|
48
67
|
name: activesupport
|
49
|
-
|
68
|
+
prerelease: false
|
69
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
50
70
|
none: false
|
51
|
-
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 5
|
75
|
+
segments:
|
76
|
+
- 2
|
77
|
+
- 3
|
78
|
+
version: "2.3"
|
55
79
|
- - <
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
hash: 11
|
82
|
+
segments:
|
83
|
+
- 4
|
84
|
+
version: "4"
|
58
85
|
type: :runtime
|
59
|
-
|
60
|
-
|
61
|
-
- !ruby/object:Gem::Dependency
|
86
|
+
version_requirements: *id004
|
87
|
+
- !ruby/object:Gem::Dependency
|
62
88
|
name: eventmachine
|
63
|
-
|
89
|
+
prerelease: false
|
90
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
64
91
|
none: false
|
65
|
-
requirements:
|
92
|
+
requirements:
|
66
93
|
- - ~>
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
hash: 19
|
96
|
+
segments:
|
97
|
+
- 0
|
98
|
+
- 12
|
99
|
+
version: "0.12"
|
69
100
|
type: :runtime
|
70
|
-
|
71
|
-
|
72
|
-
- !ruby/object:Gem::Dependency
|
101
|
+
version_requirements: *id005
|
102
|
+
- !ruby/object:Gem::Dependency
|
73
103
|
name: faraday
|
74
|
-
|
104
|
+
prerelease: false
|
105
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
75
106
|
none: false
|
76
|
-
requirements:
|
77
|
-
- -
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
hash: 7
|
111
|
+
segments:
|
112
|
+
- 0
|
113
|
+
- 6
|
114
|
+
version: "0.6"
|
80
115
|
- - <
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
hash: 27
|
118
|
+
segments:
|
119
|
+
- 0
|
120
|
+
- 8
|
121
|
+
version: "0.8"
|
83
122
|
type: :runtime
|
84
|
-
|
85
|
-
|
86
|
-
- !ruby/object:Gem::Dependency
|
123
|
+
version_requirements: *id006
|
124
|
+
- !ruby/object:Gem::Dependency
|
87
125
|
name: faraday_middleware
|
88
|
-
|
126
|
+
prerelease: false
|
127
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
89
128
|
none: false
|
90
|
-
requirements:
|
91
|
-
- -
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
hash: 7
|
133
|
+
segments:
|
134
|
+
- 0
|
135
|
+
- 6
|
136
|
+
version: "0.6"
|
94
137
|
- - <
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
hash: 27
|
140
|
+
segments:
|
141
|
+
- 0
|
142
|
+
- 8
|
143
|
+
version: "0.8"
|
97
144
|
type: :runtime
|
98
|
-
|
99
|
-
|
100
|
-
- !ruby/object:Gem::Dependency
|
145
|
+
version_requirements: *id007
|
146
|
+
- !ruby/object:Gem::Dependency
|
101
147
|
name: hashie
|
102
|
-
|
148
|
+
prerelease: false
|
149
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
103
150
|
none: false
|
104
|
-
requirements:
|
151
|
+
requirements:
|
105
152
|
- - ~>
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
hash: 15
|
155
|
+
segments:
|
156
|
+
- 1
|
157
|
+
- 0
|
158
|
+
version: "1.0"
|
108
159
|
type: :runtime
|
109
|
-
|
110
|
-
|
111
|
-
- !ruby/object:Gem::Dependency
|
160
|
+
version_requirements: *id008
|
161
|
+
- !ruby/object:Gem::Dependency
|
112
162
|
name: mime-types
|
113
|
-
|
163
|
+
prerelease: false
|
164
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
114
165
|
none: false
|
115
|
-
requirements:
|
166
|
+
requirements:
|
116
167
|
- - ~>
|
117
|
-
- !ruby/object:Gem::Version
|
118
|
-
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
hash: 47
|
170
|
+
segments:
|
171
|
+
- 1
|
172
|
+
- 16
|
173
|
+
version: "1.16"
|
119
174
|
type: :runtime
|
120
|
-
|
121
|
-
|
122
|
-
- !ruby/object:Gem::Dependency
|
175
|
+
version_requirements: *id009
|
176
|
+
- !ruby/object:Gem::Dependency
|
123
177
|
name: multi_json
|
124
|
-
|
178
|
+
prerelease: false
|
179
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
125
180
|
none: false
|
126
|
-
requirements:
|
181
|
+
requirements:
|
127
182
|
- - ~>
|
128
|
-
- !ruby/object:Gem::Version
|
129
|
-
|
183
|
+
- !ruby/object:Gem::Version
|
184
|
+
hash: 15
|
185
|
+
segments:
|
186
|
+
- 1
|
187
|
+
- 0
|
188
|
+
version: "1.0"
|
130
189
|
type: :runtime
|
131
|
-
|
132
|
-
|
133
|
-
- !ruby/object:Gem::Dependency
|
190
|
+
version_requirements: *id010
|
191
|
+
- !ruby/object:Gem::Dependency
|
134
192
|
name: multipart-post
|
135
|
-
|
193
|
+
prerelease: false
|
194
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
136
195
|
none: false
|
137
|
-
requirements:
|
196
|
+
requirements:
|
138
197
|
- - ~>
|
139
|
-
- !ruby/object:Gem::Version
|
140
|
-
|
198
|
+
- !ruby/object:Gem::Version
|
199
|
+
hash: 13
|
200
|
+
segments:
|
201
|
+
- 1
|
202
|
+
- 1
|
203
|
+
version: "1.1"
|
141
204
|
type: :runtime
|
142
|
-
|
143
|
-
|
144
|
-
- !ruby/object:Gem::Dependency
|
205
|
+
version_requirements: *id011
|
206
|
+
- !ruby/object:Gem::Dependency
|
145
207
|
name: twitter-stream
|
146
|
-
|
208
|
+
prerelease: false
|
209
|
+
requirement: &id012 !ruby/object:Gem::Requirement
|
147
210
|
none: false
|
148
|
-
requirements:
|
211
|
+
requirements:
|
149
212
|
- - ~>
|
150
|
-
- !ruby/object:Gem::Version
|
151
|
-
|
213
|
+
- !ruby/object:Gem::Version
|
214
|
+
hash: 9
|
215
|
+
segments:
|
216
|
+
- 0
|
217
|
+
- 1
|
218
|
+
version: "0.1"
|
152
219
|
type: :runtime
|
153
|
-
|
154
|
-
version_requirements: *70192463348020
|
220
|
+
version_requirements: *id012
|
155
221
|
description: A Ruby API for interfacing with Campfire, the 37Signals chat application.
|
156
|
-
email:
|
222
|
+
email:
|
157
223
|
- brandon@opensoul.org
|
158
224
|
executables: []
|
225
|
+
|
159
226
|
extensions: []
|
160
|
-
|
227
|
+
|
228
|
+
extra_rdoc_files:
|
161
229
|
- README.markdown
|
162
|
-
files:
|
230
|
+
files:
|
163
231
|
- .gemtest
|
164
232
|
- .gitignore
|
165
233
|
- .rspec
|
@@ -191,29 +259,40 @@ files:
|
|
191
259
|
- tinder.gemspec
|
192
260
|
homepage: http://github.com/collectiveidea/tinder
|
193
261
|
licenses: []
|
262
|
+
|
194
263
|
post_install_message:
|
195
264
|
rdoc_options: []
|
196
|
-
|
265
|
+
|
266
|
+
require_paths:
|
197
267
|
- lib
|
198
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
268
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
199
269
|
none: false
|
200
|
-
requirements:
|
201
|
-
- -
|
202
|
-
- !ruby/object:Gem::Version
|
203
|
-
|
204
|
-
|
270
|
+
requirements:
|
271
|
+
- - ">="
|
272
|
+
- !ruby/object:Gem::Version
|
273
|
+
hash: 3
|
274
|
+
segments:
|
275
|
+
- 0
|
276
|
+
version: "0"
|
277
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
205
278
|
none: false
|
206
|
-
requirements:
|
207
|
-
- -
|
208
|
-
- !ruby/object:Gem::Version
|
279
|
+
requirements:
|
280
|
+
- - ">="
|
281
|
+
- !ruby/object:Gem::Version
|
282
|
+
hash: 23
|
283
|
+
segments:
|
284
|
+
- 1
|
285
|
+
- 3
|
286
|
+
- 6
|
209
287
|
version: 1.3.6
|
210
288
|
requirements: []
|
289
|
+
|
211
290
|
rubyforge_project:
|
212
|
-
rubygems_version: 1.8.
|
291
|
+
rubygems_version: 1.8.10
|
213
292
|
signing_key:
|
214
293
|
specification_version: 3
|
215
294
|
summary: Ruby wrapper for the Campfire API
|
216
|
-
test_files:
|
295
|
+
test_files:
|
217
296
|
- spec/fixtures/rooms.json
|
218
297
|
- spec/fixtures/rooms/room80749.json
|
219
298
|
- spec/fixtures/rooms/room80751.json
|