iparith 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/iparith.gemspec +2 -2
- data/lib/iparith/check.rb +18 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '092a28925f0cdb1ab5bae535692cd6b6d31324266bbdb46f0a1ecfcd16ffc3de'
|
4
|
+
data.tar.gz: 864e1bd78d5eadafc1445f46f9b16265f547198d997368a9fa34499e81099354
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38e5b55359bda853c3155ec7b8c8a74b47c6c46a5f1d18683f95a06bd2310e76e71b0f15b4e9dc26387b9aecdc9a37a43f150e80b06a618717e6650054cbb610
|
7
|
+
data.tar.gz: 76df03d48c82752fb2377409d590dafd25d07e22a78bd5a3594346435c7aaa7783157c91addb58ef14c9a38fa12065c997e476cae0642afdf686392ec2ec2ffa
|
data/iparith.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'iparith'
|
3
|
-
spec.version = '0.0.
|
3
|
+
spec.version = '0.0.3'
|
4
4
|
spec.authors = ['Forgot-His-Name']
|
5
5
|
spec.email = ['103605633+Forgot-His-Name@users.noreply.github.com']
|
6
6
|
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.homepage = 'https://github.com/Forgot-His-Name/iparith'
|
10
10
|
spec.license = "BSD-3-Clause"
|
11
11
|
|
12
|
-
spec.files = ['iparith.gemspec', 'lib/iparith.rb', 'lib/iparith/parse.rb']
|
12
|
+
spec.files = ['iparith.gemspec', 'lib/iparith.rb', 'lib/iparith/parse.rb', 'lib/iparith/check.rb']
|
13
13
|
spec.require_paths = ['lib']
|
14
14
|
|
15
15
|
spec.add_runtime_dependency 'ipaddr', '~> 1.2'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module IPArith
|
2
|
+
|
3
|
+
def self.prefix_valid?(ipstr)
|
4
|
+
netstr, mask = ipstr.split('/')
|
5
|
+
|
6
|
+
pref = ::IPAddr.new ipstr
|
7
|
+
|
8
|
+
# mask must be assumed /32 if not defined
|
9
|
+
# /32 prefixes always valid in this check
|
10
|
+
# so, we just return true after successfuly parse ipstr
|
11
|
+
return true unless mask
|
12
|
+
|
13
|
+
pref.to_s == netstr
|
14
|
+
rescue ::IPAddr::InvalidAddressError, ::IPAddr::AddressFamilyError
|
15
|
+
nil
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iparith
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Forgot-His-Name
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ipaddr
|
@@ -33,6 +33,7 @@ extra_rdoc_files: []
|
|
33
33
|
files:
|
34
34
|
- iparith.gemspec
|
35
35
|
- lib/iparith.rb
|
36
|
+
- lib/iparith/check.rb
|
36
37
|
- lib/iparith/parse.rb
|
37
38
|
homepage: https://github.com/Forgot-His-Name/iparith
|
38
39
|
licenses:
|