innowhite 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/innowhite.gemspec +1 -1
  2. data/lib/innowhite.rb +70 -73
  3. metadata +2 -2
data/innowhite.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{innowhite}
5
- s.version = "0.1.1"
5
+ s.version = "0.1.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = [%q{bainur}]
data/lib/innowhite.rb CHANGED
@@ -1,87 +1,84 @@
1
1
  require 'nokogiri'
2
- module InnowhiteLib
2
+ class Innowhite
3
3
 
4
- class Innowhite
5
-
6
- attr_accessor :mod_name, :org_name, :sub, :server_address, :private_key
7
-
8
- def initialize(mod_name, org_name = nil, parent_org = "innowhite")
9
- load_settings
10
- @mod_name = mod_name.gsub(/ /,'')
11
- @org_name = org_name unless org_name.blank?
12
- @parent_org = parent_org
13
- end
4
+ attr_accessor :mod_name, :org_name, :sub, :server_address, :private_key
14
5
 
15
- def load_settings
16
- settings = YAML.load_file('config/innowhite.yml')
17
- @server_address = settings["innowhite"]["server_address"]
18
- @private_key = settings["innowhite"]["private_key"]
19
- @org_name = settings["innowhite"]["organization"]
20
- end
6
+ def initialize(mod_name, org_name = nil, parent_org = "innowhite")
7
+ load_settings
8
+ @mod_name = mod_name.gsub(/ /,'')
9
+ @org_name = org_name unless org_name.blank?
10
+ @parent_org = parent_org
11
+ end
21
12
 
22
- def create_room
23
- room_id = set_room_id
24
- address = join_room_helper(@server_address,@org_name, room_id, @mod_name,true)
25
- return {:address => address, :room_id => room_id}
26
- end
13
+ def load_settings
14
+ settings = YAML.load_file('config/innowhite.yml')
15
+ @server_address = settings["innowhite"]["server_address"]
16
+ @private_key = settings["innowhite"]["private_key"]
17
+ @org_name = settings["innowhite"]["organization"]
18
+ end
27
19
 
28
- def set_room_id
29
- room_id = ""
30
- doc = Nokogiri::XML(open("#{@server_address}CreateRoom?parentOrg=innowhite&orgName=#{@sub_name}&user=#{@mod_name}&checksum=#{generate_checksum("innowhite",@sub_name, @mod_name)}"))
31
- status = doc.xpath('//returnStatus').text.gsub("\n","") rescue ""
32
- if status.include?('SUCCESS')
33
- room_id = doc.xpath('//roomId').text.gsub("\n","").to_i
34
- elsif status.include?('AUTH_FAILED')
35
- room_id = "AUTH_FAILED"
36
- elsif status.include?('EXPIRED')
37
- room_id = 'EXPIRED'
38
- elsif status.include?('OUT_OF_SERVICE')
39
- room_id = 'OUT_OF_SERVICE'
40
- else
41
- room_id = "Error With the Server #{@server_address}CreateRoom?parentOrg=innowhite&orgName=#{@sub_name}&user=#{@mod_name}&checksum=#{generate_checksum("innowhite",@sub_name, @mod_name)}"
42
- end
43
- return room_id
44
- end
45
-
46
- def join_meeting(room_id, user)
47
- address = join_room_helper(@server_address,@org_name, room_id, user, false)
48
- return address
49
- end
20
+ def create_room
21
+ room_id = set_room_id
22
+ address = join_room_helper(@server_address,@org_name, room_id, @mod_name,true)
23
+ return {:address => address, :room_id => room_id}
24
+ end
50
25
 
51
- def get_sessions(status)
52
- ids = []
53
- descs = []
54
- res = []
55
- x = Nokogiri::XML(open("http://innowhite.com/get_active_session?orgName=#{@org_name}&status=#{status}"))
56
- x.xpath('//web-session/session-id').each{|m| ids << m.text}
57
- x.xpath('//web-session/session-desc').each{|m| descs << m.text}
58
-
59
- ids.each_with_index do |id, index|
60
- res << {:id => id, :description => descs[index]}
61
- end
62
- return res
26
+ def set_room_id
27
+ room_id = ""
28
+ doc = Nokogiri::XML(open("#{@server_address}CreateRoom?parentOrg=innowhite&orgName=#{@sub_name}&user=#{@mod_name}&checksum=#{generate_checksum("innowhite",@sub_name, @mod_name)}"))
29
+ status = doc.xpath('//returnStatus').text.gsub("\n","") rescue ""
30
+ if status.include?('SUCCESS')
31
+ room_id = doc.xpath('//roomId').text.gsub("\n","").to_i
32
+ elsif status.include?('AUTH_FAILED')
33
+ room_id = "AUTH_FAILED"
34
+ elsif status.include?('EXPIRED')
35
+ room_id = 'EXPIRED'
36
+ elsif status.include?('OUT_OF_SERVICE')
37
+ room_id = 'OUT_OF_SERVICE'
38
+ else
39
+ room_id = "Error With the Server #{@server_address}CreateRoom?parentOrg=innowhite&orgName=#{@sub_name}&user=#{@mod_name}&checksum=#{generate_checksum("innowhite",@sub_name, @mod_name)}"
63
40
  end
41
+ return room_id
42
+ end
64
43
 
65
- private
44
+ def join_meeting(room_id, user)
45
+ address = join_room_helper(@server_address,@org_name, room_id, user, false)
46
+ return address
47
+ end
66
48
 
67
- def join_room_helper(server_addr, org_name, room_id,user, is_teacher)
68
- action = "#{server_addr}JoinRoom?"
69
- address = "parentOrg=innowhite&orgName=#{org_name}&roomId=#{room_id}&user=#{user}&roomLeader=#{is_teacher}"
70
- checksum = address+@private_key
71
- return "#{action}#{address}&checksum=#{generating_checksum(checksum)}"
72
- end
49
+ def get_sessions(status)
50
+ ids = []
51
+ descs = []
52
+ res = []
53
+ x = Nokogiri::XML(open("http://innowhite.com/get_active_session?orgName=#{@org_name}&status=#{status}"))
54
+ x.xpath('//web-session/session-id').each{|m| ids << m.text}
55
+ x.xpath('//web-session/session-desc').each{|m| descs << m.text}
73
56
 
74
- def generating_checksum(params)
75
- Digest::SHA1.hexdigest(params)
57
+ ids.each_with_index do |id, index|
58
+ res << {:id => id, :description => descs[index]}
76
59
  end
60
+ return res
61
+ end
77
62
 
78
- def generate_checksum(parent_org, org_name,user_name)
79
- Digest::SHA1.hexdigest(generate_information_url(parent_org, org_name,user_name))
80
- end
63
+ private
81
64
 
82
- def generate_information_url(parent_org, org_name,user_name)
83
- "parentOrg=#{parent_org}&orgName=#{org_name}&user=#{user_name}#{@private_key}"
84
- end
65
+ def join_room_helper(server_addr, org_name, room_id,user, is_teacher)
66
+ action = "#{server_addr}JoinRoom?"
67
+ address = "parentOrg=innowhite&orgName=#{org_name}&roomId=#{room_id}&user=#{user}&roomLeader=#{is_teacher}"
68
+ checksum = address+@private_key
69
+ return "#{action}#{address}&checksum=#{generating_checksum(checksum)}"
70
+ end
71
+
72
+ def generating_checksum(params)
73
+ Digest::SHA1.hexdigest(params)
74
+ end
75
+
76
+ def generate_checksum(parent_org, org_name,user_name)
77
+ Digest::SHA1.hexdigest(generate_information_url(parent_org, org_name,user_name))
78
+ end
79
+
80
+ def generate_information_url(parent_org, org_name,user_name)
81
+ "parentOrg=#{parent_org}&orgName=#{org_name}&user=#{user_name}#{@private_key}"
82
+ end
85
83
 
86
- end
87
- end
84
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - bainur