sort_alphabetical 0.1.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/sort_alphabetical.rb +8 -23
- metadata +36 -68
- data/.travis.yml +0 -4
- data/Gemfile +0 -9
- data/Gemfile.lock +0 -30
- data/Rakefile +0 -19
- data/Readme.md +0 -32
- data/VERSION +0 -1
- data/init.rb +0 -1
- data/sort_alphabetical.gemspec +0 -45
- data/spec/sort_alphabetical_spec.rb +0 -43
- data/spec/spec_helper.rb +0 -3
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4f328170a42d8ae534ff643e7b2864f2ceca1317
|
4
|
+
data.tar.gz: 59210f479fa4dc71f5d071e61d709d5629a84766
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c3140e1ce5d1e4c7e13e28e347ef752026597104cc46987dc4f80b31b90c8072891b15b6d65d150cface4326fa7885576d034a64b02fb162b60b1d20014761e9
|
7
|
+
data.tar.gz: 930e5e2c3778edc8c7ed7400db76360d6b0aab32bec852ec1e706ac1372bcc7990091080dd2bed7b222070f95e3f0d839e49485c6bb0f76c190b0047febf2823
|
data/lib/sort_alphabetical.rb
CHANGED
@@ -1,17 +1,7 @@
|
|
1
1
|
# TODO do something like with_utf8 do ...
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
end
|
6
|
-
|
7
|
-
require 'active_support/version'
|
8
|
-
if ActiveSupport::VERSION::MAJOR > 2
|
9
|
-
# pick what we need
|
10
|
-
require 'active_support/core_ext/string/multibyte'
|
11
|
-
else
|
12
|
-
# load everything, its a mess in there ...
|
13
|
-
require 'active_support'
|
14
|
-
end
|
3
|
+
require 'unicode_utils/compatibility_decomposition'
|
4
|
+
require 'unicode_utils/general_category'
|
15
5
|
require 'sort_alphabetical/core_ext'
|
16
6
|
|
17
7
|
module SortAlphabetical
|
@@ -24,18 +14,13 @@ module SortAlphabetical
|
|
24
14
|
else
|
25
15
|
item = item.to_s
|
26
16
|
end
|
27
|
-
[
|
17
|
+
[normalize(item), item] # when both á and a are present, sort them a, á
|
28
18
|
end
|
29
19
|
end
|
30
20
|
|
31
|
-
def
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
# returns an array of unicode codepoints, in canonical order
|
38
|
-
def split_codepoints(string)
|
39
|
-
string.mb_chars.normalize(:d).split(//u)
|
21
|
+
def normalize(string)
|
22
|
+
UnicodeUtils.compatibility_decomposition(string).split('').select do |c|
|
23
|
+
UnicodeUtils.general_category(c) =~ /Letter|Separator|Punctuation|Number/
|
24
|
+
end.join
|
40
25
|
end
|
41
|
-
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,91 +1,59 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: sort_alphabetical
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 3
|
10
|
-
version: 0.1.3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Michael Grosser
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
11
|
+
date: 2013-09-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: unicode_utils
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.0
|
22
20
|
type: :runtime
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
-
none: false
|
25
|
-
requirements:
|
26
|
-
- - ">="
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 3
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
32
|
-
name: activesupport
|
33
|
-
version_requirements: *id001
|
34
21
|
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.0
|
35
27
|
description:
|
36
28
|
email: michael@grosser.it
|
37
29
|
executables: []
|
38
|
-
|
39
30
|
extensions: []
|
40
|
-
|
41
31
|
extra_rdoc_files: []
|
42
|
-
|
43
|
-
files:
|
44
|
-
- .travis.yml
|
45
|
-
- Gemfile
|
46
|
-
- Gemfile.lock
|
47
|
-
- Rakefile
|
48
|
-
- Readme.md
|
49
|
-
- VERSION
|
50
|
-
- init.rb
|
32
|
+
files:
|
51
33
|
- lib/sort_alphabetical.rb
|
52
34
|
- lib/sort_alphabetical/core_ext.rb
|
53
|
-
|
54
|
-
|
55
|
-
-
|
56
|
-
|
57
|
-
homepage: http://github.com/grosser/sort_alphabetical
|
58
|
-
licenses: []
|
59
|
-
|
35
|
+
homepage: https://github.com/grosser/sort_alphabetical
|
36
|
+
licenses:
|
37
|
+
- MIT
|
38
|
+
metadata: {}
|
60
39
|
post_install_message:
|
61
40
|
rdoc_options: []
|
62
|
-
|
63
|
-
require_paths:
|
41
|
+
require_paths:
|
64
42
|
- lib
|
65
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
none: false
|
76
|
-
requirements:
|
77
|
-
- - ">="
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
hash: 3
|
80
|
-
segments:
|
81
|
-
- 0
|
82
|
-
version: "0"
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
83
53
|
requirements: []
|
84
|
-
|
85
54
|
rubyforge_project:
|
86
|
-
rubygems_version:
|
55
|
+
rubygems_version: 2.0.6
|
87
56
|
signing_key:
|
88
|
-
specification_version:
|
57
|
+
specification_version: 4
|
89
58
|
summary: Sort UTF8 Strings alphabetical via Enumerable extension
|
90
59
|
test_files: []
|
91
|
-
|
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
activesupport (3.1.0)
|
5
|
-
multi_json (~> 1.0)
|
6
|
-
diff-lcs (1.1.3)
|
7
|
-
git (1.2.5)
|
8
|
-
jeweler (1.6.4)
|
9
|
-
bundler (~> 1.0)
|
10
|
-
git (>= 1.2.5)
|
11
|
-
rake
|
12
|
-
multi_json (1.0.3)
|
13
|
-
rake (0.9.2)
|
14
|
-
rspec (2.6.0)
|
15
|
-
rspec-core (~> 2.6.0)
|
16
|
-
rspec-expectations (~> 2.6.0)
|
17
|
-
rspec-mocks (~> 2.6.0)
|
18
|
-
rspec-core (2.6.4)
|
19
|
-
rspec-expectations (2.6.0)
|
20
|
-
diff-lcs (~> 1.1.2)
|
21
|
-
rspec-mocks (2.6.0)
|
22
|
-
|
23
|
-
PLATFORMS
|
24
|
-
ruby
|
25
|
-
|
26
|
-
DEPENDENCIES
|
27
|
-
activesupport
|
28
|
-
jeweler
|
29
|
-
rake
|
30
|
-
rspec (~> 2)
|
data/Rakefile
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
task :default do
|
2
|
-
sh "RAILS='~>2' && (bundle || bundle install) && bundle exec rspec spec"
|
3
|
-
sh "RAILS='~>3' && (bundle || bundle install) && bundle exec rspec spec"
|
4
|
-
end
|
5
|
-
|
6
|
-
begin
|
7
|
-
require 'jeweler'
|
8
|
-
Jeweler::Tasks.new do |gem|
|
9
|
-
gem.name = 'sort_alphabetical'
|
10
|
-
gem.summary = "Sort UTF8 Strings alphabetical via Enumerable extension"
|
11
|
-
gem.email = "michael@grosser.it"
|
12
|
-
gem.homepage = "http://github.com/grosser/#{gem.name}"
|
13
|
-
gem.authors = ["Michael Grosser"]
|
14
|
-
end
|
15
|
-
|
16
|
-
Jeweler::GemcutterTasks.new
|
17
|
-
rescue LoadError
|
18
|
-
puts "Jeweler, or one of its dependencies, is not available. Install it with: gem install jeweler"
|
19
|
-
end
|
data/Readme.md
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
Adds `sort_alphabetical` and `sort_alphabetical_by` to Enumberable(Array/Hash...),
|
2
|
-
which sorts UTF8 Strings alphabetical.
|
3
|
-
This sorting is done by placing variants on the same level as base character (A comes before Ä but ÄA comes before AB).
|
4
|
-
|
5
|
-
Setup
|
6
|
-
=====
|
7
|
-
- As Rails plugin: `rails plugin install git://github.com/grosser/sort_alphabetical.git `
|
8
|
-
- As gem: ` sudo gem install sort_alphabetical `
|
9
|
-
|
10
|
-
Usage
|
11
|
-
=====
|
12
|
-
['b','á'].sort_alphabetical == ['á','b']
|
13
|
-
[['b',1],['á',2]].sort_alphabetical_by(&:first) == [['á',2],['b',1]]
|
14
|
-
|
15
|
-
SortAlphabetical.to_ascii('á') == 'a'
|
16
|
-
|
17
|
-
TODO
|
18
|
-
====
|
19
|
-
- fix specs for 1.9
|
20
|
-
- Sort non-ascii-convertables like ß(ss), œ(oe) , fi(fi), see [Ligatures](http://en.wikipedia.org/wiki/Typographical_ligature)
|
21
|
-
- Integrate natural sorting e.g. `['a11', 'a2'] => ['a2', 'a11']` like [NaturalSort](http://rubyforge.org/projects/naturalsort)
|
22
|
-
|
23
|
-
Authors
|
24
|
-
=======
|
25
|
-
- original string_to_ascii: [Marc-Andre](http://marc-andre.ca/).
|
26
|
-
- [Maxime Menant](https://github.com/maxime-menant)
|
27
|
-
|
28
|
-
[Michael Grosser](http://grosser.it)<br/>
|
29
|
-
michael@grosser.it<br/>
|
30
|
-
Hereby placed under public domain, do what you want, just do not hold me accountable...<br/>
|
31
|
-
[![Build Status](https://secure.travis-ci.org/grosser/sort_alphabetical.png)](http://travis-ci.org/grosser/sort_alphabetical)
|
32
|
-
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.3
|
data/init.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'sort_alphabetical'
|
data/sort_alphabetical.gemspec
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{sort_alphabetical}
|
8
|
-
s.version = "0.1.3"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Michael Grosser"]
|
12
|
-
s.date = %q{2011-10-24}
|
13
|
-
s.email = %q{michael@grosser.it}
|
14
|
-
s.files = [
|
15
|
-
".travis.yml",
|
16
|
-
"Gemfile",
|
17
|
-
"Gemfile.lock",
|
18
|
-
"Rakefile",
|
19
|
-
"Readme.md",
|
20
|
-
"VERSION",
|
21
|
-
"init.rb",
|
22
|
-
"lib/sort_alphabetical.rb",
|
23
|
-
"lib/sort_alphabetical/core_ext.rb",
|
24
|
-
"sort_alphabetical.gemspec",
|
25
|
-
"spec/sort_alphabetical_spec.rb",
|
26
|
-
"spec/spec_helper.rb"
|
27
|
-
]
|
28
|
-
s.homepage = %q{http://github.com/grosser/sort_alphabetical}
|
29
|
-
s.require_paths = ["lib"]
|
30
|
-
s.rubygems_version = %q{1.6.2}
|
31
|
-
s.summary = %q{Sort UTF8 Strings alphabetical via Enumerable extension}
|
32
|
-
|
33
|
-
if s.respond_to? :specification_version then
|
34
|
-
s.specification_version = 3
|
35
|
-
|
36
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
37
|
-
s.add_runtime_dependency(%q<activesupport>, [">= 0"])
|
38
|
-
else
|
39
|
-
s.add_dependency(%q<activesupport>, [">= 0"])
|
40
|
-
end
|
41
|
-
else
|
42
|
-
s.add_dependency(%q<activesupport>, [">= 0"])
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe "SortAlphabetical"do
|
5
|
-
it "sorts ascii correctly" do
|
6
|
-
%w(b c a).sort_alphabetical.should == %w(a b c)
|
7
|
-
end
|
8
|
-
|
9
|
-
it "sorts UTF8 chars without accents" do
|
10
|
-
%w(b a á ä o ó x ö í i c).sort_alphabetical.should == %w(a á ä b c i í o ó ö x)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "sorts by merging base with accented" do
|
14
|
-
%w(AA AB ÄA).sort_alphabetical.should == %w(AA ÄA AB)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "sorts words" do
|
18
|
-
%w(hellö hello hellá).sort_alphabetical.should == %w(hellá hello hellö)
|
19
|
-
end
|
20
|
-
|
21
|
-
it "obeys order for ligatures" do
|
22
|
-
pending
|
23
|
-
%w(asb aßc asd).sort_alphabetical.should == %w(asb aßc asd)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "sorts ˇ" do
|
27
|
-
["ˇ"].sort_alphabetical.should == ["ˇ"]
|
28
|
-
end
|
29
|
-
|
30
|
-
describe :to_ascii do
|
31
|
-
it "removes any accents" do
|
32
|
-
SortAlphabetical.to_ascii('á').should == 'a'
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe :sort_alphabetical_by do
|
37
|
-
it "sorts using given block" do
|
38
|
-
silence_warnings do
|
39
|
-
%w(za yá xä xa).sort_alphabetical_by{|x|x.chars.to_a.reverse.join}.should == %w(xa xä yá za)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
data/spec/spec_helper.rb
DELETED