naturally 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/naturally.rb +1 -1
- data/lib/naturally/version.rb +1 -1
- data/spec/naturally_spec.rb +7 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c7fe0629f54a4f0418f2ef7bd0b698bac3ed282
|
4
|
+
data.tar.gz: 87063a64049efd21df9051ebf72b18cc4142e0b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b5485915f455c893d8fc1fd0afd1116c602447e863a54cf8704fe42fb21269f71834d80369ed701389483d063293592b2b342226a608cea0804eda3298b6090
|
7
|
+
data.tar.gz: ff836d19c5b40dc8a79ae0f6e638dd3272ae51026b2ee3fe1dd7ee8a07e1e1d9ef9a4880a3b724ed193a92aa36d9816f12963c56b2c3c5cff26c0cbcf311d9c5
|
data/lib/naturally.rb
CHANGED
@@ -37,7 +37,7 @@ module Naturally
|
|
37
37
|
# @return [Array<Segment>] an array of Segments which
|
38
38
|
# can be sorted naturally via a standard #sort.
|
39
39
|
def self.normalize(complex_number)
|
40
|
-
tokens = complex_number.to_s.scan(/\p{Word}+/)
|
40
|
+
tokens = complex_number.to_s.gsub(/\_/,'').scan(/\p{Word}+/)
|
41
41
|
tokens.map { |t| Segment.new(t) }
|
42
42
|
end
|
43
43
|
|
data/lib/naturally/version.rb
CHANGED
data/spec/naturally_spec.rb
CHANGED
@@ -66,6 +66,13 @@ describe Naturally do
|
|
66
66
|
)
|
67
67
|
end
|
68
68
|
|
69
|
+
it 'sorts strings suffixed with underscore and numbers correctly' do
|
70
|
+
it_sorts(
|
71
|
+
this: %w(item_10 item_11 item_1 item_7 item_5 item_3 item_4 item_6 item_2),
|
72
|
+
to_this: %w(item_1 item_2 item_3 item_4 item_5 item_6 item_7 item_10 item_11)
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
69
76
|
it 'sorts letters with digits correctly' do
|
70
77
|
it_sorts(
|
71
78
|
this: %w(1 a 2 b 3 c),
|