sakai-info 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +12 -6
- data/README.md +50 -78
- data/ROADMAP.md +19 -17
- data/bin/sakai-info +94 -43
- data/lib/sakai-info.rb +32 -5
- data/lib/sakai-info/announcement.rb +30 -34
- data/lib/sakai-info/assignment.rb +45 -80
- data/lib/sakai-info/authz.rb +77 -94
- data/lib/sakai-info/cli.rb +1 -23
- data/lib/sakai-info/cli/help.rb +45 -35
- data/lib/sakai-info/content.rb +28 -49
- data/lib/sakai-info/database.rb +114 -0
- data/lib/sakai-info/gradebook.rb +48 -50
- data/lib/sakai-info/group.rb +21 -32
- data/lib/sakai-info/message.rb +16 -25
- data/lib/sakai-info/sakai_object.rb +11 -4
- data/lib/sakai-info/samigo.rb +38 -61
- data/lib/sakai-info/site.rb +128 -186
- data/lib/sakai-info/user.rb +77 -68
- data/lib/sakai-info/version.rb +1 -1
- metadata +36 -11
- data/lib/sakai-info/configuration.rb +0 -288
- data/lib/sakai-info/db.rb +0 -19
- data/lib/sakai-info/instance.rb +0 -122
data/lib/sakai-info/db.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# sakai-info/db.rb
|
2
|
-
# SakaiInfo::DB library
|
3
|
-
#
|
4
|
-
# Created 2012-02-16 daveadams@gmail.com
|
5
|
-
# Last updated 2012-02-19 daveadams@gmail.com
|
6
|
-
#
|
7
|
-
# https://github.com/daveadams/sakai-info
|
8
|
-
#
|
9
|
-
# This software is public domain.
|
10
|
-
#
|
11
|
-
|
12
|
-
module SakaiInfo
|
13
|
-
class DB
|
14
|
-
def self.connect(instance_name = :default)
|
15
|
-
Configuration.get_instance(instance_name).connect
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
data/lib/sakai-info/instance.rb
DELETED
@@ -1,122 +0,0 @@
|
|
1
|
-
# sakai-info/instance.rb
|
2
|
-
# SakaiInfo::Instance library
|
3
|
-
#
|
4
|
-
# Created 2012-02-19 daveadams@gmail.com
|
5
|
-
# Last updated 2012-02-19 daveadams@gmail.com
|
6
|
-
#
|
7
|
-
# https://github.com/daveadams/sakai-info
|
8
|
-
#
|
9
|
-
# This software is public domain.
|
10
|
-
#
|
11
|
-
|
12
|
-
module SakaiInfo
|
13
|
-
class ConnectionFailureException < SakaiException; end
|
14
|
-
|
15
|
-
class Instance
|
16
|
-
def self.create(config)
|
17
|
-
case config["dbtype"].downcase
|
18
|
-
when "oracle" then
|
19
|
-
OracleInstance.new(config)
|
20
|
-
when "mysql" then
|
21
|
-
MySqlInstance.new(config)
|
22
|
-
else
|
23
|
-
raise UnsupportedConfigException.new("Database type '#{config["dbtype"]}' is not supported.")
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class OracleInstance
|
29
|
-
DEFAULT_PORT = 1521
|
30
|
-
|
31
|
-
def initialize(config)
|
32
|
-
# fix NLS_LANG if necessary
|
33
|
-
ENV["NLS_LANG"] ||= "AMERICAN_AMERICA.UTF8"
|
34
|
-
|
35
|
-
# include Oracle driver
|
36
|
-
require 'oci8'
|
37
|
-
|
38
|
-
@username = config["username"]
|
39
|
-
@password = config["password"]
|
40
|
-
if config["host"].nil? or config["host"] == ""
|
41
|
-
@service = config["service"]
|
42
|
-
else
|
43
|
-
@host = config["host"]
|
44
|
-
@port = config["port"].nil? ? DEFAULT_PORT : config["port"].to_i
|
45
|
-
@service = "//#{@host}:#{@port}/#{config["service"]}"
|
46
|
-
end
|
47
|
-
|
48
|
-
# close the connection upon exit
|
49
|
-
at_exit {
|
50
|
-
if @connection
|
51
|
-
begin
|
52
|
-
if @connection.methods.include? :ping
|
53
|
-
@connection.logoff if @connection.ping
|
54
|
-
else
|
55
|
-
@connection.logoff
|
56
|
-
end
|
57
|
-
rescue
|
58
|
-
# it's ok
|
59
|
-
end
|
60
|
-
end
|
61
|
-
}
|
62
|
-
end
|
63
|
-
|
64
|
-
def dbtype
|
65
|
-
"oracle"
|
66
|
-
end
|
67
|
-
|
68
|
-
def alive?
|
69
|
-
is_alive = false
|
70
|
-
begin
|
71
|
-
@connection.exec("select 1 from dual") do |row|
|
72
|
-
if row[0] == 1
|
73
|
-
is_alive = true
|
74
|
-
end
|
75
|
-
end
|
76
|
-
rescue
|
77
|
-
# doesn't matter what the exception is
|
78
|
-
@connection = nil
|
79
|
-
is_alive = false
|
80
|
-
end
|
81
|
-
|
82
|
-
is_alive
|
83
|
-
end
|
84
|
-
|
85
|
-
def connect
|
86
|
-
if @connection and self.alive?
|
87
|
-
return @connection
|
88
|
-
end
|
89
|
-
|
90
|
-
begin
|
91
|
-
@connection = OCI8.new(@username, @password, @service)
|
92
|
-
rescue => e
|
93
|
-
@connection = nil
|
94
|
-
raise ConnectionFailureException.new("Could not connect: #{e}")
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
class MySqlInstance
|
100
|
-
DEFAULT_PORT = 3306
|
101
|
-
|
102
|
-
def initialize(config)
|
103
|
-
@username = config["username"]
|
104
|
-
@password = config["password"]
|
105
|
-
@dbname = config["dbname"]
|
106
|
-
@host = config["host"]
|
107
|
-
@port = config["port"].nil? ? 3306 : config["port"].to_i
|
108
|
-
end
|
109
|
-
|
110
|
-
def dbtype
|
111
|
-
"mysql"
|
112
|
-
end
|
113
|
-
|
114
|
-
def alive?
|
115
|
-
false
|
116
|
-
end
|
117
|
-
|
118
|
-
def connect
|
119
|
-
raise UnsupportedConfigException.new("MySQL will be supported in a future release.")
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|