rex-text 0.2.11 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/rex/text/table.rb +14 -6
- data/lib/rex/text/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af387bec6195c86e46f665cf9df0db78cf47d08c
|
4
|
+
data.tar.gz: 03f4a51320429e552c67c8fcab91dfc987ee064b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78c9aa4d327088e047ff829ba3212767234f9f4511f380d9e5eccd25d0713743d10c4ec227309e0d505f1bc0d57f3ddac837ae1fc9fdf2b245b86e3a21ccb10d
|
7
|
+
data.tar.gz: 9e43a178354eb9155d0a6cb07961f5ff9c9f913e0fd2736f4512822a216511ff0c5efaa15882bda6e1a7d1d841935f6140c86c5495001b90e17816d09af2d8b8
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/rex/text/table.rb
CHANGED
@@ -184,6 +184,18 @@ class Table
|
|
184
184
|
rows << fields
|
185
185
|
end
|
186
186
|
|
187
|
+
def ip_cmp(a, b)
|
188
|
+
begin
|
189
|
+
a = IPAddr.new(a.to_s)
|
190
|
+
b = IPAddr.new(b.to_s)
|
191
|
+
return 1 if a.ipv6? && b.ipv4?
|
192
|
+
return -1 if a.ipv4? && b.ipv6?
|
193
|
+
a <=> b
|
194
|
+
rescue IPAddr::Error
|
195
|
+
nil
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
187
199
|
#
|
188
200
|
# Sorts the rows based on the supplied index of sub-arrays
|
189
201
|
# If the supplied index is an IPv4 address, handle it differently, but
|
@@ -199,15 +211,11 @@ class Table
|
|
199
211
|
cmp = 1
|
200
212
|
elsif a[index] =~ /^[0-9]+$/ and b[index] =~ /^[0-9]+$/
|
201
213
|
cmp = a[index].to_i <=> b[index].to_i
|
202
|
-
elsif
|
203
|
-
cmp = 1
|
204
|
-
elsif a[index].kind_of?(IPAddr) && b[index].kind_of?(IPAddr) && a[index].ipv4? && b[index].ipv6?
|
205
|
-
cmp = -1
|
206
|
-
elsif !(a[index].kind_of?(IPAddr) || b[index].kind_of?(IPAddr)) && (valid_ip?(a[index]) && valid_ip?(b[index]))
|
207
|
-
cmp = IPAddr.new(a[index]) <=> IPAddr.new(b[index])
|
214
|
+
elsif (cmp = ip_cmp(a[index], b[index])) != nil
|
208
215
|
else
|
209
216
|
cmp = a[index] <=> b[index] # assumes otherwise comparable.
|
210
217
|
end
|
218
|
+
cmp ||= 0
|
211
219
|
order == :forward ? cmp : -cmp
|
212
220
|
end
|
213
221
|
end
|
data/lib/rex/text/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rex-text
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David 'thelightcosine' Maloney
|
@@ -88,7 +88,7 @@ cert_chain:
|
|
88
88
|
G+Hmcg1v810agasPdoydE0RTVZgEOOMoQ07qu7JFXVWZ9ZQpHT7qJATWL/b2csFG
|
89
89
|
8mVuTXnyJOKRJA==
|
90
90
|
-----END CERTIFICATE-----
|
91
|
-
date: 2017-
|
91
|
+
date: 2017-02-27 00:00:00.000000000 Z
|
92
92
|
dependencies:
|
93
93
|
- !ruby/object:Gem::Dependency
|
94
94
|
name: bundler
|
metadata.gz.sig
CHANGED
Binary file
|