ku-ldap 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -51,7 +51,9 @@ User metadata:
51
51
  user.primary_institution
52
52
  user.department
53
53
  user.email
54
- user.group_name
54
+ user.primary_group
55
+ user.groups
56
+ user.group_ids
55
57
 
56
58
  ### Groups
57
59
 
@@ -20,6 +20,11 @@ module KU
20
20
  def initialize entry
21
21
  @entry = entry || Hash.new([])
22
22
  end
23
+
24
+ def ==(other)
25
+ id == other.id
26
+ end
27
+ alias eq? ==
23
28
 
24
29
  private
25
30
 
@@ -43,8 +43,16 @@ module KU
43
43
  self[:mail]
44
44
  end
45
45
 
46
- def group_name
47
- self[:employeetype]
46
+ def primary_group
47
+ Group.new self[:employeetype]
48
+ end
49
+
50
+ def groups
51
+ @groups ||= KU::LDAP.groups(:memberuid, id, :eq)
52
+ end
53
+
54
+ def group_ids
55
+ groups.map(&:id)
48
56
  end
49
57
 
50
58
  private
@@ -1,5 +1,5 @@
1
1
  module KU
2
2
  module LDAP
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -1,5 +1,6 @@
1
1
  require_relative '../../../spec_helper'
2
2
  require_relative '../../../../lib/ku/ldap/entry/user'
3
+ require_relative '../../../../lib/ku/ldap/entry/group'
3
4
 
4
5
  describe KU::LDAP::Entry::User do
5
6
 
@@ -62,7 +63,7 @@ describe KU::LDAP::Entry::User do
62
63
  attrs[:o] << 'primary_institution'
63
64
  attrs[:departmentnumber] << 'department'
64
65
  attrs[:mail] << 'email'
65
- attrs[:employeetype] << 'group_name'
66
+ attrs[:employeetype] << {cn: ['primary_group']}
66
67
  attrs
67
68
  end
68
69
 
@@ -70,10 +71,14 @@ describe KU::LDAP::Entry::User do
70
71
  @user = subject.send :new, attributes
71
72
  end
72
73
 
73
- %w(id first_name last_name full_name title primary_institution department email group_name).each do |attribute|
74
+ %w(id first_name last_name full_name title primary_institution department email).each do |attribute|
74
75
  it "must return #{attribute}" do
75
76
  @user.send(attribute.to_sym).must_equal attribute
76
77
  end
77
78
  end
79
+
80
+ it 'must return primary_group' do
81
+ @user.primary_group.must_equal KU::LDAP::Entry::Group.new(cn: ['primary_group'])
82
+ end
78
83
  end
79
84
  end
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: ku-ldap
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - jamiehodge
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-04 00:00:00.000000000 Z
12
+ date: 2013-04-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  prerelease: false