dynamic_controller 0.0.10 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 10ab55586865bb17ead955fc52d22acd43805fe4f6f9f482b74508fc8590c675
4
+ data.tar.gz: 9d67b6592e3aa6d1ec5f101a51ec575a6c62296c80bca12d1b4b17a1c574df86
5
+ SHA512:
6
+ metadata.gz: e1914f74be4f514b2d5c7764055066c0a2be9aaae82f9366c6b61ea099dcfed8419b01e8e7554f05b50b5d44a4e179da62de0b205774fc67a7869ef6a5c13d07
7
+ data.tar.gz: 4aaf26c8bbccb2eb0b8549e95f91307584fd543addf4498f63db50fefb141bb4e0360a82c078bdd03660b5a43c39f67d8b3c48112063a46975f61188f192f2b4
data/.coveralls.yml ADDED
@@ -0,0 +1,2 @@
1
+ service_name: travis-ci
2
+ repo_token: avCtn6MOznu5tlb4T8XQrAGRXokJlcD7q
data/.gitignore CHANGED
@@ -2,4 +2,5 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
- .idea
5
+ .idea
6
+ coverage
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ dynamic_controller
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.0.0-p247
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - 2.0
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in dynamic_controller.gemspec
4
4
  gemspec
5
+
6
+ gem 'coveralls', require: false
data/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # DynamicController
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/dynamic_controller.png)](https://rubygems.org/gems/dynamic_controller)
4
+ [![Build Status](https://travis-ci.org/gabynaiman/dynamic_controller.png?branch=master)](https://travis-ci.org/gabynaiman/dynamic_controller)
5
+ [![Coverage Status](https://coveralls.io/repos/gabynaiman/dynamic_controller/badge.png?branch=master)](https://coveralls.io/r/gabynaiman/dynamic_controller?branch=master)
6
+ [![Code Climate](https://codeclimate.com/github/gabynaiman/dynamic_controller.png)](https://codeclimate.com/github/gabynaiman/dynamic_controller)
7
+ [![Dependency Status](https://gemnasium.com/gabynaiman/dynamic_controller.png)](https://gemnasium.com/gabynaiman/dynamic_controller)
8
+
3
9
  Simple way to add CRUD actions into Rails controllers.
4
10
 
5
11
  Suppoted formats HTML and JSON.
data/Rakefile CHANGED
@@ -1 +1,10 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new do |task|
5
+ task.pattern = 'spec/**/*_spec.rb'
6
+ task.rspec_opts = '--tty --color -f documentation'
7
+ task.verbose = false
8
+ end
9
+
10
+ task default: :spec
@@ -16,12 +16,15 @@ Gem::Specification.new do |s|
16
16
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
17
  s.require_paths = ["lib"]
18
18
 
19
- s.add_dependency 'ransack'
20
- s.add_dependency 'kaminari'
21
- s.add_dependency 'nql', '0.0.5'
19
+ s.add_dependency 'ransack', '~> 0.7'
20
+ s.add_dependency 'kaminari', '~> 0.13'
21
+ s.add_dependency 'nql', '~> 0.1'
22
22
 
23
- s.add_development_dependency 'rails'
24
- s.add_development_dependency 'sqlite3'
25
- s.add_development_dependency 'rspec-rails'
26
- s.add_development_dependency 'factory_girl_rails'
23
+ s.add_development_dependency "bundler", "~> 1.3"
24
+ s.add_development_dependency "rake", '~> 11.0'
25
+ s.add_development_dependency "simplecov"
26
+ s.add_development_dependency 'rails', '~> 3.2'
27
+ s.add_development_dependency 'sqlite3', '~> 1.3.0'
28
+ s.add_development_dependency 'rspec-rails', '~> 2.12'
29
+ s.add_development_dependency 'factory_girl_rails', '~> 3.4'
27
30
  end
@@ -49,6 +49,8 @@ module DynamicController
49
49
  end
50
50
 
51
51
  def handle_error(error)
52
+ Rails.logger.error error
53
+
52
54
  respond_to do |format|
53
55
  format.html { raise error }
54
56
  format.json { render json: error.message, status: :internal_server_error }
@@ -72,34 +74,5 @@ module DynamicController
72
74
  end
73
75
  end
74
76
 
75
- def ransack_query
76
- search_query.is_a?(String) ? NQL.to_ransack(search_query) : search_query
77
- end
78
-
79
- def search_query_valid?
80
- begin
81
- search_node_valid? ransack_query, model_extended_attributes
82
- rescue NQL::InvalidExpressionError => ex
83
- Rails.logger.debug "Invalid search query: #{params[:q]} | Error: #{ex.message}"
84
- false
85
- end
86
- end
87
-
88
- def search_node_valid?(node, valid_attributes)
89
- return true unless node
90
- node.deep_symbolize_keys.each do |k, v|
91
- if k == :a
92
- return false unless valid_attributes.include?(v['0'.to_sym][:name])
93
- else
94
- if v.is_a?(Hash)
95
- return false unless search_node_valid?(v, valid_attributes)
96
- elsif v.is_a?(Array)
97
- v.select { |e| e.is_a?(Hash) }.each { |e| return false unless search_node_valid?(e, valid_attributes) }
98
- end
99
- end
100
- end
101
- true
102
- end
103
-
104
77
  end
105
78
  end
@@ -12,19 +12,12 @@ module DynamicController
12
12
  model = resource_class
13
13
  end
14
14
 
15
- empty_collection = model.where('1=2').page(params[:page])
16
-
17
- if search_query_valid?
18
- begin
19
- self.collection = model.search(ransack_query).result(distinct: true).page(params[:page])
20
- self.collection.all #Force load to handle exception here
21
- rescue ActiveRecord::StatementInvalid => ex
22
- Rails.logger.debug "Invalid search query: #{params[:q]} | Error: #{ex.message}"
23
- self.collection = empty_collection
24
- end
25
- else
26
- self.collection = empty_collection
27
- end
15
+ self.collection =
16
+ if search_query.is_a? String
17
+ model.nql(search_query, distinct: true).page(params[:page])
18
+ else
19
+ model.search(search_query).result(distinct: true).page(params[:page])
20
+ end
28
21
 
29
22
  Responder.new(self).index
30
23
  end
@@ -1,3 +1,3 @@
1
1
  module DynamicController
2
- VERSION = '0.0.10'
2
+ VERSION = '0.0.12'
3
3
  end
@@ -0,0 +1,8 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+
4
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
5
+ SimpleCov::Formatter::HTMLFormatter,
6
+ Coveralls::SimpleCov::Formatter
7
+ ]
8
+ SimpleCov.start
@@ -7,9 +7,6 @@
7
7
  # Ignore bundler config
8
8
  /.bundle
9
9
 
10
- # Ignore the default SQLite database.
11
- /db/*.sqlite3
12
-
13
10
  # Ignore all logfiles and tempfiles.
14
11
  /log/*.log
15
12
  /tmp
Binary file
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,4 @@
1
- # This file is copied to spec/ when you run 'rails generate rspec:install'
1
+ require 'coverage_helper'
2
2
  ENV["RAILS_ENV"] ||= 'test'
3
3
  require File.expand_path("../dummy/config/environment", __FILE__)
4
4
  require 'rspec/rails'
metadata CHANGED
@@ -1,128 +1,155 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic_controller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
5
- prerelease:
4
+ version: 0.0.12
6
5
  platform: ruby
7
6
  authors:
8
7
  - Gabriel Naiman
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-11-15 00:00:00.000000000 Z
11
+ date: 2023-06-28 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: ransack
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
19
+ version: '0.7'
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
29
- version: '0'
26
+ version: '0.7'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: kaminari
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ~>
36
32
  - !ruby/object:Gem::Version
37
- version: '0'
33
+ version: '0.13'
38
34
  type: :runtime
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: '0'
40
+ version: '0.13'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: nql
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - '='
45
+ - - ~>
52
46
  - !ruby/object:Gem::Version
53
- version: 0.0.5
47
+ version: '0.1'
54
48
  type: :runtime
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: 0.0.5
54
+ version: '0.1'
62
55
  - !ruby/object:Gem::Dependency
63
- name: rails
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
64
71
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
72
  requirements:
67
- - - ! '>='
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '11.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '11.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
68
88
  - !ruby/object:Gem::Version
69
89
  version: '0'
70
90
  type: :development
71
91
  prerelease: false
72
92
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
93
  requirements:
75
- - - ! '>='
94
+ - - '>='
76
95
  - !ruby/object:Gem::Version
77
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rails
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: '3.2'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '3.2'
78
111
  - !ruby/object:Gem::Dependency
79
112
  name: sqlite3
80
113
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
114
  requirements:
83
- - - ! '>='
115
+ - - ~>
84
116
  - !ruby/object:Gem::Version
85
- version: '0'
117
+ version: 1.3.0
86
118
  type: :development
87
119
  prerelease: false
88
120
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
121
  requirements:
91
- - - ! '>='
122
+ - - ~>
92
123
  - !ruby/object:Gem::Version
93
- version: '0'
124
+ version: 1.3.0
94
125
  - !ruby/object:Gem::Dependency
95
126
  name: rspec-rails
96
127
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
128
  requirements:
99
- - - ! '>='
129
+ - - ~>
100
130
  - !ruby/object:Gem::Version
101
- version: '0'
131
+ version: '2.12'
102
132
  type: :development
103
133
  prerelease: false
104
134
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
135
  requirements:
107
- - - ! '>='
136
+ - - ~>
108
137
  - !ruby/object:Gem::Version
109
- version: '0'
138
+ version: '2.12'
110
139
  - !ruby/object:Gem::Dependency
111
140
  name: factory_girl_rails
112
141
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
142
  requirements:
115
- - - ! '>='
143
+ - - ~>
116
144
  - !ruby/object:Gem::Version
117
- version: '0'
145
+ version: '3.4'
118
146
  type: :development
119
147
  prerelease: false
120
148
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
149
  requirements:
123
- - - ! '>='
150
+ - - ~>
124
151
  - !ruby/object:Gem::Version
125
- version: '0'
152
+ version: '3.4'
126
153
  description: Simple way to add CRUD actions into Rails controllers
127
154
  email:
128
155
  - gabynaiman@gmail.com
@@ -130,7 +157,11 @@ executables: []
130
157
  extensions: []
131
158
  extra_rdoc_files: []
132
159
  files:
160
+ - .coveralls.yml
133
161
  - .gitignore
162
+ - .ruby-gemset
163
+ - .ruby-version
164
+ - .travis.yml
134
165
  - Gemfile
135
166
  - README.md
136
167
  - Rakefile
@@ -153,6 +184,7 @@ files:
153
184
  - spec/controllers/redefined_responders_json_spec.rb
154
185
  - spec/controllers/two_level_nested_crud_actions_html_spec.rb
155
186
  - spec/controllers/two_level_nested_crud_actions_json_spec.rb
187
+ - spec/coverage_helper.rb
156
188
  - spec/custom_responder_format_spec.rb
157
189
  - spec/dummy/.gitignore
158
190
  - spec/dummy/Gemfile
@@ -217,6 +249,7 @@ files:
217
249
  - spec/dummy/db/migrate/20120929185302_create_streets.rb
218
250
  - spec/dummy/db/schema.rb
219
251
  - spec/dummy/db/seeds.rb
252
+ - spec/dummy/db/test.sqlite3
220
253
  - spec/dummy/doc/README_FOR_APP
221
254
  - spec/dummy/lib/assets/.gitkeep
222
255
  - spec/dummy/lib/tasks/.gitkeep
@@ -236,32 +269,24 @@ files:
236
269
  - spec/spec_helper.rb
237
270
  homepage: https://github.com/gabynaiman/dynamic_controller
238
271
  licenses: []
272
+ metadata: {}
239
273
  post_install_message:
240
274
  rdoc_options: []
241
275
  require_paths:
242
276
  - lib
243
277
  required_ruby_version: !ruby/object:Gem::Requirement
244
- none: false
245
278
  requirements:
246
- - - ! '>='
279
+ - - '>='
247
280
  - !ruby/object:Gem::Version
248
281
  version: '0'
249
- segments:
250
- - 0
251
- hash: 925622353
252
282
  required_rubygems_version: !ruby/object:Gem::Requirement
253
- none: false
254
283
  requirements:
255
- - - ! '>='
284
+ - - '>='
256
285
  - !ruby/object:Gem::Version
257
286
  version: '0'
258
- segments:
259
- - 0
260
- hash: 925622353
261
287
  requirements: []
262
- rubyforge_project:
263
- rubygems_version: 1.8.24
288
+ rubygems_version: 3.0.9
264
289
  signing_key:
265
- specification_version: 3
290
+ specification_version: 4
266
291
  summary: Simple way to add CRUD actions into Rails controllers
267
292
  test_files: []