toqua 0.1.0 → 0.1.1

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
- SHA1:
3
- metadata.gz: 43a5f057196fff4c8cd5b4b182eae2e1f53ea7b7
4
- data.tar.gz: db0835906e1e11b74eec8dda63519326684be04a
2
+ SHA256:
3
+ metadata.gz: 916b22b6028606a1246d9db1e16ac9503d1342828b58abd78e0a49a0c461327e
4
+ data.tar.gz: a45688b8586ccf47e9d8add6001b66352f1d3ebf4262e6c20830af642de55f19
5
5
  SHA512:
6
- metadata.gz: a2beeb545bf067166984712a900ecbce55e4ece2828bb844b4aab65f27950990856d4f87e53737522613f0ae1ef2f6d6155ac9868a7662ee9e219071f5784e53
7
- data.tar.gz: bd3b513750b11822c272e037be436126f9c9a209a2fd7821680fb3ce7d138c22b71aefca3253c6e8674a22d018fcdae5aec66e7a30d864c7e42a3fa22355e9a0
6
+ metadata.gz: 8ff22a518706c525abc96a1e6fd0f943b81d411b6776fbf7eff4f60ed7096c604bc9a207984c890601c381f534de94e961851d7a227f097e88ace9fa53701b80
7
+ data.tar.gz: 9d1ca894baea9d61532e316a310cfbbd51bf60c374c0f998cc5720567b054994ae95d3d4d532d56b618796ae9cf36a6040f5b7545bbd8e264d66b627935f7bc7
data/README.md CHANGED
@@ -132,7 +132,7 @@ Finally, the method `paginated?` available in both the controller and the views
132
132
 
133
133
  ### Search
134
134
 
135
- Small utility to help in the implementation of searching, using [Doure](https://github.com/rogercampos/doure) as a way to filter an AR model. Given that you have a model with filters defined, ex:
135
+ Small utility to help in the implementation of searching, using [Doure](https://github.com/rogercampos/doure) as a way to filter an AR model. You'll also need to include [recursive struct](https://github.com/aetherknight/recursive-open-struct) as a dependency to use search. Given that you have a model with filters defined, ex:
136
136
 
137
137
  ```ruby
138
138
  class Post < ApplicationRecord
@@ -193,6 +193,7 @@ def default_search_params
193
193
  end
194
194
  ```
195
195
 
196
+ As a final note, remember to take care of properly sanitize the input of your search criteria to avoid unintended usage, using TransformParams as seen before or by any other means. Toqua doesn't apply any sanitization by default, since the values that may come from the view can vary between use cases (strings, arrays, hashes, etc.).
196
197
 
197
198
 
198
199
  ### Sorting
@@ -1,3 +1,5 @@
1
+ require 'recursive-open-struct'
2
+
1
3
  module Toqua
2
4
  module Search
3
5
  extend ActiveSupport::Concern
@@ -8,7 +10,7 @@ module Toqua
8
10
  end
9
11
 
10
12
  def search_params
11
- params[:q].permit!
13
+ params[:q].permit! if params[:q]
12
14
  (params[:q] || {}).to_h.reverse_merge(default_search_params)
13
15
  end
14
16
 
@@ -18,7 +20,7 @@ module Toqua
18
20
 
19
21
  def search_object
20
22
  @search_object ||= begin
21
- Class.new(Hashie::Mash) do
23
+ Class.new(RecursiveOpenStruct) do
22
24
  extend ActiveModel::Naming
23
25
 
24
26
  def self.model_name
@@ -11,6 +11,7 @@ module Toqua
11
11
  attr_name, direction = params[:s].to_s.split("+").map(&:strip)
12
12
  raise "You must provide an attribute to sort by" unless attr_name
13
13
  raise "You must provide a direction" unless direction
14
+
14
15
  direction.downcase!
15
16
  raise "Direction must be ASC or DESC" unless ["asc", "desc"].include?(direction)
16
17
 
@@ -1,3 +1,3 @@
1
1
  module Toqua
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -30,4 +30,5 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency "minitest-rails"
31
31
  spec.add_development_dependency "sqlite3"
32
32
  spec.add_development_dependency "order_query", ">= 0.3.4"
33
+ spec.add_development_dependency "recursive-open-struct"
33
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toqua
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roger Campos
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-24 00:00:00.000000000 Z
11
+ date: 2018-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: 0.3.4
139
+ - !ruby/object:Gem::Dependency
140
+ name: recursive-open-struct
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
139
153
  description: Collection of small utilities for controllers in rails applications
140
154
  email:
141
155
  - roger@rogercampos.com
@@ -178,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
192
  version: '0'
179
193
  requirements: []
180
194
  rubyforge_project:
181
- rubygems_version: 2.5.2
195
+ rubygems_version: 2.7.3
182
196
  signing_key:
183
197
  specification_version: 4
184
198
  summary: Collection of small utilities for controllers in rails applications