sane 0.24.2 → 0.24.3
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +1 -4
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/sane/socket_ips.rb +34 -0
- data/lib/sane/string_blank.rb +3 -0
- data/spec/spec.sane.rb +4 -0
- metadata +6 -18
data/ChangeLog
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
0.
|
2
|
-
remove __dir__ (deemed too confusing, since it would seem to imply that __file__ also exists, which it doesn't)
|
3
|
-
change __DIR__ from /a/b/ to /a/b (also confused me once, can't have that!)
|
4
|
-
add Numeric#group_digits(',')
|
1
|
+
0.25.6 add Socket.get_host_ips, remove dependency on andand until I need it again.
|
5
2
|
|
6
3
|
# 3: add hash_set_operators
|
7
4
|
# 0.2.2: add Regex+Regex, bug fixes
|
data/Rakefile
CHANGED
@@ -7,5 +7,5 @@ Jeweler::Tasks.new do |s|
|
|
7
7
|
s.description = s.summary = %q{Helpers for ruby core to make it easier to work with--things that are missing from core but should arguably be there}
|
8
8
|
s.email = ["rogerdpack@gmail.com"]
|
9
9
|
s.add_dependency 'os'
|
10
|
-
s.add_dependency 'andand' # turns out to be pretty useful...
|
10
|
+
#s.add_dependency 'andand' # turns out to be pretty useful...
|
11
11
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.24.
|
1
|
+
0.24.3
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class Numeric
|
2
|
+
def ord; self; end unless RUBY_VERSION[0..2] == '1.9' # helper for 1.8/1.9
|
3
|
+
end
|
4
|
+
|
5
|
+
require 'socket' # sane already loads it for BasicSocket.reverse_lookup
|
6
|
+
|
7
|
+
class Socket
|
8
|
+
class << self
|
9
|
+
def get_host_ips
|
10
|
+
get_ips(Socket.gethostname)
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_ips hostname
|
14
|
+
begin
|
15
|
+
|
16
|
+
socket_info = Socket.getaddrinfo(hostname, nil,
|
17
|
+
Socket::AF_UNSPEC, Socket::SOCK_STREAM, nil,
|
18
|
+
Socket::AI_CANONNAME).select{|type| type[0] == 'AF_INET'}
|
19
|
+
|
20
|
+
raise if socket_info.length == 0
|
21
|
+
ips = socket_info.map{|info| info[3]}
|
22
|
+
return ips
|
23
|
+
rescue => e # getaddrinfo failed...
|
24
|
+
begin
|
25
|
+
ipInt = gethostbyname(hostname)[3] # do a DNS lookup
|
26
|
+
return ["%d.%d.%d.%d" % [ipInt[0].ord, ipInt[1].ord, ipInt[2].ord, ipInt[3].ord]]
|
27
|
+
rescue SocketError # happens in certain instances...
|
28
|
+
return nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
data/spec/spec.sane.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sane
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 121
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 24
|
9
|
-
-
|
10
|
-
version: 0.24.
|
9
|
+
- 3
|
10
|
+
version: 0.24.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Roger Pack
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-09-23 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: os
|
@@ -31,20 +31,6 @@ dependencies:
|
|
31
31
|
version: "0"
|
32
32
|
type: :runtime
|
33
33
|
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: andand
|
36
|
-
prerelease: false
|
37
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
-
none: false
|
39
|
-
requirements:
|
40
|
-
- - ">="
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
hash: 3
|
43
|
-
segments:
|
44
|
-
- 0
|
45
|
-
version: "0"
|
46
|
-
type: :runtime
|
47
|
-
version_requirements: *id002
|
48
34
|
description: Helpers for ruby core to make it easier to work with--things that are missing from core but should arguably be there
|
49
35
|
email:
|
50
36
|
- rogerdpack@gmail.com
|
@@ -83,7 +69,9 @@ files:
|
|
83
69
|
- lib/sane/pps.rb
|
84
70
|
- lib/sane/require_relative.rb
|
85
71
|
- lib/sane/sane_random.rb
|
72
|
+
- lib/sane/socket_ips.rb
|
86
73
|
- lib/sane/string.rb
|
74
|
+
- lib/sane/string_blank.rb
|
87
75
|
- lib/sane/test.rb
|
88
76
|
- lib/sane/test/assertions.rb
|
89
77
|
- lib/sane/thread.rb
|