dictionary_order_sort 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -4
- data/Rakefile +2 -15
- data/lib/dictionary_order_sort/set.rb +5 -0
- data/lib/dictionary_order_sort/version.rb +1 -1
- data/lib/dictionary_order_sort.rb +1 -0
- data/test/dict_sort_test.rb +5 -1
- metadata +5 -4
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# Dictionary Order Sort
|
2
2
|
|
3
|
-
|
3
|
+
[![Build Status](https://secure.travis-ci.org/ndbroadbent/dictionary_order_sort.png)](http://travis-ci.org/ndbroadbent/dictionary_order_sort)
|
4
4
|
|
5
|
-
|
5
|
+
Sorts an array of strings in the same manner as the Linux `sort` command running with the `--dictionary-order` option. Only blanks and alphanumeric characters are considered.
|
6
6
|
|
7
|
-
|
7
|
+
I created this gem because I needed to use the `comm` command in a Capistrano recipe, and wanted to sort the list of files in Ruby. `comm` requires the input files to be sorted using the collating sequence specified by `LC_COLLATE', and this defaults to dictionary sort.
|
8
8
|
|
9
9
|
# Installation
|
10
10
|
|
@@ -24,4 +24,4 @@ Use it like this:
|
|
24
24
|
["a", "a-2", "_a-3", "abc_", "_def_"].dict_sort
|
25
25
|
|
26
26
|
#=> ["a", "a-2", "_a-3", "abc_", "_def_"]
|
27
|
-
```
|
27
|
+
```
|
data/Rakefile
CHANGED
@@ -5,24 +5,11 @@ ENV["TEST_CORES"] = "1"
|
|
5
5
|
require 'bundler'
|
6
6
|
Bundler::GemHelper.install_tasks
|
7
7
|
|
8
|
-
|
9
|
-
task :isolated do
|
10
|
-
Dir["test/assets*_test.rb"].each do |file|
|
11
|
-
dash_i = [
|
12
|
-
'test',
|
13
|
-
'lib',
|
14
|
-
]
|
15
|
-
ruby "-I#{dash_i.join ':'}", file
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
Rake::TestTask.new("test:regular") do |t|
|
8
|
+
Rake::TestTask.new("test") do |t|
|
21
9
|
t.libs << 'lib'
|
22
10
|
t.libs << 'test'
|
23
|
-
t.pattern = 'test
|
11
|
+
t.pattern = 'test/*_test.rb'
|
24
12
|
t.verbose = true
|
25
13
|
end
|
26
14
|
|
27
|
-
task :test => ['test:isolated', 'test:regular']
|
28
15
|
task :default => :test
|
data/test/dict_sort_test.rb
CHANGED
@@ -9,9 +9,13 @@ class TestArrayDictSort < MiniTest::Unit::TestCase
|
|
9
9
|
def test_dict_sort
|
10
10
|
arr = ['a', 'a-2', '_a-3', 'abc_', '_def_', 'b', 'ce', 'd_a', '-b_', '___b']
|
11
11
|
|
12
|
-
system_sort = `echo #{arr.join("\\\\n")} | sort`.split
|
12
|
+
system_sort = `echo #{arr.join("\\\\n")} | sort --dictionary-order`.split
|
13
13
|
ruby_sort = arr.dict_sort
|
14
14
|
|
15
15
|
assert_equal ruby_sort, system_sort
|
16
16
|
end
|
17
|
+
|
18
|
+
def test_set
|
19
|
+
assert Set.new.respond_to?(:dict_sort)
|
20
|
+
end
|
17
21
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dictionary_order_sort
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-09 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Sort an array in the same order as `sort --dictionary-sort`
|
15
15
|
email:
|
@@ -19,6 +19,7 @@ extensions: []
|
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
21
|
- lib/dictionary_order_sort.rb
|
22
|
+
- lib/dictionary_order_sort/set.rb
|
22
23
|
- lib/dictionary_order_sort/array.rb
|
23
24
|
- lib/dictionary_order_sort/version.rb
|
24
25
|
- MIT-LICENSE
|
@@ -39,7 +40,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
39
40
|
version: '0'
|
40
41
|
segments:
|
41
42
|
- 0
|
42
|
-
hash: -
|
43
|
+
hash: -2472803673037020292
|
43
44
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
45
|
none: false
|
45
46
|
requirements:
|
@@ -48,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
48
49
|
version: '0'
|
49
50
|
segments:
|
50
51
|
- 0
|
51
|
-
hash: -
|
52
|
+
hash: -2472803673037020292
|
52
53
|
requirements: []
|
53
54
|
rubyforge_project:
|
54
55
|
rubygems_version: 1.8.24
|