yaleldap 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5943d287b4b24158bc7ffb8cb6785f3df39fff70
4
- data.tar.gz: 128656225ea369cd377915e5b4a271d62d5ea4bc
3
+ metadata.gz: 12d18261da5f2af81134acde14dda46077a89652
4
+ data.tar.gz: 5da0fffd53d2ec47c5486cec9f26a8a644da0ba9
5
5
  SHA512:
6
- metadata.gz: a7805a8bcd7e614b1c5c3818b2e8dbd0d4eb8779e883efb1dacdd9e3f74d02e1332d3cfba815de42e8b24a124f05d9e6073a67db7f66f92fa02589cbeee8aeb1
7
- data.tar.gz: 9587d3fc6858642104dbdf6740346b23247056d9897611776d833ebc194b9e7a6066eebcfdbed1e3c142ab1400bd63e2822325b20c0d22444e2d24a8918673aa
6
+ metadata.gz: 5c3df73a33cf141c6383d1b6175ed7eb7413a62c22301e362719d276ffb1a36de89cc4221a228964e8aa2151ded3ab470657bbf662a30dbe648086c5e343b8d0
7
+ data.tar.gz: beac04df0d2afabfb7025b56f4bb7975746f77906b91a8169649b9df1ae65fd0b477fa0138e6e81945712a19744d981af498a6ffe20e472bd5b0ac4c7c67518d
data/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ [![Gem Version](https://badge.fury.io/rb/yaleldap.svg)](http://badge.fury.io/rb/yaleldap)
2
+ [![Dependency Status](https://gemnasium.com/YaleSTC/yaleldap.svg)](https://gemnasium.com/YaleSTC/yaleldap)
3
+ [![Inline docs](http://inch-ci.org/github/YaleSTC/yaleldap.png?branch=master)](http://inch-ci.org/github/YaleSTC/yaleldap)
4
+
1
5
  # Yaleldap
2
6
 
3
7
  Automatically connects to the LDAP server if you are on campus/VPN. Can be queried by UPI, and it will return a simple ruby hash with the relevant information.
@@ -18,9 +22,31 @@ Or install it yourself as:
18
22
 
19
23
  ## Usage
20
24
 
21
- `YaleLDAP.lookup_by_upi("123456")` will return a hash with commonly needed LDAP attributes.
25
+ ###UPI
26
+ ```
27
+ YaleLDAP.lookup_by_upi("12714662")
28
+ => {:first_name=>"Casey", :last_name=>"Watts", :yale_upi=>"12714662", :netid=>"csw3", :email=>"casey.watts@yale.edu", :collegename=>"", :college=>"", :class_year=>""}
29
+ ```
30
+
31
+ ###NetID
32
+ ```
33
+ YaleLDAP.lookup_by_netid("csw3")
34
+ => {:first_name=>"Casey", :last_name=>"Watts", :yale_upi=>"12714662", :netid=>"csw3", :email=>"casey.watts@yale.edu", :collegename=>"", :college=>"", :class_year=>""}
35
+ ```
36
+
37
+ ###Email
38
+ ```
39
+ YaleLDAP.lookup_by_email("casey.watts@yale.edu")
40
+ => {:first_name=>"Casey", :last_name=>"Watts", :yale_upi=>"12714662", :netid=>"csw3", :email=>"casey.watts@yale.edu", :collegename=>"", :college=>"", :class_year=>""}
41
+ ```
42
+
43
+
44
+ ## Documentation
45
+ The source code is documented on rdoc.info
22
46
 
47
+ <http://rdoc.info/github/YaleSTC/yaleldap/master/frames>
23
48
 
49
+ For more background on how the `net-ldap` gem works, check out this [Yale-specific gist](https://gist.github.com/caseywatts/ddea3996853050d1e5ad)
24
50
 
25
51
  ## Contributing
26
52
 
@@ -1,3 +1,5 @@
1
- module Yaleldap
2
- VERSION = "0.0.1"
1
+ #Version Goes Here
2
+ module YaleLDAP
3
+ #Version Number
4
+ VERSION = "0.0.2"
3
5
  end
data/lib/yaleldap.rb CHANGED
@@ -1,13 +1,32 @@
1
1
  require "yaleldap/version"
2
2
  require "net-ldap"
3
3
 
4
+ #YaleLDAP Module is xyz
4
5
  module YaleLDAP
6
+ # Yale's LDAP Host
5
7
  LDAP_HOST = 'directory.yale.edu'
8
+
9
+ # Yale's LDAP Port
6
10
  LDAP_PORT = 389
11
+
12
+ # Specify to LDAP that we are searching for people
7
13
  LDAP_BASE = 'ou=People,o=yale.edu'
14
+
15
+ # The most common Yale LDAP atttributes that we care about extracting
8
16
  LDAP_ATTRS = %w(uid givenname sn mail collegename college class UPI)
9
17
 
10
- # test with YaleLDAP.lookup_by_upi("12714662")
18
+ ##
19
+ # Lookup LDAP information by upi
20
+ #
21
+ # @param
22
+ # upi as a string, ex "12714662"
23
+ #
24
+ # @return
25
+ # Standard hash (see extract_attributes)
26
+ #
27
+ # @example
28
+ # YaleLDAP.lookup_by_upi("12714662")
29
+
11
30
  def self.lookup_by_upi(upi)
12
31
  ldap = Net::LDAP.new host: LDAP_HOST, port: LDAP_PORT
13
32
  upifilter = Net::LDAP::Filter.eq('UPI', upi)
@@ -17,6 +36,18 @@ module YaleLDAP
17
36
  extract_attributes(ldap_response)
18
37
  end
19
38
 
39
+ ##
40
+ # Lookup LDAP information by netid
41
+ #
42
+ # @param
43
+ # netid as a string, ex "csw3"
44
+ #
45
+ # @return
46
+ # Standard hash (see extract_attributes)
47
+ #
48
+ # @example
49
+ # YaleLDAP.lookup_by_netid("csw3")
50
+ #
20
51
  def self.lookup_by_netid(netid)
21
52
  ldap = Net::LDAP.new host: LDAP_HOST, port: LDAP_PORT
22
53
  upifilter = Net::LDAP::Filter.eq('uid', netid)
@@ -26,6 +57,18 @@ module YaleLDAP
26
57
  extract_attributes(ldap_response)
27
58
  end
28
59
 
60
+ ##
61
+ # Lookup LDAP information by Yale email address
62
+ #
63
+ # @param
64
+ # email as a string, ex "casey.watts@yale.edu"
65
+ #
66
+ # @return
67
+ # Standard hash (see extract_attributes)
68
+ #
69
+ # @example
70
+ # YaleLDAP.lookup_by_email("casey.watts@yale.edu")
71
+ #
29
72
  def self.lookup_by_email(email)
30
73
  ldap = Net::LDAP.new host: LDAP_HOST, port: LDAP_PORT
31
74
  upifilter = Net::LDAP::Filter.eq('mail', email)
@@ -36,6 +79,11 @@ module YaleLDAP
36
79
  end
37
80
 
38
81
  private
82
+ #
83
+ # Input a raw LDAP response
84
+ #
85
+ # Output is a hash with keys: first_name, last_name, upi, netid, email, collegename, college, class_year
86
+ #
39
87
  def self.extract_attributes(ldap_response)
40
88
  # everyone has these
41
89
  first_name = ldap_response[0][:givenname][0]
data/yaleldap.gemspec CHANGED
@@ -5,7 +5,7 @@ require 'yaleldap/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "yaleldap"
8
- spec.version = Yaleldap::VERSION
8
+ spec.version = YaleLDAP::VERSION
9
9
  spec.authors = ["caseywatts"]
10
10
  spec.email = ["casey.s.watts@gmail.com"]
11
11
  spec.summary = %q{Easy connection to Yale's LDAP}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaleldap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - caseywatts
@@ -93,3 +93,4 @@ signing_key:
93
93
  specification_version: 4
94
94
  summary: Easy connection to Yale's LDAP
95
95
  test_files: []
96
+ has_rdoc: