sakai-info 0.1.0 → 0.2.0
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.
- 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/CHANGELOG.md
CHANGED
@@ -1,12 +1,18 @@
|
|
1
|
-
sakai-info Change History
|
2
|
-
=========================
|
1
|
+
# sakai-info Change History #
|
3
2
|
|
4
|
-
0.
|
5
|
-
-----
|
3
|
+
## 0.2.0 ##
|
6
4
|
|
7
|
-
*Released 2012-02
|
5
|
+
*Released 2012-02-24*
|
6
|
+
|
7
|
+
* Sequel now used as the database driver, enabling MySQL and Sqlite support
|
8
|
+
* Simplified configuration file format
|
9
|
+
* CLI tool now provides details on user and site objects
|
10
|
+
|
11
|
+
## 0.1.0 ##
|
12
|
+
|
13
|
+
*Released 2012-02-19*
|
8
14
|
|
9
15
|
* Initial release
|
10
16
|
* Oracle-only support
|
11
|
-
*
|
17
|
+
* Extremely limited CLI functionality
|
12
18
|
|
data/README.md
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
sakai-info
|
2
|
-
==========
|
1
|
+
# sakai-info #
|
3
2
|
|
4
3
|
*sakai-info* is a command line tool and a suite of Ruby libraries which enable
|
5
4
|
the exploration of a Sakai database without the intermediation of a Java VM or
|
@@ -9,34 +8,31 @@ Because the primary goal of this tool is to assist in information gathering
|
|
9
8
|
and troubleshooting, no capability to change the database is included in the
|
10
9
|
tool or the libraries.
|
11
10
|
|
12
|
-
Meta
|
13
|
-
|
14
|
-
last updated: 2012-02-
|
15
|
-
author: David Adams (daveadams@gmail.com)
|
11
|
+
## Meta ##
|
12
|
+
|
13
|
+
last updated: 2012-02-24
|
14
|
+
author: David Adams (daveadams@gmail.com)
|
16
15
|
github url: https://github.com/daveadams/sakai-info
|
17
16
|
|
18
|
-
Testing
|
19
|
-
-------
|
17
|
+
## Testing ##
|
20
18
|
|
21
19
|
Tests are defined in ./test using Test::Unit. The default `rake` action is to
|
22
20
|
run all tests.
|
23
21
|
|
24
|
-
Building
|
25
|
-
--------
|
22
|
+
## Building ##
|
26
23
|
|
27
24
|
Use `rake` to test and build the gem:
|
28
25
|
|
29
26
|
$ rake gem:build
|
30
|
-
|
27
|
+
|
31
28
|
The resulting gem will be saved to the working directory as
|
32
|
-
`sakai-info-0.
|
29
|
+
`sakai-info-0.2.0.gem`.
|
33
30
|
|
34
31
|
Cleanup built gems using:
|
35
32
|
|
36
33
|
$ rake clean
|
37
34
|
|
38
|
-
Installing
|
39
|
-
----------
|
35
|
+
## Installing ##
|
40
36
|
|
41
37
|
Install the *sakai-info* gem locally with:
|
42
38
|
|
@@ -46,78 +42,56 @@ Uninstall with:
|
|
46
42
|
|
47
43
|
$ rake gem:uninstall
|
48
44
|
|
49
|
-
|
50
|
-
-------------------
|
51
|
-
|
52
|
-
For this release, only Oracle databases are supported. MySQL support is planned
|
53
|
-
as soon as possible. Support for SQLite or some other lightweight database may
|
54
|
-
be implemented for unit testing purposes.
|
55
|
-
|
56
|
-
System Requirements
|
57
|
-
-------------------
|
45
|
+
## Database Connectivity ##
|
58
46
|
|
59
|
-
|
47
|
+
[Sequel](http://sequel.rubyforge.org) is used for database connectivity. Driver
|
48
|
+
gems must also be installed to support whatever database or databases you use.
|
60
49
|
|
61
|
-
|
62
|
-
|
63
|
-
R2 versions 11.2.0.1 and 11.2.0.3, using the Oracle Instant Client version
|
64
|
-
11.2.0.3.
|
50
|
+
Oracle support requires the `ruby-oci8` gem, and MySQL support requires the
|
51
|
+
`mysql` gem. Some unit tests make use of the `sqlite3` gem.
|
65
52
|
|
66
|
-
Configuration
|
67
|
-
-------------
|
53
|
+
## Configuration ##
|
68
54
|
|
69
55
|
To run, *sakai-info* needs to be able to connect to your Sakai database server.
|
70
56
|
It is possible to specify multiple instances to choose from at runtime.
|
71
57
|
|
72
58
|
In this release, *sakai-info* expects a to find the config in a file located at
|
73
59
|
`$HOME/.sakai-info`. The file must be in YAML format and can contain one or
|
74
|
-
more Sakai database connection
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
`service` will be used to find the corresponding `tnsnames.ora` entry.
|
87
|
-
|
88
|
-
Multiple instances may be specified by using the following format:
|
89
|
-
|
90
|
-
default: production
|
91
|
-
instances:
|
92
|
-
production:
|
93
|
-
dbtype: oracle
|
94
|
-
username: sakai
|
95
|
-
password: <password>
|
96
|
-
service: SAKAIPROD
|
97
|
-
host: oracle.db
|
98
|
-
port: 1521
|
99
|
-
test:
|
100
|
-
dbtype: oracle
|
101
|
-
username: sakai
|
102
|
-
password: <password>
|
103
|
-
service: SAKAITEST
|
104
|
-
|
105
|
-
The `default` key identifies which of the connections under `instances` you
|
106
|
-
wish to be used in the absence of any explicit specification. Other instances
|
107
|
-
will be referenced by the corresponding YAML key (eg, `production` and `test`
|
108
|
-
in the example above).
|
109
|
-
|
110
|
-
Command Line Usage
|
111
|
-
------------------
|
60
|
+
more Sakai database connection nicknames and connection strings, for example:
|
61
|
+
|
62
|
+
prod: oracle://sakai:password@SAKAIPROD
|
63
|
+
test: mysql://test:password@mysql.host:3307/db_name
|
64
|
+
|
65
|
+
The first connection in the list is the default connection. Other connections
|
66
|
+
may be specified using the corresponding YAML key, which functions as a
|
67
|
+
nickname for the connection.
|
68
|
+
|
69
|
+
[More information on how to specify a Sequel connection string.](http://sequel.rubyforge.org/rdoc/files/doc/opening_databases_rdoc.html)
|
70
|
+
|
71
|
+
## Command Line Usage ##
|
112
72
|
|
113
73
|
After installing the gem, the `sakai-info` program should be found in your
|
114
|
-
PATH. For
|
115
|
-
details, run:
|
74
|
+
PATH. For usage details, run:
|
116
75
|
|
117
76
|
$ sakai-info help
|
118
77
|
|
119
|
-
|
120
|
-
|
78
|
+
To look up information about a user, run:
|
79
|
+
|
80
|
+
$ sakai-info user id
|
81
|
+
|
82
|
+
For users, `id` can be either the user_id or the eid of the user you want
|
83
|
+
details on.
|
84
|
+
|
85
|
+
Similarly to look up information about a site, run:
|
86
|
+
|
87
|
+
$ sakai-info site id
|
88
|
+
|
89
|
+
For sites, `id` is the `site_id` of the desired site.
|
90
|
+
|
91
|
+
Further details are available for both object types, see the corresponding
|
92
|
+
help pages for more information.
|
93
|
+
|
94
|
+
## Library Usage ##
|
121
95
|
|
122
96
|
To use the library in your own Ruby programs, simply specify:
|
123
97
|
|
@@ -131,18 +105,16 @@ program.
|
|
131
105
|
Full RDoc documentation for each class is not available in this release, but is
|
132
106
|
planned for a future release.
|
133
107
|
|
134
|
-
Change History
|
135
|
-
--------------
|
108
|
+
## Change History ##
|
136
109
|
|
137
110
|
See CHANGELOG.md
|
138
111
|
|
139
|
-
Future Plans
|
140
|
-
------------
|
112
|
+
## Future Plans ##
|
141
113
|
|
142
114
|
See ROADMAP.md
|
143
115
|
|
144
|
-
License
|
145
|
-
|
116
|
+
## License ##
|
117
|
+
|
146
118
|
This work is dedicated to the public domain. No rights are reserved. See
|
147
119
|
LICENSE for more information.
|
148
120
|
|
data/ROADMAP.md
CHANGED
@@ -1,14 +1,18 @@
|
|
1
|
-
sakai-info Roadmap
|
2
|
-
==================
|
1
|
+
# sakai-info Roadmap #
|
3
2
|
|
4
|
-
*Last updated 2012-02-
|
3
|
+
*Last updated 2012-02-24*
|
5
4
|
|
6
|
-
|
5
|
+
### 0.3 ###
|
7
6
|
|
8
|
-
*
|
9
|
-
*
|
10
|
-
|
11
|
-
|
7
|
+
* CLI access to more objects, eg quizzes, tools, assignments, and groups
|
8
|
+
* Sqlite test infrastructure for a few basic objects
|
9
|
+
|
10
|
+
### 0.5 ###
|
11
|
+
|
12
|
+
* Test fixtures and basic unit tests for all represented objects
|
13
|
+
* RDoc coverage for every class
|
14
|
+
|
15
|
+
------
|
12
16
|
|
13
17
|
Other things on the wishlist for future releases:
|
14
18
|
|
@@ -25,13 +29,11 @@ Other things on the wishlist for future releases:
|
|
25
29
|
* Generalized reporting capabilities
|
26
30
|
* Storage utilization per-site
|
27
31
|
* Session and event statistics
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
* A web interface for searching and exploring the database
|
32
|
+
* Metrics on various elements
|
33
|
+
* Typical quiz duration
|
34
|
+
* Quiz/assignment completion rates
|
35
|
+
* Forum post rates, post length
|
36
|
+
* Additional tools
|
37
|
+
* httpd log analysis helper
|
38
|
+
* RPC client for Sakai-monitoring servlet
|
37
39
|
|
data/bin/sakai-info
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# sakai-info library
|
6
6
|
#
|
7
7
|
# Created 2012-02-15 daveadams@gmail.com
|
8
|
-
# Last updated 2012-02-
|
8
|
+
# Last updated 2012-02-24 daveadams@gmail.com
|
9
9
|
#
|
10
10
|
# https://github.com/daveadams/sakai-info
|
11
11
|
#
|
@@ -17,63 +17,114 @@ include SakaiInfo
|
|
17
17
|
|
18
18
|
require 'sakai-info/cli'
|
19
19
|
|
20
|
-
ObjectModes =
|
20
|
+
ObjectModes = {
|
21
|
+
"site" => Site,
|
22
|
+
"user" => User
|
23
|
+
}
|
21
24
|
|
22
|
-
|
23
|
-
|
25
|
+
flags = []
|
26
|
+
args = []
|
27
|
+
db_name = nil
|
24
28
|
|
25
|
-
|
26
|
-
|
27
|
-
|
29
|
+
while arg = ARGV.shift
|
30
|
+
if arg =~ /^-/
|
31
|
+
if arg == "-D"
|
32
|
+
db_name = ARGV.shift
|
33
|
+
elsif arg =~ /^--database=/
|
34
|
+
db_name = arg.split("=")[1]
|
28
35
|
else
|
29
|
-
|
36
|
+
flags << arg
|
30
37
|
end
|
31
|
-
|
38
|
+
else
|
39
|
+
args << arg
|
40
|
+
end
|
41
|
+
end
|
32
42
|
|
33
|
-
|
34
|
-
|
35
|
-
|
43
|
+
if args.length < 1
|
44
|
+
STDERR.puts "ERROR: No command was given."
|
45
|
+
STDERR.puts "Run '#{File.basename($0)} help' for a list of commands."
|
46
|
+
exit 1
|
47
|
+
end
|
36
48
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
49
|
+
case args[0]
|
50
|
+
when "help" then
|
51
|
+
if not args[1].nil?
|
52
|
+
CLI::Help.help args[1]
|
53
|
+
else
|
54
|
+
CLI::Help.help
|
55
|
+
end
|
56
|
+
exit
|
44
57
|
|
45
|
-
|
46
|
-
|
47
|
-
|
58
|
+
when "version" then
|
59
|
+
puts VERSION
|
60
|
+
exit
|
48
61
|
|
62
|
+
when "test" then
|
63
|
+
DB.load_config
|
64
|
+
success = 0
|
65
|
+
failure = 0
|
66
|
+
dbs = nil
|
67
|
+
|
68
|
+
if db_name.nil?
|
69
|
+
dbs = DB.databases
|
49
70
|
else
|
50
|
-
|
51
|
-
|
52
|
-
mode = ARGV[0]
|
53
|
-
ARGV.shift
|
54
|
-
# continue on
|
71
|
+
dbs = { db_name => DB.databases[db_name] }
|
72
|
+
end
|
55
73
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
74
|
+
dbs.each do |nickname, connection_string|
|
75
|
+
begin
|
76
|
+
print "Trying #{nickname}... "; STDOUT.flush
|
77
|
+
db = Sequel.connect(connection_string)
|
78
|
+
if db.test_connection
|
79
|
+
puts "OK"
|
80
|
+
success += 1
|
81
|
+
else
|
82
|
+
puts "FAIL"
|
83
|
+
failure += 1
|
84
|
+
end
|
85
|
+
rescue => e
|
86
|
+
puts "FAIL"
|
87
|
+
puts " #{e}"
|
88
|
+
failure += 1
|
60
89
|
end
|
61
90
|
end
|
62
|
-
else
|
63
|
-
STDERR.puts "ERROR: No command was given."
|
64
|
-
STDERR.puts "Run 'sakai-info help' for a list of commands."
|
65
|
-
exit 1
|
66
|
-
end
|
67
91
|
|
68
|
-
|
92
|
+
if failure > 0
|
93
|
+
puts "WARNING: Some connections failed"
|
94
|
+
exit 1
|
95
|
+
else
|
96
|
+
puts "OK: All connection tests succeeded"
|
97
|
+
exit
|
98
|
+
end
|
69
99
|
|
70
|
-
|
71
|
-
|
72
|
-
|
100
|
+
else
|
101
|
+
# test to see if it's an accepted object mode
|
102
|
+
if ObjectModes.keys.include? args[0]
|
103
|
+
mode = args.shift
|
104
|
+
id = args.shift
|
73
105
|
|
74
|
-
|
75
|
-
|
76
|
-
|
106
|
+
else
|
107
|
+
STDERR.puts "ERROR: Command '#{args[0]}' was not recognized."
|
108
|
+
STDERR.puts "Run '#{File.basename($0)} help' for a list of commands."
|
109
|
+
exit 1
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
# load database config and set instance to the instance given on the command line
|
114
|
+
DB.load_config
|
115
|
+
if not db_name.nil?
|
116
|
+
DB.default_database = db_name
|
117
|
+
end
|
77
118
|
|
119
|
+
if flags.include? "--all"
|
120
|
+
serials = ObjectModes[mode].all_serializations
|
121
|
+
else
|
122
|
+
serials = [:default] + flags.collect{|flag|flag.gsub(/^--/,'').to_sym}
|
123
|
+
end
|
124
|
+
begin
|
125
|
+
puts ObjectModes[mode].find(id).to_yaml(serials)
|
126
|
+
rescue ObjectNotFoundException
|
127
|
+
STDERR.puts "ERROR: Could not find #{mode} with an ID of '#{id}'"
|
128
|
+
exit 1
|
78
129
|
end
|
79
130
|
|
data/lib/sakai-info.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# Base library file
|
3
3
|
#
|
4
4
|
# Created 2012-02-15 daveadams@gmail.com
|
5
|
-
# Last updated 2012-02-
|
5
|
+
# Last updated 2012-02-24 daveadams@gmail.com
|
6
6
|
#
|
7
7
|
# https://github.com/daveadams/sakai-info
|
8
8
|
#
|
@@ -13,6 +13,7 @@ require 'yaml'
|
|
13
13
|
require 'json'
|
14
14
|
require 'rexml/document'
|
15
15
|
require 'base64'
|
16
|
+
require 'sequel'
|
16
17
|
|
17
18
|
require 'sakai-info/version'
|
18
19
|
|
@@ -30,6 +31,34 @@ module SakaiInfo
|
|
30
31
|
super("Could not find a #{@classname} object for '#{@identifier}'")
|
31
32
|
end
|
32
33
|
end
|
34
|
+
|
35
|
+
class Util
|
36
|
+
# misc support functions
|
37
|
+
FILESIZE_LABELS = ["bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
|
38
|
+
def self.format_filesize(i_size)
|
39
|
+
size = i_size.to_f
|
40
|
+
negative = false
|
41
|
+
|
42
|
+
if size < 0
|
43
|
+
negative = true
|
44
|
+
size = -size
|
45
|
+
end
|
46
|
+
|
47
|
+
label = 0
|
48
|
+
(FILESIZE_LABELS.size - 1).times do
|
49
|
+
if size >= 1024.0
|
50
|
+
size = size / 1024.0
|
51
|
+
label += 1
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
if size >= 100.0 or label == 0
|
56
|
+
"#{negative ? "-" : ""}#{size.to_i.to_s} #{FILESIZE_LABELS[label]}"
|
57
|
+
else
|
58
|
+
"#{negative ? "-" : ""}#{sprintf("%.1f", size)} #{FILESIZE_LABELS[label]}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
33
62
|
end
|
34
63
|
|
35
64
|
# extensions to other objects
|
@@ -39,10 +68,8 @@ class String
|
|
39
68
|
end
|
40
69
|
end
|
41
70
|
|
42
|
-
# baseline
|
43
|
-
require 'sakai-info/
|
44
|
-
require 'sakai-info/db'
|
45
|
-
require 'sakai-info/configuration'
|
71
|
+
# baseline db connectivity
|
72
|
+
require 'sakai-info/database'
|
46
73
|
|
47
74
|
# base objects
|
48
75
|
require 'sakai-info/sakai_object'
|