naturalsorter 3.0.28 → 3.0.29

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2c3dd53e850c9f543a6720acd9076261217782b794a42bf911cad9e5ffde9b72
4
- data.tar.gz: 9512924d1830308f8b6c16d272e9c450551efc04b2456dc0aea884216c223089
3
+ metadata.gz: c2e74c8afd80ac74a50b5512b063bb9787061a4d921220958e6b4fe4cc50b5a6
4
+ data.tar.gz: 852db30bdd5503eb99ba0e1a8a6734f2291793a81f0b588aa107345e09f6bf6a
5
5
  SHA512:
6
- metadata.gz: 6671128838d34e04e4598030edc12be861902680be0fb952f360fb1e089fe33c0c6cbdaa928ea600f15680bb2fd0254969d0480dc5b560d1f0124d418ce61ddf
7
- data.tar.gz: 9b38c32f74cc56aff89feda824e3430c24f8ee8e3d3cde08776bf94f208c991fab2ba84763f63b99e489957c4aade6e8f23c4984e9870d62d16b2ad6258e3834
6
+ metadata.gz: 5ae502c169639242eea60fb9e14add9d3242cf2fc66b1df948d0b1b00cdead5c9d53d954bc7a650fb970f87c4568d362490e168a593aad2c2a33421650b4622f
7
+ data.tar.gz: 7b08f71ad042cc08cad72166e59d9aa4ca6cc8ab03e4e8df891f14654f56966dc45e08ba15a77bdf57e018c8b10dcce74553d03ce267d17904751c4b6481bec8
data/README.markdown CHANGED
@@ -1,11 +1,9 @@
1
1
  # NaturalSorter
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/naturalsorter.png)](http://badge.fury.io/rb/naturalsorter)
4
- [![Dependency Status](https://www.versioneye.com/ruby/naturalsorter/badge?style=flat)](https://www.versioneye.com/ruby/naturalsorter)
5
4
  [![Build Status](https://travis-ci.org/versioneye/naturalsorter.png)](https://travis-ci.org/versioneye/naturalsorter)
6
5
  [![Coverage Status](https://coveralls.io/repos/versioneye/naturalsorter/badge.svg?branch=master&service=github)](https://coveralls.io/github/versioneye/naturalsorter?branch=master)
7
6
  [![Code Climate](https://codeclimate.com/github/versioneye/naturalsorter.png)](https://codeclimate.com/github/versioneye/naturalsorter)
8
- [![Bountysource](https://www.bountysource.com/badge/tracker?tracker_id=157523)](https://www.bountysource.com/trackers/157523-versioneye-naturalsorter?utm_source=157523&utm_medium=shield&utm_campaign=TRACKER_BADGE)
9
7
 
10
8
 
11
9
  ## The Mission
@@ -1,3 +1,3 @@
1
1
  module Naturalsorter
2
- VERSION = "3.0.28"
2
+ VERSION = "3.0.29"
3
3
  end
data/lib/naturalsorter.rb CHANGED
@@ -51,10 +51,12 @@ module Naturalsorter
51
51
  end
52
52
 
53
53
 
54
- def self.sort_version_by_method(array, method, asc = true )
55
- return array if (array.nil? || array.empty? || array.length == 1 )
56
- return array.sort { |a,b| Versioncmp.compare(a.send(method), b.send(method)) } if asc
57
- return array.sort { |a,b| Versioncmp.compare(b.send(method), a.send(method)) }
54
+ def self.sort_version_by_method( array, method, asc = true )
55
+ return array if (array.nil? || array.empty? || array.length < 1 || method.to_s.strip.empty? )
56
+ return array if (array[0].nil? || array[1].nil?)
57
+ return array if (array[0].send(method).nil? || array[1].send(method).nil?)
58
+ return array&.sort { |a,b| Versioncmp.compare(a.send(method), b.send(method)) } if asc
59
+ return array&.sort { |a,b| Versioncmp.compare(b.send(method), a.send(method)) }
58
60
  end
59
61
 
60
62
 
@@ -118,7 +120,7 @@ module Naturalsorter
118
120
  (0..min_length).each do |z|
119
121
  ver = versions[z]
120
122
  cur = newests[z]
121
- if (cur > ver)
123
+ if cur > ver
122
124
  return false
123
125
  end
124
126
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: naturalsorter
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.28
4
+ version: 3.0.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - reiz
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-10-11 00:00:00.000000000 Z
12
+ date: 2025-05-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
103
  requirements: []
104
- rubygems_version: 3.0.8
104
+ rubygems_version: 3.3.6
105
105
  signing_key:
106
106
  specification_version: 4
107
107
  summary: Sorting arrays in natural order