data_table 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.2-p290@data_table
data/Gemfile.lock CHANGED
@@ -1,73 +1,79 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- data_table (0.4.0)
4
+ data_table (0.4.1)
5
5
  rails (~> 3.0)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
- abstract (1.0.0)
11
- actionmailer (3.0.10)
12
- actionpack (= 3.0.10)
13
- mail (~> 2.2.19)
14
- actionpack (3.0.10)
15
- activemodel (= 3.0.10)
16
- activesupport (= 3.0.10)
17
- builder (~> 2.1.2)
18
- erubis (~> 2.6.6)
19
- i18n (~> 0.5.0)
20
- rack (~> 1.2.1)
21
- rack-mount (~> 0.6.14)
22
- rack-test (~> 0.5.7)
23
- tzinfo (~> 0.3.23)
24
- activemodel (3.0.10)
25
- activesupport (= 3.0.10)
26
- builder (~> 2.1.2)
27
- i18n (~> 0.5.0)
28
- activerecord (3.0.10)
29
- activemodel (= 3.0.10)
30
- activesupport (= 3.0.10)
31
- arel (~> 2.0.10)
32
- tzinfo (~> 0.3.23)
33
- activeresource (3.0.10)
34
- activemodel (= 3.0.10)
35
- activesupport (= 3.0.10)
36
- activesupport (3.0.10)
37
- arel (2.0.10)
38
- builder (2.1.2)
10
+ actionmailer (3.2.3)
11
+ actionpack (= 3.2.3)
12
+ mail (~> 2.4.4)
13
+ actionpack (3.2.3)
14
+ activemodel (= 3.2.3)
15
+ activesupport (= 3.2.3)
16
+ builder (~> 3.0.0)
17
+ erubis (~> 2.7.0)
18
+ journey (~> 1.0.1)
19
+ rack (~> 1.4.0)
20
+ rack-cache (~> 1.2)
21
+ rack-test (~> 0.6.1)
22
+ sprockets (~> 2.1.2)
23
+ activemodel (3.2.3)
24
+ activesupport (= 3.2.3)
25
+ builder (~> 3.0.0)
26
+ activerecord (3.2.3)
27
+ activemodel (= 3.2.3)
28
+ activesupport (= 3.2.3)
29
+ arel (~> 3.0.2)
30
+ tzinfo (~> 0.3.29)
31
+ activeresource (3.2.3)
32
+ activemodel (= 3.2.3)
33
+ activesupport (= 3.2.3)
34
+ activesupport (3.2.3)
35
+ i18n (~> 0.6)
36
+ multi_json (~> 1.0)
37
+ arel (3.0.2)
38
+ builder (3.0.0)
39
39
  diff-lcs (1.1.2)
40
- erubis (2.6.6)
41
- abstract (>= 1.0.0)
42
- i18n (0.5.0)
43
- mail (2.2.19)
44
- activesupport (>= 2.3.6)
40
+ erubis (2.7.0)
41
+ hike (1.2.1)
42
+ i18n (0.6.0)
43
+ journey (1.0.3)
44
+ json (1.6.6)
45
+ mail (2.4.4)
45
46
  i18n (>= 0.4.0)
46
47
  mime-types (~> 1.16)
47
48
  treetop (~> 1.4.8)
48
- mime-types (1.16)
49
- polyglot (0.3.2)
50
- rack (1.2.3)
51
- rack-mount (0.6.14)
52
- rack (>= 1.0.0)
53
- rack-test (0.5.7)
49
+ mime-types (1.18)
50
+ multi_json (1.2.0)
51
+ polyglot (0.3.3)
52
+ rack (1.4.1)
53
+ rack-cache (1.2)
54
+ rack (>= 0.4)
55
+ rack-ssl (1.3.2)
56
+ rack
57
+ rack-test (0.6.1)
54
58
  rack (>= 1.0)
55
- rails (3.0.10)
56
- actionmailer (= 3.0.10)
57
- actionpack (= 3.0.10)
58
- activerecord (= 3.0.10)
59
- activeresource (= 3.0.10)
60
- activesupport (= 3.0.10)
59
+ rails (3.2.3)
60
+ actionmailer (= 3.2.3)
61
+ actionpack (= 3.2.3)
62
+ activerecord (= 3.2.3)
63
+ activeresource (= 3.2.3)
64
+ activesupport (= 3.2.3)
61
65
  bundler (~> 1.0)
62
- railties (= 3.0.10)
63
- railties (3.0.10)
64
- actionpack (= 3.0.10)
65
- activesupport (= 3.0.10)
66
+ railties (= 3.2.3)
67
+ railties (3.2.3)
68
+ actionpack (= 3.2.3)
69
+ activesupport (= 3.2.3)
70
+ rack-ssl (~> 1.3.2)
66
71
  rake (>= 0.8.7)
67
72
  rdoc (~> 3.4)
68
- thor (~> 0.14.4)
69
- rake (0.9.2)
70
- rdoc (3.9.4)
73
+ thor (~> 0.14.6)
74
+ rake (0.9.2.2)
75
+ rdoc (3.12)
76
+ json (~> 1.4)
71
77
  rr (1.0.0)
72
78
  rspec (2.0.1)
73
79
  rspec-core (~> 2.0.1)
@@ -80,11 +86,16 @@ GEM
80
86
  rspec-core (~> 2.0.1)
81
87
  rspec-expectations (~> 2.0.1)
82
88
  shoulda (2.11.3)
89
+ sprockets (2.1.2)
90
+ hike (~> 1.2)
91
+ rack (~> 1.0)
92
+ tilt (~> 1.1, != 1.3.0)
83
93
  thor (0.14.6)
94
+ tilt (1.3.3)
84
95
  treetop (1.4.10)
85
96
  polyglot
86
97
  polyglot (>= 0.3.1)
87
- tzinfo (0.3.29)
98
+ tzinfo (0.3.32)
88
99
 
89
100
  PLATFORMS
90
101
  ruby
@@ -58,7 +58,7 @@ module DataTable
58
58
  options = field.extract_options!
59
59
 
60
60
  if options[:split]
61
- _split_where_condition query, field, options[:split]
61
+ _split_where_condition query, field, options
62
62
  elsif options[:date]
63
63
  _date_where_condition query, field.first
64
64
  else
@@ -77,15 +77,21 @@ module DataTable
77
77
  end
78
78
  end
79
79
 
80
- def _split_where_condition query, fields, splitter
80
+ def _split_where_condition query, fields, options
81
81
  conditions = []
82
82
  parameters = []
83
- split_query = query.split splitter
83
+ split_query = query.split options[:split]
84
+ types = options[:types] || ([:string] * fields.size)
84
85
 
85
86
  if split_query.size == fields.size
86
- fields.map do |f|
87
- conditions << "UPPER(#{f}) LIKE ?"
88
- parameters << "%#{split_query.shift.upcase}%"
87
+ fields.zip(split_query).zip(types).each do |((field, query), type)|
88
+ if type == :numeric
89
+ conditions << "#{field} = ?"
90
+ parameters << query.to_i
91
+ else
92
+ conditions << "UPPER(#{field}) LIKE ?"
93
+ parameters << "%#{query.upcase}%"
94
+ end
89
95
  end
90
96
 
91
97
  ["(" + conditions.join(" AND ") + ")", *parameters]
@@ -1,3 +1,3 @@
1
1
  module DataTable
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
@@ -73,6 +73,11 @@ describe DataTable do
73
73
  send(:_where_conditions, "q1 q-2", ['F1', ['P1', 'P2', {:split => '-'}]]).should ==
74
74
  ["(UPPER(F1) LIKE ?) AND (UPPER(F1) LIKE ? OR (UPPER(P1) LIKE ? AND UPPER(P2) LIKE ?))", "%Q1%", "%Q-2%", "%Q%", "%2%"]
75
75
  end
76
+
77
+ it "should not use like with a numeric split query" do
78
+ send(:_where_conditions, "101-04", [['foo', 'bar', {:split => '-', :types => [:numeric, :numeric]}]]).should ==
79
+ ["((foo = ? AND bar = ?))", 101, 4]
80
+ end
76
81
  end
77
82
  end
78
83
 
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.4.1
4
+ version: 0.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-23 00:00:00.000000000 -04:00
13
- default_executable:
12
+ date: 2012-04-03 00:00:00.000000000Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: rails
17
- requirement: &2160570720 !ruby/object:Gem::Requirement
16
+ requirement: &70103816205680 !ruby/object:Gem::Requirement
18
17
  none: false
19
18
  requirements:
20
19
  - - ~>
@@ -22,10 +21,10 @@ dependencies:
22
21
  version: '3.0'
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *2160570720
24
+ version_requirements: *70103816205680
26
25
  - !ruby/object:Gem::Dependency
27
26
  name: rspec
28
- requirement: &2160572760 !ruby/object:Gem::Requirement
27
+ requirement: &70103816204540 !ruby/object:Gem::Requirement
29
28
  none: false
30
29
  requirements:
31
30
  - - ~>
@@ -33,10 +32,10 @@ dependencies:
33
32
  version: 2.0.0
34
33
  type: :development
35
34
  prerelease: false
36
- version_requirements: *2160572760
35
+ version_requirements: *70103816204540
37
36
  - !ruby/object:Gem::Dependency
38
37
  name: shoulda
39
- requirement: &2160586200 !ruby/object:Gem::Requirement
38
+ requirement: &70103816203880 !ruby/object:Gem::Requirement
40
39
  none: false
41
40
  requirements:
42
41
  - - ~>
@@ -44,10 +43,10 @@ dependencies:
44
43
  version: 2.11.0
45
44
  type: :development
46
45
  prerelease: false
47
- version_requirements: *2160586200
46
+ version_requirements: *70103816203880
48
47
  - !ruby/object:Gem::Dependency
49
48
  name: rr
50
- requirement: &2160591700 !ruby/object:Gem::Requirement
49
+ requirement: &70103816203420 !ruby/object:Gem::Requirement
51
50
  none: false
52
51
  requirements:
53
52
  - - ~>
@@ -55,7 +54,7 @@ dependencies:
55
54
  version: 1.0.0
56
55
  type: :development
57
56
  prerelease: false
58
- version_requirements: *2160591700
57
+ version_requirements: *70103816203420
59
58
  description: Simple data preparation from AR/Mongoid to the jQuery DataTables plugin
60
59
  email:
61
60
  - jason.dew@gmail.com
@@ -64,6 +63,7 @@ extensions: []
64
63
  extra_rdoc_files: []
65
64
  files:
66
65
  - .gitignore
66
+ - .rvmrc
67
67
  - Gemfile
68
68
  - Gemfile.lock
69
69
  - LICENSE
@@ -82,7 +82,6 @@ files:
82
82
  - spec/data_table_spec.rb
83
83
  - spec/mongoid_data_table_spec.rb
84
84
  - spec/spec_helper.rb
85
- has_rdoc: true
86
85
  homepage: http://rubygems.org/gems/data_table
87
86
  licenses: []
88
87
  post_install_message:
@@ -103,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
102
  version: '0'
104
103
  requirements: []
105
104
  rubyforge_project: data_table
106
- rubygems_version: 1.6.2
105
+ rubygems_version: 1.8.10
107
106
  signing_key:
108
107
  specification_version: 3
109
108
  summary: Simple data preparation from AR/Mongoid to the jQuery DataTables plugin