ucb_groups 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a1bdf549f13edf65d636beb2404cd2a5b6157ddb
4
- data.tar.gz: aa0116d5ffea6cdc906625032a27e6159d4b273c
3
+ metadata.gz: 44afd05e9f0cda43ea10a6bc30255a8b3f44b199
4
+ data.tar.gz: ec73f0e642dc406795ac8565d3b7b010bb6b1a9b
5
5
  SHA512:
6
- metadata.gz: 589a70bcc804a10e3f7c9e8ef2ffd0c233b0155f73f306ef6dcba4cd1af5b4d0d12a64b3a7ddca312d4794e0462902f90101cd2f3cbe063fc0f352f7d672982d
7
- data.tar.gz: fc314a5db50aac3ad35b183acc134d7e785eb9d93e9658765175126b27f14a33d9eb427c8286982a7a269daf5e86638b4873dca26e5f9ef0a91e32dab9f10fa8
6
+ metadata.gz: 7ba3c534c2a9cfce09ed164dc98e54f5a6bef9fcb2b2d084349ee1607fe2ca4365e140d1100e4601e5fde40d55069666f7cb77f1c4ffc39c5ba744e9a2680f8e
7
+ data.tar.gz: e6ba58c3607583394757680f4f7679df8bbb282241c676a03f963aa4d40d116675bd154dafabc70e122cd50099f09b4b209761821378cc38bead8c54ca951611
data/README.md CHANGED
@@ -27,8 +27,10 @@ Then...
27
27
 
28
28
  Get list of groups in namespace:
29
29
  ```
30
- UcbGroups::CampusGroup.find(<namespace>)
30
+ groups = UcbGroups::CampusGroup.find(<namespace>)
31
31
  => [CampusGroup, CampusGroup, ...]
32
+ groups.first
33
+ =>
32
34
  ```
33
35
 
34
36
  Find people in one or more groups:
@@ -1,18 +1,19 @@
1
1
  module UcbGroups
2
2
  class CampusGroup
3
- attr_accessor :dn, :description, :namespace, :name
3
+ attr_accessor :id, :name, :description, :namespace, :dn
4
4
 
5
5
  def initialize(ldap_entry)
6
6
  @dn = ldap_entry[:dn].first.to_s
7
7
  @description = ldap_entry[:description].first.to_s
8
- @namespace, @name = parse_dn
8
+ @name = ldap_entry[:displayName].first.to_s
9
+ @namespace, @id = parse_dn
9
10
  end
10
11
 
11
12
  def self.find(namespace)
12
13
  args = {
13
14
  :base => "ou=campus groups,dc=berkeley,dc=edu",
14
15
  :filter => build_filter(namespace),
15
- :attributes => %w(dn description name),
16
+ :attributes => %w(name displayName description dn)
16
17
  }
17
18
  LdapConn.conn.search(args).map { |entry| CampusGroup.new(entry) }
18
19
  end
@@ -8,10 +8,10 @@ module UcbGroups
8
8
  raise(LdapBindFailedException)
9
9
  end
10
10
 
11
- def self.authenticate(username, password, host='nds.berkeley.edu')
11
+ def self.authenticate(username, password, host)
12
12
  @username = username
13
13
  @password = password
14
- @host = host
14
+ @host = host || 'nds.berkeley.edu'
15
15
  end
16
16
 
17
17
  def self.authenticate_from_config(config_file)
@@ -45,7 +45,7 @@ module UcbGroups
45
45
  end
46
46
 
47
47
  def namespace_groups
48
- @namespace_groups ||= CampusGroup.find(namespace).map(&:name)
48
+ @namespace_groups ||= CampusGroup.find(namespace).map(&:id)
49
49
  end
50
50
  end
51
51
  end
@@ -1,3 +1,3 @@
1
1
  module UcbGroups
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/ucb_groups.rb CHANGED
@@ -26,6 +26,10 @@ module UcbGroups
26
26
  super("You must provide at least one group or one org")
27
27
  end
28
28
  end
29
+
30
+ def self.root
31
+ File.expand_path(File.join(__FILE__, '..', '..'))
32
+ end
29
33
  end
30
34
 
31
35
 
data/spec/spec_helper.rb CHANGED
@@ -2,6 +2,6 @@ require_relative '../lib/ucb_groups'
2
2
  require 'yaml'
3
3
 
4
4
  RSpec.configure do |config|
5
- ldap_yml = File.expand_path(File.dirname("#{__FILE__}") + "/../ldap.yml")
5
+ ldap_yml = File.expand_path(File.join(UcbGroups.root, "config", "ldap.yml"))
6
6
  UcbGroups::LdapConn.authenticate_from_config(ldap_yml)
7
7
  end
@@ -5,7 +5,8 @@ describe "CampusGroup" do
5
5
  let(:entry) do
6
6
  {
7
7
  :dn => ["cn=edu:berkeley:app:calmessages:faculty,ou=campus groups,dc=berkeley,dc=edu"],
8
- :description => ["Instructors"]
8
+ :description => ["UCB Instructors"],
9
+ :displayName => ["Instructors"]
9
10
  }
10
11
  end
11
12
 
@@ -17,9 +18,10 @@ describe "CampusGroup" do
17
18
  it "initializes an entry" do
18
19
  group = UcbGroups::CampusGroup.new(entry)
19
20
 
20
- group.dn.should eql(entry[:dn].first)
21
+ group.id.should eql("faculty")
22
+ group.name.should eql("Instructors")
21
23
  group.description.should eql(entry[:description].first)
22
24
  group.namespace.should eql("calmessages")
23
- group.name.should eql("faculty")
25
+ group.dn.should eql(entry[:dn].first)
24
26
  end
25
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ucb_groups
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - sahglie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-18 00:00:00.000000000 Z
11
+ date: 2013-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler