natural_sort 0.1.0 → 0.2.0

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
  SHA1:
3
- metadata.gz: 4eaf8c2b84481c81c04561961d96b2ae8691c06a
4
- data.tar.gz: cf25e73d6eeb71dc9e1072c724ea814dd524e277
3
+ metadata.gz: 2dfd714b89645e2d4fc0026d19e90f0281422d61
4
+ data.tar.gz: 3164c7c67926ff12f6cc1231cb38195000f14da1
5
5
  SHA512:
6
- metadata.gz: 8b0d846ad70d7bcafe66a32eda7f8b4be406288967ce34493eadc0591271ba8af1e9200caa9b3be0d7ebdf614693716b74baec7c9f7b3fefc989fcb307e64ccc
7
- data.tar.gz: 7a48ce33aca18bbd35e3cc86d99156cc6af615200719f975ced0557fc8da5fe99283d66035318f3c4e23eff7281c61d0f7cae05084de1b4d11656d4006f6ce6e
6
+ metadata.gz: ecfff960d299ddae782abd505017044ee7d3bcbcf3ca34bc4538b2412ef5632b84d72dfc99f98e9adaa906798cfb78254521e4813e7c6ab04e56eb916852eea4
7
+ data.tar.gz: e996ca5915e77c65a77e063bc7459663a0d9e69e8f52eb105d2413f8de350896deded52e8b73c43d41352984c9a568f65cb9e7f7be4452b054840a18094c1be9
data/README.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Natural Sort
2
2
 
3
+ [![Build Status](https://api.travis-ci.org/rwz/natural_sort.svg?branch=master)][travis]
4
+ [![Gem Version](http://img.shields.io/gem/v/natural_sort.svg)][gem]
5
+ [![Code Climate](http://img.shields.io/codeclimate/github/rwz/natural_sort.svg)][codeclimate]
6
+
7
+ [travis]: https://travis-ci.org/rwz/natural_sort
8
+ [gem]: https://rubygems.org/gems/natural_sort
9
+ [codeclimate]: https://codeclimate.com/github/rwz/natural_sort
10
+
3
11
  Natual sorting implementation in Ruby.
4
12
 
5
13
  ## Installation
@@ -21,10 +29,19 @@ Or install it yourself as:
21
29
  ## Usage
22
30
 
23
31
  ```ruby
24
- require "natual_sort"
32
+ list = ["a10", "a", "a20", "a1b", "a1a", "a2", "a0", "a1"]
33
+ list.sort(&NaturalSort) # => ["a", "a0", "a1", "a1a", "a1b", "a2", "a10", "a20"]
34
+ ```
35
+
36
+ ```ruby
37
+ list = ["a10", "a", "a20", "a1b", "a1a", "a2", "a0", "a1"]
38
+ NaturalSort.sort(list) # => ["a", "a0", "a1", "a1a", "a1b", "a2", "a10", "a20"]
39
+ ```
25
40
 
41
+ ```ruby
26
42
  list = ["a10", "a", "a20", "a1b", "a1a", "a2", "a0", "a1"]
27
- list.sort(&NatualSort) # => ["a", "a0", "a1", "a1a", "a1b", "a2", "a10", "a20"]
43
+ NaturalSort.sort! list # => ["a", "a0", "a1", "a1a", "a1b", "a2", "a10", "a20"]
44
+ list # => ["a", "a0", "a1", "a1a", "a1b", "a2", "a10", "a20"]
28
45
  ```
29
46
 
30
47
  ```ruby
@@ -59,7 +76,7 @@ class MyClass
59
76
  using NatualSort
60
77
 
61
78
  list.natural_sort # => ["a", "a0", "a1", "a1a"...
62
- ubuntu_releases.natual_sort_by(&:number) # => [ UbuntuRelease.new("8.10"...
79
+ ubuntu_releases.natural_sort_by(&:number) # => [ UbuntuRelease.new("8.10"...
63
80
  end
64
81
  ```
65
82
 
@@ -73,4 +90,3 @@ https://github.com/rwz/natural_sort.
73
90
 
74
91
  The gem is available as open source under the terms of the [MIT
75
92
  License](http://opensource.org/licenses/MIT).
76
-
data/lib/natural_sort.rb CHANGED
@@ -14,6 +14,10 @@ module NaturalSort
14
14
  input.sort(&self)
15
15
  end
16
16
 
17
+ def sort!(input)
18
+ input.sort!(&self)
19
+ end
20
+
17
21
  def compare(a, b)
18
22
  SegmentedString.new(a) <=> SegmentedString.new(b)
19
23
  end
@@ -1,3 +1,3 @@
1
1
  module NaturalSort
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.2.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: natural_sort
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Pravosud
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-03 00:00:00.000000000 Z
11
+ date: 2016-11-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -44,7 +44,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
44
44
  version: '0'
45
45
  requirements: []
46
46
  rubyforge_project:
47
- rubygems_version: 2.5.1
47
+ rubygems_version: 2.6.7
48
48
  signing_key:
49
49
  specification_version: 4
50
50
  summary: Natural sorting support for Ruby