paginate_alphabetically 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/paginate_alphabetically.rb +2 -2
- data/test/test_paginate_alphabetically.rb +3 -3
- metadata +13 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
@@ -6,7 +6,7 @@ module PaginateAlphabetically
|
|
6
6
|
|
7
7
|
module ClassMethods
|
8
8
|
def pagination_letters
|
9
|
-
all.sort_by{|obj| obj.send(@attribute)}.group_by {|group| group.send(@attribute)[0].chr.upcase}.keys
|
9
|
+
all.sort_by{|obj| obj.send(@attribute).upcase}.group_by {|group| group.send(@attribute)[0].chr.upcase}.keys
|
10
10
|
end
|
11
11
|
|
12
12
|
def first_letter
|
@@ -16,7 +16,7 @@ module PaginateAlphabetically
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def alphabetical_group(letter = nil)
|
19
|
-
find(:all, :conditions => ["#{@attribute.to_s} LIKE ?", "#{letter || first_letter}%"], :order => @attribute)
|
19
|
+
find(:all, :conditions => ["#{@attribute.to_s.upcase} LIKE ?", "#{letter || first_letter}%"], :order => @attribute)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -9,7 +9,7 @@ end
|
|
9
9
|
|
10
10
|
class PaginateAlphabeticallyTest < ActiveSupport::TestCase
|
11
11
|
def setup
|
12
|
-
%w(
|
12
|
+
%w(one two Three four Five Six).map {|name| Thing.create!(:name => name)}
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_pagination_letters
|
@@ -26,11 +26,11 @@ class PaginateAlphabeticallyTest < ActiveSupport::TestCase
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_alphabetical_group_without_specifying_letter
|
29
|
-
assert_equal ['Five', '
|
29
|
+
assert_equal ['Five', 'four'], Thing.alphabetical_group.map(&:name)
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_alphabetical_group_specifying_letter
|
33
|
-
assert_equal ['Three', '
|
33
|
+
assert_equal ['Three', 'two'], Thing.alphabetical_group('t').map(&:name)
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_class_without_pagination_has_no_pagination_methods
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paginate_alphabetically
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Eden Development
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-09-05 00:00:00 +01:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: activerecord
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 9
|
27
30
|
segments:
|
28
31
|
- 2
|
29
32
|
- 3
|
@@ -35,9 +38,11 @@ dependencies:
|
|
35
38
|
name: sqlite3-ruby
|
36
39
|
prerelease: false
|
37
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
38
42
|
requirements:
|
39
43
|
- - "="
|
40
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 21
|
41
46
|
segments:
|
42
47
|
- 1
|
43
48
|
- 2
|
@@ -78,23 +83,27 @@ rdoc_options:
|
|
78
83
|
require_paths:
|
79
84
|
- lib
|
80
85
|
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
81
87
|
requirements:
|
82
88
|
- - ">="
|
83
89
|
- !ruby/object:Gem::Version
|
90
|
+
hash: 3
|
84
91
|
segments:
|
85
92
|
- 0
|
86
93
|
version: "0"
|
87
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
88
96
|
requirements:
|
89
97
|
- - ">="
|
90
98
|
- !ruby/object:Gem::Version
|
99
|
+
hash: 3
|
91
100
|
segments:
|
92
101
|
- 0
|
93
102
|
version: "0"
|
94
103
|
requirements: []
|
95
104
|
|
96
105
|
rubyforge_project:
|
97
|
-
rubygems_version: 1.3.
|
106
|
+
rubygems_version: 1.3.7
|
98
107
|
signing_key:
|
99
108
|
specification_version: 3
|
100
109
|
summary: An easy way to paginate a list of ActiveRecord objects alphabetically by any given attribute.
|