opentok 4.0.1 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d2fae46bf000803f799b735577710403ffce59964996cd8500d4fdb5120f91ad
4
- data.tar.gz: 685e27da471dca277ffb5fcf6208b36514d573d93d6e9f20b1ad228798ddf63b
3
+ metadata.gz: 348ea4d3600d65e0e68b7078f4b694144c1eb03410ef46dccf2b27f235fd4c34
4
+ data.tar.gz: 900521793c8e747b77b50a081a83328a004df84231a048f6f5b6e07a75d7bbbd
5
5
  SHA512:
6
- metadata.gz: 99452a3e40b21dc5d95a212e9784131933321c4423f46a85d89f4e6daad96cc9ad5c18c214267a457ad65f455abd84dddb6a1ddc08a163fbd388041d2224c756
7
- data.tar.gz: 7a404e42e30cbc7f3fcb36d220a85dd456781655660bb60ab13e1a845cc4f472d44705f77ce5e1886b150a6b301ffa2c9136683c2454ef2a3beb64517b511397
6
+ metadata.gz: ac9f2f38462314084442b364b63af518569bc1931ffd70300be797a295303648236c28cb910a88804b0d63cc110194ae30334c7ea1a4e25be7f0ccaa148c676a
7
+ data.tar.gz: aa8d99ffc987557ed346c3e9188057aa3239d77f88da4d94f09cb39c4283447a27bc0e39da2fff007095a8268bf9b14aed623d7748371a0d3385fa329cb91a2f
@@ -0,0 +1,128 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity
10
+ and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ - Demonstrating empathy and kindness toward other people
21
+ - Being respectful of differing opinions, viewpoints, and experiences
22
+ - Giving and gracefully accepting constructive feedback
23
+ - Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ - Focusing on what is best not just for us as individuals, but for the
26
+ overall community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ - The use of sexualized language or imagery, and sexual attention or
31
+ advances of any kind
32
+ - Trolling, insulting or derogatory comments, and personal or political attacks
33
+ - Public or private harassment
34
+ - Publishing others' private information, such as a physical or email
35
+ address, without their explicit permission
36
+ - Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ devrel@vonage.com.
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series
86
+ of actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or
93
+ permanent ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within
113
+ the community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.0, available at
119
+ https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120
+
121
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct
122
+ enforcement ladder](https://github.com/mozilla/diversity).
123
+
124
+ [homepage]: https://www.contributor-covenant.org
125
+
126
+ For answers to common questions about this code of conduct, see the FAQ at
127
+ https://www.contributor-covenant.org/faq. Translations are available at
128
+ https://www.contributor-covenant.org/translations.
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # OpenTok Ruby SDK
2
2
 
3
- [![Build Status](https://travis-ci.org/opentok/OpenTok-Ruby-SDK.png)](https://travis-ci.org/opentok/OpenTok-Ruby-SDK)
3
+ [![Build Status](https://travis-ci.org/opentok/OpenTok-Ruby-SDK.png)](https://travis-ci.org/opentok/OpenTok-Ruby-SDK) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)
4
+
5
+ <img src="https://assets.tokbox.com/img/vonage/Vonage_VideoAPI_black.svg" height="48px" alt="Tokbox is now known as Vonage" />
4
6
 
5
7
  The OpenTok Ruby SDK lets you generate
6
8
  [sessions](https://tokbox.com/developer/guides/create-session/) and
@@ -49,18 +51,32 @@ require "opentok"
49
51
  opentok = OpenTok::OpenTok.new api_key, api_secret
50
52
  ```
51
53
 
54
+ ### Initialization Options
55
+
56
+ You can specify a custom timeout value for HTTP requests when initializing a new `OpenTok::OpenTok`
57
+ object:
58
+
59
+ ```ruby
60
+ require "opentok"
61
+
62
+ opentok = OpenTok::OpenTok.new api_key, api_secret, :timeout_length => 10
63
+ ```
64
+
65
+ The value for `:timeout_length` is an integer representing the number of seconds to wait for an HTTP
66
+ request to complete. The default is set to 2 seconds.
67
+
52
68
  ## Creating Sessions
53
69
 
54
70
  To create an OpenTok Session, use the `OpenTok#create_session(properties)` method.
55
71
  The `properties` parameter is an optional Hash used to specify the following:
56
72
 
57
- * Whether the session uses the [OpenTok Media
73
+ - Whether the session uses the [OpenTok Media
58
74
  Router](https://tokbox.com/developer/guides/create-session/#media-mode),
59
75
  which is required for some OpenTok features (such as archiving)
60
76
 
61
- * A location hint for the OpenTok server.
77
+ - A location hint for the OpenTok server.
62
78
 
63
- * Whether the session is automatically archived.
79
+ - Whether the session is automatically archived.
64
80
 
65
81
  The `session_id` method of the returned `OpenTok::Session` instance is useful to
66
82
  get a sessionId that can be saved to a persistent store (such as a database).
@@ -108,11 +124,11 @@ token = session.generate_token({
108
124
  });
109
125
  ```
110
126
 
111
- ## Working with Streams
127
+ ## Working with Streams
112
128
 
113
129
  Use this method to get information for an OpenTok stream or for all streams in a session.
114
130
  For example, you can call this method to get information about layout classes used by an
115
- OpenTok stream.
131
+ OpenTok stream.
116
132
 
117
133
  To get information of a specific stream in a session, call
118
134
  `opentok.streams.find(session_id, stream_id)`. The return object is a `Stream` object and
@@ -139,8 +155,7 @@ expect(all_streams[0].layoutClassList[1]).to eq "focus"
139
155
  You can only archive sessions that use the OpenTok Media Router
140
156
  (sessions with the media mode set to routed).
141
157
 
142
- You can start the recording of an OpenTok Session using the `opentok.archives.create(session_id,
143
- options)` method. This will return an `OpenTok::Archive` instance. The parameter `options` is an
158
+ You can start the recording of an OpenTok Session using the `opentok.archives.create(session_id, options)` method. This will return an `OpenTok::Archive` instance. The parameter `options` is an
144
159
  optional Hash used to set the `has_audio`, `has_video`, and `name` options. Note that you can
145
160
  only start an Archive on a Session that has clients connected.
146
161
 
@@ -170,7 +185,7 @@ recorded to a single (composed) file.
170
185
 
171
186
  For composed archives you can set the resolution of the archive, either "640x480" (SD, the default)
172
187
  or "1280x720" (HD). The `resolution` parameter is optional and could be included in the options
173
- hash (second argument) of the `opentok.archives.create()` method.
188
+ hash (second argument) of the `opentok.archives.create()` method.
174
189
 
175
190
  ```ruby
176
191
  opts = {
@@ -262,15 +277,15 @@ opentok.archives.layout(archive_id, opts)
262
277
 
263
278
  The hash `opts` has two entries:
264
279
 
265
- * The `type` is the layout type for the archive. Valid values are "bestFit" (best fit)
280
+ - The `type` is the layout type for the archive. Valid values are "bestFit" (best fit)
266
281
  "custom" (custom), "horizontalPresentation" (horizontal presentation),
267
282
  "pip" (picture-in-picture), and "verticalPresentation" (vertical presentation)).
268
283
 
269
- * If you specify a "custom" layout type, set the `stylesheet` property.
270
- (For other layout types, do not set the stylesheet property.)
284
+ - If you specify a "custom" layout type, set the `stylesheet` property.
285
+ (For other layout types, do not set the stylesheet property.)
271
286
 
272
287
  See [Customizing the video layout for composed archives](https://tokbox.com/developer/guides/archiving/layout-control.html)
273
- for more details.
288
+ for more details.
274
289
 
275
290
  You can set the initial layout class for a client's streams by setting the layout option when you
276
291
  create the token for the client, using the `opentok.generate_token` method. And you can also change
@@ -296,7 +311,7 @@ For more information on setting stream layout classes, see the
296
311
  [Changing the composed archive layout classes for an OpenTok
297
312
  stream](https://tokbox.com/developer/rest/#change-stream-layout-classes-composed).
298
313
 
299
- Please keep in mind that the `streams.layout` method applies to archive and broadcast streams only.
314
+ Please keep in mind that the `streams.layout` method applies to archive and broadcast streams only.
300
315
 
301
316
  For more information on archiving, see the
302
317
  [OpenTok archiving](https://tokbox.com/opentok/tutorials/archiving/) programming guide.
@@ -305,7 +320,7 @@ For more information on archiving, see the
305
320
 
306
321
  You can send a signal using the `opentok.signals.send(session_id, connection_id, opts)` method.
307
322
  If `connection_id` is nil or an empty string, then the signal is send to all valid connections in
308
- the session.
323
+ the session.
309
324
 
310
325
  An example of `opts` field can be as follows:
311
326
 
@@ -316,11 +331,11 @@ opts = { :type => "chat",
316
331
  ```
317
332
 
318
333
  The maximum length of the `type` string is 128 bytes, and it must contain only letters
319
- (A-Z and a-z), numbers (0-9), '-', '_', and '~'.
334
+ (A-Z and a-z), numbers (0-9), '-', '\_', and '~'.
320
335
 
321
336
  The `data` string must not exceed the maximum size (8 kB).
322
337
 
323
- The `connection_id` and `opts` parameter are jointly optional by default. Hence you can also
338
+ The `connection_id` and `opts` parameter are jointly optional by default. Hence you can also
324
339
  use `opentok.signals.send(session_id)`
325
340
 
326
341
  For more information on signaling, see the
@@ -334,16 +349,17 @@ To successfully start broadcasting a session, at least one publishing client mus
334
349
  the session.
335
350
 
336
351
  You can only have one active live streaming broadcast at a time for a session (however, having more
337
- than one would not be useful).
352
+ than one would not be useful).
338
353
 
339
354
  The live streaming broadcast can target one HLS endpoint and up to five RTMP servers simultaneously
340
- for a session.
355
+ for a session.
341
356
 
342
357
  You can only start live streaming for sessions that use the OpenTok Media Router (with the
343
358
  media mode set to routed). You cannot use live streaming with sessions that have the media mode set
344
359
  to relayed.
345
360
 
346
361
  To create a HLS only broadcast:
362
+
347
363
  ```ruby
348
364
  opts = {
349
365
  :outputs => {
@@ -369,43 +385,45 @@ broadcast = opentok.broadcasts.create(session_id, opts)
369
385
  ```
370
386
 
371
387
  The returned Broadcast object has information about the broadcast, like id, sessionId , projectId,
372
- createdAt, updatedAt, resolution, status, and a Hash of broadcastUrls. The broadcastUrls
388
+ createdAt, updatedAt, resolution, status, and a Hash of broadcastUrls. The broadcastUrls
373
389
  consists of an HLS URL and an array of RTMP objects. The RTMP objects resembles the `rtmp` value
374
- in `opts` in the example above.
390
+ in `opts` in the example above.
375
391
 
376
392
  For more information on broadcast, see the
377
393
  [OpenTok Broadcast guide](https://tokbox.com/developer/rest/#start_broadcast) programming guide.
378
394
 
379
- To get information about a broadcast stream
395
+ To get information about a broadcast stream
396
+
380
397
  ```ruby
381
398
  my_broadcast = opentok.broadcasts.find broadcast_id
382
399
  ```
400
+
383
401
  The Broadcast object returned has properties describing the broadcast, like id, sessionId,
384
- projectId, createdAt, updatedAt, resolution, status, and a Hash of broadcastUrls. The broadcastUrls
402
+ projectId, createdAt, updatedAt, resolution, status, and a Hash of broadcastUrls. The broadcastUrls
385
403
  consists of an HLS URL and an array of RTMP objects. The RTMP objects resembles the `rtmp` value
386
- in `opts` in the example above.
404
+ in `opts` in the example above.
387
405
 
388
406
  To stop a broadcast:
389
407
 
390
408
  ```ruby
391
409
  my_broadcast = opentok.broadcasts.stop broadcast_id
392
-
410
+
393
411
  # stop at a broadcast object level too
394
- #
412
+ #
395
413
  my_broadcast = opentok.broadcasts.find broadcast_id
396
414
  ret_broadcast = my_broadcast.stop
397
-
398
- # Both the above returned objects has the "broadcastUrls" property as a nil value and the status
415
+
416
+ # Both the above returned objects has the "broadcastUrls" property as a nil value and the status
399
417
  # property value is "stopped"
400
418
  ```
401
419
 
420
+ To change the layout of a broadcast dynamically
402
421
 
403
- To change the layout of a broadcast dynamically
404
422
  ```ruby
405
423
  opentok.broadcasts.layout(started_broadcast_id, {
406
424
  :type => "verticalPresentation"
407
425
  })
408
-
426
+
409
427
  # On an object level
410
428
  my_broadcast = opentok.broadcasts.find broadcast_id
411
429
  my_broadcast.layout(
@@ -417,28 +435,28 @@ opentok.broadcasts.layout(started_broadcast_id, {
417
435
 
418
436
  The hash above has two entries.
419
437
 
420
- * The `type` is the layout type for the archive. Valid values are "bestFit" (best fit),
438
+ - The `type` is the layout type for the archive. Valid values are "bestFit" (best fit),
421
439
  "custom" (custom), "horizontalPresentation" (horizontal presentation),
422
- "pip" (picture-in-picture), and "verticalPresentation" (vertical presentation).
440
+ "pip" (picture-in-picture), and "verticalPresentation" (vertical presentation).
423
441
 
424
- * If you specify a "custom" layout type, set the `stylesheet` property. (For other layout types,
425
- do not set the stylesheet property.)
442
+ - If you specify a "custom" layout type, set the `stylesheet` property. (For other layout types,
443
+ do not set the stylesheet property.)
426
444
 
427
445
  Refer to [Customizing the video layout for composed
428
446
  archives](https://tokbox.com/developer/guides/archiving/layout-control.html)
429
- for more details.
447
+ for more details.
430
448
 
431
449
  You can also change the layout of an individual stream dynamically. Refer to
432
450
  [working with Streams](#working-with-streams).
433
451
 
434
- ## Force disconnect
452
+ ## Force disconnect
435
453
 
436
454
  You can cause a client to be forced to disconnect from a session by using the
437
455
  `opentok.connections.forceDisconnect(session_id, connection_id)` method.
438
456
 
439
457
  ## Initiating a SIP call
440
458
 
441
- You can initiate a SIP call using the `opentok.sip.dial(session_id, token, sip_uri, opts)` method.
459
+ You can initiate a SIP call using the `opentok.sip.dial(session_id, token, sip_uri, opts)` method.
442
460
  This requires a SIP URL. You will often need to pass options for authenticating to the SIP provider
443
461
  and specifying encrypted session establishment.
444
462
 
@@ -453,15 +471,14 @@ response = opentok.sip.dial(session_id, token, "sip:+15128675309@acme.pstn.examp
453
471
  For more information on SIP Interconnect, see the
454
472
  [OpenTok SIP Interconnect](https://tokbox.com/developer/guides/sip/) developer guide.
455
473
 
456
-
457
474
  # Samples
458
475
 
459
476
  There are three sample applications included in this repository. To get going as fast as possible, clone the whole
460
477
  repository and read the README in each of the sample directories:
461
478
 
462
- * [HelloWorld](sample/HelloWorld/README.md)
463
- * [Archiving](sample/Archiving/README.md)
464
- * [Broadcast](sample/Broadcast/README.md)
479
+ - [HelloWorld](sample/HelloWorld/README.md)
480
+ - [Archiving](sample/Archiving/README.md)
481
+ - [Broadcast](sample/Broadcast/README.md)
465
482
 
466
483
  # Documentation
467
484
 
@@ -485,7 +502,7 @@ about each release.
485
502
 
486
503
  The SDK adds support for Ruby v2.7 and now requires Ruby v2.1.0 or higher.
487
504
  For Ruby v2.0.0 please continue to use the OpenTok Ruby SDK v3.0.0.
488
- For Ruby v1.9.3 please continue to use the OpenTok Ruby SDK v2.5.0.
505
+ For Ruby v1.9.3 please continue to use the OpenTok Ruby SDK v2.5.0.
489
506
 
490
507
  **Changes in v3.0.0:**
491
508
 
@@ -511,15 +528,16 @@ See the reference documentation
511
528
  <http://www.tokbox.com/opentok/libraries/server/ruby/reference/index.html> and in the
512
529
  docs directory of the SDK.
513
530
 
514
-
515
531
  # Development and Contributing
516
532
 
517
533
  Interested in contributing? We :heart: pull requests! See the [Development](DEVELOPING.md) and
518
534
  [Contribution](CONTRIBUTING.md) guidelines.
519
535
 
520
- # Support
536
+ ## Getting Help
521
537
 
522
- See <https://support.tokbox.com> for all our support options.
538
+ We love to hear from you so if you have questions, comments or find a bug in the project, let us know! You can either:
523
539
 
524
- Find a bug? File it on the [Issues](https://github.com/opentok/opentok-ruby-sdk/issues) page. Hint:
525
- test cases are really helpful!
540
+ - Open an issue on this repository
541
+ - See <https://support.tokbox.com/> for support options
542
+ - Tweet at us! We're [@VonageDev on Twitter](https://twitter.com/VonageDev)
543
+ - Or [join the Vonage Developer Community Slack](https://developer.nexmo.com/community/slack)
@@ -12,18 +12,20 @@ module OpenTok
12
12
  class Client
13
13
  include HTTParty
14
14
 
15
- open_timeout 2 # Set HTTParty default timeout (open/read) to 2 seconds
16
-
17
15
  # TODO: expose a setting for http debugging for developers
18
16
  # debug_output $stdout
19
17
 
20
- def initialize(api_key, api_secret, api_url, ua_addendum="")
18
+ attr_accessor :api_key, :api_secret, :api_url, :ua_addendum, :timeout_length
19
+
20
+ def initialize(api_key, api_secret, api_url, ua_addendum='', opts={})
21
21
  self.class.base_uri api_url
22
22
  self.class.headers({
23
- "User-Agent" => "OpenTok-Ruby-SDK/#{VERSION}" + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}" + (ua_addendum ? " #{ua_addendum}" : "")
23
+ "User-Agent" => "OpenTok-Ruby-SDK/#{VERSION}" + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}" + (ua_addendum ? " #{ua_addendum}" : "")
24
24
  })
25
25
  @api_key = api_key
26
26
  @api_secret = api_secret
27
+ @timeout_length = opts[:timeout_length] || 2
28
+ self.class.open_timeout @timeout_length
27
29
  end
28
30
 
29
31
  def generate_jwt(api_key, api_secret)
@@ -69,7 +69,7 @@ module OpenTok
69
69
  # @private
70
70
  # don't want these to be mutable, may cause bugs related to inconsistency since these values are
71
71
  # cached in objects that this can create
72
- attr_reader :api_key, :api_secret, :api_url, :ua_addendum
72
+ attr_reader :api_key, :api_secret, :timeout_length, :api_url, :ua_addendum
73
73
 
74
74
  ##
75
75
  # Create a new OpenTok object.
@@ -79,9 +79,11 @@ module OpenTok
79
79
  # @param [String] api_secret Your OpenTok API key.
80
80
  # @option opts [Symbol] :api_url Do not set this parameter. It is for internal use by TokBox.
81
81
  # @option opts [Symbol] :ua_addendum Do not set this parameter. It is for internal use by TokBox.
82
+ # @option opts [Symbol] :timeout_length Custom timeout in seconds. If not provided, defaults to 2 seconds.
82
83
  def initialize(api_key, api_secret, opts={})
83
84
  @api_key = api_key.to_s()
84
85
  @api_secret = api_secret
86
+ @timeout_length = opts[:timeout_length] || 2
85
87
  @api_url = opts[:api_url] || API_URL
86
88
  @ua_addendum = opts[:ua_addendum]
87
89
  end
@@ -1,4 +1,4 @@
1
1
  module OpenTok
2
2
  # @private
3
- VERSION = '4.0.1'
3
+ VERSION = '4.1.0'
4
4
  end
@@ -0,0 +1,51 @@
1
+ require "opentok/opentok"
2
+ require "opentok/version"
3
+
4
+ require "spec_helper"
5
+ require "shared/opentok_generates_tokens"
6
+
7
+ describe OpenTok::Client do
8
+ before(:each) do
9
+ now = Time.parse("2017-04-18 20:17:40 +1000")
10
+ allow(Time).to receive(:now) { now }
11
+ end
12
+
13
+ let(:api_key) { "123456" }
14
+ let(:api_secret) { "1234567890abcdef1234567890abcdef1234567890" }
15
+ let(:api_url) { "https://api.opentok.com" }
16
+
17
+
18
+ let(:client) { OpenTok::Client.new api_key, api_secret, api_url }
19
+ subject { client }
20
+
21
+ context "when initialized with no options" do
22
+ it { should be_an_instance_of OpenTok::Client }
23
+
24
+ it "should have an api_key property" do
25
+ expect(client.api_key).to eq api_key
26
+ end
27
+
28
+ it "should have an api_secret property" do
29
+ expect(client.api_secret).to eq api_secret
30
+ end
31
+
32
+ it "should be able to access HTTParty open_timeout method" do
33
+ expect(OpenTok::Client).to respond_to(:open_timeout)
34
+ end
35
+
36
+ it 'should have a default timeout_length property of 2 seconds' do
37
+ expect(client.timeout_length).to eq 2
38
+ end
39
+ end
40
+
41
+ context "when initialized with timeout_length custom option" do
42
+ let(:client) { OpenTok::Client.new api_key, api_secret, api_url, ua_addendum='', :timeout_length => timeout_length }
43
+ let(:timeout_length) { 10 }
44
+
45
+ it { should be_an_instance_of(OpenTok::Client) }
46
+
47
+ it "should override timeout_length default with custom integer" do
48
+ expect(client.timeout_length).to eq 10
49
+ end
50
+ end
51
+ end
@@ -31,6 +31,10 @@ describe OpenTok::OpenTok do
31
31
  expect(opentok.api_url).to eq default_api_url
32
32
  end
33
33
 
34
+ it "has the default timeout set" do
35
+ expect(opentok.timeout_length).to eq 2
36
+ end
37
+
34
38
  include_examples "opentok generates tokens"
35
39
 
36
40
  describe "#create_session" do
@@ -139,6 +143,17 @@ describe OpenTok::OpenTok do
139
143
  # include_examples "generates tokens"
140
144
  end
141
145
 
146
+ context "with a custom timeout_length" do
147
+ let(:timeout_length) { 10 }
148
+ let(:opentok) { OpenTok::OpenTok.new api_key, api_secret, :timeout_length => timeout_length }
149
+
150
+ it { should be_an_instance_of(OpenTok::OpenTok) }
151
+
152
+ it "should have an timeout_length property" do
153
+ expect(opentok.timeout_length).to eq timeout_length
154
+ end
155
+ end
156
+
142
157
  context "with an addendum to the user agent string" do
143
158
  let(:opentok) { OpenTok::OpenTok.new api_key, api_secret, :ua_addendum => ua_addendum }
144
159
  let(:ua_addendum) { "BOOYAH"}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentok
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stijn Mathysen
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2020-03-28 00:00:00.000000000 Z
15
+ date: 2020-04-28 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: bundler
@@ -173,6 +173,7 @@ files:
173
173
  - ".gitignore"
174
174
  - ".travis.yml"
175
175
  - ".yardopts"
176
+ - CODE_OF_CONDUCT.md
176
177
  - CONTRIBUTING.md
177
178
  - DEVELOPING.md
178
179
  - Gemfile
@@ -274,6 +275,7 @@ files:
274
275
  - spec/matchers/token.rb
275
276
  - spec/opentok/archives_spec.rb
276
277
  - spec/opentok/broadcasts_spec.rb
278
+ - spec/opentok/client_spec.rb
277
279
  - spec/opentok/connection_spec.rb
278
280
  - spec/opentok/opentok_spec.rb
279
281
  - spec/opentok/session_spec.rb
@@ -302,7 +304,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
302
304
  - !ruby/object:Gem::Version
303
305
  version: '0'
304
306
  requirements: []
305
- rubygems_version: 3.1.2
307
+ rubygems_version: 3.0.0
306
308
  signing_key:
307
309
  specification_version: 4
308
310
  summary: Ruby gem for the OpenTok API
@@ -352,6 +354,7 @@ test_files:
352
354
  - spec/matchers/token.rb
353
355
  - spec/opentok/archives_spec.rb
354
356
  - spec/opentok/broadcasts_spec.rb
357
+ - spec/opentok/client_spec.rb
355
358
  - spec/opentok/connection_spec.rb
356
359
  - spec/opentok/opentok_spec.rb
357
360
  - spec/opentok/session_spec.rb