data_table 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -30,11 +30,11 @@ module DataTable
30
30
  end
31
31
 
32
32
  def _order_by_fields params, fields
33
- [fields[params[:iSortCol_0].to_i], params[:sSortDir_0]]
33
+ [fields[params[:iSortCol_0].to_i], params[:sSortDir_0] || "asc"]
34
34
  end
35
35
 
36
36
  def _sanitize string
37
- string.strip.gsub(/([\^\\\/\.\+\*\?\|\[\]\(\)\{\}\$])/) { "\\#{$1}" }
37
+ string.to_s.strip.gsub(/([\^\\\/\.\+\*\?\|\[\]\(\)\{\}\$])/) { "\\#{$1}" }
38
38
  end
39
39
  end
40
40
  end
@@ -1,3 +1,3 @@
1
1
  module DataTable
2
- VERSION = "0.3.6"
2
+ VERSION = "0.3.7"
3
3
  end
@@ -48,15 +48,21 @@ describe DataTable do
48
48
  context "#_order_by_fields" do
49
49
 
50
50
  it "should find the field name and pass the sort direction" do
51
- send(:_order_by_fields,
52
- {:iSortCol_0 => "1", :sSortDir_0 => "asc"},
53
- %w(foo bar baz)).should == ["bar", "asc"]
51
+ send(:_order_by_fields, {:iSortCol_0 => "1", :sSortDir_0 => "asc"}, %w(foo bar baz)).should == ["bar", "asc"]
52
+ end
53
+
54
+ it "should use defaults if none are given" do
55
+ send(:_order_by_fields, {}, %w(foo bar baz)).should == ["foo", "asc"]
54
56
  end
55
57
 
56
58
  end
57
59
 
58
60
  context "#_sanitize" do
59
61
 
62
+ it "should work for nil" do
63
+ send(:_sanitize, nil).should == ""
64
+ end
65
+
60
66
  it "should escape characters for the regex" do
61
67
  send(:_sanitize, " ^\\/.+*?|[](){}$ ").should == "\\^\\\\\\/\\.\\+\\*\\?\\|\\[\\]\\(\\)\\{\\}\\$"
62
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_table
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-09 00:00:00.000000000 -04:00
12
+ date: 2011-09-12 00:00:00.000000000 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
17
- requirement: &2153171720 !ruby/object:Gem::Requirement
17
+ requirement: &2153508480 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 3.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2153171720
25
+ version_requirements: *2153508480
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rspec
28
- requirement: &2153171220 !ruby/object:Gem::Requirement
28
+ requirement: &2153507980 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 2.0.0
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *2153171220
36
+ version_requirements: *2153507980
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: shoulda
39
- requirement: &2153170760 !ruby/object:Gem::Requirement
39
+ requirement: &2153507520 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 2.11.0
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *2153170760
47
+ version_requirements: *2153507520
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rr
50
- requirement: &2153170300 !ruby/object:Gem::Requirement
50
+ requirement: &2153507060 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,7 +55,7 @@ dependencies:
55
55
  version: 1.0.0
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *2153170300
58
+ version_requirements: *2153507060
59
59
  description: Simple data preparation from AR/Mongoid to the jQuery DataTables plugin
60
60
  email:
61
61
  - jason.dew@gmail.com