sort_it_out 0.9.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Histroy.txt +5 -0
- data/README.rdoc +15 -4
- data/VERSION +1 -1
- data/lib/sort_it_out.rb +1 -1
- data/lib/sort_it_out/sortable.rb +11 -3
- data/sort_it_out.gemspec +4 -4
- metadata +25 -9
data/Histroy.txt
CHANGED
data/README.rdoc
CHANGED
@@ -43,12 +43,23 @@ Simplest case:
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
In the previous example a before filter is run that will set up an @order variable containing a SQL fragment
|
46
|
+
In the previous example a before filter is run that will set up an @order variable containing a SQL fragment
|
47
47
|
for the order clause. The order clause will be set up from the parameters :order and :direction.
|
48
48
|
|
49
|
+
Include a default sort direction:
|
50
|
+
|
51
|
+
class UsersController< ApplicationController
|
52
|
+
sortable :default => { :attribute => :name, :direction => 'DESC' }
|
53
|
+
|
54
|
+
def index
|
55
|
+
User.find( :all, :order => @order ) # @order is set up by sort_it_out
|
56
|
+
...
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
49
60
|
More complex case:
|
50
61
|
|
51
|
-
|
62
|
+
|
52
63
|
class UsersController< ApplicationController
|
53
64
|
sortable :default => :name, :map => { :name => [:name_last, :name_first, :name_middle] }
|
54
65
|
|
@@ -58,8 +69,8 @@ More complex case:
|
|
58
69
|
end
|
59
70
|
end
|
60
71
|
|
61
|
-
In the previous example a default field to sort by is configured. Thus, if there is no :order param, the
|
62
|
-
default field is used. There is also a map set up. If the :order param is :name, then the order clause will
|
72
|
+
In the previous example a default field to sort by is configured. Thus, if there is no :order param, the
|
73
|
+
default field is used. There is also a map set up. If the :order param is :name, then the order clause will
|
63
74
|
be built using the name_last, name_first and name_middle fields.
|
64
75
|
|
65
76
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
1.0.0
|
data/lib/sort_it_out.rb
CHANGED
data/lib/sort_it_out/sortable.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module SortItOut
|
2
2
|
module Sortable
|
3
|
-
|
3
|
+
|
4
4
|
def self.included( base )
|
5
5
|
base.extend( ActMethods )
|
6
6
|
end
|
@@ -20,7 +20,15 @@ module SortItOut
|
|
20
20
|
module InstanceMethods
|
21
21
|
def resolve_sort
|
22
22
|
order = params[:order]
|
23
|
-
|
23
|
+
unless order
|
24
|
+
if self.options[:default].is_a?( String ) || self.options[:default].is_a?( Symbol )
|
25
|
+
order = params[:order] = self.options[:default]
|
26
|
+
elsif self.options[:default].is_a?( Hash )
|
27
|
+
order = params[:order] = self.options[:default][:attribute]
|
28
|
+
params[:direction] = self.options[:default][:direction]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
24
32
|
params[:direction] = 'ASC' unless params[:direction]
|
25
33
|
@order = order.nil? ? "" : resolve_order_clause( order, params[:direction] )
|
26
34
|
end
|
@@ -39,6 +47,6 @@ module SortItOut
|
|
39
47
|
end
|
40
48
|
end
|
41
49
|
end
|
42
|
-
|
50
|
+
|
43
51
|
end
|
44
52
|
end
|
data/sort_it_out.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{sort_it_out}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "1.0.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jason Harrelson"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2010-09-30}
|
13
13
|
s.description = %q{Easily apply sorting to your Rails controller actions.}
|
14
14
|
s.email = %q{jason@lookforwardenterprises.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
s.homepage = %q{http://github.com/midas/sort_it_out}
|
35
35
|
s.rdoc_options = ["--charset=UTF-8"]
|
36
36
|
s.require_paths = ["lib"]
|
37
|
-
s.rubygems_version = %q{1.3.
|
37
|
+
s.rubygems_version = %q{1.3.7}
|
38
38
|
s.summary = %q{Easily apply sorting to your Rails controller actions.}
|
39
39
|
s.test_files = [
|
40
40
|
"spec/sort_it_out_spec.rb",
|
@@ -45,7 +45,7 @@ Gem::Specification.new do |s|
|
|
45
45
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
46
46
|
s.specification_version = 3
|
47
47
|
|
48
|
-
if Gem::Version.new(Gem::
|
48
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
49
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
50
50
|
else
|
51
51
|
s.add_dependency(%q<rspec>, [">= 0"])
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sort_it_out
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 23
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Jason Harrelson
|
@@ -9,19 +15,23 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date:
|
18
|
+
date: 2010-09-30 00:00:00 -05:00
|
13
19
|
default_executable:
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
22
|
name: rspec
|
17
|
-
|
18
|
-
|
19
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
20
26
|
requirements:
|
21
27
|
- - ">="
|
22
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
23
32
|
version: "0"
|
24
|
-
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
25
35
|
description: Easily apply sorting to your Rails controller actions.
|
26
36
|
email: jason@lookforwardenterprises.com
|
27
37
|
executables: []
|
@@ -55,21 +65,27 @@ rdoc_options:
|
|
55
65
|
require_paths:
|
56
66
|
- lib
|
57
67
|
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
58
69
|
requirements:
|
59
70
|
- - ">="
|
60
71
|
- !ruby/object:Gem::Version
|
72
|
+
hash: 3
|
73
|
+
segments:
|
74
|
+
- 0
|
61
75
|
version: "0"
|
62
|
-
version:
|
63
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
64
78
|
requirements:
|
65
79
|
- - ">="
|
66
80
|
- !ruby/object:Gem::Version
|
81
|
+
hash: 3
|
82
|
+
segments:
|
83
|
+
- 0
|
67
84
|
version: "0"
|
68
|
-
version:
|
69
85
|
requirements: []
|
70
86
|
|
71
87
|
rubyforge_project:
|
72
|
-
rubygems_version: 1.3.
|
88
|
+
rubygems_version: 1.3.7
|
73
89
|
signing_key:
|
74
90
|
specification_version: 3
|
75
91
|
summary: Easily apply sorting to your Rails controller actions.
|