canvas_webex 0.7 → 0.8
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.
@@ -18,12 +18,23 @@
|
|
18
18
|
|
19
19
|
class CiscoWebexConference < WebConference
|
20
20
|
|
21
|
+
after_save :format_scheduled_date
|
22
|
+
|
23
|
+
user_setting_field :scheduled_date, {
|
24
|
+
name: -> { t('scheduled_date_setting', 'Scheduled Date') },
|
25
|
+
description: -> { t('scheduled_date_setting_description', 'Scheduled Date') },
|
26
|
+
type: :date_picker,
|
27
|
+
visible: true,
|
28
|
+
default: '',
|
29
|
+
location: 'userSettings'
|
30
|
+
}
|
31
|
+
|
21
32
|
user_setting_field :external_emails, {
|
22
|
-
name: ->{ t('external_emails_setting', 'External Emails') },
|
23
|
-
description: ->{ t('external_emails_setting_description', 'External emails') },
|
33
|
+
name: -> { t('external_emails_setting', 'External Emails') },
|
34
|
+
description: -> { t('external_emails_setting_description', 'External emails') },
|
24
35
|
type: :text,
|
25
36
|
visible: true,
|
26
|
-
default:
|
37
|
+
default: '',
|
27
38
|
location: 'members'
|
28
39
|
}
|
29
40
|
|
@@ -32,9 +43,12 @@ class CiscoWebexConference < WebConference
|
|
32
43
|
# Returns a meeting.
|
33
44
|
def initiate_conference
|
34
45
|
unless self.conference_key.present?
|
35
|
-
options = {
|
36
|
-
|
37
|
-
|
46
|
+
options = {
|
47
|
+
duration: self.duration || 999999,
|
48
|
+
emails: settings[:external_emails].nil? ? [] : settings[:external_emails].strip.split(';'),
|
49
|
+
scheduled_date: scheduled_date.in_time_zone(user.time_zone),
|
50
|
+
time_zone: user.time_zone
|
51
|
+
}
|
38
52
|
webex_meeting = CanvasWebex::Meeting.create(self.title, options)
|
39
53
|
self.conference_key = webex_meeting.meeting_key
|
40
54
|
save
|
@@ -49,7 +63,13 @@ class CiscoWebexConference < WebConference
|
|
49
63
|
if self.started_at.nil?
|
50
64
|
:created
|
51
65
|
elsif meeting && self.ended_at.nil?
|
52
|
-
|
66
|
+
if self.end_at && self.end_at > Time.now
|
67
|
+
:active
|
68
|
+
elsif self.end_at.nil?
|
69
|
+
:active
|
70
|
+
else
|
71
|
+
:closed
|
72
|
+
end
|
53
73
|
else
|
54
74
|
unless self.ended_at
|
55
75
|
self.close
|
@@ -60,6 +80,13 @@ class CiscoWebexConference < WebConference
|
|
60
80
|
end
|
61
81
|
end
|
62
82
|
|
83
|
+
# Public: The schedule date of the conference
|
84
|
+
#
|
85
|
+
# Returns the scheduled date of the conference or nil if there isn't a scheduled date
|
86
|
+
def scheduled_date
|
87
|
+
@scheduled_date ||= user.time_zone.parse(settings[:scheduled_date]).utc unless settings[:scheduled_date].blank?
|
88
|
+
end
|
89
|
+
|
63
90
|
# Public: Add an admin to the conference and create a meeting URL (required by WebConference).
|
64
91
|
#
|
65
92
|
# admin - The user to add to the conference as an admin.
|
@@ -101,6 +128,11 @@ class CiscoWebexConference < WebConference
|
|
101
128
|
conference_status
|
102
129
|
end
|
103
130
|
|
131
|
+
def as_json(options={})
|
132
|
+
format_scheduled_date
|
133
|
+
super(options)
|
134
|
+
end
|
135
|
+
|
104
136
|
protected
|
105
137
|
|
106
138
|
def webex_client
|
@@ -114,5 +146,13 @@ class CiscoWebexConference < WebConference
|
|
114
146
|
self.conference_key && CanvasWebex::Meeting.retrieve(self.conference_key)
|
115
147
|
end
|
116
148
|
|
149
|
+
def format_scheduled_date
|
150
|
+
if date = user.time_zone &&!user_settings[:scheduled_date].blank? && user_settings[:scheduled_date]
|
151
|
+
unless date =~ /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/
|
152
|
+
user_settings[:scheduled_date] = user.time_zone.parse(date).utc.iso8601
|
153
|
+
save
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
117
157
|
|
118
158
|
end
|
data/lib/canvas_webex/service.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module CanvasWebex
|
2
2
|
class Service
|
3
|
+
|
3
4
|
attr_reader :webex_id, :password, :site_id, :site_name, :partner_id, :status, :meeting_password
|
4
5
|
|
5
6
|
|
@@ -38,7 +39,12 @@ module CanvasWebex
|
|
38
39
|
}
|
39
40
|
end
|
40
41
|
xml.schedule{
|
41
|
-
|
42
|
+
if options[:scheduled_date]
|
43
|
+
xml.startDate options[:scheduled_date].in_time_zone('America/Los_Angeles').strftime("%m/%d/%Y %T") rescue nil
|
44
|
+
xml.timeZoneID 4
|
45
|
+
else
|
46
|
+
xml.startDate
|
47
|
+
end
|
42
48
|
xml.duration(options[:duration].to_i)
|
43
49
|
}
|
44
50
|
if options[:emails]
|
data/lib/canvas_webex/version.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CiscoWebexConference do
|
4
|
+
subject { CiscoWebexConference.new }
|
5
|
+
|
6
|
+
describe 'conference_status' do
|
7
|
+
it 'is created when there is no start date' do
|
8
|
+
subject.stub(:started_at) { nil }
|
9
|
+
subject.conference_status.should == :created
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'is active when there is a start date, a meeting, and no end date' do
|
13
|
+
subject.stub(:started_at) { Time.now }
|
14
|
+
subject.stub(:meeting) { [1, 2, 3] }
|
15
|
+
subject.conference_status.should == :active
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'is active when the end at is in the future' do
|
19
|
+
subject.stub(:started_at) { Time.now }
|
20
|
+
subject.stub(:meeting) { [1, 2, 3] }
|
21
|
+
subject.stub(:end_at) { Time.now + 1200 }
|
22
|
+
subject.conference_status.should == :active
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'is closed when the end at is in the past' do
|
26
|
+
subject.stub(:started_at) { Time.now }
|
27
|
+
subject.stub(:meeting) { [1, 2, 3] }
|
28
|
+
subject.stub(:end_at) { Time.now - 1200 }
|
29
|
+
subject.conference_status.should == :closed
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'is closed if there is no meeting' do
|
33
|
+
subject.stub(:started_at) { Time.now }
|
34
|
+
subject.stub(:meeting) { nil }
|
35
|
+
subject.conference_status.should == :closed
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -6,6 +6,33 @@ require 'net/http'
|
|
6
6
|
require 'webmock/rspec'
|
7
7
|
require 'pry'
|
8
8
|
|
9
|
+
class WebConference
|
10
|
+
def self.after_save(*args)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.user_setting_field(arg, arg2)
|
14
|
+
end
|
15
|
+
|
16
|
+
def started_at
|
17
|
+
end
|
18
|
+
|
19
|
+
def ended_at
|
20
|
+
end
|
21
|
+
|
22
|
+
def end_at
|
23
|
+
end
|
24
|
+
|
25
|
+
def end_at=(arg)
|
26
|
+
end
|
27
|
+
|
28
|
+
def save
|
29
|
+
end
|
30
|
+
|
31
|
+
def close
|
32
|
+
end
|
33
|
+
end
|
34
|
+
require 'models/cisco_webex_conference'
|
35
|
+
|
9
36
|
WebMock.disable_net_connect!
|
10
37
|
|
11
38
|
|
@@ -20,7 +47,7 @@ end
|
|
20
47
|
def stub_call(fixture_name, status = 200, request_body = nil)
|
21
48
|
stub = stub_request(:post, "https://instructure.webex.com/WBXService/XMLService")
|
22
49
|
stub = stub.with(body: request_body) if request_body
|
23
|
-
stub.to_return(status: status, body:fixture(fixture_name), headers:{
|
50
|
+
stub.to_return(status: status, body: fixture(fixture_name), headers: {
|
24
51
|
:content_type => 'application/xml; charset=utf-8'})
|
25
52
|
end
|
26
53
|
|
@@ -36,7 +63,7 @@ end
|
|
36
63
|
|
37
64
|
class String
|
38
65
|
def camelcase(first_letter = :upper)
|
39
|
-
|
40
|
-
|
66
|
+
return self if self !~ /_/ && self =~ /[A-Z]+.*/
|
67
|
+
split('_').map { |e| e.capitalize }.join
|
41
68
|
end
|
42
69
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: canvas_webex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.8'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-12-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- spec/fixtures/recording_list.xml
|
124
124
|
- spec/lib/canvas_webex/meeting_spec.rb
|
125
125
|
- spec/lib/canvas_webex/service_spec.rb
|
126
|
+
- spec/models/cisco_webex_conference_spec.rb
|
126
127
|
- spec/spec_helper.rb
|
127
128
|
homepage: http://instructure.com
|
128
129
|
licenses: []
|
@@ -159,5 +160,6 @@ test_files:
|
|
159
160
|
- spec/fixtures/recording_list.xml
|
160
161
|
- spec/lib/canvas_webex/meeting_spec.rb
|
161
162
|
- spec/lib/canvas_webex/service_spec.rb
|
163
|
+
- spec/models/cisco_webex_conference_spec.rb
|
162
164
|
- spec/spec_helper.rb
|
163
165
|
has_rdoc:
|