canvas_connect 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,25 +24,27 @@ module CanvasConnect
24
24
  class MeetingFolderError < StandardError; end
25
25
  class MeetingNotFound < StandardError; end
26
26
 
27
- # Public: Configure as a Canvas plugin.
28
- #
29
- # Returns nothing.
30
- def self.register
31
- Rails.configuration.to_prepare do
32
- view_path = File.expand_path('../app/views', File.dirname(__FILE__))
33
- unless ApplicationController.view_paths.include?(view_path)
34
- ApplicationController.view_paths.unshift(view_path)
35
- end
27
+ configure_method = Proc.new do
28
+ view_path = File.expand_path('../app/views', File.dirname(__FILE__))
29
+ unless ApplicationController.view_paths.include?(view_path)
30
+ ApplicationController.view_paths.unshift(view_path)
31
+ end
36
32
 
37
- ActiveSupport::Dependencies.autoload_paths << File.expand_path('../app/models', File.dirname(__FILE__))
33
+ ActiveSupport::Dependencies.autoload_paths << File.expand_path('../app/models', File.dirname(__FILE__))
38
34
 
39
- require_dependency File.expand_path('../app/models/adobe_connect_conference.rb', File.dirname(__FILE__))
40
- require_dependency "canvas/plugins/validators/adobe_connect_validator"
41
- require_dependency "canvas/plugins/adobe_connect"
42
- require_dependency "canvas_connect/meeting_archive"
35
+ require_dependency File.expand_path('../app/models/adobe_connect_conference.rb', File.dirname(__FILE__))
36
+ require_dependency "canvas/plugins/validators/adobe_connect_validator"
37
+ require_dependency "canvas/plugins/adobe_connect"
38
+ require_dependency "canvas_connect/meeting_archive"
43
39
 
44
- Canvas::Plugins::AdobeConnect.new
45
- end
40
+ Canvas::Plugins::AdobeConnect.new
41
+ end
42
+
43
+ if CANVAS_RAILS2
44
+ Rails.configuration.to_prepare(&configure_method)
45
+ else
46
+ class Railtie < Rails::Railtie; end
47
+ Railtie.config.to_prepare(&configure_method)
46
48
  end
47
49
 
48
50
  # Public: Find the plugin configuration.
@@ -76,5 +78,3 @@ module CanvasConnect
76
78
  @client
77
79
  end
78
80
  end
79
-
80
- CanvasConnect.register
@@ -15,6 +15,8 @@
15
15
  # You should have received a copy of the GNU Affero General Public License along
16
16
  # with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  #
18
+ require 'active_support/core_ext/object'
19
+
18
20
  module CanvasConnect
19
21
  class MeetingArchive
20
22
  ATTRIBUTES = [:name, :url_path, :date_begin, :date_end, :date_modified, :duration, :date_created]
@@ -22,7 +24,7 @@ module CanvasConnect
22
24
 
23
25
  def self.retrieve(meeting_id, client = CanvasConnect.client)
24
26
  result = client.sco_contents(sco_id: meeting_id, filter_icon: 'archive')
25
- Array(result.at_xpath('results/scos').try(:children)).map do |archive|
27
+ result.css('results scos').map do |archive|
26
28
  MeetingArchive.new(Nokogiri::XML(archive.to_xml))
27
29
  end
28
30
  end
@@ -42,7 +44,7 @@ module CanvasConnect
42
44
 
43
45
  def method_missing(meth, *args, &block)
44
46
  if ATTRIBUTES.include?(meth)
45
- @attr_cache[meth] ||= @archive.at_xpath("//#{meth.to_s.dasherize}").try(:text)
47
+ @attr_cache[meth] ||= @archive.at_css("#{meth.to_s.dasherize}").try(:text)
46
48
  else
47
49
  super
48
50
  end
@@ -1,3 +1,3 @@
1
1
  module CanvasConnect
2
- VERSION = '0.2'
2
+ VERSION = '0.3'
3
3
  end
metadata CHANGED
@@ -1,32 +1,36 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canvas_connect
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: '0.3'
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Zach Pendleton
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-10-06 00:00:00.000000000 Z
12
+ date: 2013-12-04 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rake
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - '>='
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: 0.9.6
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - '>='
27
+ - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: 0.9.6
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: adobe_connect
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ~>
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ~>
39
44
  - !ruby/object:Gem::Version
@@ -60,33 +65,30 @@ files:
60
65
  - lib/canvas_connect.rb
61
66
  - lib/canvas_connect/meeting_archive.rb
62
67
  - lib/canvas_connect/version.rb
63
- - spec_canvas/lib/canvas/plugins/validators/adobe_connect_validator_spec.rb
64
- - spec_canvas/lib/canvas_connect/meeting_archive_spec.rb
65
- - spec_canvas/lib/canvas_connect/response_spec.rb
66
- - spec_canvas/lib/canvas_connect/service_spec.rb
67
- - spec_canvas/models/adobe_connect_conference_spec.rb
68
68
  homepage: http://instructure.com
69
69
  licenses: []
70
- metadata: {}
71
70
  post_install_message:
72
71
  rdoc_options: []
73
72
  require_paths:
74
73
  - app
75
74
  - lib
76
75
  required_ruby_version: !ruby/object:Gem::Requirement
76
+ none: false
77
77
  requirements:
78
- - - '>='
78
+ - - ! '>='
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
81
  required_rubygems_version: !ruby/object:Gem::Requirement
82
+ none: false
82
83
  requirements:
83
- - - '>='
84
+ - - ! '>='
84
85
  - !ruby/object:Gem::Version
85
86
  version: '0'
86
87
  requirements: []
87
88
  rubyforge_project:
88
- rubygems_version: 2.0.3
89
+ rubygems_version: 1.8.23
89
90
  signing_key:
90
- specification_version: 4
91
+ specification_version: 3
91
92
  summary: Adobe Connect integration for Instructure Canvas (http://instructure.com).
92
93
  test_files: []
94
+ has_rdoc:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 44f5fe287ab3b420a5dfe8d086ecb2baf9f52204
4
- data.tar.gz: 8d25e01e810dc848577605c98e6eb7f25e19ed73
5
- SHA512:
6
- metadata.gz: 7df57750b292460c1d85d931d11dc4ba54d25e65a62dabec02df23568c1ae4d9aff473c2baef293a83e98352723492ba0373efa1d0abece052104ea9032b7d13
7
- data.tar.gz: 0c045d467ec9046be597a6b3f6d6af6723bbd00c51bbf0727e639dd00ca35e5cb373c854bb2435e251a53f035bd572545a9184da8eb14ad742997221474ad0c2
@@ -1,45 +0,0 @@
1
- #
2
- # Copyright (C) 2012 Instructure, Inc.
3
- #
4
- # This file is part of Canvas.
5
- #
6
- # Canvas is free software: you can redistribute it and/or modify it under
7
- # the terms of the GNU Affero General Public License as published by the Free
8
- # Software Foundation, version 3 of the License.
9
- #
10
- # Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
11
- # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
- # A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13
- # details.
14
- #
15
- # You should have received a copy of the GNU Affero General Public License along
16
- # with this program. If not, see <http://www.gnu.org/licenses/>.
17
- #
18
-
19
- require File.expand_path(File.dirname(__FILE__) + '/../../../../../../../../spec/spec_helper')
20
-
21
- describe Canvas::Plugins::Validators::AdobeConnectValidator do
22
- let(:plugin_setting) { mock }
23
-
24
- subject { Canvas::Plugins::Validators::AdobeConnectValidator }
25
-
26
- it 'should allow an empty hash' do
27
- subject.validate({}, plugin_setting).should eql Hash.new
28
- end
29
-
30
- it 'should error on missing keys' do
31
- plugin_setting.expects(:errors).returns(stub(:add_to_base => true))
32
- subject.validate({:domain => 'example.com'}, plugin_setting).should be_false
33
- end
34
-
35
- it 'should pass if all keys exist' do
36
- valid_keys = {
37
- :domain => 'example.com',
38
- :login => 'username',
39
- :password => 'password',
40
- :meeting_container => 'folder_name'
41
- }
42
-
43
- subject.validate(valid_keys, plugin_setting).should eql valid_keys
44
- end
45
- end
@@ -1,71 +0,0 @@
1
- #
2
- # Copyright (C) 2013 Instructure, Inc.
3
- #
4
- # This file is part of Canvas.
5
- #
6
- # Canvas is free software: you can redistribute it and/or modify it under
7
- # the terms of the GNU Affero General Public License as published by the Free
8
- # Software Foundation, version 3 of the License.
9
- #
10
- # Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
11
- # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
- # A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13
- # details.
14
- #
15
- # You should have received a copy of the GNU Affero General Public License along
16
- # with this program. If not, see <http://www.gnu.org/licenses/>.
17
- #
18
-
19
- require File.expand_path(File.dirname(__FILE__) + '/../../../../../../spec/spec_helper')
20
-
21
- describe CanvasConnect::Response do
22
-
23
- describe CanvasConnect::MeetingArchive do
24
-
25
- subject { CanvasConnect::MeetingArchive.retrieve(38230, nil).first }
26
-
27
- before (:each) do
28
- subject.should_receive(:archive) {
29
- '<?xml version="1.0" encoding="utf-8"?>
30
- <results>
31
- <status code="ok"/>
32
- <scos>
33
- <sco sco-id="38230" source-sco-id="" folder-id="38223" type="content" icon="archive" display-seq="0" duration="0" is-folder="0">
34
- <name>Test Recording</name>
35
- <url-path>/p3u8rj0rvuj/</url-path>
36
- <date-begin>2013-09-05T12:13:03.387-06:00</date-begin>
37
- <date-end>2013-09-05T12:13:28.970-06:00</date-end>
38
- <date-created>2013-09-05T12:13:03.387-06:00</date-created>
39
- <date-modified>2013-09-05T12:13:29.727-06:00</date-modified>
40
- </sco>
41
- </scos>
42
- </results>'
43
- }
44
- end
45
-
46
- it "returns the name" do
47
- subject.name.should == 'Test Recording'
48
- end
49
-
50
- it "returns the url_path" do
51
- subject.url_path.should == '/p3u8rj0rvuj/'
52
- end
53
-
54
- it "returns the date_begin" do
55
- subject.date_begin.should == '2013-09-05T12:13:03.387-06:00'
56
- end
57
-
58
- it "returns the date end" do
59
- subject.date_end.should == '2013-09-05T12:13:28.970-06:00'
60
- end
61
-
62
- it "returns the date created" do
63
- subject.date_created.should == '2013-09-05T12:13:03.387-06:00'
64
- end
65
-
66
- it "returns the date modified" do
67
- subject.date_modified.should == '2013-09-05T12:13:29.727-06:00'
68
- end
69
-
70
- end
71
- end
@@ -1,52 +0,0 @@
1
- #
2
- # Copyright (C) 2012 Instructure, Inc.
3
- #
4
- # This file is part of Canvas.
5
- #
6
- # Canvas is free software: you can redistribute it and/or modify it under
7
- # the terms of the GNU Affero General Public License as published by the Free
8
- # Software Foundation, version 3 of the License.
9
- #
10
- # Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
11
- # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
- # A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13
- # details.
14
- #
15
- # You should have received a copy of the GNU Affero General Public License along
16
- # with this program. If not, see <http://www.gnu.org/licenses/>.
17
- #
18
-
19
- require File.expand_path(File.dirname(__FILE__) + '/../../../../../../spec/spec_helper')
20
-
21
- describe CanvasConnect::Response do
22
- let(:body) { '<?xml version="1.0"?><items><item>Item Name</item></items>' }
23
- subject { CanvasConnect::Response.new(200, {}, body) }
24
-
25
- it { should respond_to(:status) }
26
- it { should respond_to(:headers) }
27
- it { should respond_to(:body) }
28
-
29
- its(:body) { should be_an_instance_of(Nokogiri::XML::Document) }
30
-
31
- describe 'initialize' do
32
- it 'should require a status' do
33
- lambda { CanvasConnect::Response.new }.should raise_error(ArgumentError)
34
- end
35
-
36
- it 'should require headers' do
37
- lambda { CanvasConnect::Response.new(200) }.should raise_error(ArgumentError)
38
- end
39
-
40
- it 'should require a body' do
41
- lambda { CanvasConnect::Response.new(200, {}) }.should raise_error(ArgumentError)
42
- end
43
- end
44
-
45
- describe 'simple delegator' do
46
- let(:body) { '<?xml version="1.0"?><items><item>Item Name</item></items>' }
47
-
48
- it 'should delegate to body' do
49
- subject.xpath('//item').text.should eql 'Item Name'
50
- end
51
- end
52
- end
@@ -1,104 +0,0 @@
1
- #
2
- # Copyright (C) 2012 Instructure, Inc.
3
- #
4
- # This file is part of Canvas.
5
- #
6
- # Canvas is free software: you can redistribute it and/or modify it under
7
- # the terms of the GNU Affero General Public License as published by the Free
8
- # Software Foundation, version 3 of the License.
9
- #
10
- # Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
11
- # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
- # A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13
- # details.
14
- #
15
- # You should have received a copy of the GNU Affero General Public License along
16
- # with this program. If not, see <http://www.gnu.org/licenses/>.
17
- #
18
-
19
- require File.expand_path(File.dirname(__FILE__) + '/../../../../../../spec/spec_helper')
20
-
21
- describe CanvasConnect::Service do
22
- subject { CanvasConnect::Service.new('username', 'password', 'http://connect.example.com') }
23
-
24
- before(:each) do
25
- subject.stubs(:session_key).returns('CookieValue')
26
- end
27
-
28
- let(:login_response) do
29
- body = <<-END
30
- <?xml version="1.0" encoding="utf-8"?>
31
- <results>
32
- <status code="ok" />
33
- </results>
34
- END
35
-
36
- CanvasConnect::Response.new(200, {}, body)
37
- end
38
-
39
- let(:session_response) do
40
- body = <<-END
41
- <?xml version="1.0" encoding="utf-8"?>
42
- <results>
43
- <status code="ok" />
44
- <common locale="en" time-zone-id="1" time-zone-java-id="America/Denver">
45
- <cookie>CookieValue</cookie>
46
- <date>2012-12-21T12:00:00Z</date>
47
- <host>http://connect.example.com</host>
48
- <local-host>SpecHost</local-host>
49
- <admin-host>http://connect.example.com</admin-host>
50
- <url>/api/xml?action=common-info&session=CookieValue</url>
51
- <version>9.0.0.1</version>
52
- <account account-id="1" />
53
- <user user-id="1" type="user">
54
- <name>Don Draper</name>
55
- <login>don@sterlingcooperdraperpryce.com</login>
56
- </user>
57
- </common>
58
- <reg-user>
59
- <is-reg-user>false</is-reg-user>
60
- </reg-user>
61
- </results>
62
- END
63
-
64
- CanvasConnect::Response.new(200, {}, body)
65
- end
66
-
67
- it { should respond_to(:username) }
68
- it { should respond_to(:domain) }
69
- it { should respond_to(:is_authenticated) }
70
-
71
- describe 'initialize' do
72
- it 'should require a username' do
73
- lambda { CanvasConnect::Service.new }.should raise_error(ArgumentError)
74
- end
75
-
76
- it 'should require a password' do
77
- lambda { CanvasConnect::Service.new('username') }.should raise_error(ArgumentError)
78
- end
79
-
80
- it 'should require a domain' do
81
- lambda { CanvasConnect::Service.new('username', 'password') }.should raise_error(ArgumentError)
82
- end
83
- end
84
-
85
- describe 'log in' do
86
- it 'should authenticate the given user' do
87
- subject.expects(:request).with('login', { :login => 'username', :password => 'password' }, true).returns(login_response)
88
- subject.log_in
89
- subject.should be_logged_in
90
- end
91
- end
92
-
93
- describe 'method_missing' do
94
- before(:each) do
95
- Struct.new('FakeResponse', :status, :headers, :body)
96
- @fake_response = Struct::FakeResponse.new(200, {}, '')
97
- end
98
-
99
- it 'should pass unknown methods onto the Adobe Connect API' do
100
- subject.send(:client).expects(:get).with('http://connect.example.com/api/xml?action=fake-call', {'session' => 'CookieValue'}).returns(@fake_response)
101
- subject.fake_call.should be_an_instance_of(CanvasConnect::Response)
102
- end
103
- end
104
- end
@@ -1,54 +0,0 @@
1
- #
2
- # Copyright (C) 2012 Instructure, Inc.
3
- #
4
- # This file is part of Canvas.
5
- #
6
- # Canvas is free software: you can redistribute it and/or modify it under
7
- # the terms of the GNU Affero General Public License as published by the Free
8
- # Software Foundation, version 3 of the License.
9
- #
10
- # Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
11
- # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
- # A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13
- # details.
14
- #
15
- # You should have received a copy of the GNU Affero General Public License along
16
- # with this program. If not, see <http://www.gnu.org/licenses/>.
17
- #
18
-
19
- require File.expand_path(File.dirname(__FILE__) + '/../../../../../spec/spec_helper')
20
-
21
- describe AdobeConnectConference do
22
- CONNECT_CONFIG = {
23
- :domain => 'http://connect.example.com',
24
- :username => 'user',
25
- :password => 'password',
26
- :password_dec => 'password',
27
- :meeting_container => 'canvas_meetings'
28
- }
29
-
30
- before(:each) do
31
- @conference = AdobeConnectConference.new
32
- @conference.stubs(:config).returns(CONNECT_CONFIG)
33
- end
34
-
35
- subject { AdobeConnectConference.new }
36
-
37
- context 'with an admin participant' do
38
- before(:each) do
39
- @user = User.new(:name => 'Don Draper')
40
- AdobeConnect::Service.stubs(:user_session).returns('CookieValue')
41
- @conference.expects(:add_host).with(@user).returns(@user)
42
- end
43
-
44
- it 'should generate an admin url using unique format if stored' do
45
- stored_url = 'canvas-mtg-ACCOUNT_ID-ID-CREATED_SECONDS'
46
- @conference.settings[:meeting_url_id] = stored_url
47
- @conference.admin_join_url(@user).should == "http://connect.example.com/#{stored_url}"
48
- end
49
-
50
- it 'should generate an admin url using legacy format' do
51
- @conference.admin_join_url(@user).should == "http://connect.example.com/canvas-meeting-#{@conference.id}"
52
- end
53
- end
54
- end