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 +1 -0
- data/Gemfile.lock +66 -55
- data/lib/data_table/active_record.rb +12 -6
- data/lib/data_table/version.rb +1 -1
- data/spec/active_record_data_table_spec.rb +5 -0
- metadata +12 -13
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.
|
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
rack (~> 1.2
|
21
|
-
rack-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
arel (
|
38
|
-
builder (
|
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.
|
41
|
-
|
42
|
-
i18n (0.
|
43
|
-
|
44
|
-
|
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.
|
49
|
-
|
50
|
-
|
51
|
-
rack
|
52
|
-
|
53
|
-
|
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.
|
56
|
-
actionmailer (= 3.
|
57
|
-
actionpack (= 3.
|
58
|
-
activerecord (= 3.
|
59
|
-
activeresource (= 3.
|
60
|
-
activesupport (= 3.
|
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.
|
63
|
-
railties (3.
|
64
|
-
actionpack (= 3.
|
65
|
-
activesupport (= 3.
|
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.
|
69
|
-
rake (0.9.2)
|
70
|
-
rdoc (3.
|
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.
|
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
|
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,
|
80
|
+
def _split_where_condition query, fields, options
|
81
81
|
conditions = []
|
82
82
|
parameters = []
|
83
|
-
split_query = query.split
|
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.
|
87
|
-
|
88
|
-
|
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]
|
data/lib/data_table/version.rb
CHANGED
@@ -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.
|
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:
|
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: &
|
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: *
|
24
|
+
version_requirements: *70103816205680
|
26
25
|
- !ruby/object:Gem::Dependency
|
27
26
|
name: rspec
|
28
|
-
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: *
|
35
|
+
version_requirements: *70103816204540
|
37
36
|
- !ruby/object:Gem::Dependency
|
38
37
|
name: shoulda
|
39
|
-
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: *
|
46
|
+
version_requirements: *70103816203880
|
48
47
|
- !ruby/object:Gem::Dependency
|
49
48
|
name: rr
|
50
|
-
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: *
|
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.
|
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
|