bigbluebutton-api-ruby 1.9.1 → 2.0.0.pre.rc.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.
@@ -302,9 +302,9 @@ describe BigBlueButton::BigBlueButtonApi do
302
302
  before {
303
303
  api.should_receive(:send_api_request).with(:getMeetings, {}).
304
304
  and_return(flattened_response)
305
- formatter_mock = mock(BigBlueButton::BigBlueButtonFormatter)
306
- formatter_mock.should_receive(:flatten_objects).with(:meetings, :meeting)
307
- BigBlueButton::BigBlueButtonFormatter.should_receive(:new).and_return(formatter_mock)
305
+ formatter_double = double(BigBlueButton::BigBlueButtonFormatter)
306
+ formatter_double.should_receive(:flatten_objects).with(:meetings, :meeting)
307
+ BigBlueButton::BigBlueButtonFormatter.should_receive(:new).and_return(formatter_double)
308
308
  BigBlueButton::BigBlueButtonFormatter.should_receive(:format_meeting).with(meeting_hash1)
309
309
  BigBlueButton::BigBlueButtonFormatter.should_receive(:format_meeting).with(meeting_hash2)
310
310
  }
@@ -381,27 +381,27 @@ describe BigBlueButton::BigBlueButtonApi do
381
381
  describe "#last_http_response" do
382
382
  # we test this through a #test_connection call
383
383
 
384
- let(:request_mock) { mock }
384
+ let(:request_double) { double }
385
385
  before {
386
386
  api.should_receive(:get_url)
387
387
  # this return value will be stored in @http_response
388
- api.should_receive(:send_request).and_return(request_mock)
388
+ api.should_receive(:send_request).and_return(request_double)
389
389
  # to return fast from #send_api_request
390
- request_mock.should_receive(:body).and_return("")
390
+ request_double.should_receive(:body).and_return("")
391
391
  api.test_connection
392
392
  }
393
- it { api.last_http_response.should == request_mock }
393
+ it { api.last_http_response.should == request_double }
394
394
  end
395
395
 
396
396
  describe "#last_xml_response" do
397
397
  # we test this through a #test_connection call
398
398
 
399
- let(:request_mock) { mock }
399
+ let(:request_double) { double }
400
400
  let(:expected_xml) { "<response><returncode>SUCCESS</returncode></response>" }
401
401
  before {
402
402
  api.should_receive(:get_url)
403
- api.should_receive(:send_request).and_return(request_mock)
404
- request_mock.should_receive(:body).at_least(1).and_return(expected_xml)
403
+ api.should_receive(:send_request).and_return(request_double)
404
+ request_double.should_receive(:body).at_least(1).and_return(expected_xml)
405
405
  api.test_connection
406
406
  }
407
407
  it { api.last_xml_response.should == expected_xml }
@@ -441,15 +441,6 @@ describe BigBlueButton::BigBlueButtonApi do
441
441
  end
442
442
  end
443
443
 
444
- context "when method = :setConfigXML" do
445
- it {
446
- api.url = 'http://my-test-server.com/bigbluebutton/api'
447
- response = api.get_url(:setConfigXML, { param1: 1, param2: 2 })
448
- response[0].should eql('http://my-test-server.com/bigbluebutton/api/setConfigXML')
449
- response[1].should match(/checksum=.*&param1=1&param2=2/)
450
- }
451
- end
452
-
453
444
  context "discards params with nil value" do
454
445
  let(:params) { { :param1 => "value1", :param2 => nil } }
455
446
  subject { api.get_url(:join, params)[0] }
@@ -512,22 +503,22 @@ describe BigBlueButton::BigBlueButtonApi do
512
503
  let(:data) { "any data" }
513
504
  let(:url) { "http://test-server:8080?param1=value1&checksum=12345" }
514
505
  let(:make_request) { api.send_api_request(method, params, data) }
515
- let(:response_mock) { mock() } # mock of what send_request() would return
506
+ let(:response_double) { double() } # mock of what send_request() would return
516
507
 
517
508
  before { api.should_receive(:get_url).with(method, params).and_return([url, nil]) }
518
509
 
519
510
  context "returns an empty hash if the response body is empty" do
520
511
  before do
521
- api.should_receive(:send_request).with(url, data).and_return(response_mock)
522
- response_mock.should_receive(:body).and_return("")
512
+ api.should_receive(:send_request).with(url, data).and_return(response_double)
513
+ response_double.should_receive(:body).and_return("")
523
514
  end
524
515
  it { make_request.should == { } }
525
516
  end
526
517
 
527
518
  context "hashfies and validates the response body" do
528
519
  before do
529
- api.should_receive(:send_request).with(url, data).and_return(response_mock)
530
- response_mock.should_receive(:body).twice.and_return("response-body")
520
+ api.should_receive(:send_request).with(url, data).and_return(response_double)
521
+ response_double.should_receive(:body).twice.and_return("response-body")
531
522
  end
532
523
 
533
524
  context "checking if it has a :response key" do
@@ -545,15 +536,15 @@ describe BigBlueButton::BigBlueButtonApi do
545
536
  let(:response) { { :returncode => "SUCCESS" } }
546
537
  let(:formatted_response) { { :returncode => true, :messageKey => "", :message => "" } }
547
538
  before do
548
- api.should_receive(:send_request).with(url, data).and_return(response_mock)
549
- response_mock.should_receive(:body).twice.and_return("response-body")
539
+ api.should_receive(:send_request).with(url, data).and_return(response_double)
540
+ response_double.should_receive(:body).twice.and_return("response-body")
550
541
  BigBlueButton::BigBlueButtonHash.should_receive(:from_xml).with("response-body").and_return(response)
551
542
 
552
543
  # here starts the validation
553
544
  # doesn't test the resulting format, only that the formatter was called
554
- formatter_mock = mock(BigBlueButton::BigBlueButtonFormatter)
555
- BigBlueButton::BigBlueButtonFormatter.should_receive(:new).with(response).and_return(formatter_mock)
556
- formatter_mock.should_receive(:default_formatting).and_return(formatted_response)
545
+ formatter_double = double(BigBlueButton::BigBlueButtonFormatter)
546
+ BigBlueButton::BigBlueButtonFormatter.should_receive(:new).with(response).and_return(formatter_double)
547
+ formatter_double.should_receive(:default_formatting).and_return(formatted_response)
557
548
  end
558
549
  it { make_request }
559
550
  end
@@ -562,13 +553,13 @@ describe BigBlueButton::BigBlueButtonApi do
562
553
  let(:response) { { :returncode => true } }
563
554
  let(:formatted_response) { { } }
564
555
  before do
565
- api.should_receive(:send_request).with(url, data).and_return(response_mock)
566
- response_mock.should_receive(:body).twice.and_return("response-body")
556
+ api.should_receive(:send_request).with(url, data).and_return(response_double)
557
+ response_double.should_receive(:body).twice.and_return("response-body")
567
558
  BigBlueButton::BigBlueButtonHash.should_receive(:from_xml).with("response-body").and_return(response)
568
559
 
569
- formatter_mock = mock(BigBlueButton::BigBlueButtonFormatter)
570
- BigBlueButton::BigBlueButtonFormatter.should_receive(:new).with(response).and_return(formatter_mock)
571
- formatter_mock.should_receive(:default_formatting).and_return(formatted_response)
560
+ formatter_double = double(BigBlueButton::BigBlueButtonFormatter)
561
+ BigBlueButton::BigBlueButtonFormatter.should_receive(:new).with(response).and_return(formatter_double)
562
+ formatter_double.should_receive(:default_formatting).and_return(formatted_response)
572
563
  end
573
564
  it { expect { make_request }.to raise_error(BigBlueButton::BigBlueButtonException) }
574
565
  end
@@ -580,25 +571,25 @@ describe BigBlueButton::BigBlueButtonApi do
580
571
  let(:res) { Net::HTTPResponse.new(1.0, '200', 'OK') }
581
572
 
582
573
  before do
583
- @http_mock = mock(Net::HTTP)
584
- @http_mock.should_receive(:"open_timeout=").with(api.timeout)
585
- @http_mock.should_receive(:"read_timeout=").with(api.timeout)
586
- Net::HTTP.should_receive(:new).with("test-server", 8080).and_return(@http_mock)
574
+ @http_double = double(Net::HTTP)
575
+ @http_double.should_receive(:"open_timeout=").with(api.timeout)
576
+ @http_double.should_receive(:"read_timeout=").with(api.timeout)
577
+ Net::HTTP.should_receive(:new).with("test-server", 8080).and_return(@http_double)
587
578
  res.stub(:body) { "ok" }
588
579
  end
589
580
 
590
581
  context "standard case" do
591
- before { @http_mock.should_receive(:get).with("/res?param1=value1&checksum=12345", {}).and_return(res) }
582
+ before { @http_double.should_receive(:get).with("/res?param1=value1&checksum=12345", {}).and_return(res) }
592
583
  it { api.send(:send_request, url).should == res }
593
584
  end
594
585
 
595
586
  context "handles a TimeoutError" do
596
- before { @http_mock.should_receive(:get) { raise TimeoutError } }
587
+ before { @http_double.should_receive(:get) { raise TimeoutError } }
597
588
  it { expect { api.send(:send_request, url) }.to raise_error(BigBlueButton::BigBlueButtonException) }
598
589
  end
599
590
 
600
591
  context "handles general Exceptions" do
601
- before { @http_mock.should_receive(:get) { raise Exception } }
592
+ before { @http_double.should_receive(:get) { raise Exception } }
602
593
  it { expect { api.send(:send_request, url) }.to raise_error(BigBlueButton::BigBlueButtonException) }
603
594
  end
604
595
 
@@ -607,7 +598,7 @@ describe BigBlueButton::BigBlueButtonApi do
607
598
  before {
608
599
  path = "/res?param1=value1&checksum=12345"
609
600
  opts = { 'Content-Type' => 'application/xml' }
610
- @http_mock.should_receive(:post).with(path, data, opts).and_return(res)
601
+ @http_double.should_receive(:post).with(path, data, opts).and_return(res)
611
602
  }
612
603
  it {
613
604
  api.send(:send_request, url, data).should == res
@@ -616,7 +607,7 @@ describe BigBlueButton::BigBlueButtonApi do
616
607
 
617
608
  context "get with headers" do
618
609
  let(:headers_hash) { { :anything => "anything" } }
619
- before { @http_mock.should_receive(:get).with("/res?param1=value1&checksum=12345", headers_hash).and_return(res) }
610
+ before { @http_double.should_receive(:get).with("/res?param1=value1&checksum=12345", headers_hash).and_return(res) }
620
611
  it {
621
612
  api.request_headers = headers_hash
622
613
  api.send(:send_request, url).should == res
@@ -629,7 +620,7 @@ describe BigBlueButton::BigBlueButtonApi do
629
620
  before {
630
621
  path = "/res?param1=value1&checksum=12345"
631
622
  opts = { 'Content-Type' => 'application/xml', :anything => "anything" }
632
- @http_mock.should_receive(:post).with(path, data, opts).and_return(res)
623
+ @http_double.should_receive(:post).with(path, data, opts).and_return(res)
633
624
  }
634
625
  it {
635
626
  api.request_headers = headers_hash
@@ -694,11 +685,11 @@ describe BigBlueButton::BigBlueButtonApi do
694
685
  context "formats the response" do
695
686
  before {
696
687
  api.should_receive(:send_api_request).with(:getRecordings, anything).and_return(flattened_response)
697
- formatter_mock = mock(BigBlueButton::BigBlueButtonFormatter)
698
- formatter_mock.should_receive(:flatten_objects).with(:recordings, :recording)
688
+ formatter_double = double(BigBlueButton::BigBlueButtonFormatter)
689
+ formatter_double.should_receive(:flatten_objects).with(:recordings, :recording)
699
690
  BigBlueButton::BigBlueButtonFormatter.should_receive(:format_recording).with(recording1)
700
691
  BigBlueButton::BigBlueButtonFormatter.should_receive(:format_recording).with(recording2)
701
- BigBlueButton::BigBlueButtonFormatter.should_receive(:new).and_return(formatter_mock)
692
+ BigBlueButton::BigBlueButtonFormatter.should_receive(:new).and_return(formatter_double)
702
693
  }
703
694
  it { api.get_recordings }
704
695
  end
@@ -53,10 +53,10 @@ describe BigBlueButton::BigBlueButtonFormatter do
53
53
  formatter.to_boolean(:false1)
54
54
  formatter.to_boolean(:false2)
55
55
  }
56
- it { hash[:true1].should be_true }
57
- it { hash[:true2].should be_true }
58
- it { hash[:false1].should be_false }
59
- it { hash[:false2].should be_false }
56
+ it { hash[:true1].should be true }
57
+ it { hash[:true2].should be true }
58
+ it { hash[:false1].should be false }
59
+ it { hash[:false2].should be false }
60
60
 
61
61
  context "returns false if the param doesn't exists" do
62
62
  subject { BigBlueButton::BigBlueButtonFormatter.new({ :param => 1}) }
@@ -207,7 +207,7 @@ describe BigBlueButton::BigBlueButtonFormatter do
207
207
  context "when :returncode should be false" do
208
208
  before { input[:returncode] = "ERROR" }
209
209
  subject { formatter.default_formatting }
210
- it { subject[:returncode].should be_false }
210
+ it { subject[:returncode].should be false }
211
211
  end
212
212
 
213
213
  context "when :messageKey is empty" do
metadata CHANGED
@@ -1,114 +1,44 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bigbluebutton-api-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.1
4
+ version: 2.0.0.pre.rc.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mconf
8
8
  - Leonardo Crauss Daronco
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-03-31 00:00:00.000000000 Z
12
+ date: 2025-09-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: childprocess
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - ">="
19
- - !ruby/object:Gem::Version
20
- version: 1.0.1
21
- type: :runtime
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- version: 1.0.1
28
- - !ruby/object:Gem::Dependency
29
- name: ffi
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: 1.9.24
35
- type: :runtime
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- version: 1.9.24
42
- - !ruby/object:Gem::Dependency
43
- name: json
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- version: 1.8.6
49
- type: :runtime
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: 1.8.6
56
- - !ruby/object:Gem::Dependency
57
- name: nokogiri
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: 1.10.4
63
- type: :runtime
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: 1.10.4
70
- - !ruby/object:Gem::Dependency
71
- name: rack
15
+ name: xml-simple
72
16
  requirement: !ruby/object:Gem::Requirement
73
17
  requirements:
74
- - - ">="
18
+ - - "~>"
75
19
  - !ruby/object:Gem::Version
76
- version: 1.6.11
20
+ version: '1.1'
77
21
  type: :runtime
78
22
  prerelease: false
79
23
  version_requirements: !ruby/object:Gem::Requirement
80
24
  requirements:
81
- - - ">="
25
+ - - "~>"
82
26
  - !ruby/object:Gem::Version
83
- version: 1.6.11
27
+ version: '1.1'
84
28
  - !ruby/object:Gem::Dependency
85
- name: rubyzip
29
+ name: base64
86
30
  requirement: !ruby/object:Gem::Requirement
87
31
  requirements:
88
32
  - - ">="
89
33
  - !ruby/object:Gem::Version
90
- version: 1.3.0
34
+ version: 0.1.0
91
35
  type: :runtime
92
36
  prerelease: false
93
37
  version_requirements: !ruby/object:Gem::Requirement
94
38
  requirements:
95
39
  - - ">="
96
40
  - !ruby/object:Gem::Version
97
- version: 1.3.0
98
- - !ruby/object:Gem::Dependency
99
- name: xml-simple
100
- requirement: !ruby/object:Gem::Requirement
101
- requirements:
102
- - - "~>"
103
- - !ruby/object:Gem::Version
104
- version: '1.1'
105
- type: :runtime
106
- prerelease: false
107
- version_requirements: !ruby/object:Gem::Requirement
108
- requirements:
109
- - - "~>"
110
- - !ruby/object:Gem::Version
111
- version: '1.1'
41
+ version: 0.1.0
112
42
  description: Provides methods to access BigBlueButton in a ruby application through
113
43
  its API
114
44
  email:
@@ -137,7 +67,6 @@ files:
137
67
  - Rakefile
138
68
  - bigbluebutton-api-ruby.gemspec
139
69
  - docker-compose.yml
140
- - examples/config_xml.rb
141
70
  - examples/create.rb
142
71
  - examples/get_version_example.rb
143
72
  - examples/join_example.rb
@@ -162,17 +91,12 @@ files:
162
91
  - features/support/features_helpers.rb
163
92
  - features/support/hooks.rb
164
93
  - lib/bigbluebutton_api.rb
165
- - lib/bigbluebutton_config_layout.rb
166
- - lib/bigbluebutton_config_xml.rb
167
94
  - lib/bigbluebutton_exception.rb
168
95
  - lib/bigbluebutton_formatter.rb
169
96
  - lib/bigbluebutton_hash_to_xml.rb
170
97
  - lib/bigbluebutton_modules.rb
171
- - spec/bigbluebutton_api_0.81_spec.rb
172
98
  - spec/bigbluebutton_api_0.9_spec.rb
173
99
  - spec/bigbluebutton_api_spec.rb
174
- - spec/bigbluebutton_config_layout_spec.rb
175
- - spec/bigbluebutton_config_xml_spec.rb
176
100
  - spec/bigbluebutton_exception_spec.rb
177
101
  - spec/bigbluebutton_formatter_spec.rb
178
102
  - spec/bigbluebutton_hash_to_xml_spec.rb
@@ -185,7 +109,7 @@ homepage: https://github.com/mconf/bigbluebutton-api-ruby/
185
109
  licenses:
186
110
  - MIT
187
111
  metadata: {}
188
- post_install_message:
112
+ post_install_message:
189
113
  rdoc_options: []
190
114
  require_paths:
191
115
  - lib
@@ -193,15 +117,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
193
117
  requirements:
194
118
  - - ">="
195
119
  - !ruby/object:Gem::Version
196
- version: '0'
120
+ version: 3.2.0
197
121
  required_rubygems_version: !ruby/object:Gem::Requirement
198
122
  requirements:
199
- - - ">="
123
+ - - ">"
200
124
  - !ruby/object:Gem::Version
201
- version: '0'
125
+ version: 1.3.1
202
126
  requirements: []
203
- rubygems_version: 3.3.5
204
- signing_key:
127
+ rubygems_version: 3.4.20
128
+ signing_key:
205
129
  specification_version: 4
206
130
  summary: BigBlueButton integration for ruby
207
131
  test_files: []
@@ -1,74 +0,0 @@
1
- $:.unshift File.expand_path(File.dirname(__FILE__))
2
- $:.unshift File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib')
3
-
4
- require 'bigbluebutton_api'
5
- require 'prepare'
6
-
7
- begin
8
- prepare
9
-
10
- puts "---------------------------------------------------"
11
- config_xml = @api.get_default_config_xml
12
- config_xml = BigBlueButton::BigBlueButtonConfigXml.new(config_xml)
13
- puts "The default config.xml was taken from the server"
14
-
15
- puts "---------------------------------------------------"
16
- layouts = @api.get_available_layouts
17
- puts "The available layouts are"
18
- puts layouts.inspect
19
- puts "The default layouts are"
20
- puts @api.get_default_layouts.inspect
21
-
22
- puts "---------------------------------------------------"
23
- num = rand(1000)
24
- meeting_name = "Test Meeting #{num}"
25
- meeting_id = "test-meeting-#{num}"
26
- username = "House #{rand(1000)}"
27
- username2 = "Cameron #{rand(1000)}"
28
- options = { :moderatorPW => "54321",
29
- :attendeePW => "12345",
30
- :welcome => 'Welcome to my meeting',
31
- :dialNumber => '1-800-000-0000x00000#',
32
- :logoutURL => 'https://github.com/mconf/bigbluebutton-api-ruby',
33
- :maxParticipants => 25 }
34
- response = @api.create_meeting(meeting_name, meeting_id, options)
35
- puts "A meeting has been created: #{meeting_id}"
36
-
37
- puts "---------------------------------------------------"
38
- url = @api.join_meeting_url(meeting_id, username, options[:moderatorPW])
39
- puts "Please join the meeting as moderator using the link: #{url}"
40
- puts "*** You will be using the DEFAULT config.xml ***"
41
- puts "Waiting 30 seconds for you to join..."
42
- puts
43
- sleep(30)
44
-
45
- puts "---------------------------------------------------"
46
- puts "Creating a new config.xml"
47
- # config_xml.set_attribute("layout", "showToolbar", "false", false)
48
- config_xml.set_attribute("skinning", "enabled", "false", false)
49
- config_xml.set_attribute("layout", "defaultLayout", "Webinar", false)
50
- config_xml.set_attribute("layout", "showLayoutTools", "false", false)
51
- config_xml.set_attribute("ChatModule", "privateEnabled", "false")
52
- config_xml.set_attribute("VideoconfModule", "resolutions", "320x240")
53
- config_xml.set_attribute("VideoconfModule", "presenterShareOnly", "true")
54
-
55
- puts "---------------------------------------------------"
56
- token = @api.set_config_xml(meeting_id, config_xml)
57
- puts "Setting the new config.xml returned the token: #{token}"
58
-
59
- puts "---------------------------------------------------"
60
- url = @api.join_meeting_url(meeting_id, username2, options[:moderatorPW], { :configToken => token })
61
- puts "Please join the meeting again using the link: #{url}"
62
- puts "*** You will be using the MODIFIED config.xml, with the following modifications: ***"
63
- puts "*** - Disabled layout (will show the default layout, as was used in BBB < 0.8)"
64
- puts "*** - Default layout to Webinar"
65
- puts "*** - Hidden layout tools"
66
- puts "*** - Disabled private chat"
67
- puts "*** - Restricted video resolutions to 320x240 only"
68
- puts "*** - Disabled video sharing except for the presenter"
69
- puts
70
-
71
- rescue Exception => ex
72
- puts "Failed with error #{ex.message}"
73
- puts ex.backtrace
74
- end
@@ -1,58 +0,0 @@
1
- require "xmlsimple"
2
-
3
- module BigBlueButton
4
-
5
- # A helper class to work with layout definition files.
6
- # You set an xml file on it (usually obtained from a property of in the XML obtained from
7
- # BigBlueButtonApi#get_default_config_xml), use it to work with the layouts, and then get
8
- # the new xml from this class.
9
- #
10
- # === Usage example:
11
- #
12
- # xml = api.get_default_config_xml
13
- # config_xml = BigBlueButton::BigBlueButtonConfigXml.new(xml)
14
- # url = config_xml.get_attribute("LayoutModule", "layoutConfig", true)
15
- # # send a request to 'url' to fetch the xml file into 'response'
16
- #
17
- # layout_config = BigBlueButton::BigBlueButtonConfigLayout.new(response)
18
- # layout_config.get_available_layouts
19
- #
20
- class BigBlueButtonConfigLayout
21
-
22
- attr_accessor :xml
23
-
24
- # xml (string):: The XML that has the definition of all layouts, usually fetched from
25
- # the web conference server.
26
- def initialize(xml)
27
- @xml = nil
28
- opts = { 'ForceArray' => false, 'KeepRoot' => true }
29
- begin
30
- @xml = XmlSimple.xml_in(xml, opts)
31
- rescue Exception => e
32
- exception = BigBlueButton::BigBlueButtonException.new("Error parsing the layouts XML. Error: #{e.message}")
33
- exception.key = 'XMLParsingError'
34
- raise exception
35
- end
36
- end
37
-
38
- # Returns an array with the name of each layout available in the XML.
39
- # Will return only unique names, ordered the way they are ordered in the XML.
40
- # Returns nil if the XML is not properly formatted and an empty
41
- # array if there are no layouts in the file.
42
- def get_available_layouts
43
- if xml_has_layouts
44
- xml["layouts"]["layout"].map{ |l| l["name"] }.uniq
45
- else
46
- nil
47
- end
48
- end
49
-
50
- protected
51
-
52
- def xml_has_layouts
53
- @xml and @xml["layouts"] and @xml["layouts"]["layout"]
54
- end
55
-
56
- end
57
-
58
- end
@@ -1,125 +0,0 @@
1
- require "xmlsimple"
2
-
3
- module BigBlueButton
4
-
5
- # A helper class to work with config.xml files.
6
- # You set an xml file on it (usually obtained via BigBlueButtonApi#get_default_config_xml),
7
- # use it to modify this xml, and then get the new xml from this class (usually to set in the
8
- # server using BigBlueButtonApi#set_config_xml).
9
- #
10
- # === Usage example:
11
- #
12
- # xml = api.get_default_config_xml
13
- # config_xml = BigBlueButton::BigBlueButtonConfigXml.new(xml)
14
- #
15
- # # change the xml a bit
16
- # config_xml.set_attribute("skinning", "enabled", "false", false)
17
- # config_xml.set_attribute("layout", "defaultLayout", "Webinar", false)
18
- # config_xml.set_attribute("layout", "showLayoutTools", "false", false)
19
- #
20
- # # set the new xml in the server
21
- # api.set_config_xml("meeting-id", config_xml)
22
- #
23
- class BigBlueButtonConfigXml
24
-
25
- attr_accessor :xml
26
-
27
- def initialize(xml)
28
- @original_string = nil
29
- @xml = nil
30
- unless xml.nil?
31
- opts = { 'ForceArray' => false, 'KeepRoot' => true }
32
- begin
33
- @xml = XmlSimple.xml_in(xml, opts)
34
- @original_string = self.as_string.clone
35
- rescue Exception => e
36
- exception = BigBlueButton::BigBlueButtonException.new("Error parsing the config XML. Error: #{e.message}")
37
- exception.key = 'XMLParsingError'
38
- raise exception
39
- end
40
- end
41
- end
42
-
43
- def get_attribute(finder, attr_name, is_module=true)
44
- if is_module
45
- tag = find_module(finder)
46
- else
47
- tag = find_tag(finder)
48
- end
49
- if tag
50
- find_attribute(tag, attr_name)
51
- else
52
- nil
53
- end
54
- end
55
-
56
- def set_attribute(finder, attr_name, value, is_module=true)
57
- if is_module
58
- tag = find_module(finder)
59
- else
60
- tag = find_tag(finder)
61
- end
62
- if tag
63
- attr = find_attribute(tag, attr_name)
64
- if attr
65
- # saves always as string
66
- tag[attr_name] = value.is_a?(String) ? value : value.to_s
67
- else
68
- nil
69
- end
70
- else
71
- nil
72
- end
73
- end
74
-
75
- def as_string
76
- XmlSimple.xml_out(@xml, { 'RootName' => nil, 'XmlDeclaration' => false, 'NoIndent' => true })
77
- end
78
-
79
- def is_modified?
80
- @xml and
81
- self.as_string != @original_string
82
- end
83
-
84
- protected
85
-
86
- def find_module(module_name)
87
- if xml_has_modules
88
- modules = @xml["config"]["modules"]["module"]
89
- modules = [modules] unless modules.is_a?(Array)
90
- modules.each do |mod|
91
- if mod["name"] == module_name
92
- return mod
93
- end
94
- end
95
- end
96
- nil
97
- end
98
-
99
- def find_tag(name)
100
- if xml_has_config
101
- @xml["config"][name]
102
- end
103
- end
104
-
105
- def find_attribute(mod, attr_name)
106
- if mod and mod[attr_name]
107
- return mod[attr_name]
108
- else
109
- return nil
110
- end
111
- end
112
-
113
- def xml_has_modules
114
- xml_has_config and
115
- @xml["config"]["modules"] and
116
- @xml["config"]["modules"]["module"]
117
- end
118
-
119
- def xml_has_config
120
- @xml and @xml["config"]
121
- end
122
-
123
- end
124
-
125
- end