twilio-ruby 3.2.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/.gitignore +5 -0
  2. data/Gemfile +3 -0
  3. data/README.md +70 -6
  4. data/README.rdoc +0 -0
  5. data/lib/twilio-ruby/rest/{accounts/account.rb → accounts.rb} +2 -0
  6. data/lib/twilio-ruby/rest/{applications/application.rb → applications.rb} +1 -0
  7. data/lib/twilio-ruby/rest/{available_phone_numbers/available_phone_numbers.rb → available_phone_numbers.rb} +2 -0
  8. data/lib/twilio-ruby/rest/{calls/call.rb → calls.rb} +6 -0
  9. data/lib/twilio-ruby/rest/client.rb +140 -27
  10. data/lib/twilio-ruby/rest/conferences/participants.rb +18 -1
  11. data/lib/twilio-ruby/rest/{conferences/conference.rb → conferences.rb} +2 -0
  12. data/lib/twilio-ruby/rest/{incoming_phone_numbers/incoming_phone_numbers.rb → incoming_phone_numbers.rb} +2 -0
  13. data/lib/twilio-ruby/rest/instance_resource.rb +39 -0
  14. data/lib/twilio-ruby/rest/list_resource.rb +67 -7
  15. data/lib/twilio-ruby/rest/{notifications/notification.rb → notifications.rb} +1 -0
  16. data/lib/twilio-ruby/rest/{outgoing_caller_ids/outgoing_caller_ids.rb → outgoing_caller_ids.rb} +2 -0
  17. data/lib/twilio-ruby/rest/{recordings/recording.rb → recordings.rb} +2 -2
  18. data/lib/twilio-ruby/rest/{sandbox/sandbox.rb → sandbox.rb} +0 -0
  19. data/lib/twilio-ruby/rest/sms/messages.rb +2 -0
  20. data/lib/twilio-ruby/rest/sms/short_codes.rb +1 -0
  21. data/lib/twilio-ruby/rest/{sms/sms.rb → sms.rb} +0 -0
  22. data/lib/twilio-ruby/rest/{transcriptions/transcription.rb → transcriptions.rb} +1 -0
  23. data/lib/twilio-ruby/version.rb +3 -0
  24. data/lib/twilio-ruby.rb +29 -44
  25. data/test/twilio_spec.rb +141 -4
  26. data/twilio-ruby.gemspec +25 -11
  27. metadata +178 -84
  28. data/lib/twilio-ruby/rest/accounts/accounts.rb +0 -5
  29. data/lib/twilio-ruby/rest/applications/applications.rb +0 -5
  30. data/lib/twilio-ruby/rest/available_phone_numbers/available_phone_number.rb +0 -5
  31. data/lib/twilio-ruby/rest/calls/calls.rb +0 -10
  32. data/lib/twilio-ruby/rest/conferences/conferences.rb +0 -5
  33. data/lib/twilio-ruby/rest/conferences/participant.rb +0 -17
  34. data/lib/twilio-ruby/rest/incoming_phone_numbers/incoming_phone_number.rb +0 -5
  35. data/lib/twilio-ruby/rest/notifications/notifications.rb +0 -5
  36. data/lib/twilio-ruby/rest/outgoing_caller_ids/outgoing_caller_id.rb +0 -5
  37. data/lib/twilio-ruby/rest/recordings/recordings.rb +0 -5
  38. data/lib/twilio-ruby/rest/sms/message.rb +0 -5
  39. data/lib/twilio-ruby/rest/sms/short_code.rb +0 -5
  40. data/lib/twilio-ruby/rest/transcriptions/transcriptions.rb +0 -5
@@ -8,28 +8,88 @@ module Twilio
8
8
  @instance_class = Twilio::REST.const_get @resource_name.chop
9
9
  @uri, @client = uri, client
10
10
  end
11
-
12
- # Grab a list of this kind of resource and return it as an array.
11
+
12
+ def inspect # :nodoc:
13
+ "<#{self.class} @uri=#{@uri}>"
14
+ end
15
+
16
+ ##
17
+ # Grab a list of this kind of resource and return it as an array. The
18
+ # array includes a special attribute named +total+ which will return the
19
+ # total number of items in the list on Twilio's server. This may differ
20
+ # from the +size+ and +length+ attributes of the returned array since
21
+ # by default Twilio will only return 50 resources, and the maximum number
22
+ # of resources you can request is 1000.
23
+ #
24
+ # The optional +params+ hash allows you to filter the list returned. The
25
+ # filters for each list resource type are defined by Twilio
13
26
  def list(params = {})
14
27
  raise "Can't get a resource list without a REST Client" unless @client
15
28
  response = @client.get @uri, params
16
29
  resources = response[detwilify(@resource_name)]
17
- resources.map do |resource|
18
- @instance_class.new "#{@uri}/#{resource['sid']}", @client, resource
30
+ resource_list = resources.map do |resource|
31
+ @instance_class.new "#{@uri}/#{resource[instance_sid_key]}", @client,
32
+ resource
19
33
  end
34
+ # set the +total+ property on the array
35
+ resource_list.instance_eval {
36
+ eigenclass = class << self; self; end
37
+ eigenclass.send :define_method, :total, &lambda {response['total']}
38
+ }
39
+ # update the list's internal total if we just fetched the whole list
40
+ @total = response['total'] if params.empty?
41
+ resource_list
20
42
  end
21
43
 
22
- # Return an empty instance resource object with the proper URI.
44
+ ##
45
+ # Ask Twilio for the total number of items in the list and cache it.
46
+ # Calling this method makes an HTTP GET request to <tt>@uri</tt> with a
47
+ # page size parameter of 1 to minimize data over the wire while still
48
+ # obtaining the total. Don't use this or #total if you are planning to
49
+ # call #list anyway, since the array returned from #list will have a
50
+ # +total+ attribute as well.
51
+ def total!
52
+ raise "Can't get a resource total without a REST Client" unless @client
53
+ response = @client.get @uri, :page_size => 1
54
+ @total = response['total']
55
+ end
56
+
57
+ ##
58
+ # Return the cached total number of items in the list, or fetch and cache.
59
+ def total
60
+ @total ||= total!
61
+ end
62
+
63
+ ##
64
+ # Return an empty instance resource object with the proper URI. Note that
65
+ # this will never raise a Twilio::REST::RequestError on 404 since no HTTP
66
+ # request is made. The HTTP request is made when attempting to access an
67
+ # attribute of the returned instance resource object, such as
68
+ # its #date_created or #voice_url attributes.
23
69
  def get(sid)
24
70
  @instance_class.new "#{@uri}/#{sid}", @client
25
71
  end
26
-
27
- # Return a newly created resource.
72
+ alias :find :get # for the ActiveRecord lovers
73
+
74
+ ##
75
+ # Return a newly created resource. Some +params+ may be required. Consult
76
+ # the Twilio REST API documentation related to the kind of resource you
77
+ # are attempting to create for details. Calling this method makes an HTTP
78
+ # POST request to <tt>@uri</tt> with the given params
28
79
  def create(params = {})
29
80
  raise "Can't create a resource without a REST Client" unless @client
30
81
  response = @client.post @uri, params
31
82
  @instance_class.new "#{@uri}/#{response['sid']}", @client, response
32
83
  end
84
+
85
+ private
86
+
87
+ ##
88
+ # Return the JSON key containing the sid of each instance. Overridden for
89
+ # conference participants and perhaps other resources.
90
+ def instance_sid_key
91
+ 'sid'
92
+ end
33
93
  end
34
94
  end
35
95
  end
@@ -1,5 +1,6 @@
1
1
  module Twilio
2
2
  module REST
3
+ class Notifications < ListResource; end
3
4
  class Notification < InstanceResource; end
4
5
  end
5
6
  end
@@ -5,5 +5,7 @@ module Twilio
5
5
  create :phone_number => phone_number
6
6
  end
7
7
  end
8
+
9
+ class OutgoingCallerId < InstanceResource; end
8
10
  end
9
11
  end
@@ -1,12 +1,12 @@
1
1
  module Twilio
2
2
  module REST
3
- class Recording < InstanceResource
3
+ class Recordings < ListResource; end
4
4
 
5
+ class Recording < InstanceResource
5
6
  def initialize(uri, client, params={})
6
7
  super uri, client, params
7
8
  resource :transcriptions
8
9
  end
9
-
10
10
  end
11
11
  end
12
12
  end
@@ -7,5 +7,7 @@ module Twilio
7
7
  @resource_name = 'sms_messages'
8
8
  end
9
9
  end
10
+
11
+ class Message < InstanceResource; end
10
12
  end
11
13
  end
@@ -1,5 +1,6 @@
1
1
  module Twilio
2
2
  module REST
3
3
  class ShortCodes < ListResource; end
4
+ class ShortCode < InstanceResource; end
4
5
  end
5
6
  end
File without changes
@@ -1,5 +1,6 @@
1
1
  module Twilio
2
2
  module REST
3
+ class Transcriptions < ListResource; end
3
4
  class Transcription < InstanceResource; end
4
5
  end
5
6
  end
@@ -0,0 +1,3 @@
1
+ module Twilio
2
+ VERSION = '3.3.0'
3
+ end
data/lib/twilio-ruby.rb CHANGED
@@ -1,52 +1,37 @@
1
- TWILIO_RUBY_ROOT = File.expand_path(File.dirname(__FILE__))
2
-
3
1
  require 'net/http'
4
2
  require 'net/https'
5
3
  require 'builder'
6
- require 'json'
4
+ require 'multi_json'
7
5
  require 'cgi'
8
6
  require 'openssl'
9
7
  require 'base64'
10
8
  require 'jwt'
11
9
 
12
-
13
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/util"
14
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/util/request_validator"
15
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/util/capability"
16
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/errors"
17
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/utils"
18
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/list_resource"
19
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/instance_resource"
20
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/sandbox/sandbox"
21
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/accounts/account"
22
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/accounts/accounts"
23
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/calls/call"
24
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/calls/calls"
25
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/sms/sms"
26
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/sms/message"
27
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/sms/messages"
28
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/sms/short_code"
29
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/sms/short_codes"
30
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/applications/application"
31
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/applications/applications"
32
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/outgoing_caller_ids/outgoing_caller_id"
33
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/outgoing_caller_ids/outgoing_caller_ids"
34
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/incoming_phone_numbers/incoming_phone_number"
35
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/incoming_phone_numbers/incoming_phone_numbers"
36
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/available_phone_numbers/available_phone_number"
37
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/available_phone_numbers/available_phone_numbers"
38
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/available_phone_numbers/country"
39
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/available_phone_numbers/local"
40
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/available_phone_numbers/toll_free"
41
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/conferences/conference"
42
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/conferences/conferences"
43
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/conferences/participant"
44
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/conferences/participants"
45
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/recordings/recording"
46
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/recordings/recordings"
47
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/transcriptions/transcription"
48
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/transcriptions/transcriptions"
49
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/notifications/notification"
50
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/notifications/notifications"
51
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/client"
52
- require "#{TWILIO_RUBY_ROOT}/twilio-ruby/twiml/response"
10
+ require 'twilio-ruby/version'
11
+ require 'twilio-ruby/util'
12
+ require 'twilio-ruby/util/request_validator'
13
+ require 'twilio-ruby/util/capability'
14
+ require 'twilio-ruby/twiml/response'
15
+ require 'twilio-ruby/rest/errors'
16
+ require 'twilio-ruby/rest/utils'
17
+ require 'twilio-ruby/rest/list_resource'
18
+ require 'twilio-ruby/rest/instance_resource'
19
+ require 'twilio-ruby/rest/sandbox'
20
+ require 'twilio-ruby/rest/accounts'
21
+ require 'twilio-ruby/rest/calls'
22
+ require 'twilio-ruby/rest/sms'
23
+ require 'twilio-ruby/rest/sms/messages'
24
+ require 'twilio-ruby/rest/sms/short_codes'
25
+ require 'twilio-ruby/rest/applications'
26
+ require 'twilio-ruby/rest/outgoing_caller_ids'
27
+ require 'twilio-ruby/rest/incoming_phone_numbers'
28
+ require 'twilio-ruby/rest/available_phone_numbers'
29
+ require 'twilio-ruby/rest/available_phone_numbers/country'
30
+ require 'twilio-ruby/rest/available_phone_numbers/local'
31
+ require 'twilio-ruby/rest/available_phone_numbers/toll_free'
32
+ require 'twilio-ruby/rest/conferences'
33
+ require 'twilio-ruby/rest/conferences/participants'
34
+ require 'twilio-ruby/rest/recordings'
35
+ require 'twilio-ruby/rest/transcriptions'
36
+ require 'twilio-ruby/rest/notifications'
37
+ require 'twilio-ruby/rest/client'
data/test/twilio_spec.rb CHANGED
@@ -1,6 +1,7 @@
1
- require 'rubygems'
1
+ $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
2
2
  require 'twilio-ruby'
3
3
  require 'fakeweb'
4
+ require 'rack'
4
5
 
5
6
  describe Twilio::REST::Client do
6
7
  before :all do
@@ -21,14 +22,14 @@ describe Twilio::REST::Client do
21
22
  end
22
23
 
23
24
  it 'should set up the proper http ssl connection when a different domain is given' do
24
- twilio = Twilio::REST::Client.new('someSid', 'someToken', 'api.faketwilio.com')
25
+ twilio = Twilio::REST::Client.new('someSid', 'someToken', :host => 'api.faketwilio.com')
25
26
  twilio.instance_variable_get('@connection').address.should == 'api.faketwilio.com'
26
27
  twilio.instance_variable_get('@connection').port.should == 443
27
28
  twilio.instance_variable_get('@connection').use_ssl?.should == true
28
29
  end
29
30
 
30
31
  it 'should set up the proper http ssl connection when a proxy_host is given' do
31
- twilio = Twilio::REST::Client.new('someSid', 'someToken', 'api.faketwilio.com', 'localhost')
32
+ twilio = Twilio::REST::Client.new('someSid', 'someToken', :host => 'api.faketwilio.com', :proxy_addr => 'localhost')
32
33
  twilio.instance_variable_get('@connection').proxy?.should == true
33
34
  twilio.instance_variable_get('@connection').proxy_address.should == 'localhost'
34
35
  twilio.instance_variable_get('@connection').proxy_port.should == 80
@@ -38,7 +39,7 @@ describe Twilio::REST::Client do
38
39
  end
39
40
 
40
41
  it 'should set up the proper http ssl connection when a proxy_host and proxy_port are given' do
41
- twilio = Twilio::REST::Client.new('someSid', 'someToken', 'api.faketwilio.com', 'localhost', 13128)
42
+ twilio = Twilio::REST::Client.new('someSid', 'someToken', :host => 'api.faketwilio.com', :proxy_addr => 'localhost', :proxy_port => 13128)
42
43
  twilio.instance_variable_get('@connection').proxy?.should == true
43
44
  twilio.instance_variable_get('@connection').proxy_address.should == 'localhost'
44
45
  twilio.instance_variable_get('@connection').proxy_port.should == 13128
@@ -208,3 +209,139 @@ describe Twilio::Util::RequestValidator do
208
209
  validator.validate(url, params, signature).should == true
209
210
  end
210
211
  end
212
+
213
+ describe Twilio::Util::Capability do
214
+ before :each do
215
+ @capability = Twilio::Util::Capability.new 'myAccountSid', 'myAuthToken'
216
+ end
217
+
218
+ def queries(q)
219
+ q.scan(/scope:client:(incoming|outgoing)\?(\S+)/).map{|(type, query)| [type, Rack::Utils.parse_query(query)]}
220
+ end
221
+
222
+ it 'should return a valid jwt when #generate is called' do
223
+ token = @capability.generate
224
+ decoded = JWT.decode token, 'myAuthToken'
225
+ decoded['scope'].should_not be_nil
226
+ decoded['iss'].should_not be_nil
227
+ decoded['exp'].should_not be_nil
228
+ end
229
+
230
+ it 'should properly set the iss key in the payload' do
231
+ token = @capability.generate
232
+ decoded = JWT.decode token, 'myAuthToken'
233
+ decoded['iss'].should == 'myAccountSid'
234
+ end
235
+
236
+ it 'should properly set the exp key based on the default hour ttl' do
237
+ seconds = Time.now.to_i
238
+ token = @capability.generate
239
+ decoded = JWT.decode token, 'myAuthToken'
240
+ decoded['exp'].should == seconds + 3600
241
+ end
242
+
243
+ it 'should properly set the exp key based on the ttl passed to #generate' do
244
+ ttl = rand 10000
245
+ seconds = Time.now.to_i
246
+ token = @capability.generate ttl
247
+ decoded = JWT.decode token, 'myAuthToken'
248
+ decoded['exp'].should == seconds + ttl
249
+ end
250
+
251
+ it 'should generate a proper incoming client scope string' do
252
+ @capability.allow_client_incoming 'andrew'
253
+ token = @capability.generate
254
+ decoded = JWT.decode token, 'myAuthToken'
255
+ queries(decoded['scope']).should == [['incoming', {'clientName' => 'andrew'}]]
256
+ end
257
+
258
+ it 'should generate multiple proper incoming client scope strings' do
259
+ @capability.allow_client_incoming 'andrew'
260
+ @capability.allow_client_incoming 'bridget'
261
+ token = @capability.generate
262
+ decoded = JWT.decode token, 'myAuthToken'
263
+ queries(decoded['scope']).should == [
264
+ ['incoming', {'clientName' => 'andrew'}],
265
+ ['incoming', {'clientName' => 'bridget'}]
266
+ ]
267
+ end
268
+
269
+ it 'should generate a proper outgoing client scope string' do
270
+ @capability.allow_client_outgoing 'myAppSid'
271
+ token = @capability.generate
272
+ decoded = JWT.decode token, 'myAuthToken'
273
+ queries(decoded['scope']).should == [['outgoing', {'appSid' => 'myAppSid'}]]
274
+ end
275
+
276
+ it 'should generate a proper outgoing client scope string with parameters' do
277
+ app_params_hash = {'key' => 'a value', :foo => 'bar/baz'}
278
+ @capability.allow_client_outgoing 'myAppSid', app_params_hash
279
+ app_params = @capability.instance_eval {url_encode(app_params_hash)}
280
+ params_hash = {'appSid' => 'myAppSid', 'appParams' => app_params}
281
+ params = @capability.instance_eval {url_encode(params_hash)}
282
+ token = @capability.generate
283
+ decoded = JWT.decode token, 'myAuthToken'
284
+ queries(decoded['scope']).should == [['outgoing', params_hash]]
285
+ end
286
+
287
+ it 'should generate a proper outgoing client scope string based on the ' +
288
+ 'client name when calling #allow_client_incoming first' do
289
+ @capability.allow_client_incoming 'andrew'
290
+ @capability.allow_client_outgoing 'myAppSid'
291
+ token = @capability.generate
292
+ decoded = JWT.decode token, 'myAuthToken'
293
+ queries(decoded['scope']).should == [
294
+ ['incoming', {'clientName' => 'andrew'}],
295
+ ['outgoing', {'clientName' => 'andrew', 'appSid' => 'myAppSid'}]
296
+ ]
297
+ end
298
+
299
+ it 'should generate a proper outgoing client scope string based on the ' +
300
+ 'client name when calling #allow_client_incoming second' do
301
+ @capability.allow_client_outgoing 'myAppSid'
302
+ @capability.allow_client_incoming 'andrew'
303
+ token = @capability.generate
304
+ decoded = JWT.decode token, 'myAuthToken'
305
+ queries(decoded['scope']).should == [["incoming", {"clientName"=>"andrew"}], ["outgoing", {"clientName"=>"andrew", "appSid"=>"myAppSid"}]]
306
+ end
307
+
308
+ it 'should generate a proper outgoing client scope string with parameters ' +
309
+ 'and a client name when calling #allow_client_incoming first' do
310
+ @capability.allow_client_incoming 'andrew'
311
+ app_params_hash = {'key' => 'a value', :foo => 'bar/baz'}
312
+ @capability.allow_client_outgoing 'myAppSid', app_params_hash
313
+ app_params = @capability.instance_eval {url_encode(app_params_hash)}
314
+ params_hash = {'appSid' => 'myAppSid', 'appParams' => app_params, 'clientName' => 'andrew'}
315
+ params = @capability.instance_eval {url_encode(params_hash)}
316
+ token = @capability.generate
317
+ decoded = JWT.decode token, 'myAuthToken'
318
+ scopes = queries(decoded['scope'])
319
+ scopes.shift.should == ["incoming", {"clientName"=>"andrew"}]
320
+ scope = scopes.shift
321
+ scope.first.should == 'outgoing'
322
+ Rack::Utils.parse_query(scope.last['appParams']).should == {'key' => 'a value', 'foo' => 'bar/baz'}
323
+ scope.last["clientName"].should == "andrew"
324
+ scope.last["appSid"].should == "myAppSid"
325
+ scopes.should be_empty
326
+ end
327
+
328
+ it 'should generate a proper outgoing client scope string with parameters ' +
329
+ 'and a client name when calling #allow_client_incoming second' do
330
+ app_params_hash = {'key' => 'a value', :foo => 'bar/baz'}
331
+ @capability.allow_client_outgoing 'myAppSid', app_params_hash
332
+ @capability.allow_client_incoming 'andrew'
333
+ app_params = @capability.instance_eval {url_encode(app_params_hash)}
334
+ params_hash = {'appSid' => 'myAppSid', 'appParams' => app_params, 'clientName' => 'andrew'}
335
+ params = @capability.instance_eval {url_encode(params_hash)}
336
+ token = @capability.generate
337
+ decoded = JWT.decode token, 'myAuthToken'
338
+ scopes = queries(decoded['scope'])
339
+ scopes.shift.should == ["incoming", {"clientName"=>"andrew"}]
340
+ scope = scopes.shift
341
+ scope.first.should == 'outgoing'
342
+ Rack::Utils.parse_query(scope.last['appParams']).should == {'key' => 'a value', 'foo' => 'bar/baz'}
343
+ scope.last["clientName"].should == "andrew"
344
+ scope.last["appSid"].should == "myAppSid"
345
+ scopes.should be_empty
346
+ end
347
+ end
data/twilio-ruby.gemspec CHANGED
@@ -1,15 +1,29 @@
1
+ require 'lib/twilio-ruby/version'
2
+
1
3
  Gem::Specification.new do |s|
2
- s.name = "twilio-ruby"
3
- s.version = "3.2.0"
4
- s.author = "Andrew Benton"
5
- s.email = "andrew@twilio.com"
6
- s.description = "A simple library for communicating with the Twilio REST API, building TwiML, and generating Twilio Client Capability Tokens"
7
- s.summary = "A simple library for communicating with the Twilio REST API, building TwiML, and generating Twilio Client Capability Tokens"
8
- s.homepage = "http://github.com/twilio/twilio-ruby"
4
+ s.name = 'twilio-ruby'
5
+ s.version = Twilio::VERSION
6
+ s.author = 'Andrew Benton'
7
+ s.email = 'andrew@twilio.com'
8
+
9
+ s.description = 'A simple library for communicating with the Twilio REST API, building TwiML, and generating Twilio Client Capability Tokens'
10
+ s.summary = 'A simple library for communicating with the Twilio REST API, building TwiML, and generating Twilio Client Capability Tokens'
11
+ s.homepage = 'http://github.com/twilio/twilio-ruby'
12
+
9
13
  s.platform = Gem::Platform::RUBY
10
- s.files = Dir['lib/**/*.rb'] + Dir['test/**/*.rb'] + ['examples.rb', 'Rakefile', 'LICENSE', 'README.md', 'twilio-ruby.gemspec']
14
+ s.require_paths = %w[lib]
15
+ s.files = `git ls-files`.split("\n")
11
16
  s.test_files = Dir['test/**/*.rb']
12
- s.add_dependency("json", ">= 1.2.0")
13
- s.add_dependency("builder", ">= 2.1.2")
14
- s.add_dependency("jwt", ">= 0.1.2")
17
+
18
+ s.add_dependency('multi_json', '>= 1.0.3')
19
+ s.add_dependency('builder', '>= 2.1.2')
20
+ s.add_dependency('jwt', '>= 0.1.2')
21
+
22
+ s.add_development_dependency 'rake', '~> 0.9.0'
23
+ s.add_development_dependency 'rspec', '~> 2.6.0'
24
+ s.add_development_dependency 'fakeweb', '~> 1.3.0'
25
+ s.add_development_dependency 'rack', '~> 1.3.0'
26
+
27
+ s.extra_rdoc_files = ['README.md', 'README.rdoc', 'examples.rb', 'LICENSE']
28
+ s.rdoc_options = ['--line-numbers', '--inline-source', '--title', 'twilio-ruby', '--main', 'README.md']
15
29
  end