rex-text 0.2.11 → 0.2.12

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: 8849750ccde97e100a88b0eb765bfd064cc695be
4
- data.tar.gz: 4b0e04c8bbb6fd428e24f640f477b8f4c5b68c81
3
+ metadata.gz: af387bec6195c86e46f665cf9df0db78cf47d08c
4
+ data.tar.gz: 03f4a51320429e552c67c8fcab91dfc987ee064b
5
5
  SHA512:
6
- metadata.gz: fdb6ff6f05b44414fdb15c0d6ecc8624af322f3f116ce27baa89935bfe68bfa26448d2f1dc15569cc197d83d15f44657f042bd526b47dafe8d4785c45b80e8b8
7
- data.tar.gz: 0bb8053e1d26cc63bfeb4ef9379303f770c93d615fc903c411b3e6fc6ea543b0d5e1e4cf32716c594cad6f5e0b187f6b114f72ecf6dd2f0fb005651fa7e8350c
6
+ metadata.gz: 78c9aa4d327088e047ff829ba3212767234f9f4511f380d9e5eccd25d0713743d10c4ec227309e0d505f1bc0d57f3ddac837ae1fc9fdf2b245b86e3a21ccb10d
7
+ data.tar.gz: 9e43a178354eb9155d0a6cb07961f5ff9c9f913e0fd2736f4512822a216511ff0c5efaa15882bda6e1a7d1d841935f6140c86c5495001b90e17816d09af2d8b8
checksums.yaml.gz.sig CHANGED
Binary file
@@ -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 a[index].kind_of?(IPAddr) && a[index].kind_of?(IPAddr) && a[index].ipv6? && b[index].ipv4?
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
@@ -1,5 +1,5 @@
1
1
  module Rex
2
2
  module Text
3
- VERSION = "0.2.11"
3
+ VERSION = "0.2.12"
4
4
  end
5
5
  end
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.11
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-01-18 00:00:00.000000000 Z
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