mit_stalker 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ v1.0.3. Workaround for people not registered on linux.mit.edu.
2
+
1
3
  v1.0.2. Workaround for people undergoing name changes.
2
4
 
3
5
  v1.0.1. Fixed copy-pasted manifest.
data/lib/mit_stalker.rb CHANGED
@@ -110,21 +110,31 @@ module MitStalker
110
110
  nil
111
111
  end
112
112
 
113
+ # Flips an official full-name (e.g. Costan, Victor-Marius) to its normal form.
114
+ def self.flip_full_name(name)
115
+ name.split(',', 2).map(&:strip).reverse.join(' ')
116
+ end
117
+
113
118
  # Retrieves information about an MIT student from an Athena username.
114
119
  #
115
120
  # Returns a hash containing user information, or nil if the user was not
116
121
  # found.
117
122
  def self.from_user_name(user_name)
118
123
  full_name = full_name_from_user_name user_name
119
- return nil unless full_name
120
124
 
121
- users = parse_mitdir_response finger(full_name, 'web.mit.edu')
125
+ if full_name
126
+ users = parse_mitdir_response finger(full_name, 'web.mit.edu')
127
+ else
128
+ users = []
129
+ end
122
130
  if users.empty?
123
131
  users = parse_mitdir_response finger(user_name, 'web.mit.edu')
124
132
  end
125
133
 
126
- user = refine_mitdir_response_by_name(users, full_name)
134
+ user = refine_mitdir_response_by_name(users, full_name) if full_name
127
135
  user = refine_mitdir_response_by_email(users, user_name) unless user
128
- user and user.merge(:full_name => full_name)
136
+ return nil unless user
137
+
138
+ user.merge :full_name => (full_name || flip_full_name(user[:name]))
129
139
  end
130
140
  end
data/mit_stalker.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{mit_stalker}
5
- s.version = "1.0.2"
5
+ s.version = "1.0.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Victor Costan"]
9
- s.date = %q{2010-02-07}
9
+ s.date = %q{2010-05-02}
10
10
  s.description = %q{Fetches publicly available information about MIT students.}
11
11
  s.email = %q{victor@zergling.net}
12
12
  s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README.textile", "lib/mit_stalker.rb"]
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Mit_stalker", "--main", "README.textile"]
16
16
  s.require_paths = ["lib"]
17
17
  s.rubyforge_project = %q{zerglings}
18
- s.rubygems_version = %q{1.3.5}
18
+ s.rubygems_version = %q{1.3.6}
19
19
  s.summary = %q{Fetches publicly available information about MIT students.}
20
20
  s.test_files = ["test/mit_stalker_test.rb"]
21
21
 
@@ -86,10 +86,21 @@ class MitStalkerTest < Test::Unit::TestCase
86
86
  assert_equal 'Li, Alice', user[:name]
87
87
  end
88
88
 
89
+ def test_flip_full_name
90
+ assert_equal 'Victor Marius Costan',
91
+ MitStalker.flip_full_name('Costan, Victor Marius'), 'flipped'
92
+ assert_equal 'Victor Marius Costan',
93
+ MitStalker.flip_full_name('Victor Marius Costan'), 'canonical'
94
+ end
95
+
89
96
  def test_from_user_name
90
97
  assert_equal nil, MitStalker.from_user_name('no_such_user')
91
98
 
92
99
  info = MitStalker.from_user_name 'devadas'
93
100
  assert_equal 'Devadas, Srinivas', info[:name]
101
+
102
+ info = MitStalker.from_user_name 'nickolai'
103
+ assert_equal 'Zeldovich, Nickolai', info[:name]
104
+ assert_equal 'Nickolai Zeldovich', info[:full_name]
94
105
  end
95
106
  end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mit_stalker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 3
9
+ version: 1.0.3
5
10
  platform: ruby
6
11
  authors:
7
12
  - Victor Costan
@@ -9,29 +14,37 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-02-07 00:00:00 -05:00
17
+ date: 2010-05-02 00:00:00 -04:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: echoe
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 3
29
+ - 1
30
+ - 1
23
31
  version: 3.1.1
24
- version:
32
+ type: :development
33
+ version_requirements: *id001
25
34
  - !ruby/object:Gem::Dependency
26
35
  name: flexmock
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
30
38
  requirements:
31
39
  - - ">="
32
40
  - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ - 8
44
+ - 6
33
45
  version: 0.8.6
34
- version:
46
+ type: :development
47
+ version_requirements: *id002
35
48
  description: Fetches publicly available information about MIT students.
36
49
  email: victor@zergling.net
37
50
  executables: []
@@ -73,18 +86,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
86
  requirements:
74
87
  - - ">="
75
88
  - !ruby/object:Gem::Version
89
+ segments:
90
+ - 0
76
91
  version: "0"
77
- version:
78
92
  required_rubygems_version: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - ">="
81
95
  - !ruby/object:Gem::Version
96
+ segments:
97
+ - 1
98
+ - 2
82
99
  version: "1.2"
83
- version:
84
100
  requirements: []
85
101
 
86
102
  rubyforge_project: zerglings
87
- rubygems_version: 1.3.5
103
+ rubygems_version: 1.3.6
88
104
  signing_key:
89
105
  specification_version: 3
90
106
  summary: Fetches publicly available information about MIT students.