sort_it_out 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
data/Histroy.txt CHANGED
@@ -1,4 +1,14 @@
1
+ = 0.9.2 2009-11-15
2
+
3
+ * Added ability yo specify default sort as a string that is a SQL fragment.
4
+
5
+
1
6
  = 0.9.1 2009-11-15
2
7
 
8
+ * Fixed bug when there is no mapping specified for sortable.
9
+
10
+
11
+ = 0.9.0 2009-11-15
12
+
3
13
  * Ported from a lib in a project to this Gem.
4
14
  * No tests yet.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.1
1
+ 0.9.2
data/lib/sort_it_out.rb CHANGED
@@ -4,7 +4,7 @@ $:.unshift(File.dirname(__FILE__)) unless
4
4
  require 'sort_it_out/sortable.rb'
5
5
 
6
6
  module SortItOut
7
- VERSION = '0.9.1'
7
+ VERSION = '0.9.2'
8
8
  end
9
9
 
10
10
  ActionController::Base.send( :include, SortItOut::Sortable ) if defined?( ActionController::Base )
@@ -30,7 +30,13 @@ module SortItOut
30
30
  def resolve_order_clause( order, dir="ASC" )
31
31
  translated = self.options[:map][order.to_sym] unless self.options[:map].nil?
32
32
  order = translated unless translated.nil?
33
- return order.is_a?( Array ) ? order.map { |field| "#{field} #{dir}" }.join( ", " ) : "#{order} #{dir}"
33
+ if order.is_a?( Array )
34
+ return order.map { |field| "#{field} #{dir}" }.join( ", " )
35
+ elsif order.is_a?( String ) && (order.include?( "," ) || order.include?( "ASC") || order.include?( "DESC" ))
36
+ return order
37
+ else order.is_a?( Symbol )
38
+ return "#{order.to_s} #{dir}"
39
+ end
34
40
  end
35
41
  end
36
42
 
data/sort_it_out.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sort_it_out}
8
- s.version = "0.9.1"
8
+ s.version = "0.9.2"
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"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sort_it_out
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Harrelson