mit_stalker 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OThiMGJhYTQ0ZmQ2ZWQzZWFjZGRiZGQxMzNhNzgxZGIzZGIyOWU3Mg==
5
+ data.tar.gz: !binary |-
6
+ MDBlNzJiMTliMWYwODc5MTljODgwMDgxOGQwNzQ0ZDUzZTdiYWU1MA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ Y2Q0M2ZlMDNiYWY0YzJkMGU0NWU3NzlhNmE2ODYxODc5MzM0N2FhNzA1ZTJk
10
+ NDAxOWJjZmVlMmJiNDZhYWQyMTg3ZmE5MGUzOGZjNWQ2MmUwZjFkMzM1ZTBm
11
+ ODc3NGJmZDM4YjFhYTU3YjU0OWMzNGY5OTRlMjBhNjgxNjJkYjA=
12
+ data.tar.gz: !binary |-
13
+ YTI3ZmFmNzc4MDQxYmM2NDllYjI4ZGVkZjkzN2JhOWRkNWJhMWRjNDIxMzk3
14
+ ZjM0MTAzZTY4NmNhNTc1ZGRkZjNhYTNlNjJhNmVhOTExOWQ4ZThkNzgyZGM1
15
+ MDcwZjk0MmJiNjE3NzEwZGU2MjAwMjYwYWYzNTNkNTUyOWU4OGE=
data/.project ADDED
@@ -0,0 +1,23 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>mit_stalker</name>
4
+ <comment></comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ <buildCommand>
9
+ <name>com.aptana.ide.core.unifiedBuilder</name>
10
+ <arguments>
11
+ </arguments>
12
+ </buildCommand>
13
+ <buildCommand>
14
+ <name>org.rubypeople.rdt.core.rubybuilder</name>
15
+ <arguments>
16
+ </arguments>
17
+ </buildCommand>
18
+ </buildSpec>
19
+ <natures>
20
+ <nature>com.aptana.ruby.core.rubynature</nature>
21
+ <nature>org.rubypeople.rdt.core.rubynature</nature>
22
+ </natures>
23
+ </projectDescription>
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source :rubygems
2
+
3
+ group :development do
4
+ gem 'mocha', '>= 0.14.0', :require => false
5
+ gem 'minitest', '>= 4.7.3'
6
+ gem 'yard', '>= 0.8.7'
7
+ gem 'bundler', '>= 1.3.5'
8
+ gem 'jeweler', '>= 1.8.7'
9
+ gem 'simplecov', '>= 0', :platform => :mri_19
10
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,65 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.3.5)
5
+ builder (3.2.2)
6
+ faraday (0.8.8)
7
+ multipart-post (~> 1.2.0)
8
+ git (1.2.6)
9
+ github_api (0.10.1)
10
+ addressable
11
+ faraday (~> 0.8.1)
12
+ hashie (>= 1.2)
13
+ multi_json (~> 1.4)
14
+ nokogiri (~> 1.5.2)
15
+ oauth2
16
+ hashie (2.0.5)
17
+ highline (1.6.19)
18
+ httpauth (0.2.0)
19
+ jeweler (1.8.7)
20
+ builder
21
+ bundler (~> 1.0)
22
+ git (>= 1.2.5)
23
+ github_api (= 0.10.1)
24
+ highline (>= 1.6.15)
25
+ nokogiri (= 1.5.10)
26
+ rake
27
+ rdoc
28
+ json (1.8.0)
29
+ jwt (0.1.8)
30
+ multi_json (>= 1.5)
31
+ metaclass (0.0.1)
32
+ minitest (5.0.6)
33
+ mocha (0.14.0)
34
+ metaclass (~> 0.0.1)
35
+ multi_json (1.7.9)
36
+ multi_xml (0.5.5)
37
+ multipart-post (1.2.0)
38
+ nokogiri (1.5.10)
39
+ oauth2 (0.9.2)
40
+ faraday (~> 0.8)
41
+ httpauth (~> 0.2)
42
+ jwt (~> 0.1.4)
43
+ multi_json (~> 1.0)
44
+ multi_xml (~> 0.5)
45
+ rack (~> 1.2)
46
+ rack (1.5.2)
47
+ rake (10.1.0)
48
+ rdoc (4.0.1)
49
+ json (~> 1.4)
50
+ simplecov (0.7.1)
51
+ multi_json (~> 1.0)
52
+ simplecov-html (~> 0.7.1)
53
+ simplecov-html (0.7.1)
54
+ yard (0.8.7)
55
+
56
+ PLATFORMS
57
+ ruby
58
+
59
+ DEPENDENCIES
60
+ bundler (>= 1.3.5)
61
+ jeweler (>= 1.8.7)
62
+ minitest (>= 4.7.3)
63
+ mocha (>= 0.14.0)
64
+ simplecov
65
+ yard (>= 0.8.7)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Victor Costan
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -1,28 +1,38 @@
1
- # Rakefile that uses echoe to manage mit_stalker's gemspec.
2
- #
3
- # Author:: Victor Costan
4
- # Copyright:: Copyright (C) 2009 Zergling.Net
5
- # License:: MIT
1
+ # encoding: utf-8
6
2
 
7
3
  require 'rubygems'
8
- require 'echoe'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
9
13
 
10
- Echoe.new('mit_stalker') do |p|
11
- p.project = 'zerglings' # RubyForge project.
12
-
13
- p.author = 'Victor Costan'
14
- p.email = 'victor@zergling.net'
15
- p.summary = "Fetches publicly available information about MIT students."
16
- p.url = 'http://github.com/costan/mit_stalker'
17
- p.dependencies = []
18
- p.development_dependencies = ["echoe >=3.1.1", "flexmock >=0.8.6"]
19
-
20
- p.need_tar_gz = true
21
- p.need_zip = true
22
- p.rdoc_pattern = /^(lib|bin|tasks|ext)|^BUILD|^README|^CHANGELOG|^TODO|^LICENSE|^COPYING$/
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "mit_stalker"
18
+ gem.homepage = "http://github.com/pwnall/mit_stalker"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Fetches publicly available information about MIT students.}
21
+ gem.description = %Q{Fetches publicly available information about MIT students.}
22
+ gem.email = "victor@costan.us"
23
+ gem.authors = ["Victor Costan"]
24
+ # dependencies defined in Gemfile
23
25
  end
26
+ Jeweler::RubygemsDotOrgTasks.new
24
27
 
25
- if $0 == __FILE__
26
- Rake.application = Rake::Application.new
27
- Rake.application.run
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/*_test.rb'
32
+ test.verbose = true
28
33
  end
34
+
35
+ task :default => :test
36
+
37
+ require 'yard'
38
+ YARD::Rake::YardocTask.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.5
data/lib/mit_stalker.rb CHANGED
@@ -1,42 +1,49 @@
1
- # Fetch publicly available information about MIT students.
2
- #
3
- # Author:: Victor Costan
4
- # Copyright:: Copyright (C) 2009 Zergling.Net
5
- # License:: MIT
1
+ # Fetch publicly available information about MIT students.
6
2
 
7
3
  require 'socket'
4
+ require 'timeout'
8
5
 
9
6
 
10
- # Fetch publicly available information about MIT students.
7
+ # Fetch publicly available information about MIT students.
11
8
  module MitStalker
9
+ class <<self
10
+ # The number of seconds to wait for a finger result.
11
+ attr_accessor :finger_timeout
12
+ end
13
+ self.finger_timeout = 10
14
+
12
15
  # Issues a finger request to a server.
13
16
  #
14
17
  # Returns a string containing the finger response, or nil if something went
15
18
  # wrong.
16
19
  def self.finger(request, host)
17
20
  begin
18
- client = TCPSocket.open host, 'finger'
19
- client.send request + "\n", 0 # 0 means standard packet
20
- result = client.readlines.join
21
- client.close
22
-
23
- return result
21
+ Timeout.timeout(self.finger_timeout) do
22
+ client = TCPSocket.open host, 'finger'
23
+ client.send request + "\n", 0 # 0 means standard packet
24
+ result = client.readlines.join
25
+ client.close
26
+
27
+ return result
28
+ end
29
+ rescue Timeout::Error
30
+ return nil
24
31
  rescue
25
32
  return nil
26
33
  end
27
34
  end
28
-
35
+
29
36
  # Retrieves an MIT student's full name, based on the Athena username.
30
37
  #
31
38
  # Returns a string containing the full name, or nil if the Athena username is
32
- # not recognized.
39
+ # not recognized.
33
40
  def self.full_name_from_user_name(user_name)
34
41
  athena_data = finger user_name.downcase, 'linux.mit.edu'
35
42
  return nil if athena_data.nil?
36
- match = athena_data.match /(N|n)ame\: (.*)$/
43
+ match = /(N|n)ame\: (.*)$/.match athena_data
37
44
  match and match[2].strip
38
45
  end
39
-
46
+
40
47
  # Parses a MIT directory response into users.
41
48
  #
42
49
  # Returns a (possibly empty) array of hashes, with one hash per user. A hash
@@ -44,8 +51,8 @@ module MitStalker
44
51
  # {:name => 'Victor Costan', :year => '1'}
45
52
  def self.parse_mitdir_response(response)
46
53
  return [] if response.nil?
47
-
48
- lines = response.split("\r\n").reverse
54
+
55
+ lines = response.split("\r\n").reverse
49
56
  users = []
50
57
  user = {}
51
58
  lines.each do |line|
@@ -54,15 +61,15 @@ module MitStalker
54
61
  user = {}
55
62
  next
56
63
  end
57
-
64
+
58
65
  match = /([^:]*):(.+)/.match line
59
66
  break unless match
60
-
67
+
61
68
  user[match[1].strip.downcase.gsub(' ', '_').to_sym] = match[2].strip
62
69
  end
63
70
  users
64
71
  end
65
-
72
+
66
73
  # Computes a name vector from a full name.
67
74
  #
68
75
  # The same name, in different formats, should yield the same vector. Different
@@ -70,24 +77,24 @@ module MitStalker
70
77
  def self.name_vector(name)
71
78
  name.gsub(/\W/, ' ').gsub(/ +/, ' ').split.sort
72
79
  end
73
-
80
+
74
81
  # Narrows down a MIT directory response to a single user.
75
82
  #
76
83
  # Returns a single user information hash, or nil if no user has the given
77
- # full name.
84
+ # full name.
78
85
  def self.refine_mitdir_response_by_name(users, full_name)
79
86
  vector = name_vector(full_name)
80
87
  user_base_info = users.find { |user| name_vector(user[:name]) == vector }
81
88
  return nil unless user_base_info
82
-
89
+
83
90
  # Don't make an extra request for the same info.
84
91
  return users.first if users.length == 1
85
-
92
+
86
93
  # Requesting by alias should return a single name.
87
94
  users = parse_mitdir_response finger(user_base_info[:alias], 'web.mit.edu')
88
95
  users and users.first
89
96
  end
90
-
97
+
91
98
  # Narrows down a MIT directory response to a single user.
92
99
  #
93
100
  # Returns a single user information hash, or nil if no user has the given
@@ -104,26 +111,26 @@ module MitStalker
104
111
  next unless users
105
112
  user = users.first
106
113
  if user[:email] and user[:email].split('@').first == user_name
107
- return user
114
+ return user
108
115
  end
109
116
  end
110
117
  end
111
118
  nil
112
119
  end
113
-
120
+
114
121
  # Flips an official full-name (e.g. Costan, Victor-Marius) to its normal form.
115
122
  def self.flip_full_name(name)
116
123
  name.split(',', 2).map(&:strip).reverse.join(' ')
117
124
  end
118
-
125
+
119
126
  # Retrieves information about an MIT student from an Athena username.
120
127
  #
121
128
  # Returns a hash containing user information, or nil if the user was not
122
129
  # found.
123
- def self.from_user_name(user_name)
130
+ def self.from_user_name(user_name, finger_timeout=10)
124
131
  user_name = user_name.downcase
125
132
  full_name = full_name_from_user_name user_name
126
-
133
+
127
134
  if full_name
128
135
  users = parse_mitdir_response finger(full_name, 'web.mit.edu')
129
136
  else
@@ -132,11 +139,11 @@ module MitStalker
132
139
  if users.empty?
133
140
  users = parse_mitdir_response finger(user_name, 'web.mit.edu')
134
141
  end
135
-
142
+
136
143
  user = refine_mitdir_response_by_name(users, full_name) if full_name
137
144
  user = refine_mitdir_response_by_email(users, user_name) unless user
138
145
  return nil unless user
139
-
146
+
140
147
  user.merge :full_name => (full_name || flip_full_name(user[:name]))
141
148
  end
142
149
  end
data/mit_stalker.gemspec CHANGED
@@ -1,36 +1,70 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
1
4
  # -*- encoding: utf-8 -*-
2
5
 
3
6
  Gem::Specification.new do |s|
4
7
  s.name = "mit_stalker"
5
- s.version = "1.0.4"
8
+ s.version = "1.0.5"
6
9
 
7
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
11
  s.authors = ["Victor Costan"]
9
- s.date = "2012-02-11"
12
+ s.date = "2013-09-05"
10
13
  s.description = "Fetches publicly available information about MIT students."
11
- s.email = "victor@zergling.net"
12
- s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README.textile", "lib/mit_stalker.rb"]
13
- s.files = ["CHANGELOG", "LICENSE", "Manifest", "README.textile", "Rakefile", "lib/mit_stalker.rb", "test/fixtures/multi_response.txt", "test/fixtures/no_response.txt", "test/fixtures/single_response.txt", "test/mit_stalker_test.rb", "mit_stalker.gemspec"]
14
- s.homepage = "http://github.com/costan/mit_stalker"
15
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Mit_stalker", "--main", "README.textile"]
14
+ s.email = "victor@costan.us"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.textile"
18
+ ]
19
+ s.files = [
20
+ ".project",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.textile",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "lib/mit_stalker.rb",
28
+ "mit_stalker.gemspec",
29
+ "test/fixtures/mixed_response.txt",
30
+ "test/fixtures/multi_response.txt",
31
+ "test/fixtures/no_response.txt",
32
+ "test/fixtures/single_response.txt",
33
+ "test/fixtures/single_response2.txt",
34
+ "test/helper.rb",
35
+ "test/mit_stalker_test.rb"
36
+ ]
37
+ s.homepage = "http://github.com/pwnall/mit_stalker"
38
+ s.licenses = ["MIT"]
16
39
  s.require_paths = ["lib"]
17
- s.rubyforge_project = "zerglings"
18
- s.rubygems_version = "1.8.15"
40
+ s.rubygems_version = "2.0.7"
19
41
  s.summary = "Fetches publicly available information about MIT students."
20
- s.test_files = ["test/mit_stalker_test.rb"]
21
42
 
22
43
  if s.respond_to? :specification_version then
23
- s.specification_version = 3
44
+ s.specification_version = 4
24
45
 
25
46
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
- s.add_development_dependency(%q<echoe>, [">= 3.1.1"])
27
- s.add_development_dependency(%q<flexmock>, [">= 0.8.6"])
47
+ s.add_development_dependency(%q<mocha>, [">= 0.14.0"])
48
+ s.add_development_dependency(%q<minitest>, [">= 4.7.3"])
49
+ s.add_development_dependency(%q<yard>, [">= 0.8.7"])
50
+ s.add_development_dependency(%q<bundler>, [">= 1.3.5"])
51
+ s.add_development_dependency(%q<jeweler>, [">= 1.8.7"])
52
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
28
53
  else
29
- s.add_dependency(%q<echoe>, [">= 3.1.1"])
30
- s.add_dependency(%q<flexmock>, [">= 0.8.6"])
54
+ s.add_dependency(%q<mocha>, [">= 0.14.0"])
55
+ s.add_dependency(%q<minitest>, [">= 4.7.3"])
56
+ s.add_dependency(%q<yard>, [">= 0.8.7"])
57
+ s.add_dependency(%q<bundler>, [">= 1.3.5"])
58
+ s.add_dependency(%q<jeweler>, [">= 1.8.7"])
59
+ s.add_dependency(%q<simplecov>, [">= 0"])
31
60
  end
32
61
  else
33
- s.add_dependency(%q<echoe>, [">= 3.1.1"])
34
- s.add_dependency(%q<flexmock>, [">= 0.8.6"])
62
+ s.add_dependency(%q<mocha>, [">= 0.14.0"])
63
+ s.add_dependency(%q<minitest>, [">= 4.7.3"])
64
+ s.add_dependency(%q<yard>, [">= 0.8.7"])
65
+ s.add_dependency(%q<bundler>, [">= 1.3.5"])
66
+ s.add_dependency(%q<jeweler>, [">= 1.8.7"])
67
+ s.add_dependency(%q<simplecov>, [">= 0"])
35
68
  end
36
69
  end
70
+
@@ -0,0 +1,31 @@
1
+ Student data loaded as of Sep 29, Staff data loaded as of Sep 29.
2
+
3
+ Notify Personnel or use WebSIS as appropriate to change your information.
4
+
5
+ Our on-line help system describes
6
+ How to change data, how the directory works, where to get more info.
7
+ For a listing of help topics, enter finger help@mit.edu. Try finger
8
+ help_about@mit.edu to read about how the directory works.
9
+ Directory bluepages may be found at http://mit.edu/communications/bp.
10
+
11
+ There were 3 matches to your request.
12
+
13
+ Complete information will be shown only when one individual matches
14
+ your query. Resubmit your query with more information.
15
+ For example, use both firstname and lastname or use the alias field.
16
+
17
+ name: Li, An
18
+ department: Electrical Eng & Computer Sci
19
+ email: _anli@MIT.EDU
20
+ year: 4
21
+ alias: A-li2
22
+
23
+ name: Costan, Victor Marius
24
+ department: Electrical Eng & Computer Sci
25
+ year: G
26
+ alias: V-costan
27
+
28
+ name: Li, Alice
29
+ department: Electrical Eng & Computer Sci
30
+ year: 4
31
+ alias: A-li
@@ -0,0 +1,19 @@
1
+ Student data loaded as of Feb 3, Staff data loaded as of Feb 3.
2
+
3
+ Notify Personnel or use WebSIS as appropriate to change your information.
4
+
5
+ Our on-line help system describes
6
+ How to change data, how the directory works, where to get more info.
7
+ For a listing of help topics, enter finger help@mit.edu. Try finger
8
+ help_about@mit.edu to read about how the directory works.
9
+ Directory bluepages may be found at http://mit.edu/communications/bp.
10
+
11
+ There was 1 match to your request.
12
+
13
+ name: Li, Alice
14
+ email: aliceli@MIT.EDU
15
+ address: MacGregor House # B322
16
+ department: Electrical Eng & Computer Sci
17
+ school: School Of Engineering
18
+ year: 4
19
+ alias: A-li
data/test/helper.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'minitest/autorun'
11
+ require 'minitest/unit'
12
+ require 'mocha/setup'
13
+
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
16
+ require 'mit_stalker'
17
+
18
+ MiniTest.autorun
@@ -1,26 +1,31 @@
1
- # Author:: Victor Costan
2
- # Copyright:: Copyright (C) 2009 Zergling.Net
3
- # License:: MIT
1
+ require File.expand_path('./helper', File.dirname(__FILE__))
4
2
 
5
- require 'mit_stalker'
6
- require 'test/unit'
7
- require 'flexmock/test_unit'
8
3
 
9
-
10
- class MitStalkerTest < Test::Unit::TestCase
4
+ class MitStalkerTest < Minitest::Test
11
5
  def fixture(name)
12
6
  File.read File.join(File.dirname(__FILE__), 'fixtures', name)
13
7
  end
14
-
8
+
15
9
  def test_finger
16
10
  assert_equal nil, MitStalker.finger('root', 'nosuchhostname.com'),
17
11
  'Invalid hostname'
18
-
19
- result = MitStalker.finger('no_such_user', 'web.mit.edu')
20
- assert_operator(/matche?s? to your (query)|(request)/, :=~, result,
12
+
13
+ result = MitStalker.finger 'no_such_user', 'linux.mit.edu'
14
+ assert_operator(/no_such_user/, :=~, result,
21
15
  "The finger response looks incorrect")
16
+
17
+ begin
18
+ MitStalker.finger_timeout = 1
19
+
20
+ start_time = Time.now
21
+ result = MitStalker.finger 'no_such_user', 'web.mit.edu'
22
+ assert_equal nil, result, 'Invalid timeout result'
23
+ assert_in_delta Time.now - start_time, 1, 0.2, 'Bad timeout duration'
24
+ ensure
25
+ MitStalker.finger_timeout = 10
26
+ end
22
27
  end
23
-
28
+
24
29
  def test_full_name
25
30
  assert_equal 'Srinivas Devadas',
26
31
  MitStalker.full_name_from_user_name('devadas'),
@@ -30,16 +35,16 @@ class MitStalkerTest < Test::Unit::TestCase
30
35
  'Capital letter in user name'
31
36
  assert_equal nil, MitStalker.full_name_from_user_name('no_user')
32
37
  end
33
-
38
+
34
39
  def test_parse_mitdir_no_response
35
40
  assert_equal [],
36
41
  MitStalker.parse_mitdir_response(fixture('no_response.txt'))
37
42
  end
38
-
43
+
39
44
  def test_parse_mitdir_single_response
40
45
  response = MitStalker.parse_mitdir_response fixture('single_response.txt')
41
46
  assert_equal 1, response.length, 'Response should have 1 user'
42
-
47
+
43
48
  assert_equal 'Costan, Victor Marius', response.first[:name]
44
49
  assert_equal 'costan@MIT.EDU', response.first[:email]
45
50
  assert_equal 'G', response.first[:year]
@@ -47,40 +52,40 @@ class MitStalkerTest < Test::Unit::TestCase
47
52
  assert_equal 'http://www.costan.us', response.first[:url]
48
53
  assert_equal 'V-costan', response.first[:alias]
49
54
  end
50
-
55
+
51
56
  def test_parse_mitdir_multiple_responses
52
57
  response = MitStalker.parse_mitdir_response fixture('multi_response.txt')
53
58
  assert_equal 155, response.length, 'Response should have 110 users'
54
-
59
+
55
60
  response.each do |user|
56
61
  assert_operator(/Li/, :=~, user[:name], "Name doesn't match query")
57
62
  assert_operator(/li/i, :=~, user[:alias], "Alias doesn't match query")
58
63
  end
59
64
  end
60
-
65
+
61
66
  def test_name_vector
62
67
  ['Victor-Marius Costan', 'Victor Marius Costan', 'Costan, Victor-Marius',
63
68
  'Costan, Victor Marius'].each do |name|
64
69
  assert_equal ['Costan', 'Marius', 'Victor'], MitStalker.name_vector(name)
65
70
  end
66
71
  end
67
-
72
+
68
73
  def test_refine_mitdir_response_by_name
69
- flexmock(MitStalker).should_receive(:finger).with('Y-li16', 'web.mit.edu').
70
- and_return(fixture('single_response.txt')).once
71
-
72
- multi_response =
73
- MitStalker.parse_mitdir_response fixture('multi_response.txt')
74
+ MitStalker.expects(:finger).with('Y-li16', 'web.mit.edu').
75
+ returns(fixture('single_response.txt')).once
76
+
77
+ multi_response = MitStalker.parse_mitdir_response(
78
+ fixture('multi_response.txt'))
74
79
  user = MitStalker.refine_mitdir_response_by_name multi_response,
75
80
  'Yan Ping Li'
76
81
  assert_equal 'costan@MIT.EDU', user[:email], 'Wrong user information'
77
82
  end
78
-
83
+
79
84
  def test_refine_mitdir_response_by_email
80
- flexmock(MitStalker).should_receive(:finger).with('V-costan', 'web.mit.edu').
81
- and_return(fixture('single_response.txt')).once
82
- flexmock(MitStalker).should_receive(:finger).with('A-li', 'web.mit.edu').
83
- and_return(fixture('single_response2.txt')).once
85
+ MitStalker.expects(:finger).with('V-costan', 'web.mit.edu').
86
+ returns(fixture('single_response.txt')).once
87
+ MitStalker.expects(:finger).with('A-li', 'web.mit.edu').
88
+ returns(fixture('single_response2.txt')).once
84
89
 
85
90
  mixed_response =
86
91
  MitStalker.parse_mitdir_response fixture('mixed_response.txt')
@@ -89,24 +94,27 @@ class MitStalkerTest < Test::Unit::TestCase
89
94
  assert user, 'No user returned'
90
95
  assert_equal 'Li, Alice', user[:name]
91
96
  end
92
-
97
+
93
98
  def test_flip_full_name
94
99
  assert_equal 'Victor Marius Costan',
95
100
  MitStalker.flip_full_name('Costan, Victor Marius'), 'flipped'
96
101
  assert_equal 'Victor Marius Costan',
97
102
  MitStalker.flip_full_name('Victor Marius Costan'), 'canonical'
98
103
  end
99
-
104
+
100
105
  def test_from_user_name
101
106
  assert_equal nil, MitStalker.from_user_name('no_such_user')
102
-
107
+
103
108
  info = MitStalker.from_user_name 'devadas'
109
+ assert info, 'No info returned'
104
110
  assert_equal 'Devadas, Srinivas', info[:name]
105
-
111
+
106
112
  info = MitStalker.from_user_name 'Devadas'
113
+ assert info, 'No info returned'
107
114
  assert_equal 'Devadas, Srinivas', info[:name], 'capitalized user name'
108
115
 
109
116
  info = MitStalker.from_user_name 'nickolai'
117
+ assert info, 'No info returned'
110
118
  assert_equal 'Zeldovich, Nickolai', info[:name]
111
119
  assert_equal 'Nickolai Zeldovich', info[:full_name]
112
120
  end
metadata CHANGED
@@ -1,88 +1,145 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mit_stalker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
5
- prerelease:
4
+ version: 1.0.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Victor Costan
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-02-11 00:00:00.000000000 Z
11
+ date: 2013-09-05 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: echoe
16
- requirement: &18723780 !ruby/object:Gem::Requirement
17
- none: false
14
+ name: mocha
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
21
- version: 3.1.1
19
+ version: 0.14.0
22
20
  type: :development
23
21
  prerelease: false
24
- version_requirements: *18723780
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.14.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 4.7.3
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 4.7.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: yard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.8.7
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.8.7
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.3.5
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 1.3.5
69
+ - !ruby/object:Gem::Dependency
70
+ name: jeweler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: 1.8.7
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: 1.8.7
25
83
  - !ruby/object:Gem::Dependency
26
- name: flexmock
27
- requirement: &18723280 !ruby/object:Gem::Requirement
28
- none: false
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
29
86
  requirements:
30
87
  - - ! '>='
31
88
  - !ruby/object:Gem::Version
32
- version: 0.8.6
89
+ version: '0'
33
90
  type: :development
34
91
  prerelease: false
35
- version_requirements: *18723280
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
36
97
  description: Fetches publicly available information about MIT students.
37
- email: victor@zergling.net
98
+ email: victor@costan.us
38
99
  executables: []
39
100
  extensions: []
40
101
  extra_rdoc_files:
41
- - CHANGELOG
42
- - LICENSE
102
+ - LICENSE.txt
43
103
  - README.textile
44
- - lib/mit_stalker.rb
45
104
  files:
46
- - CHANGELOG
47
- - LICENSE
48
- - Manifest
105
+ - .project
106
+ - Gemfile
107
+ - Gemfile.lock
108
+ - LICENSE.txt
49
109
  - README.textile
50
110
  - Rakefile
111
+ - VERSION
51
112
  - lib/mit_stalker.rb
113
+ - mit_stalker.gemspec
114
+ - test/fixtures/mixed_response.txt
52
115
  - test/fixtures/multi_response.txt
53
116
  - test/fixtures/no_response.txt
54
117
  - test/fixtures/single_response.txt
118
+ - test/fixtures/single_response2.txt
119
+ - test/helper.rb
55
120
  - test/mit_stalker_test.rb
56
- - mit_stalker.gemspec
57
- homepage: http://github.com/costan/mit_stalker
58
- licenses: []
121
+ homepage: http://github.com/pwnall/mit_stalker
122
+ licenses:
123
+ - MIT
124
+ metadata: {}
59
125
  post_install_message:
60
- rdoc_options:
61
- - --line-numbers
62
- - --inline-source
63
- - --title
64
- - Mit_stalker
65
- - --main
66
- - README.textile
126
+ rdoc_options: []
67
127
  require_paths:
68
128
  - lib
69
129
  required_ruby_version: !ruby/object:Gem::Requirement
70
- none: false
71
130
  requirements:
72
131
  - - ! '>='
73
132
  - !ruby/object:Gem::Version
74
133
  version: '0'
75
134
  required_rubygems_version: !ruby/object:Gem::Requirement
76
- none: false
77
135
  requirements:
78
136
  - - ! '>='
79
137
  - !ruby/object:Gem::Version
80
- version: '1.2'
138
+ version: '0'
81
139
  requirements: []
82
- rubyforge_project: zerglings
83
- rubygems_version: 1.8.15
140
+ rubyforge_project:
141
+ rubygems_version: 2.0.7
84
142
  signing_key:
85
- specification_version: 3
143
+ specification_version: 4
86
144
  summary: Fetches publicly available information about MIT students.
87
- test_files:
88
- - test/mit_stalker_test.rb
145
+ test_files: []
data/CHANGELOG DELETED
@@ -1,9 +0,0 @@
1
- v1.0.4. Correct handling of capital letters in input.
2
-
3
- v1.0.3. Workaround for people not registered on linux.mit.edu.
4
-
5
- v1.0.2. Workaround for people undergoing name changes.
6
-
7
- v1.0.1. Fixed copy-pasted manifest.
8
-
9
- v1.0. Initial release.
data/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License
2
-
3
- Copyright (c) 2009 Zergling.Net
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
data/Manifest DELETED
@@ -1,10 +0,0 @@
1
- CHANGELOG
2
- LICENSE
3
- Manifest
4
- README.textile
5
- Rakefile
6
- lib/mit_stalker.rb
7
- test/fixtures/multi_response.txt
8
- test/fixtures/no_response.txt
9
- test/fixtures/single_response.txt
10
- test/mit_stalker_test.rb