data_tables-responder 0.4.4rc1 → 0.5.0rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 5faa27861eee2591709eae8eb5eb1b6e24a4e35b56bc6f03fa6edb5d53584094
4
- data.tar.gz: 59dd8eec6c905047b663cc511cf704e9f2501b0d30ae9a3ae825de21594ba088
2
+ SHA1:
3
+ metadata.gz: 973286b550d47b37f1ea777940f52f5dcaab7f36
4
+ data.tar.gz: b3ed8b4330f79dd2956558c0a139ce91697959a4
5
5
  SHA512:
6
- metadata.gz: 1fbb2fd0cda0f0870d40371275f9483ab6601296b63ccc21cb92d19974f250af9d81a89471b27d74e3bac17862759c66fd1d0314d80e5512751afd12f5349343
7
- data.tar.gz: 0f09e4c09b931f285c05333dc9f77528b935d32edbd012794a2c6b514645c2f04e3134843490cc49e6de69f3cd3a5c1e0a394481aa4e7f5a69bf030e4d6f72f1
6
+ metadata.gz: 4eefb2fada6a7bf4add8e1090a758f2819f3b769bcfafd489c65bfc07bef5407dde0f2904d4ac786ea2af6f5fd811df4e9f6cf1a08153d5f7f64141bcf8d4009
7
+ data.tar.gz: 90d762f1a69a0b726f843bb557278384f4628620b43bd20ea4e8cf777b2b774f7b8a210287fba055e40b5f3587ed190b9ca24e7c53ae0aa49dfeedf07abf2997
data/.travis.yml CHANGED
@@ -2,38 +2,27 @@ language: ruby
2
2
  sudo: false
3
3
 
4
4
  cache: bundler
5
-
6
- before_install:
7
- - gem update --system
8
- - gem install bundler
9
-
10
- before_script:
11
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
12
- - chmod +x ./cc-test-reporter
13
- - ./cc-test-reporter before-build
14
-
15
5
  script:
16
6
  - bundle exec rspec
17
7
 
18
- after_script:
19
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
8
+ after_success:
9
+ - bundle exec codeclimate-test-reporter
20
10
 
21
11
  addons:
22
- postgresql: 9.4
12
+ postgresql: "9.4"
23
13
 
24
14
  rvm:
25
- - 2.6
26
- - 2.5
27
15
  - 2.4
16
+ - 2.3
28
17
 
29
18
  gemfile:
30
- - gemfiles/activerecord-4.2.Gemfile
31
- - gemfiles/activerecord-5.0.Gemfile
32
19
  - gemfiles/activerecord-5.1.Gemfile
33
- - gemfiles/activerecord-5.2.Gemfile
20
+ - gemfiles/activerecord-5.0.Gemfile
21
+ - gemfiles/activerecord-4.2.Gemfile
22
+ - gemfiles/activerecord-4.1.Gemfile
34
23
 
35
24
  matrix:
36
25
  exclude:
37
26
 
38
- - rvm: 2.6
39
- gemfile: gemfiles/activerecord-4.2.Gemfile
27
+ - rvm: 2.4
28
+ gemfile: gemfiles/activerecord-4.1.Gemfile
data/Gemfile CHANGED
@@ -7,6 +7,9 @@ group :test do
7
7
  # Generates coverage stats of specs
8
8
  gem 'simplecov'
9
9
 
10
+ # Publishes coverage to codeclimate
11
+ gem 'codeclimate-test-reporter'
12
+
10
13
  # Gives CircleCI more perspective on our tests
11
14
  gem 'rspec_junit_formatter'
12
15
 
@@ -16,4 +19,6 @@ group :test do
16
19
 
17
20
  gem 'combustion'
18
21
 
22
+ gem 'pg'
23
+
19
24
  end
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2019 Dale Stevens
3
+ Copyright (c) 2016 Dale Stevens
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,7 +1,8 @@
1
- [![Version ](https://img.shields.io/gem/v/data_tables-responder.svg)](https://rubygems.org/gems/data_tables-responder)
1
+ [![Version ](https://img.shields.io/gem/v/data_tables-responder.svg?maxAge=2592000)](https://rubygems.org/gems/data_tables-responder)
2
2
  [![Build Status ](https://travis-ci.org/TwilightCoders/data_tables-responder.svg)](https://travis-ci.org/TwilightCoders/data_tables-responder)
3
3
  [![Code Climate ](https://api.codeclimate.com/v1/badges/5032242cc2798697105a/maintainability)](https://codeclimate.com/github/TwilightCoders/data_tables-responder/maintainability)
4
- [![Test Coverage](https://api.codeclimate.com/v1/badges/5032242cc2798697105a/test_coverage)](https://codeclimate.com/github/TwilightCoders/data_tables-responder/test_coverage)
4
+ [![Test Coverage](https://codeclimate.com/github/TwilightCoders/data_tables-responder/badges/coverage.svg)](https://codeclimate.com/github/TwilightCoders/data_tables-responder/coverage)
5
+ [![Dependencies ](https://gemnasium.com/badges/github.com/TwilightCoders/data_tables-responder.svg)](https://gemnasium.com/github.com/TwilightCoders/data_tables-responder)
5
6
 
6
7
  # DataTables::Responder
7
8
 
@@ -29,17 +29,17 @@ Gem::Specification.new do |spec|
29
29
  spec.require_paths = ['lib', 'spec']
30
30
 
31
31
  rails_versions = ['>= 4.1', '< 6']
32
- spec.required_ruby_version = '>= 2.3'
32
+ spec.required_ruby_version = '>= 2.1'
33
33
 
34
34
  spec.add_runtime_dependency 'active_model_serializers', '~> 0'
35
- spec.add_runtime_dependency 'quick_count', '~> 0.1'
35
+ spec.add_runtime_dependency 'quick_count', ['>= 0.0.3', '< 0.1.0']
36
36
  spec.add_runtime_dependency 'railties', rails_versions
37
37
 
38
38
  spec.add_development_dependency 'activerecord', rails_versions
39
- spec.add_development_dependency 'pg'
40
- spec.add_development_dependency 'pry-byebug'
41
- spec.add_development_dependency 'bundler'
42
- spec.add_development_dependency 'rake'
39
+ spec.add_development_dependency 'pg', '~> 0'
40
+ spec.add_development_dependency 'pry-byebug', '~> 3'
41
+ spec.add_development_dependency 'bundler', '~> 1.3'
42
+ spec.add_development_dependency 'rake', '~> 12.0'
43
43
  spec.add_development_dependency 'combustion', '~> 0.7'
44
44
 
45
45
  end
@@ -1,4 +1,3 @@
1
1
  eval_gemfile File.join(File.dirname(__FILE__), "../Gemfile")
2
2
 
3
3
  gem 'activerecord', '~> 4.1.0'
4
- gem 'pg', '~> 0.20.0'
@@ -1,4 +1,3 @@
1
1
  eval_gemfile File.join(File.dirname(__FILE__), "../Gemfile")
2
2
 
3
3
  gem 'activerecord', '~> 4.2.0'
4
- gem 'pg', '~> 0.20.0'
@@ -49,19 +49,12 @@ module DataTables
49
49
 
50
50
  def search_by_type(model, column, query, &block)
51
51
  arel_column = model.arel_table[column]
52
- column_type = model.columns_hash[column.to_s]&.type
53
-
54
- result = case column_type
52
+ result = case model.columns_hash[column.to_s]&.type
55
53
  when :string
56
- query = Array.wrap(query)
57
54
  # I'm pretty sure this is safe from SQL Injection
58
- arel_column.matches_any(query.map { |q| "%#{q}%" })
55
+ arel_column.matches("%#{query}%")
59
56
  when :integer
60
- query = Array.wrap(query)
61
- arel_column.eq_any(query.map(&:to_i))
62
- when :float
63
- query = Array.wrap(query)
64
- arel_column.eq_any(query.map(&:to_f))
57
+ value = query&.to_i and arel_column.eq(value)
65
58
  when :datetime
66
59
  datetime = Time.parse(query)
67
60
  range = (datetime-1.second)..(datetime+1.second)
@@ -1,5 +1,5 @@
1
1
  module DataTables
2
2
  module Responder
3
- VERSION = '0.4.4rc1'
3
+ VERSION = '0.5.0rc1'
4
4
  end
5
5
  end
@@ -208,7 +208,7 @@ describe DataTables::Responder do
208
208
  expect(response_sql).to include('"comments".* FROM "comments"')
209
209
  expect(response_sql).to include('INNER JOIN "posts" ON "posts"."id" = "comments"."post_id"')
210
210
  expect(response_sql).to include('JOIN "users" ON "users"."id" = "posts"."user_id"')
211
- expect(response_sql).to include('"users"."email" ILIKE \'%foo@bar.baz%\'')
211
+ expect(response_sql).to include('WHERE ("users"."email" ILIKE \'%foo@bar.baz%\')')
212
212
  expect(response_sql).to include('ORDER BY "users"."email" ASC')
213
213
  expect(response_sql).to include('LIMIT 10 OFFSET 0')
214
214
  end
@@ -244,7 +244,7 @@ describe DataTables::Responder do
244
244
  response_sql = response.to_sql
245
245
 
246
246
  expect(response.count).to eq(1)
247
- expect(response_sql).to include('"posts"."title" ILIKE \'%foo%\'')
247
+ expect(response_sql).to include('WHERE ("posts"."title" ILIKE \'%foo%\')')
248
248
  expect(response_sql).to include('ORDER BY "posts"."title" ASC')
249
249
  expect(response_sql).to include('LIMIT 10 OFFSET 0')
250
250
  end
@@ -25,13 +25,6 @@ describe DataTables::Modules::Search do
25
25
  "searchable": true,
26
26
  "orderable": true,
27
27
  "search": { "value": "", "regex": false }
28
- },
29
- {
30
- "data": "engagement_rate",
31
- "name": "",
32
- "searchable": true,
33
- "orderable": true,
34
- "search": { "value": "", "regex": false }
35
28
  }
36
29
  ],
37
30
  "draw": 3,
@@ -50,9 +43,8 @@ describe DataTables::Modules::Search do
50
43
  before(:each) do
51
44
  User.create(email: 'foo@bar.com')
52
45
  User.create(email: 'foo2@bar.com')
53
- Post.create(title: 'foo', views: 4, engagement_rate: 0.5)
54
- Post.create(title: 'bar', views: 3, engagement_rate: 1.0)
55
- Post.create(title: 'baz', views: 2, engagement_rate: 2.0)
46
+ Post.create(title: 'foo', views: 4)
47
+ Post.create(title: 'bar', views: 3)
56
48
  end
57
49
 
58
50
  it 'integers' do
@@ -66,57 +58,12 @@ describe DataTables::Modules::Search do
66
58
 
67
59
  posts = dt_module.search
68
60
 
61
+ # expect{dt_module.search}.to_not raise_error()
69
62
  expect(posts.count).to eq(1)
70
63
  expect(posts[0].views).to eq(4)
71
64
 
72
65
  end
73
66
 
74
- it 'integers for any of many values' do
75
-
76
- complex_params[:columns][2][:search] = {
77
- "value": ["4", "3", "1"],
78
- "regex": false
79
- }
80
-
81
- dt_module = DataTables::Modules::Search.new(Post, Post.all, complex_params)
82
-
83
- posts = dt_module.search
84
-
85
- expect(posts.count).to eq(2)
86
-
87
- end
88
-
89
- it 'floats' do
90
-
91
- complex_params[:columns][3][:search] = {
92
- "value": ".5",
93
- "regex": false
94
- }
95
-
96
- dt_module = DataTables::Modules::Search.new(Post, Post.all, complex_params)
97
-
98
- posts = dt_module.search
99
-
100
- expect(posts.count).to eq(1)
101
- expect(posts[0].views).to eq(4)
102
-
103
- end
104
-
105
- it 'floats for any of many values' do
106
-
107
- complex_params[:columns][3][:search] = {
108
- "value": ["1", ".5", "1.5"],
109
- "regex": false
110
- }
111
-
112
- dt_module = DataTables::Modules::Search.new(Post, Post.all, complex_params)
113
-
114
- posts = dt_module.search
115
-
116
- expect(posts.count).to eq(2)
117
-
118
- end
119
-
120
67
  it 'strings' do
121
68
 
122
69
  complex_params[:columns][1][:search] = {
@@ -128,26 +75,12 @@ describe DataTables::Modules::Search do
128
75
 
129
76
  posts = dt_module.search
130
77
 
78
+ # expect{dt_module.search}.to_not raise_error()
131
79
  expect(posts.count).to eq(1)
132
80
  expect(posts[0].title).to eq('foo')
133
81
 
134
82
  end
135
83
 
136
- it 'strings for any of many values' do
137
-
138
- complex_params[:columns][1][:search] = {
139
- "value": ["foo", "bar"],
140
- "regex": false
141
- }
142
-
143
- dt_module = DataTables::Modules::Search.new(Post, Post.all, complex_params)
144
-
145
- posts = dt_module.search
146
-
147
- expect(posts.count).to eq(2)
148
-
149
- end
150
-
151
84
  it 'uuids' do
152
85
 
153
86
  complex_params[:columns][0][:search] = {
@@ -159,6 +92,7 @@ describe DataTables::Modules::Search do
159
92
 
160
93
  users = dt_module.search
161
94
 
95
+ # expect{dt_module.search}.to_not raise_error()
162
96
  expect(users.count).to eq(1)
163
97
  expect(users[0].email).to eq('foo@bar.com')
164
98
 
@@ -12,8 +12,7 @@ ActiveRecord::Schema.define do
12
12
  create_table :posts, :force => true do |t|
13
13
  t.uuid :user_id
14
14
  t.string :title
15
- t.integer :views
16
- t.float :engagement_rate
15
+ t.integer :views # for testing integers
17
16
  t.timestamps
18
17
  end
19
18
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_tables-responder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4rc1
4
+ version: 0.5.0rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dale Stevens
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-01 00:00:00.000000000 Z
11
+ date: 2017-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -28,16 +28,22 @@ dependencies:
28
28
  name: quick_count
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.3
34
+ - - "<"
32
35
  - !ruby/object:Gem::Version
33
- version: '0.1'
36
+ version: 0.1.0
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - "~>"
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.0.3
44
+ - - "<"
39
45
  - !ruby/object:Gem::Version
40
- version: '0.1'
46
+ version: 0.1.0
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: railties
43
49
  requirement: !ruby/object:Gem::Requirement
@@ -82,58 +88,58 @@ dependencies:
82
88
  name: pg
83
89
  requirement: !ruby/object:Gem::Requirement
84
90
  requirements:
85
- - - ">="
91
+ - - "~>"
86
92
  - !ruby/object:Gem::Version
87
93
  version: '0'
88
94
  type: :development
89
95
  prerelease: false
90
96
  version_requirements: !ruby/object:Gem::Requirement
91
97
  requirements:
92
- - - ">="
98
+ - - "~>"
93
99
  - !ruby/object:Gem::Version
94
100
  version: '0'
95
101
  - !ruby/object:Gem::Dependency
96
102
  name: pry-byebug
97
103
  requirement: !ruby/object:Gem::Requirement
98
104
  requirements:
99
- - - ">="
105
+ - - "~>"
100
106
  - !ruby/object:Gem::Version
101
- version: '0'
107
+ version: '3'
102
108
  type: :development
103
109
  prerelease: false
104
110
  version_requirements: !ruby/object:Gem::Requirement
105
111
  requirements:
106
- - - ">="
112
+ - - "~>"
107
113
  - !ruby/object:Gem::Version
108
- version: '0'
114
+ version: '3'
109
115
  - !ruby/object:Gem::Dependency
110
116
  name: bundler
111
117
  requirement: !ruby/object:Gem::Requirement
112
118
  requirements:
113
- - - ">="
119
+ - - "~>"
114
120
  - !ruby/object:Gem::Version
115
- version: '0'
121
+ version: '1.3'
116
122
  type: :development
117
123
  prerelease: false
118
124
  version_requirements: !ruby/object:Gem::Requirement
119
125
  requirements:
120
- - - ">="
126
+ - - "~>"
121
127
  - !ruby/object:Gem::Version
122
- version: '0'
128
+ version: '1.3'
123
129
  - !ruby/object:Gem::Dependency
124
130
  name: rake
125
131
  requirement: !ruby/object:Gem::Requirement
126
132
  requirements:
127
- - - ">="
133
+ - - "~>"
128
134
  - !ruby/object:Gem::Version
129
- version: '0'
135
+ version: '12.0'
130
136
  type: :development
131
137
  prerelease: false
132
138
  version_requirements: !ruby/object:Gem::Requirement
133
139
  requirements:
134
- - - ">="
140
+ - - "~>"
135
141
  - !ruby/object:Gem::Version
136
- version: '0'
142
+ version: '12.0'
137
143
  - !ruby/object:Gem::Dependency
138
144
  name: combustion
139
145
  requirement: !ruby/object:Gem::Requirement
@@ -159,7 +165,7 @@ files:
159
165
  - ".rspec"
160
166
  - ".travis.yml"
161
167
  - Gemfile
162
- - LICENSE
168
+ - LICENSE.txt
163
169
  - README.md
164
170
  - Rakefile
165
171
  - data_tables-responder.gemspec
@@ -167,7 +173,6 @@ files:
167
173
  - gemfiles/activerecord-4.2.Gemfile
168
174
  - gemfiles/activerecord-5.0.Gemfile
169
175
  - gemfiles/activerecord-5.1.Gemfile
170
- - gemfiles/activerecord-5.2.Gemfile
171
176
  - lib/data_tables.rb
172
177
  - lib/data_tables/active_model_serializers/adapter.rb
173
178
  - lib/data_tables/active_model_serializers/adapter/meta.rb
@@ -205,14 +210,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
205
210
  requirements:
206
211
  - - ">="
207
212
  - !ruby/object:Gem::Version
208
- version: '2.3'
213
+ version: '2.1'
209
214
  required_rubygems_version: !ruby/object:Gem::Requirement
210
215
  requirements:
211
216
  - - ">"
212
217
  - !ruby/object:Gem::Version
213
218
  version: 1.3.1
214
219
  requirements: []
215
- rubygems_version: 3.0.3
220
+ rubyforge_project:
221
+ rubygems_version: 2.5.2.1
216
222
  signing_key:
217
223
  specification_version: 4
218
224
  summary: Respond to DataTable requests.
@@ -1,3 +0,0 @@
1
- eval_gemfile File.join(File.dirname(__FILE__), "../Gemfile")
2
-
3
- gem 'activerecord', '~> 5.2.0'