naturally 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +28 -34
- data/Rakefile +0 -1
- data/lib/naturally/version.rb +1 -1
- data/spec/naturally_spec.rb +3 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a36e33ade747d0c59b3788ba0bb22c1f6defb184
|
4
|
+
data.tar.gz: a81707fb161b155dc47bed22462cf8a9ed734fe5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7536fef931a0c593bc9918bff1e6407922a18cc339f8e0d96edf8e97db941232809238749fe6fd65f9fb9264cd8fa89d16d01cef8e64afe30301def32f6726f3
|
7
|
+
data.tar.gz: 00f5d433456e0516da7229ab2c64b9c5bbb448aa556e58252115a564d431078dfe19ca8fa1d28b5fd6cfaeee89e3e600db59f3c27d67f9f94e58fb5995a45888
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
# Naturally
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/naturally.png)](http://badge.fury.io/rb/naturally) [![Build Status](https://travis-ci.org/dogweather/naturally.png)](https://travis-ci.org/dogweather/naturally) [![Code Climate](https://codeclimate.com/github/dogweather/naturally.png)](https://codeclimate.com/github/dogweather/naturally)
|
3
3
|
|
4
|
-
Natural (version number) sorting with added support for legal document numbering
|
5
|
-
See Jeff Atwood's [Sorting for Humans: Natural Sort Order](http://www.codinghorror.com/blog/2007/12/sorting-for-humans-natural-sort-order.html) and the Weblaws.org post [Counting to 10 in Californian](http://www.weblaws.org/blog/2012/08/counting-from-1-to-10-in-californian/)
|
6
|
-
for the motivations to make this library.
|
4
|
+
Natural (version number) sorting with added support for **legal document numbering** and **Unicode**.
|
5
|
+
See Jeff Atwood's [Sorting for Humans: Natural Sort Order](http://www.codinghorror.com/blog/2007/12/sorting-for-humans-natural-sort-order.html) and the Weblaws.org post [Counting to 10 in Californian](http://www.weblaws.org/blog/2012/08/counting-from-1-to-10-in-californian/).
|
7
6
|
|
8
|
-
The core of the search is [from here](https://github.com/ahoward/version_sorter).
|
9
|
-
several changes to handle the particular types of numbers that come up in statutes, such
|
7
|
+
The core of the search is [from here](https://github.com/ahoward/version_sorter). It's since been extended to handle the particular types of numbers that come up in statutes, such
|
10
8
|
as *335.1, 336, 336a*, etc.
|
11
9
|
|
12
10
|
`Naturally` will also sort "numbers" in college course code format such as
|
@@ -41,35 +39,31 @@ Usually the library is used to sort an array of objects:
|
|
41
39
|
|
42
40
|
|
43
41
|
```Ruby
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
'Saucy Salamander'
|
70
|
-
]
|
71
|
-
end
|
72
|
-
end
|
42
|
+
# Define a new simple object for storing Ubuntu versions
|
43
|
+
UbuntuVersion = Struct.new(:name, :version)
|
44
|
+
|
45
|
+
# Create an array
|
46
|
+
releases = [
|
47
|
+
UbuntuVersion.new('Saucy Salamander', '13.10'),
|
48
|
+
UbuntuVersion.new('Raring Ringtail', '13.04'),
|
49
|
+
UbuntuVersion.new('Precise Pangolin', '12.04.4'),
|
50
|
+
UbuntuVersion.new('Maverick Meerkat', '10.10'),
|
51
|
+
UbuntuVersion.new('Quantal Quetzal', '12.10'),
|
52
|
+
UbuntuVersion.new('Lucid Lynx', '10.04.4')
|
53
|
+
]
|
54
|
+
|
55
|
+
# Sort by version number
|
56
|
+
sorted = Naturally.sort_by(releases, :version)
|
57
|
+
|
58
|
+
# Check what we have
|
59
|
+
expect(sorted.map(&:name)).to eq [
|
60
|
+
'Lucid Lynx',
|
61
|
+
'Maverick Meerkat',
|
62
|
+
'Precise Pangolin',
|
63
|
+
'Quantal Quetzal',
|
64
|
+
'Raring Ringtail',
|
65
|
+
'Saucy Salamander'
|
66
|
+
]
|
73
67
|
```
|
74
68
|
|
75
69
|
See [the spec for more examples](https://github.com/dogweather/naturally/blob/master/spec/naturally_spec.rb) of what Naturally can sort.
|
data/Rakefile
CHANGED
data/lib/naturally/version.rb
CHANGED
data/spec/naturally_spec.rb
CHANGED
@@ -9,7 +9,7 @@ describe Naturally do
|
|
9
9
|
b = %w[676 676.1 676.2 676.3 676.9 676.10 676.11 676.12]
|
10
10
|
Naturally.sort(a).should == b
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
it 'sorts a more complex list of strings' do
|
14
14
|
a = %w[350 351 352 352.1 352.5 353.1 354 354.3 354.4 354.45 354.5]
|
15
15
|
b = %w[350 351 352 352.1 352.5 353.1 354 354.3 354.4 354.5 354.45]
|
@@ -52,7 +52,7 @@ describe Naturally do
|
|
52
52
|
Naturally.sort(a).should == b
|
53
53
|
end
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
describe '#sort_naturally_by' do
|
57
57
|
it 'sorts by an attribute' do
|
58
58
|
UbuntuVersion = Struct.new(:name, :version)
|
@@ -75,7 +75,7 @@ describe Naturally do
|
|
75
75
|
]
|
76
76
|
end
|
77
77
|
|
78
|
-
it 'sorts by an attribute which contains unicode
|
78
|
+
it 'sorts by an attribute which contains unicode' do
|
79
79
|
Thing = Struct.new(:number, :name)
|
80
80
|
objects = [
|
81
81
|
Thing.new('1.1', 'Москва'),
|
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.3.
|
4
|
+
version: 1.3.1
|
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-
|
11
|
+
date: 2014-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Natural Sorting with support for legal numbering
|
14
14
|
email:
|
@@ -52,3 +52,4 @@ specification_version: 4
|
|
52
52
|
summary: Sorts numbers according to the way people are used to seeing them.
|
53
53
|
test_files:
|
54
54
|
- spec/naturally_spec.rb
|
55
|
+
has_rdoc:
|