cmu 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 +4 -4
- data/.gitignore +5 -4
- data/README.md +2 -2
- data/cmu.gemspec +18 -0
- data/lib/cmu.rb +30 -22
- metadata +2 -2
- data/Gemfile.lock +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5f1d6db9a03c33f678d1093b2aaaa7246905bc5
|
4
|
+
data.tar.gz: 41335f404a6043e5d8e2039e3f3dba36a8feac6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 982e255f9ff3fc111d57e30dae45f9782c401615c579418704d95a5bdca51aee84d9ae0ff64d79a3e4a4cfd93f37b4b01c1a669ba71f1485432ba7e70e6330c8
|
7
|
+
data.tar.gz: 4ff5daec086e30cad5176104a6159f1d41bfb29339533ea7da7e7b286ba2df87f36141f2dfce82e47c49647e995634798bf371aa0a947c36e4e2ed1f84a72615
|
data/.gitignore
CHANGED
@@ -24,9 +24,9 @@
|
|
24
24
|
|
25
25
|
# for a library or gem, you might want to ignore these files since the code is
|
26
26
|
# intended to run in multiple environments; otherwise, check them in:
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
Gemfile.lock
|
28
|
+
.ruby-version
|
29
|
+
.ruby-gemset
|
30
30
|
|
31
31
|
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
32
32
|
.rvmrc
|
@@ -38,7 +38,8 @@
|
|
38
38
|
.LSOverride
|
39
39
|
|
40
40
|
# Icon must ends with two \r.
|
41
|
-
Icon
|
41
|
+
Icon
|
42
|
+
|
42
43
|
|
43
44
|
# Thumbnails
|
44
45
|
._*
|
data/README.md
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
A Ruby library for CMU data. Currently only supports directory.
|
4
4
|
|
5
5
|
## Usage
|
6
|
-
|
6
|
+
Add `cmu` as a dependency to your `Gemfile`. Then, to use the library:
|
7
7
|
|
8
8
|
```ruby
|
9
|
-
>> require '
|
9
|
+
>> require 'cmu'
|
10
10
|
>> tom = CMU::Directory.find(:andrew_id=>'zhixians').first
|
11
11
|
>> tom.name
|
12
12
|
=> "Tom Shen"
|
data/cmu.gemspec
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'cmu'
|
6
|
+
s.version = '0.0.2'
|
7
|
+
s.author = 'Tom Shen'
|
8
|
+
s.email = 'tom@shen.io'
|
9
|
+
s.homepage = 'https://github.com/ScottyLabs/cmurb'
|
10
|
+
s.summary = %q{A library for CMU data}
|
11
|
+
s.description = %q{cmurb provides a clean, simple interface for accessing CMU data. It currently only supports directory data.}
|
12
|
+
s.license = 'MIT'
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.require_paths = ['lib']
|
15
|
+
|
16
|
+
# runtime dependencies
|
17
|
+
s.add_runtime_dependency 'net-ldap2'
|
18
|
+
end
|
data/lib/cmu.rb
CHANGED
@@ -10,50 +10,58 @@ module CMU
|
|
10
10
|
|
11
11
|
class Person
|
12
12
|
def initialize(data)
|
13
|
-
@
|
13
|
+
@data = {}
|
14
|
+
@data[:andrew_id] = data[:cmuAndrewId].last
|
14
15
|
if data.attribute_names.include?(:nickname)
|
15
|
-
@name = data[:nickname].last
|
16
|
+
@data[:name] = data[:nickname].last
|
16
17
|
else
|
17
|
-
@name = data[:cn].last
|
18
|
+
@data[:name] = data[:cn].last
|
18
19
|
end
|
19
|
-
@last_name = data[:sn].last
|
20
|
-
@first_name = @name.split()[0]
|
20
|
+
@data[:last_name] = data[:sn].last
|
21
|
+
@data[:first_name] = @data[:name].split()[0]
|
21
22
|
if data.attribute_names.include?(:cmupreferredmail)
|
22
|
-
@email = data[:cmupreferredmail].last
|
23
|
+
@data[:email] = data[:cmupreferredmail].last
|
23
24
|
else
|
24
|
-
@email = data[:mail].last
|
25
|
+
@data[:email] = data[:mail].last
|
25
26
|
end
|
26
27
|
if data.attribute_names.include?(:cmupreferredtelephone)
|
27
|
-
@phone = data[:cmupreferredtelephone].last.gsub(/[^0-9]/,'')
|
28
|
+
@data[:phone] = data[:cmupreferredtelephone].last.gsub(/[^0-9]/,'')
|
28
29
|
else
|
29
|
-
@phone = nil
|
30
|
+
@data[:phone] = nil
|
30
31
|
end
|
31
|
-
@role = data[:edupersonaffiliation].last
|
32
|
+
@data[:role] = data[:edupersonaffiliation].last
|
32
33
|
if data.attribute_names.include?(:title)
|
33
|
-
@title = data[:title].last
|
34
|
+
@data[:title] = data[:title].last
|
34
35
|
else
|
35
36
|
if data.attribute_names.include?(:cmutitle)
|
36
|
-
@title = data[:cmutitle].last
|
37
|
+
@data[:title] = data[:cmutitle].last
|
37
38
|
else
|
38
|
-
@title = nil
|
39
|
+
@data[:title] = nil
|
39
40
|
end
|
40
41
|
end
|
41
42
|
if data.attribute_names.include?(:cmustudentclass)
|
42
|
-
@student_class = data[:cmustudentclass].last
|
43
|
+
@data[:student_class] = data[:cmustudentclass].last
|
43
44
|
else
|
44
|
-
@student_class = nil
|
45
|
+
@data[:student_class] = nil
|
45
46
|
end
|
46
47
|
if data.attribute_names.include?(:cmustudentlevel)
|
47
|
-
@student_level = data[:cmustudentlevel].last
|
48
|
+
@data[:student_level] = data[:cmustudentlevel].last
|
48
49
|
else
|
49
|
-
@student_level = nil
|
50
|
+
@data[:student_level] = nil
|
50
51
|
end
|
51
|
-
@department = data[:cmudepartment].last
|
52
|
-
@affiliated_schools = data[:edupersonschoolcollegename]
|
52
|
+
@data[:department] = data[:cmudepartment].last
|
53
|
+
@data[:affiliated_schools] = data[:edupersonschoolcollegename]
|
53
54
|
end
|
54
|
-
|
55
|
-
|
56
|
-
|
55
|
+
|
56
|
+
def method_missing(name, *args, &blk)
|
57
|
+
if args.empty? && blk.nil? && @data.has_key?(name)
|
58
|
+
@data[name]
|
59
|
+
else
|
60
|
+
super
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
attr_reader :data
|
57
65
|
end
|
58
66
|
|
59
67
|
def Directory.search(query)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cmu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Shen
|
@@ -33,9 +33,9 @@ extra_rdoc_files: []
|
|
33
33
|
files:
|
34
34
|
- ".gitignore"
|
35
35
|
- Gemfile
|
36
|
-
- Gemfile.lock
|
37
36
|
- LICENSE
|
38
37
|
- README.md
|
38
|
+
- cmu.gemspec
|
39
39
|
- lib/cmu.rb
|
40
40
|
homepage: https://github.com/ScottyLabs/cmurb
|
41
41
|
licenses:
|