naturally 1.0.5 → 1.1.0

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: faf607f415ddcf15c148739259c52e174b0b3b46
4
- data.tar.gz: 1dc1552d7a19456bc2a94a7a5eea5fe27e034516
3
+ metadata.gz: e088049af46b6400067b7fee29e5fcf173f867c5
4
+ data.tar.gz: 0f2c8c9786b402bf168826b416229c725805744b
5
5
  SHA512:
6
- metadata.gz: e8b3ff9491b77930b6f2aee7a839e1c7855d5df50808667704ba35a645cf35c98408a2949f51435e6782538b1ead608ec8b1cd320b93612ae0dfa7661195f615
7
- data.tar.gz: 3b192cfda48fd177e3c3dc9575ec48d4ee856935d22723d7b0c740ba918b94d925886d04366c07860cb194a7bdd0091bd345e1bc987981ff49c50c978ffc6636
6
+ metadata.gz: d0e08aedc2dcaadc4af03ed0ebe01b2ae60bfa1d0f87d950aec091d0a4c52fe02c69ec0b0d398b34f147b5b85b2f587d55429a710e4cdbab500a0dbe2fd7a788
7
+ data.tar.gz: ff7350582be9a879f06069d96fca4a9e0429fd610fa212eea2390d4d8815c527eb9132d87590b4aa2bb2844f256433624b116dd6fcbbbedeb55954405ec35bf4
data/.travis.yml CHANGED
@@ -1,6 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - "1.8.7"
4
- - "1.9.2"
5
3
  - "1.9.3"
6
4
  - "2.0.0"
data/Gemfile.lock CHANGED
@@ -1,12 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- naturally (1.0.4)
4
+ naturally (1.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- diff-lcs (1.2.4)
9
+ diff-lcs (1.2.5)
10
10
  rake (10.1.1)
11
11
  rspec (2.14.1)
12
12
  rspec-core (~> 2.14.0)
@@ -1,3 +1,3 @@
1
1
  module Naturally
2
- VERSION = "1.0.5"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/naturally.rb CHANGED
@@ -1,26 +1,29 @@
1
- require "naturally/version"
1
+ require 'naturally/version'
2
2
 
3
3
  module Naturally
4
-
5
4
  # Perform a natural sort.
5
+ #
6
6
  # @param [Array<String>] an_array the list of numbers to sort.
7
7
  # @return [Array<String>] the numbers sorted naturally.
8
8
  def self.sort(an_array)
9
- return an_array.sort_by{ |x| normalize(x) }
9
+ return an_array.sort_by { |x| normalize(x) }
10
10
  end
11
11
 
12
12
  # Convert the given number into an object that can be sorted
13
- # naturally.
13
+ # naturally. This object is an array of {NumberElement} instances.
14
+ #
14
15
  # @param [String] number the number in complex form such as 1.2a.3.
15
16
  # @return [Array<NumberElement>] an array of NumberElements which is
16
17
  # able to be sorted naturally via a normal 'sort'.
17
18
  def self.normalize(number)
18
- number.to_s.scan(%r/[0-9a-zA-Z]+/o).map{|i| NumberElement.new(i)}
19
+ number.to_s.scan(%r/[0-9a-zA-Z]+/o).map { |i| NumberElement.new(i) }
19
20
  end
20
21
 
21
-
22
22
  private
23
23
 
24
+ # An entity which can be compared to other like elements for
25
+ # sorting in an array. It's an object representing
26
+ # a value which implements the {Comparable} interface.
24
27
  class NumberElement
25
28
  include Comparable
26
29
  attr_accessor :val
@@ -69,5 +72,4 @@ module Naturally
69
72
  end
70
73
  end
71
74
  end
72
-
73
- end
75
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: naturally
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robb Shecter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-02 00:00:00.000000000 Z
11
+ date: 2014-01-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Natural Sorting with support for legal numbering
14
14
  email:
@@ -47,7 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
47
47
  version: '0'
48
48
  requirements: []
49
49
  rubyforge_project:
50
- rubygems_version: 2.1.11
50
+ rubygems_version: 2.2.1
51
51
  signing_key:
52
52
  specification_version: 4
53
53
  summary: Sorts numbers according to the way people are used to seeing them.