mit-ldap 0.3.0 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mit-ldap.rb +3 -6
- data/lib/mit/ldap.rb +1 -1
- data/lib/mit/ldap/version.rb +1 -1
- data/spec/ldap_spec.rb +2 -2
- data/spec/mit_spec.rb +2 -2
- metadata +8 -8
data/lib/mit-ldap.rb
CHANGED
@@ -7,17 +7,14 @@ module MIT
|
|
7
7
|
class << self
|
8
8
|
|
9
9
|
def on_campus?
|
10
|
-
ip_addresses.
|
10
|
+
ip_addresses.map { |ip| !(ip =~ /^18\./).nil? }.any?
|
11
11
|
end
|
12
12
|
|
13
13
|
private
|
14
14
|
|
15
15
|
def ip_addresses
|
16
|
-
|
17
|
-
|
18
|
-
else
|
19
|
-
`ifconfig | sed -rn 's/.*r:([^ ]+) .*/\1/p'`
|
20
|
-
end
|
16
|
+
ifconfig = `ifconfig`
|
17
|
+
@ip_addresses ||= ifconfig.split(/\n/).grep(/inet (?:addr:)?((?:\d{1,3}\.){3}\d{1,3})/) { $1 }
|
21
18
|
end
|
22
19
|
end
|
23
20
|
end
|
data/lib/mit/ldap.rb
CHANGED
data/lib/mit/ldap/version.rb
CHANGED
data/spec/ldap_spec.rb
CHANGED
@@ -27,13 +27,13 @@ module MIT
|
|
27
27
|
end
|
28
28
|
|
29
29
|
describe ".reconnect!" do
|
30
|
-
it "reloads connection object
|
30
|
+
it "reloads connection object" do
|
31
31
|
LDAP.adapter.instance_variable_set(:@connection, nil)
|
32
32
|
LDAP.reconnect!
|
33
33
|
LDAP.adapter.instance_variable_get(:@connection).should be_a ::LDAP::Conn
|
34
34
|
end
|
35
35
|
|
36
|
-
it "calls .connect! if not connected" do
|
36
|
+
it "calls .connect! if not connected already" do
|
37
37
|
LDAP.stub(:adapter_present?).and_return(false)
|
38
38
|
LDAP.should_receive(:connect!)
|
39
39
|
LDAP.reconnect!
|
data/spec/mit_spec.rb
CHANGED
@@ -4,12 +4,12 @@ describe MIT do
|
|
4
4
|
|
5
5
|
describe ".on_campus?" do
|
6
6
|
it "returns true if IP starts with 18" do
|
7
|
-
MIT.stub(:ip_addresses).and_return(
|
7
|
+
MIT.stub(:ip_addresses).and_return(['18.0.0.0', '127.0.0.1'])
|
8
8
|
MIT.on_campus?.should be_true
|
9
9
|
end
|
10
10
|
|
11
11
|
it "returns false if no network device has a campus address" do
|
12
|
-
MIT.stub(:ip_addresses).and_return(
|
12
|
+
MIT.stub(:ip_addresses).and_return(['192.168.0.2', '127.0.0.1'])
|
13
13
|
MIT.on_campus?.should be_false
|
14
14
|
end
|
15
15
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mit-ldap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ldaptic
|
16
|
-
requirement: &
|
16
|
+
requirement: &70295147816060 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0.2'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70295147816060
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: ruby-ldap
|
27
|
-
requirement: &
|
27
|
+
requirement: &70295147813080 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0.9'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70295147813080
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70295147810340 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '2.0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70295147810340
|
47
47
|
description: Ruby interface for querying MIT LDAP server (only if you're on MITnet)
|
48
48
|
email:
|
49
49
|
- edd_d@mit.edu
|