adobe_connect 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/.yardopts ADDED
@@ -0,0 +1,6 @@
1
+ --title "Adobe Connect"
2
+ --readme README.md
3
+ --protected
4
+ --private
5
+ --plugin yard-tomdoc
6
+ lib
data/README.md CHANGED
@@ -9,7 +9,7 @@ This gem provides a wrapper for interacting with the Adobe Connect API that
9
9
 
10
10
  Add this line to your application's Gemfile:
11
11
 
12
- gem 'adobe_connect', '0.0.5'
12
+ gem 'adobe_connect', '0.0.7'
13
13
 
14
14
  And then run:
15
15
 
@@ -17,13 +17,14 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ['lib']
19
19
 
20
- gem.add_dependency 'activesupport', '>= 2.3.16'
21
- gem.add_dependency 'nokogiri', '~> 1.5.6'
20
+ gem.add_dependency 'activesupport', '>= 2.3.17'
21
+ gem.add_dependency 'nokogiri', '~> 1.5.5'
22
22
  gem.add_dependency 'pry', '>= 0.9.11.4'
23
23
  gem.add_dependency 'rake', '>= 0.9.2'
24
24
 
25
25
  gem.add_development_dependency 'minitest', '~> 4.6.0'
26
26
  gem.add_development_dependency 'mocha', '~> 0.13.2'
27
+ gem.add_development_dependency 'redcarpet'
27
28
  gem.add_development_dependency 'yard', '~> 0.8.4.1'
28
29
  gem.add_development_dependency 'yard-tomdoc', '~> 0.6.0'
29
30
  end
data/lib/adobe_connect.rb CHANGED
@@ -10,4 +10,5 @@ require 'adobe_connect/param_formatter'
10
10
  require 'adobe_connect/meeting_folder'
11
11
  require 'adobe_connect/user'
12
12
 
13
+ # Public: Namespace for AdobeConnect classes/modules.
13
14
  module AdobeConnect; end
@@ -1,25 +1,68 @@
1
1
  module AdobeConnect
2
+
3
+ # Public: Manage configuration for AdobeConnect::Service objects, like
4
+ # username/password/domain.
2
5
  module Config
3
6
 
4
7
  @settings = Hash.new
5
8
 
6
9
  class << self
10
+ # Public: Merge the given settings hash into the current settings.
11
+ #
12
+ # settings - A hash of setting options.
13
+ #
14
+ # Returns nothing.
7
15
  def merge(settings)
8
16
  @settings.merge(settings)
9
17
  end
10
18
 
19
+ # Public: Declare default Connect settings using a block.
20
+ #
21
+ # &block - A block with configuration options.
22
+ #
23
+ # Examples
24
+ #
25
+ # AdobeConnect::Config.declare do
26
+ # username 'user@example.com'
27
+ # password 'password'
28
+ # domain 'http://connect.example.com'
29
+ # end
30
+ #
31
+ # Returns nothing.
11
32
  def declare(&block)
12
33
  instance_eval(&block)
13
34
  end
14
35
 
36
+ # Public: Fetch a single key value from the current settings.
37
+ #
38
+ # key - The key to fetch.
39
+ #
40
+ # Examples
41
+ #
42
+ # AdobeConnect::Config[:username] #=> 'user@example.com'
43
+ #
44
+ # Returns the value of the key (usually a string).
15
45
  def [](key)
16
46
  @settings[key]
17
47
  end
18
48
 
49
+ # Public: Set a single key's value.
50
+ #
51
+ # key - The name of the key to set.
52
+ # value - The value to set the key to.
53
+ #
54
+ # Examples
55
+ #
56
+ # AdobeConnect::Config[:username] = 'user@example.com'
57
+ #
58
+ # Returns nothing.
19
59
  def []=(key, value)
20
60
  @settings[key] = value
21
61
  end
22
62
 
63
+ # Public: Getter for the internal settings hash.
64
+ #
65
+ # Returns a hash.
23
66
  def settings; @settings; end
24
67
 
25
68
  private
@@ -1,7 +1,15 @@
1
1
  module AdobeConnect
2
+
3
+ # Public: Represents a folder object inside of Connect.
2
4
  class MeetingFolder
3
5
  attr_reader :name, :id, :service, :url
4
6
 
7
+ # Public: Create a new AdobeConnect::MeetingFolder.
8
+ #
9
+ # id - The SCO-ID of the folder object.
10
+ # name - The name of the folder object.
11
+ # url - The Connect URL of the object.
12
+ # service - An AdobeConnect::Service object (default: Service.new).
5
13
  def initialize(id, name, url, service = AdobeConnect::Service.new)
6
14
  @name = name
7
15
  @id = id
@@ -9,10 +17,19 @@ module AdobeConnect
9
17
  @url = url
10
18
  end
11
19
 
20
+ # Public: Fetch the contents of this folder.
21
+ #
22
+ # Returns a Nokogiri object.
12
23
  def contents
13
24
  service.sco_contents(:sco_id => id)
14
25
  end
15
26
 
27
+ # Public: Find a folder on the current Connect instance.
28
+ #
29
+ # name - The name of the folder to find.
30
+ # service - An AdobeConnect::Service object (default: Service.new).
31
+ #
32
+ # Returns a new AdobeConnect::MeetingFolder object.
16
33
  def self.find(name, service = AdobeConnect::Service.new)
17
34
  response = service.sco_search_by_field(
18
35
  :query => name,
@@ -1,11 +1,20 @@
1
1
  module AdobeConnect
2
+
3
+ # Public: Responsible for translating params hashes into query strings
2
4
  class ParamFormatter
3
5
  attr_reader :params
4
6
 
7
+ # Public: Create a new AdobeConnect::ParamFormatter.
8
+ #
9
+ # params - A hash of params to format.
5
10
  def initialize(params)
6
11
  @params = params
7
12
  end
8
13
 
14
+ # Public: Translate a hash of params into a query string. Dasherize any
15
+ # underscored values, and escape URL unfriendly values.
16
+ #
17
+ # Returns a query string.
9
18
  def format
10
19
  params.sort_by { |k, v| k.to_s }.inject(['']) do |array, param|
11
20
  key, value = param.map { |p| ERB::Util.url_encode(p) }
@@ -1,21 +1,41 @@
1
1
  module AdobeConnect
2
+
3
+ # Public: A response from the Connect API.
2
4
  class Response
3
5
  attr_reader :status, :body
4
6
 
7
+ # Public: Create a new AdobeConnect::Response.
8
+ #
9
+ # response - A Net::HTTP response.
5
10
  def initialize(response)
6
11
  @response = response
7
12
  @status = response.code.to_i
8
13
  @body = Nokogiri::XML(response.body)
9
14
  end
10
15
 
16
+ # Public: Fetch the given header's value.
17
+ #
18
+ # header - The string name of the header to fetch.
19
+ #
20
+ # Returns a header value as a string.
11
21
  def fetch(header)
12
22
  @response.fetch(header)
13
23
  end
14
24
 
25
+ # Public: Execute an xpath call against the response body.
26
+ #
27
+ # *args - Arguments to pass to Nokogiri's xpath method.
28
+ #
29
+ # Returns a Nokogiri object.
15
30
  def xpath(*args)
16
31
  @body.xpath(*args)
17
32
  end
18
33
 
34
+ # Public: Execute an at_xpath call against the response body.
35
+ #
36
+ # *args - Arguments to pass to Nokogiri's xpath method.
37
+ #
38
+ # Returns a Nokogiri object.
19
39
  def at_xpath(*args)
20
40
  @body.at_xpath(*args)
21
41
  end
@@ -1,7 +1,16 @@
1
1
  module AdobeConnect
2
+
3
+ # Public: Manages calls to the Connect API.
2
4
  class Service
3
5
  attr_reader :username, :domain, :session
4
6
 
7
+ # Public: Create a new AdobeConnect::Service.
8
+ #
9
+ # options - An AdobeConnect::Config object or a hash with the keys:
10
+ # :username - An Adobe Connect username.
11
+ # :password - The Connect user's password.
12
+ # :domain - The domain for the Connect instance (with protocol
13
+ # prepended).
5
14
  def initialize(options = AdobeConnect::Config)
6
15
  @username = options[:username]
7
16
  @password = options[:password]
@@ -9,6 +18,9 @@ module AdobeConnect
9
18
  @authenticated = false
10
19
  end
11
20
 
21
+ # Public: Authenticate against the currently configured Connect service.
22
+ #
23
+ # Returns a boolean.
12
24
  def log_in
13
25
  response = request('login', { :login => username, :password => password }, false)
14
26
  if response.at_xpath('//status').attr('code') == 'ok'
@@ -20,10 +32,16 @@ module AdobeConnect
20
32
  end
21
33
  end
22
34
 
35
+ # Public: Get the current authentication status.
36
+ #
37
+ # Returns a boolean.
23
38
  def authenticated?
24
39
  @authenticated
25
40
  end
26
41
 
42
+ # Public: Get the HTTP client used to make requests.
43
+ #
44
+ # Returns a Net::HTTP instance.
27
45
  def client
28
46
  if @client.nil?
29
47
  @client = Net::HTTP.new(domain.host, domain.port)
@@ -33,6 +51,17 @@ module AdobeConnect
33
51
  @client
34
52
  end
35
53
 
54
+ # Public: Forward any missing methods to the Connect instance.
55
+ #
56
+ # method - The name of the method called.
57
+ # *args - An array of arguments passed to the method.
58
+ #
59
+ # Examples
60
+ #
61
+ # service = AdobeConnect::Service.new
62
+ # service.sco_by_url(url_path: '/example/') #=> calls service.request.
63
+ #
64
+ # Returns an AdobeConnect::Response.
36
65
  def method_missing(method, *args)
37
66
  action = method.to_s.dasherize
38
67
  params = args.first
@@ -43,6 +72,13 @@ module AdobeConnect
43
72
  private
44
73
  attr_reader :password
45
74
 
75
+ # Public: Execute a call against the Adobe Connect instance.
76
+ #
77
+ # action - The name of the API action to call.
78
+ # params - A hash of params to pass in the request.
79
+ # use_session - If true, require an active session (default: true).
80
+ #
81
+ # Returns an AdobeConnect::Response.
46
82
  def request(action, params, use_session = true)
47
83
  if use_session
48
84
  log_in unless authenticated?
@@ -1,21 +1,47 @@
1
1
  module AdobeConnect
2
+
3
+ # Public: Represents a user in a Connect environment.
2
4
  class User
3
- attr_reader :id, :app_user, :service, :errors
5
+ # Public: SCO-ID from the Adobe Connect instance.
6
+ attr_reader :id
7
+
8
+ # Public: Generic user object.
9
+ attr_reader :app_user
10
+
11
+ attr_reader :service, :errors
4
12
 
13
+ # Public: Create a new AdobeConnect User.
14
+ #
15
+ # app_user - A user object with the following methods:
16
+ # first_name - User's first name.
17
+ # last_name - User's last name.
18
+ # email - The email address for the user.
19
+ # uuid - A unique identifier for this user (used to
20
+ # generate a password).
21
+ # service - An AdobeConnect::Service object (default: Service.new)
5
22
  def initialize(app_user, service = Service.new)
6
23
  @app_user = app_user
7
24
  @service = service
8
25
  @errors = []
9
26
  end
10
27
 
28
+ # Public: Getter for the Connect user's username.
29
+ #
30
+ # Returns an email string.
11
31
  def username
12
32
  app_user.email
13
33
  end
14
34
 
35
+ # Public: Generate a password for this connect user.
36
+ #
37
+ # Returns a password string.
15
38
  def password
16
39
  Digest::MD5.hexdigest(@app_user.uuid)[0..9]
17
40
  end
18
41
 
42
+ # Public: Save this user to the Adobe Connect instance.
43
+ #
44
+ # Returns a boolean.
19
45
  def save
20
46
  response = service.principal_update(:first_name => app_user.first_name,
21
47
  :last_name => app_user.last_name, :login => app_user.email,
@@ -30,6 +56,12 @@ module AdobeConnect
30
56
  end
31
57
  end
32
58
 
59
+ # Public: Create a Connect user from the given app user.
60
+ #
61
+ # app_user - A generic user object (see #initialize for required
62
+ # attributes).
63
+ #
64
+ # Returns an AdobeConnect::User.
33
65
  def self.create(app_user)
34
66
  user = AdobeConnect::User.new(app_user)
35
67
  user.save
@@ -37,6 +69,12 @@ module AdobeConnect
37
69
  user
38
70
  end
39
71
 
72
+ # Public: Find the given app user on the Connect server.
73
+ #
74
+ # app_user - A generic user object (see #initialize for required
75
+ # attributes).
76
+ #
77
+ # Returns an AdobeConnect::User or nil.
40
78
  def self.find(app_user)
41
79
  user = AdobeConnect::User.new(app_user)
42
80
  response = user.service.principal_list(:filter_login => user.username)
@@ -48,6 +86,11 @@ module AdobeConnect
48
86
  end
49
87
 
50
88
  private
89
+ # Internal: Store request errors in @errors.
90
+ #
91
+ # response - An AdobeConnect::Response.
92
+ #
93
+ # Returns nothing.
51
94
  def save_errors(response)
52
95
  @errors = response.xpath('//invalid').map(&:attributes)
53
96
  end
@@ -1,3 +1,4 @@
1
1
  module AdobeConnect
2
- VERSION = '0.0.6'
2
+ # Public: Current Gem version.
3
+ VERSION = '0.0.7'
3
4
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adobe_connect
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Zach Pendleton
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-02-13 00:00:00 Z
18
+ date: 2013-02-14 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activesupport
@@ -25,12 +25,12 @@ dependencies:
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- hash: 35
28
+ hash: 33
29
29
  segments:
30
30
  - 2
31
31
  - 3
32
- - 16
33
- version: 2.3.16
32
+ - 17
33
+ version: 2.3.17
34
34
  type: :runtime
35
35
  version_requirements: *id001
36
36
  - !ruby/object:Gem::Dependency
@@ -41,12 +41,12 @@ dependencies:
41
41
  requirements:
42
42
  - - ~>
43
43
  - !ruby/object:Gem::Version
44
- hash: 15
44
+ hash: 9
45
45
  segments:
46
46
  - 1
47
47
  - 5
48
- - 6
49
- version: 1.5.6
48
+ - 5
49
+ version: 1.5.5
50
50
  type: :runtime
51
51
  version_requirements: *id002
52
52
  - !ruby/object:Gem::Dependency
@@ -115,9 +115,23 @@ dependencies:
115
115
  type: :development
116
116
  version_requirements: *id006
117
117
  - !ruby/object:Gem::Dependency
118
- name: yard
118
+ name: redcarpet
119
119
  prerelease: false
120
120
  requirement: &id007 !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ hash: 3
126
+ segments:
127
+ - 0
128
+ version: "0"
129
+ type: :development
130
+ version_requirements: *id007
131
+ - !ruby/object:Gem::Dependency
132
+ name: yard
133
+ prerelease: false
134
+ requirement: &id008 !ruby/object:Gem::Requirement
121
135
  none: false
122
136
  requirements:
123
137
  - - ~>
@@ -130,11 +144,11 @@ dependencies:
130
144
  - 1
131
145
  version: 0.8.4.1
132
146
  type: :development
133
- version_requirements: *id007
147
+ version_requirements: *id008
134
148
  - !ruby/object:Gem::Dependency
135
149
  name: yard-tomdoc
136
150
  prerelease: false
137
- requirement: &id008 !ruby/object:Gem::Requirement
151
+ requirement: &id009 !ruby/object:Gem::Requirement
138
152
  none: false
139
153
  requirements:
140
154
  - - ~>
@@ -146,7 +160,7 @@ dependencies:
146
160
  - 0
147
161
  version: 0.6.0
148
162
  type: :development
149
- version_requirements: *id008
163
+ version_requirements: *id009
150
164
  description: An API wrapper for interacting with Adobe Connect services.
151
165
  email:
152
166
  - zachpendleton@gmail.com
@@ -159,6 +173,7 @@ extra_rdoc_files: []
159
173
  files:
160
174
  - .gitignore
161
175
  - .travis.yml
176
+ - .yardopts
162
177
  - Gemfile
163
178
  - LICENSE.txt
164
179
  - README.md