nifty-utils 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nifty/utils/networks.rb +28 -0
- data/lib/nifty/utils/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86a0dec067d1856e587e922d6c0e052b4b9370d0
|
4
|
+
data.tar.gz: 251f41b6eb5a281a6cbe33262d6b12da55a3ac79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3cc493a0d24b90bada2d3e0527c387789594322cabd0d3c5a76ab2aa761a502745a6a5af2a15433aeec157127fa330b8c4e1123bbd901eb1d6573ee6c3db0a3
|
7
|
+
data.tar.gz: 8c46b3dc6b836bcdb5e745372e6e6332f7427efaf4baca2fbf2bbfb14a29810b30010c0eca2ae36031ee89cfff94edb298e7f6377a45b87a67e9315957cee19e
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'ipaddr'
|
2
|
+
|
3
|
+
module Nifty
|
4
|
+
module Utils
|
5
|
+
module Networks
|
6
|
+
|
7
|
+
def self.ip_in_networks?(ip, networks = [])
|
8
|
+
!!network_for_ip(networks, ip)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.network_for_ip(networks, ip)
|
12
|
+
networks.each do |i|
|
13
|
+
if IPAddr.new(i).include?(ip)
|
14
|
+
return i
|
15
|
+
end
|
16
|
+
end
|
17
|
+
return nil
|
18
|
+
rescue ArgumentError => e
|
19
|
+
if e.message == 'invalid address'
|
20
|
+
return nil
|
21
|
+
else
|
22
|
+
raise
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/nifty/utils/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nifty-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Cooke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A set of useful utilties for Rails applications.
|
14
14
|
email:
|
@@ -25,6 +25,7 @@ files:
|
|
25
25
|
- lib/nifty/utils/extensions/core.rb
|
26
26
|
- lib/nifty/utils/extensions/object.rb
|
27
27
|
- lib/nifty/utils/extensions/string.rb
|
28
|
+
- lib/nifty/utils/networks.rb
|
28
29
|
- lib/nifty/utils/railtie.rb
|
29
30
|
- lib/nifty/utils/random_string.rb
|
30
31
|
- lib/nifty/utils/until_with_max_attempts.rb
|