bigbluebutton-api-ruby 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,7 @@
1
+ === 1.1.1
2
+
3
+ * BigBlueButtonApi can now receive http headers to be sent in all get/post requests
4
+
1
5
  === 1.1.0
2
6
 
3
7
  * Updated ruby to 1.9.3-194.
data/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  GIT
2
2
  remote: git://github.com/mconf/bbbot-ruby.git
3
- revision: 83f3ccf88aa355260a791eb450a8d73f94049053
3
+ revision: 6b47fe212ea49a3120e9ee787cedd6097c9c81bd
4
4
  specs:
5
5
  bbbot-ruby (0.0.1)
6
6
 
7
7
  PATH
8
8
  remote: .
9
9
  specs:
10
- bigbluebutton-api-ruby (1.1.0)
10
+ bigbluebutton-api-ruby (1.1.1)
11
11
  xml-simple (>= 1.1.1)
12
12
 
13
13
  GEM
@@ -2,7 +2,7 @@ $:.push File.expand_path("../lib", __FILE__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'bigbluebutton-api-ruby'
5
- s.version = '1.1.0'
5
+ s.version = '1.1.1'
6
6
  s.extra_rdoc_files = ['README.rdoc', 'LICENSE', 'LICENSE_003', 'CHANGELOG.rdoc']
7
7
  s.summary = 'Provides an interface to the BigBlueButton web meeting API (https://github.com/mconf/bigbluebutton-api-ruby)'
8
8
  s.description = s.summary
@@ -35,18 +35,39 @@ module BigBlueButton
35
35
  #
36
36
  class BigBlueButtonApi
37
37
 
38
- attr_accessor :url, :supported_versions, :salt, :version, :debug, :timeout
38
+ # URL to a BigBlueButton server (e.g. http://demo.bigbluebutton.org/bigbluebutton/api)
39
+ attr_accessor :url
40
+
41
+ # Secret salt for this server
42
+ attr_accessor :salt
43
+
44
+ # API version e.g. 0.7 (valid for 0.7, 0.71 and 0.71a)
45
+ attr_accessor :version
46
+
47
+ # Flag to turn on/off debug mode
48
+ attr_accessor :debug
49
+
50
+ # Maximum wait time for HTTP requests (secs)
51
+ attr_accessor :timeout
52
+
53
+ # HTTP headers to be sent in all GET/POST requests
54
+ attr_accessor :request_headers
55
+
56
+ # Array with the version of BigBlueButton supported
57
+ # TODO: do we really need an accessor? shouldn't be internal?
58
+ attr_accessor :supported_versions
39
59
 
40
60
  # Initializes an instance
41
61
  # url:: URL to a BigBlueButton server (e.g. http://demo.bigbluebutton.org/bigbluebutton/api)
42
62
  # salt:: Secret salt for this server
43
- # version:: API version: 0.7 (valid for 0.7, 0.71 and 0.71a)
63
+ # version:: API version e.g. 0.7 (valid for 0.7, 0.71 and 0.71a)
44
64
  def initialize(url, salt, version='0.7', debug=false)
45
65
  @supported_versions = ['0.7', '0.8']
46
66
  @url = url
47
67
  @salt = salt
48
68
  @debug = debug
49
- @timeout = 10 # default timeout for api requests
69
+ @timeout = 10 # default timeout for api requests
70
+ @request_headers = {} # http headers sent in all requests
50
71
 
51
72
  @version = version || get_api_version
52
73
  unless @supported_versions.include?(@version)
@@ -532,19 +553,19 @@ module BigBlueButton
532
553
  http.open_timeout = @timeout
533
554
  http.read_timeout = @timeout
534
555
  if data.nil?
535
- response = http.get(url_parsed.request_uri)
556
+ response = http.get(url_parsed.request_uri, @request_headers)
536
557
  else
537
558
  puts "BigBlueButtonAPI: Sending as a POST request with data.size = #{data.size}" if @debug
538
- opts = { 'Content-Type' => 'text/xml' }
559
+ opts = { 'Content-Type' => 'text/xml' }.merge @request_headers
539
560
  response = http.post(url_parsed.request_uri, data, opts)
540
561
  end
541
562
  puts "BigBlueButtonAPI: URL response = #{response.body}" if @debug
542
563
 
543
564
  rescue TimeoutError => error
544
- raise BigBlueButtonException.new("Timeout error. Your server is probably down: \"#{@url}\"")
565
+ raise BigBlueButtonException.new("Timeout error. Your server is probably down: \"#{@url}\". Error: #{error}")
545
566
 
546
567
  rescue Exception => error
547
- raise BigBlueButtonException.new("Connection error. Your URL is probably incorrect: \"#{@url}\"")
568
+ raise BigBlueButtonException.new("Connection error. Your URL is probably incorrect: \"#{@url}\". Error: #{error}")
548
569
  end
549
570
 
550
571
  response
@@ -13,13 +13,14 @@ describe BigBlueButton::BigBlueButtonApi do
13
13
  describe "#initialize" do
14
14
  context "standard initialization" do
15
15
  subject { BigBlueButton::BigBlueButtonApi.new(url, salt, version, debug) }
16
- it { subject.url.should be(url) }
17
- it { subject.salt.should be(salt) }
18
- it { subject.version.should be(version) }
19
- it { subject.debug.should be(debug) }
20
- it { subject.timeout.should be(10) }
16
+ it { subject.url.should == url }
17
+ it { subject.salt.should == salt }
18
+ it { subject.version.should == version }
19
+ it { subject.debug.should == debug }
20
+ it { subject.timeout.should == 10 }
21
21
  it { subject.supported_versions.should include("0.7") }
22
22
  it { subject.supported_versions.should include("0.8") }
23
+ it { subject.request_headers.should == {} }
23
24
  end
24
25
 
25
26
  context "when the version is not informed, get it from the BBB server" do
@@ -449,7 +450,7 @@ describe BigBlueButton::BigBlueButtonApi do
449
450
  end
450
451
 
451
452
  context "standard case" do
452
- before { @http_mock.should_receive(:get).with("/res?param1=value1&checksum=12345").and_return("ok") }
453
+ before { @http_mock.should_receive(:get).with("/res?param1=value1&checksum=12345", {}).and_return("ok") }
453
454
  it { api.send(:send_request, url).should == "ok" }
454
455
  end
455
456
 
@@ -463,7 +464,7 @@ describe BigBlueButton::BigBlueButtonApi do
463
464
  it { expect { api.send(:send_request, url) }.to raise_error(BigBlueButton::BigBlueButtonException) }
464
465
  end
465
466
 
466
- context "with data" do
467
+ context "post with data" do
467
468
  let(:data) { "any data" }
468
469
  before {
469
470
  path = "/res?param1=value1&checksum=12345"
@@ -475,6 +476,29 @@ describe BigBlueButton::BigBlueButtonApi do
475
476
  }
476
477
  end
477
478
 
479
+ context "get with headers" do
480
+ let(:headers_hash) { { :anything => "anything" } }
481
+ before { @http_mock.should_receive(:get).with("/res?param1=value1&checksum=12345", headers_hash).and_return("ok") }
482
+ it {
483
+ api.request_headers = headers_hash
484
+ api.send(:send_request, url).should == "ok"
485
+ }
486
+ end
487
+
488
+ context "get with headers" do
489
+ let(:headers_hash) { { :anything => "anything" } }
490
+ let(:data) { "any data" }
491
+ before {
492
+ path = "/res?param1=value1&checksum=12345"
493
+ opts = { 'Content-Type' => 'text/xml', :anything => "anything" }
494
+ @http_mock.should_receive(:post).with(path, data, opts).and_return("ok")
495
+ }
496
+ it {
497
+ api.request_headers = headers_hash
498
+ api.send(:send_request, url, data).should == "ok"
499
+ }
500
+ end
501
+
478
502
  end
479
503
 
480
504
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bigbluebutton-api-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-05-05 00:00:00.000000000 Z
13
+ date: 2012-06-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: xml-simple
@@ -103,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
103
  version: '0'
104
104
  segments:
105
105
  - 0
106
- hash: -937799181
106
+ hash: -1556921647631366101
107
107
  required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  none: false
109
109
  requirements:
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  version: '0'
113
113
  segments:
114
114
  - 0
115
- hash: -937799181
115
+ hash: -1556921647631366101
116
116
  requirements: []
117
117
  rubyforge_project:
118
118
  rubygems_version: 1.8.24