jgrouper 0.0.3 → 0.0.4
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/HISTORY.md +9 -1
- data/README.rdoc +11 -4
- data/TODO.md +7 -10
- data/jgrouper.gemspec +0 -1
- data/lib/jgrouper/group.rb +119 -0
- data/lib/jgrouper/version.rb +1 -1
- data/lib/jgrouper.rb +13 -4
- metadata +4 -22
- data/bin/jgrouper +0 -9
- data/lib/jgrouper/shell.rb +0 -75
data/HISTORY.md
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
JGrouper History
|
2
2
|
================
|
3
3
|
|
4
|
-
JGrouper v0.0.
|
4
|
+
JGrouper v0.0.4
|
5
5
|
---------------
|
6
|
+
* Add *JGrouper::Group*
|
7
|
+
* Add *JGrouper::Group.find*
|
8
|
+
* Add *JGrouper::Group* support to *JGrouper::Shell*
|
9
|
+
* Extracted *JGrouper::Shell* to its own gem
|
10
|
+
|
11
|
+
|
12
|
+
2012-08-17 JGrouper v0.0.3
|
13
|
+
--------------------------
|
6
14
|
* Add *JGrouper::Shell*
|
7
15
|
* Add *bin/jgrouper* interactive shell
|
8
16
|
* Rename *JGrouper::Stem#root_stem* to *JGrouper::Stem#root*
|
data/README.rdoc
CHANGED
@@ -35,6 +35,15 @@
|
|
35
35
|
# Create child stem(s)
|
36
36
|
child = stem.create 'foo:bar:baz'
|
37
37
|
|
38
|
+
=== Groups
|
39
|
+
|
40
|
+
# Find by name
|
41
|
+
group = JGrouper::Group.find(name) do |group|
|
42
|
+
group.display_name # Group display name
|
43
|
+
group.name # Group name
|
44
|
+
group.uuid # Group UUID
|
45
|
+
end
|
46
|
+
|
38
47
|
=== Group Types
|
39
48
|
|
40
49
|
# Create group type
|
@@ -44,9 +53,7 @@
|
|
44
53
|
end
|
45
54
|
|
46
55
|
# Find all group types
|
47
|
-
group_types = JGrouper::GroupType.all
|
48
|
-
...
|
49
|
-
end
|
56
|
+
group_types = JGrouper::GroupType.all { |group_type| ... }
|
50
57
|
|
51
58
|
# Find group type
|
52
59
|
JGrouper::GroupType.find(name)
|
@@ -88,5 +95,5 @@ https://github.com/blairc/jgrouper
|
|
88
95
|
|
89
96
|
== See Also
|
90
97
|
|
91
|
-
JGrouper::Shell, https://github.com/blairc/jgrouper-server, http://grouper.internet2.edu
|
98
|
+
JGrouper::Shell https://github.com/blairc/jgrouper-shell, JGrouper::Server https://github.com/blairc/jgrouper-server, http://grouper.internet2.edu
|
92
99
|
|
data/TODO.md
CHANGED
@@ -3,18 +3,19 @@ JGrouper To Do
|
|
3
3
|
|
4
4
|
JGrouper v0.0.4
|
5
5
|
---------------
|
6
|
-
* Add *JGrouper::Group*
|
7
|
-
* Add *JGrouper::Group.find(name)*
|
8
|
-
* Add *JGrouper::Stem#add_group( name, display_name = nil )*
|
9
|
-
* Add *JGrouper::Group.create( name, display_name = nil )*
|
10
6
|
* Add *JGrouper::Group#types*
|
11
7
|
* Add *JGrouper::Group#add_type*
|
12
|
-
* Add *JGrouper::
|
13
|
-
* Add *JGrouper::
|
8
|
+
* Add *JGrouper::Stem#children( recurse = false )*
|
9
|
+
* Add *JGrouper::Stem#groups( recurse = false )*
|
10
|
+
* Add *JGrouper::Stem#stems( recurse = false )*
|
14
11
|
|
15
12
|
|
16
13
|
Future
|
17
14
|
------
|
15
|
+
* Add *JGrouper::Stem#add_group( name, display_name = nil )*
|
16
|
+
* Add *JGrouper::Group.create( name, display_name = nil )*
|
17
|
+
* Add *JGrouper::Group#members*
|
18
|
+
* Add *JGrouper::Group#add_member(?)*
|
18
19
|
* Add *JGrouper::Stem#delete( recurse = false )*
|
19
20
|
* Add *JGrouper::Stem.delete( name, recurse = false )*
|
20
21
|
* Add *JGrouper::Stem.find(uuid)*
|
@@ -46,8 +47,4 @@ Future
|
|
46
47
|
* JGrouper::TestCase
|
47
48
|
* JGrouper::Subject::TestCase
|
48
49
|
* JGrouper::Subject::TestCase
|
49
|
-
* Make *JGrouper::Shell* startup less chatty
|
50
|
-
* Extract *JGrouper::Shell* to own gem?
|
51
|
-
* Add *gsh* compatibility commands to *JGrouper::Shell*?
|
52
|
-
* Should *JGrouper::Shell* be able to run scripts?
|
53
50
|
|
data/jgrouper.gemspec
CHANGED
@@ -0,0 +1,119 @@
|
|
1
|
+
module JGrouper # :nodoc:
|
2
|
+
#
|
3
|
+
# = JGrouper::Group - A Grouper group
|
4
|
+
#
|
5
|
+
class Group
|
6
|
+
|
7
|
+
attr_accessor :display_name, :name, :uuid
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@grouper_group = nil
|
11
|
+
yield self if block_given?
|
12
|
+
self
|
13
|
+
end
|
14
|
+
|
15
|
+
# XXX #
|
16
|
+
# XXX # Create child stem (along with missing intermediaries).
|
17
|
+
# XXX #
|
18
|
+
# XXX # # Create child stem 'foo'
|
19
|
+
# XXX # child = stem.add_stem 'foo'
|
20
|
+
# XXX #
|
21
|
+
# XXX # # Create child stem 'foo' with display name of 'Foo'
|
22
|
+
# XXX # child = stem.add_stem 'foo', 'Foo'
|
23
|
+
# XXX #
|
24
|
+
# XXX # # Create child stem 'foo:bar:baz' along with any missing intermediaries
|
25
|
+
# XXX # child = stem.add_stem 'foo:bar:baz'
|
26
|
+
# XXX #
|
27
|
+
# XXX #
|
28
|
+
# XXX def add_stem( name, display_name = nil )
|
29
|
+
# XXX # TODO What if names.size != display_names.size?
|
30
|
+
# XXX names = name.split ':'
|
31
|
+
# XXX display_names = display_name.nil? ? names.clone.split : display_name.split(':')
|
32
|
+
# XXX
|
33
|
+
# XXX name, display_name = names.shift, display_names.shift
|
34
|
+
# XXX
|
35
|
+
# XXX child = JGrouper::Stem.find self.name.empty? ? name : [ self.name, name ].join(':') # TODO Yuck
|
36
|
+
# XXX child = JGrouper::Stem.from_grouper @grouper_stem.addChildStem(name, display_name) if child.nil?
|
37
|
+
# XXX
|
38
|
+
# XXX # TODO What if child can't be created?
|
39
|
+
# XXX child = child.add_stem( names.join(':'), display_names.join(':') ) unless names.empty?
|
40
|
+
# XXX yield child if block_given?
|
41
|
+
# XXX child
|
42
|
+
# XXX end
|
43
|
+
# XXX
|
44
|
+
# XXX #
|
45
|
+
# XXX # Create stem (along with missing intermediaries).
|
46
|
+
# XXX #
|
47
|
+
# XXX # # Create top-level 'foo' stem
|
48
|
+
# XXX # stem = JGrouper::Stem.create 'foo'
|
49
|
+
# XXX #
|
50
|
+
# XXX # # Create top-level 'foo' stem with display name of 'Foo'
|
51
|
+
# XXX # stem = JGrouper::Stem.create 'foo', 'Foo'
|
52
|
+
# XXX #
|
53
|
+
# XXX # # Create 'foo:bar:baz' stem, along with any missing intermediaries
|
54
|
+
# XXX # stem = JGrouper::Stem.create 'foo:bar:baz'
|
55
|
+
# XXX #
|
56
|
+
# XXX def self.create( name, display_name = nil )
|
57
|
+
# XXX stem = root.add_stem name, display_name
|
58
|
+
# XXX yield stem if block_given?
|
59
|
+
# XXX stem
|
60
|
+
# XXX end
|
61
|
+
|
62
|
+
#
|
63
|
+
# Find group by name or returns +nil+.
|
64
|
+
#
|
65
|
+
# group = JGrouper::Group.find(name)
|
66
|
+
#
|
67
|
+
def self.find(name)
|
68
|
+
group = from_grouper GroupFinder.findByName( GrouperSession.startRootSession, name, false ) # XXX How to handle sessions?
|
69
|
+
yield group if block_given?
|
70
|
+
group
|
71
|
+
end
|
72
|
+
|
73
|
+
# XXX #
|
74
|
+
# XXX # Generate JGrouper::Stem instance from JSON by calling +JSON.parse(json_string)+
|
75
|
+
# XXX #
|
76
|
+
# XXX def self.json_create(json)
|
77
|
+
# XXX new do |stem|
|
78
|
+
# XXX stem.display_name = json['display_name']
|
79
|
+
# XXX stem.name = json['name']
|
80
|
+
# XXX stem.uuid = json['uuid']
|
81
|
+
# XXX end
|
82
|
+
# XXX end
|
83
|
+
# XXX
|
84
|
+
# XXX #
|
85
|
+
# XXX # Return JSON representation of JGrouper::Stem instance.
|
86
|
+
# XXX #
|
87
|
+
# XXX def to_json
|
88
|
+
# XXX {
|
89
|
+
# XXX :json_class => self.class.name,
|
90
|
+
# XXX :display_name => self.display_name,
|
91
|
+
# XXX :name => self.name,
|
92
|
+
# XXX :uuid => self.uuid
|
93
|
+
# XXX }.to_json
|
94
|
+
# XXX end
|
95
|
+
|
96
|
+
#
|
97
|
+
# Return String representation of JGrouper::Group instance.
|
98
|
+
#
|
99
|
+
def to_s
|
100
|
+
%w( name display_name uuid ).collect { |k| "#{k}=#{ self.send(k) }" }.join(' | ')
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
private
|
105
|
+
|
106
|
+
def self.from_grouper(grouper)
|
107
|
+
return nil if grouper.nil?
|
108
|
+
new do |group|
|
109
|
+
group.instance_variable_set :@grouper_group, grouper # XXX Is this even needed?
|
110
|
+
|
111
|
+
group.display_name = grouper.getDisplayName
|
112
|
+
group.name = grouper.getName
|
113
|
+
group.uuid = grouper.getUuid
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
data/lib/jgrouper/version.rb
CHANGED
data/lib/jgrouper.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'java'
|
2
2
|
require 'json'
|
3
3
|
|
4
|
+
require_relative 'jgrouper/group'
|
4
5
|
require_relative 'jgrouper/group_type'
|
5
6
|
require_relative 'jgrouper/stem'
|
6
7
|
require_relative 'jgrouper/subject'
|
@@ -45,6 +46,15 @@ require_relative 'jgrouper/version'
|
|
45
46
|
# # Create child stem(s)
|
46
47
|
# child = stem.create 'foo:bar:baz'
|
47
48
|
#
|
49
|
+
# === Groups
|
50
|
+
#
|
51
|
+
# # Find by name
|
52
|
+
# group = JGrouper::Group.find(name) do |group|
|
53
|
+
# group.display_name # Group display name
|
54
|
+
# group.name # Group name
|
55
|
+
# group.uuid # Group UUID
|
56
|
+
# end
|
57
|
+
#
|
48
58
|
# === Group Types
|
49
59
|
#
|
50
60
|
# # Create group type
|
@@ -54,9 +64,7 @@ require_relative 'jgrouper/version'
|
|
54
64
|
# end
|
55
65
|
#
|
56
66
|
# # Find all group types
|
57
|
-
# group_types = JGrouper::GroupType.all
|
58
|
-
# ...
|
59
|
-
# end
|
67
|
+
# group_types = JGrouper::GroupType.all { |group_type| ... }
|
60
68
|
#
|
61
69
|
# # Find group type
|
62
70
|
# JGrouper::GroupType.find(name)
|
@@ -98,7 +106,7 @@ require_relative 'jgrouper/version'
|
|
98
106
|
#
|
99
107
|
# == See Also
|
100
108
|
#
|
101
|
-
# JGrouper::Shell, https://github.com/blairc/jgrouper-server, http://grouper.internet2.edu
|
109
|
+
# JGrouper::Shell https://github.com/blairc/jgrouper-shell, JGrouper::Server https://github.com/blairc/jgrouper-server, http://grouper.internet2.edu
|
102
110
|
#
|
103
111
|
module JGrouper
|
104
112
|
|
@@ -119,6 +127,7 @@ module JGrouper
|
|
119
127
|
# Test the above w/ GroupType?
|
120
128
|
%w( edu.internet2.middleware.subject.SubjectNotFoundException
|
121
129
|
edu.internet2.middleware.grouper.GrouperSession
|
130
|
+
edu.internet2.middleware.grouper.GroupFinder
|
122
131
|
edu.internet2.middleware.grouper.SubjectFinder
|
123
132
|
edu.internet2.middleware.grouper.StemFinder
|
124
133
|
).each { |klass| include_class klass }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jgrouper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -27,22 +27,6 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: pry
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
38
|
-
type: :runtime
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
46
30
|
- !ruby/object:Gem::Dependency
|
47
31
|
name: factory_girl
|
48
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,8 +126,7 @@ dependencies:
|
|
142
126
|
description: JRuby wrapper around the Internet2 Grouper API
|
143
127
|
email:
|
144
128
|
- blair.christensen@gmail.com
|
145
|
-
executables:
|
146
|
-
- jgrouper
|
129
|
+
executables: []
|
147
130
|
extensions: []
|
148
131
|
extra_rdoc_files: []
|
149
132
|
files:
|
@@ -154,12 +137,11 @@ files:
|
|
154
137
|
- README.rdoc
|
155
138
|
- Rakefile
|
156
139
|
- TODO.md
|
157
|
-
- bin/jgrouper
|
158
140
|
- jgrouper.gemspec
|
159
141
|
- lib/jgrouper.rb
|
142
|
+
- lib/jgrouper/group.rb
|
160
143
|
- lib/jgrouper/group_type.rb
|
161
144
|
- lib/jgrouper/group_type/test_case.rb
|
162
|
-
- lib/jgrouper/shell.rb
|
163
145
|
- lib/jgrouper/stem.rb
|
164
146
|
- lib/jgrouper/stem/test_case.rb
|
165
147
|
- lib/jgrouper/subject.rb
|
data/bin/jgrouper
DELETED
data/lib/jgrouper/shell.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
require_relative '../jgrouper'
|
2
|
-
|
3
|
-
require 'pry'
|
4
|
-
|
5
|
-
module JGrouper # :nodoc:
|
6
|
-
#
|
7
|
-
# = JGrouper::Shell - JGrouper interactive shell
|
8
|
-
#
|
9
|
-
# == Usage
|
10
|
-
#
|
11
|
-
# # Launch
|
12
|
-
# % jgrouper
|
13
|
-
#
|
14
|
-
# === Group Types
|
15
|
-
#
|
16
|
-
# Any JGrouper::GroupType methods, such as:
|
17
|
-
#
|
18
|
-
# JGrouper::Shell:0> group_type.all
|
19
|
-
#
|
20
|
-
# === Stems
|
21
|
-
#
|
22
|
-
# Any JGrouper::Stem methods, such as:
|
23
|
-
#
|
24
|
-
# JGrouper::Shell:0> stem.root_stem
|
25
|
-
#
|
26
|
-
# === Subjects
|
27
|
-
#
|
28
|
-
# Any JGrouper::Subject methods, such as:
|
29
|
-
#
|
30
|
-
# JGrouper::Shell:0> subject.root_subject
|
31
|
-
#
|
32
|
-
class Shell
|
33
|
-
|
34
|
-
def initialize
|
35
|
-
yield self if block_given?
|
36
|
-
self
|
37
|
-
end
|
38
|
-
|
39
|
-
#
|
40
|
-
# Access JGrouper::GroupType commands
|
41
|
-
#
|
42
|
-
def group_type
|
43
|
-
JGrouper::GroupType
|
44
|
-
end
|
45
|
-
|
46
|
-
#
|
47
|
-
# Start JGrouper shell
|
48
|
-
#
|
49
|
-
def self.run!
|
50
|
-
JGrouper.home ENV['GROUPER_HOME'] if ENV['GROUPER_HOME']
|
51
|
-
shell = new do |shell|
|
52
|
-
Pry.start shell,
|
53
|
-
:prompt => [ proc { |obj, nest_level| "#{obj.class.name}:#{nest_level}> " },
|
54
|
-
proc { "> " }
|
55
|
-
]
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
#
|
60
|
-
# Access JGrouper::Stem commands
|
61
|
-
#
|
62
|
-
def stem
|
63
|
-
JGrouper::Stem
|
64
|
-
end
|
65
|
-
|
66
|
-
#
|
67
|
-
# Access JGrouper::Subject commands
|
68
|
-
#
|
69
|
-
def subject
|
70
|
-
JGrouper::Subject
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|