innowhite 0.1.2 → 0.1.3

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.
Files changed (3) hide show
  1. data/innowhite.gemspec +1 -1
  2. data/lib/innowhite.rb +11 -9
  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.2"
5
+ s.version = "0.1.3"
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,20 +1,20 @@
1
+ require 'open-uri'
1
2
  require 'nokogiri'
2
3
  class Innowhite
3
4
 
4
5
  attr_accessor :mod_name, :org_name, :sub, :server_address, :private_key
5
6
 
6
- def initialize(mod_name, org_name = nil, parent_org = "innowhite")
7
+ def initialize(mod_name, org_name = nil)
7
8
  load_settings
8
9
  @mod_name = mod_name.gsub(/ /,'')
9
- @org_name = org_name unless org_name.blank?
10
- @parent_org = parent_org
10
+ @org_name = org_name.nil? ? @parent_org : org_name
11
11
  end
12
12
 
13
13
  def load_settings
14
14
  settings = YAML.load_file('config/innowhite.yml')
15
15
  @server_address = settings["innowhite"]["server_address"]
16
16
  @private_key = settings["innowhite"]["private_key"]
17
- @org_name = settings["innowhite"]["organization"]
17
+ @parent_org = settings["innowhite"]["organization"]
18
18
  end
19
19
 
20
20
  def create_room
@@ -25,7 +25,7 @@ class Innowhite
25
25
 
26
26
  def set_room_id
27
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)}"))
28
+ doc = Nokogiri::XML(open("#{@server_address}CreateRoom?parentOrg=#{@parent_org}&orgName=#{@org_name}&user=#{@mod_name}&checksum=#{generate_checksum(@parent_org,@org_name, @mod_name)}"))
29
29
  status = doc.xpath('//returnStatus').text.gsub("\n","") rescue ""
30
30
  if status.include?('SUCCESS')
31
31
  room_id = doc.xpath('//roomId').text.gsub("\n","").to_i
@@ -36,7 +36,7 @@ class Innowhite
36
36
  elsif status.include?('OUT_OF_SERVICE')
37
37
  room_id = 'OUT_OF_SERVICE'
38
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)}"
39
+ room_id = "Error With the Server #{@server_address}CreateRoom?parentOrg=#{@parent_org}&orgName=#{@org_name}&user=#{@mod_name}&checksum=#{generate_checksum(@parent_org,@org_name, @mod_name)}"
40
40
  end
41
41
  return room_id
42
42
  end
@@ -49,8 +49,10 @@ class Innowhite
49
49
  def get_sessions(status)
50
50
  ids = []
51
51
  descs = []
52
- res = []
53
- x = Nokogiri::XML(open("http://innowhite.com/get_active_session?orgName=#{@org_name}&status=#{status}"))
52
+ res = []
53
+ url = URI.escape("http://innowhite.com/get_active_session?orgName=#{@org_name}&status=#{status}")
54
+
55
+ x = Nokogiri::XML(open(url))
54
56
  x.xpath('//web-session/session-id').each{|m| ids << m.text}
55
57
  x.xpath('//web-session/session-desc').each{|m| descs << m.text}
56
58
 
@@ -64,7 +66,7 @@ class Innowhite
64
66
 
65
67
  def join_room_helper(server_addr, org_name, room_id,user, is_teacher)
66
68
  action = "#{server_addr}JoinRoom?"
67
- address = "parentOrg=innowhite&orgName=#{org_name}&roomId=#{room_id}&user=#{user}&roomLeader=#{is_teacher}"
69
+ address = "parentOrg=#{@parent_org}&orgName=#{org_name}&roomId=#{room_id}&user=#{user}&roomLeader=#{is_teacher}"
68
70
  checksum = address+@private_key
69
71
  return "#{action}#{address}&checksum=#{generating_checksum(checksum)}"
70
72
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 2
9
- version: 0.1.2
8
+ - 3
9
+ version: 0.1.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - bainur