data_table 0.4.6 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ Y2I5MDdiYWFiZmQ5MmZjNDZkYWJiNjM1YzU0ZjNiYmQwOGJiMjRkMA==
5
+ data.tar.gz: !binary |-
6
+ MWZmZGM1ZGU5YzM4OWE4MzIyYmIyNzkzNWVmZGYwMmI5MGUwOTk1Nw==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NzM2NmM1ZDkzNzRjYjQ4OTA3MTMxNjQ4NjM5ZGE5ZTNiNjgyNWNmOGMzMWY2
10
+ MjBjZjQ5NTEzODJjYTg0YzM3MzNkYTU0OTRlYzQzYWU0ODJiM2MwZjVkMWU3
11
+ NzZjMGY0ZGZjZTg2ZDdiZjlmOWYzZWI1MGEzN2JhNDkyMDk0Mzc=
12
+ data.tar.gz: !binary |-
13
+ YzYyMmMzNzE5MjVmMDI3NjMwZDZmYjliNmNiZWUzMGRiYTc4MzhmYzFlMjkz
14
+ NjgzODdhZDU1OWQyODY5MGQxOTE1M2I3OGQ4ZTA2ZDVjMDMwMGM2ZGQ2MGFh
15
+ NjZkY2NjZDE4NjQ4YWM3OGFlMjEyZTU4ZGRjZjA1NmJiYzRhY2U=
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile.lock CHANGED
@@ -1,18 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- data_table (0.4.6)
4
+ data_table (0.4.7)
5
5
  rails (~> 3.0)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
- actionmailer (3.2.12)
11
- actionpack (= 3.2.12)
12
- mail (~> 2.4.4)
13
- actionpack (3.2.12)
14
- activemodel (= 3.2.12)
15
- activesupport (= 3.2.12)
10
+ actionmailer (3.2.14)
11
+ actionpack (= 3.2.14)
12
+ mail (~> 2.5.4)
13
+ actionpack (3.2.14)
14
+ activemodel (= 3.2.14)
15
+ activesupport (= 3.2.14)
16
16
  builder (~> 3.0.0)
17
17
  erubis (~> 2.7.0)
18
18
  journey (~> 1.0.4)
@@ -20,34 +20,33 @@ GEM
20
20
  rack-cache (~> 1.2)
21
21
  rack-test (~> 0.6.1)
22
22
  sprockets (~> 2.2.1)
23
- activemodel (3.2.12)
24
- activesupport (= 3.2.12)
23
+ activemodel (3.2.14)
24
+ activesupport (= 3.2.14)
25
25
  builder (~> 3.0.0)
26
- activerecord (3.2.12)
27
- activemodel (= 3.2.12)
28
- activesupport (= 3.2.12)
26
+ activerecord (3.2.14)
27
+ activemodel (= 3.2.14)
28
+ activesupport (= 3.2.14)
29
29
  arel (~> 3.0.2)
30
30
  tzinfo (~> 0.3.29)
31
- activeresource (3.2.12)
32
- activemodel (= 3.2.12)
33
- activesupport (= 3.2.12)
34
- activesupport (3.2.12)
35
- i18n (~> 0.6)
31
+ activeresource (3.2.14)
32
+ activemodel (= 3.2.14)
33
+ activesupport (= 3.2.14)
34
+ activesupport (3.2.14)
35
+ i18n (~> 0.6, >= 0.6.4)
36
36
  multi_json (~> 1.0)
37
37
  arel (3.0.2)
38
38
  builder (3.0.4)
39
- diff-lcs (1.1.2)
39
+ diff-lcs (1.2.4)
40
40
  erubis (2.7.0)
41
- hike (1.2.1)
42
- i18n (0.6.1)
41
+ hike (1.2.3)
42
+ i18n (0.6.5)
43
43
  journey (1.0.4)
44
- json (1.7.7)
45
- mail (2.4.4)
46
- i18n (>= 0.4.0)
44
+ json (1.8.0)
45
+ mail (2.5.4)
47
46
  mime-types (~> 1.16)
48
47
  treetop (~> 1.4.8)
49
- mime-types (1.21)
50
- multi_json (1.6.1)
48
+ mime-types (1.25)
49
+ multi_json (1.7.9)
51
50
  polyglot (0.3.3)
52
51
  rack (1.4.5)
53
52
  rack-cache (1.2)
@@ -56,53 +55,51 @@ GEM
56
55
  rack
57
56
  rack-test (0.6.2)
58
57
  rack (>= 1.0)
59
- rails (3.2.12)
60
- actionmailer (= 3.2.12)
61
- actionpack (= 3.2.12)
62
- activerecord (= 3.2.12)
63
- activeresource (= 3.2.12)
64
- activesupport (= 3.2.12)
58
+ rails (3.2.14)
59
+ actionmailer (= 3.2.14)
60
+ actionpack (= 3.2.14)
61
+ activerecord (= 3.2.14)
62
+ activeresource (= 3.2.14)
63
+ activesupport (= 3.2.14)
65
64
  bundler (~> 1.0)
66
- railties (= 3.2.12)
67
- railties (3.2.12)
68
- actionpack (= 3.2.12)
69
- activesupport (= 3.2.12)
65
+ railties (= 3.2.14)
66
+ railties (3.2.14)
67
+ actionpack (= 3.2.14)
68
+ activesupport (= 3.2.14)
70
69
  rack-ssl (~> 1.3.2)
71
70
  rake (>= 0.8.7)
72
71
  rdoc (~> 3.4)
73
72
  thor (>= 0.14.6, < 2.0)
74
- rake (10.0.3)
75
- rdoc (3.12.1)
73
+ rake (10.1.0)
74
+ rdoc (3.12.2)
76
75
  json (~> 1.4)
77
- rr (1.0.0)
78
- rspec (2.0.1)
79
- rspec-core (~> 2.0.1)
80
- rspec-expectations (~> 2.0.1)
81
- rspec-mocks (~> 2.0.1)
82
- rspec-core (2.0.1)
83
- rspec-expectations (2.0.1)
84
- diff-lcs (>= 1.1.2)
85
- rspec-mocks (2.0.1)
86
- rspec-core (~> 2.0.1)
87
- rspec-expectations (~> 2.0.1)
76
+ rr (1.1.2)
77
+ rspec (2.14.1)
78
+ rspec-core (~> 2.14.0)
79
+ rspec-expectations (~> 2.14.0)
80
+ rspec-mocks (~> 2.14.0)
81
+ rspec-core (2.14.5)
82
+ rspec-expectations (2.14.2)
83
+ diff-lcs (>= 1.1.3, < 2.0)
84
+ rspec-mocks (2.14.3)
88
85
  shoulda (2.11.3)
89
86
  sprockets (2.2.2)
90
87
  hike (~> 1.2)
91
88
  multi_json (~> 1.0)
92
89
  rack (~> 1.0)
93
90
  tilt (~> 1.1, != 1.3.0)
94
- thor (0.17.0)
95
- tilt (1.3.3)
96
- treetop (1.4.12)
91
+ thor (0.18.1)
92
+ tilt (1.4.1)
93
+ treetop (1.4.15)
97
94
  polyglot
98
95
  polyglot (>= 0.3.1)
99
- tzinfo (0.3.35)
96
+ tzinfo (0.3.37)
100
97
 
101
98
  PLATFORMS
102
99
  ruby
103
100
 
104
101
  DEPENDENCIES
105
102
  data_table!
106
- rr (~> 1.0.0)
107
- rspec (~> 2.0.0)
108
- shoulda (~> 2.11.0)
103
+ rr (~> 1.0)
104
+ rspec (~> 2.0)
105
+ shoulda (~> 2.11)
data/data_table.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Jason Dew"]
9
9
  s.email = ["jason.dew@gmail.com"]
10
- s.homepage = "http://rubygems.org/gems/data_table"
10
+ s.homepage = "https://github.com/jasondew/data_table"
11
11
  s.summary = %q{Simple data preparation from AR/Mongoid to the jQuery DataTables plugin}
12
12
  s.description = %q{Simple data preparation from AR/Mongoid to the jQuery DataTables plugin}
13
13
 
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
 
21
21
  s.add_dependency "rails", "~>3.0"
22
22
 
23
- s.add_development_dependency "rspec", "~>2.0.0"
24
- s.add_development_dependency "shoulda", "~>2.11.0"
25
- s.add_development_dependency "rr", "~>1.0.0"
23
+ s.add_development_dependency "rspec", "~>2.0"
24
+ s.add_development_dependency "shoulda", "~>2.11"
25
+ s.add_development_dependency "rr", "~>1.0"
26
26
  end
@@ -37,6 +37,8 @@ module DataTable
37
37
  end
38
38
 
39
39
  def _page params
40
+ return 1 if params[:idisplaystart].blank? or params[:idisplaylength].blank?
41
+
40
42
  params[:idisplaystart].to_i / params[:idisplaylength].to_i + 1
41
43
  end
42
44
 
@@ -1,3 +1,3 @@
1
1
  module DataTable
2
- VERSION = "0.4.6"
2
+ VERSION = "0.4.7"
3
3
  end
@@ -33,22 +33,21 @@ describe DataTable do
33
33
  result.should == {:sEcho => 1, :iTotalRecords => 42, :iTotalDisplayRecords => 10, :aaData => :results}.to_json.html_safe
34
34
  end
35
35
 
36
- # won't work because of ruby 1.9.2 bug... https://gist.github.com/455547
37
- # it "should work with a pagination library that doesn't respond to #total_entries" do
38
- # params = {:sSearch => "answer", :iSortCol_0 => "0", :sSortDir_0 => "desc", :iDisplayLength => "10", :sEcho => "1"}
39
- # controller = mock!.params { params }.subject
40
- #
41
- # fields = %w(foo bar baz)
42
- # search_fields = %w(foo bar)
43
- #
44
- # mock(self).count { 42 }
45
- # mock(self)._matching_count(params, search_fields) { 10 }
46
- # mock(self)._find_objects(params, fields, search_fields) { :objects }
47
- # mock(self)._yield_and_render_array(controller, :objects, :block) { :results }
48
- #
49
- # result = for_data_table(controller, fields, search_fields, :block)
50
- # result.should == {:sEcho => 1, :iTotalRecords => 42, :iTotalDisplayRecords => 10, :aaData => :results}.to_json.html_safe
51
- # end
36
+ it "should work with a pagination library that doesn't respond to #total_entries" do
37
+ params = {:ssearch => "answer", :isortcol_0 => "0", :ssortdir_0 => "desc", :idisplaylength => "10", :secho => "1"}
38
+ controller = mock!.params { params }.subject
39
+
40
+ fields = %w(foo bar baz)
41
+ search_fields = %w(foo bar)
42
+
43
+ mock(self).count { 42 }
44
+ mock(self)._matching_count(params, search_fields) { 10 }
45
+ mock(self)._find_objects(params, fields, search_fields) { :objects }
46
+ mock(self)._yield_and_render_array(controller, :objects, :block) { :results }
47
+
48
+ result = for_data_table(controller, fields, search_fields, :block)
49
+ result.should == {:sEcho => 1, :iTotalRecords => 42, :iTotalDisplayRecords => 10, :aaData => :results}.to_json.html_safe
50
+ end
52
51
 
53
52
  end
54
53
 
@@ -77,6 +76,11 @@ describe DataTable do
77
76
  it "should return 2 when start is 10" do
78
77
  send(:_page, {idisplaystart: "10", idisplaylength: "10"}).should == 2
79
78
  end
79
+
80
+ it "should default to 1 when idisplaystart or idisplaylength are missing" do
81
+ send(:_page, {}).should == 1
82
+ end
83
+
80
84
  end
81
85
 
82
86
  end
@@ -96,6 +100,10 @@ describe DataTable do
96
100
  send(:_per_page, {idisplaylength: "-1"}).should == :all
97
101
  end
98
102
 
103
+ it "should default to 10 if idisplaylength is missing" do
104
+ send(:_per_page, {}).should == 25
105
+ end
106
+
99
107
  end
100
108
 
101
109
  end
@@ -25,8 +25,8 @@ describe DataTable do
25
25
  send(:_where_conditions, "", %w(foo bar baz)).should == nil
26
26
  end
27
27
 
28
- it "should return a mongoid $or hash with an entry for each search field" do
29
- send(:_where_conditions, "q", %w(foo bar)).should == {"$or" => [{"foo" => /q/i}, {"bar" => /q/i}]}
28
+ it "should return a mongoid $and wrapping an $or for each search field" do
29
+ send(:_where_conditions, "q", %w(foo bar)).should == {"$and" => [{"$or"=>[{"foo"=>/q/i}, {"bar"=>/q/i}]}]}
30
30
  end
31
31
 
32
32
  it "should not use $or if there is only one search field" do
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,10 @@
1
1
  require "data_table"
2
2
 
3
- RSpec.configure {|config| config.mock_with :rr }
3
+ RSpec.configure do |config|
4
+ config.treat_symbols_as_metadata_keys_with_true_values = true
5
+ config.run_all_when_everything_filtered = true
6
+ config.filter_run :focus
7
+
8
+ config.mock_with :rr
9
+ config.order = "random"
10
+ end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_table
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
5
- prerelease:
4
+ version: 0.4.7
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jason Dew
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-16 00:00:00.000000000 Z
11
+ date: 2013-09-04 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,51 +27,45 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
37
- version: 2.0.0
33
+ version: '2.0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
45
- version: 2.0.0
40
+ version: '2.0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: shoulda
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
53
- version: 2.11.0
47
+ version: '2.11'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
61
- version: 2.11.0
54
+ version: '2.11'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rr
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
69
- version: 1.0.0
61
+ version: '1.0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
77
- version: 1.0.0
68
+ version: '1.0'
78
69
  description: Simple data preparation from AR/Mongoid to the jQuery DataTables plugin
79
70
  email:
80
71
  - jason.dew@gmail.com
@@ -83,6 +74,7 @@ extensions: []
83
74
  extra_rdoc_files: []
84
75
  files:
85
76
  - .gitignore
77
+ - .rspec
86
78
  - .rvmrc
87
79
  - Gemfile
88
80
  - Gemfile.lock
@@ -102,35 +94,28 @@ files:
102
94
  - spec/data_table_spec.rb
103
95
  - spec/mongoid_data_table_spec.rb
104
96
  - spec/spec_helper.rb
105
- homepage: http://rubygems.org/gems/data_table
97
+ homepage: https://github.com/jasondew/data_table
106
98
  licenses: []
99
+ metadata: {}
107
100
  post_install_message:
108
101
  rdoc_options: []
109
102
  require_paths:
110
103
  - lib
111
104
  required_ruby_version: !ruby/object:Gem::Requirement
112
- none: false
113
105
  requirements:
114
106
  - - ! '>='
115
107
  - !ruby/object:Gem::Version
116
108
  version: '0'
117
- segments:
118
- - 0
119
- hash: 2992976277628805336
120
109
  required_rubygems_version: !ruby/object:Gem::Requirement
121
- none: false
122
110
  requirements:
123
111
  - - ! '>='
124
112
  - !ruby/object:Gem::Version
125
113
  version: '0'
126
- segments:
127
- - 0
128
- hash: 2992976277628805336
129
114
  requirements: []
130
115
  rubyforge_project: data_table
131
- rubygems_version: 1.8.25
116
+ rubygems_version: 2.0.7
132
117
  signing_key:
133
- specification_version: 3
118
+ specification_version: 4
134
119
  summary: Simple data preparation from AR/Mongoid to the jQuery DataTables plugin
135
120
  test_files:
136
121
  - spec/active_record_data_table_spec.rb