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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f05855de1c90babf9382e281e12d9549caf5257e
4
- data.tar.gz: abcdd1052203af95eb6831882d5abe3a6bb75af8
3
+ metadata.gz: 86a0dec067d1856e587e922d6c0e052b4b9370d0
4
+ data.tar.gz: 251f41b6eb5a281a6cbe33262d6b12da55a3ac79
5
5
  SHA512:
6
- metadata.gz: fcdb86d6c4177aa7d7fba77e90f3bd4ad1006ba9070e772d35c59b031bd24eb0ee12e1c09a3933277b1780d83fb4491a881b4590df4954ce6d26872aee520f4d
7
- data.tar.gz: 94655dae4c2e9577090f5bca4fd8990e802bcb7ac2c6074e7e98eaa6a079dee2929f18795ba0f959e0bc5779725774c6f1d89fde1c76dd0d481462c10504b5cb
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
@@ -1,5 +1,5 @@
1
1
  module Nifty
2
2
  module Utils
3
- VERSION = '1.1.2'
3
+ VERSION = '1.1.3'
4
4
  end
5
5
  end
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.2
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-02-20 00:00:00.000000000 Z
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