naturally 2.2.0 → 2.2.2
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
- data/.travis.yml +2 -0
- data/Gemfile +1 -1
- data/README.md +14 -7
- data/lib/naturally/version.rb +1 -1
- data/naturally.gemspec +1 -1
- metadata +4 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6b9503d643f2bc2e137219f9572cff2e930a5565c55155d4204e2a77023f1b1
|
4
|
+
data.tar.gz: 8ba1b7379a6a5b13dc4487d8c2946e46484cc46853acf792ae0502e2debba830
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7a58a43c54c821703e9eedc9455a37433d7c80cca3ccb1eeaafed11f43e5095a48e11cebb0d421d1bf36116f73a336b3ad78b5ce904895becb739e36d8655a4
|
7
|
+
data.tar.gz: a78a9c67ed7267bdb77eb2f7cb5fd5de79b22fe8297aaf634b2f30370ad00c401f22ea7ee4cc5949f3439995ea57aed86f69badfe7400731c78da27110005349
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
# Naturally
|
2
|
-
[](https://codeclimate.com/github/dogweather/naturally/maintainability)
|
2
|
+
[](https://badge.fury.io/rb/naturally)
|
4
3
|
|
5
|
-
Natural (version number) sorting with support for
|
6
|
-
|
4
|
+
Natural ("version number") sorting with support for:
|
5
|
+
|
6
|
+
* **legal document numbering**,
|
7
|
+
* **college course codes**, and
|
8
|
+
* **Unicode**.
|
9
|
+
|
10
|
+
See Jeff Atwood's [Sorting for Humans: Natural Sort Order](https://blog.codinghorror.com/sorting-for-humans-natural-sort-order/) and my post [Counting to 10 in Californian](https://blog.public.law/2012/08/07/counting-from-1-to-10-in-californian/).
|
7
11
|
|
8
12
|
## Installation
|
9
13
|
|
@@ -16,8 +20,11 @@ $ gem install naturally
|
|
16
20
|
```Ruby
|
17
21
|
require 'naturally'
|
18
22
|
|
19
|
-
# Sort a simple array of strings
|
23
|
+
# Sort a simple array of strings with legal numbering
|
20
24
|
Naturally.sort(["336", "335a", "335", "335.1"]) # => ["335", "335.1", "335a", "336"]
|
25
|
+
|
26
|
+
# Sort version numbers
|
27
|
+
Naturally.sort(["13.10", "13.04", "10.10", "10.04.4"]) # => ["10.04.4", "10.10", "13.04", "13.10"]
|
21
28
|
```
|
22
29
|
|
23
30
|
Usually the library is used to sort an array of objects:
|
@@ -38,7 +45,7 @@ releases = [
|
|
38
45
|
]
|
39
46
|
|
40
47
|
# Sort by version number
|
41
|
-
sorted = Naturally.sort
|
48
|
+
sorted = Naturally.sort(releases, by: :version)
|
42
49
|
|
43
50
|
# Check what we have
|
44
51
|
expect(sorted.map(&:name)).to eq [
|
@@ -51,7 +58,7 @@ expect(sorted.map(&:name)).to eq [
|
|
51
58
|
]
|
52
59
|
```
|
53
60
|
|
54
|
-
[More examples are in the specs](https://github.com/
|
61
|
+
[More examples are in the specs](https://github.com/public-law/naturally/blob/master/spec/naturally_spec.rb).
|
55
62
|
|
56
63
|
|
57
64
|
## Implementation Notes
|
data/lib/naturally/version.rb
CHANGED
data/naturally.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.email = ["robb@public.law"]
|
11
11
|
gem.summary = %q{Sorts numbers according to the way people are used to seeing them.}
|
12
12
|
gem.description = %q{Natural Sorting with support for legal numbering, course numbers, and other number/letter mixes.}
|
13
|
-
gem.homepage = "http://github.com/
|
13
|
+
gem.homepage = "http://github.com/public-law/naturally"
|
14
14
|
gem.required_ruby_version = '>= 2.0'
|
15
15
|
|
16
16
|
gem.files = `git ls-files`.split($/)
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: naturally
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robb Shecter
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies: []
|
13
12
|
description: Natural Sorting with support for legal numbering, course numbers, and
|
14
13
|
other number/letter mixes.
|
@@ -29,11 +28,10 @@ files:
|
|
29
28
|
- lib/naturally/version.rb
|
30
29
|
- naturally.gemspec
|
31
30
|
- spec/naturally_spec.rb
|
32
|
-
homepage: http://github.com/
|
31
|
+
homepage: http://github.com/public-law/naturally
|
33
32
|
licenses:
|
34
33
|
- MIT
|
35
34
|
metadata: {}
|
36
|
-
post_install_message:
|
37
35
|
rdoc_options: []
|
38
36
|
require_paths:
|
39
37
|
- lib
|
@@ -48,9 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
48
46
|
- !ruby/object:Gem::Version
|
49
47
|
version: '0'
|
50
48
|
requirements: []
|
51
|
-
|
52
|
-
rubygems_version: 2.7.4
|
53
|
-
signing_key:
|
49
|
+
rubygems_version: 3.6.9
|
54
50
|
specification_version: 4
|
55
51
|
summary: Sorts numbers according to the way people are used to seeing them.
|
56
52
|
test_files:
|