where_unless_blank 1.0.0 → 1.1.0

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
2
  SHA256:
3
- metadata.gz: d056cf2d1e1f1c590e473e7aa75d14b6d5d36636d58727a791792b2577ff14c6
4
- data.tar.gz: 27f749e795ce07ef6c0e8cd4afb45e12e8c629f53a05a9c30ffbbc5c27bb5ee6
3
+ metadata.gz: dacccda1ad0687f06402acfa2b749005118bded1288cb5951600beeee365a0fc
4
+ data.tar.gz: e59bb065d7e883e2347d7e0e60c8f50dde650c4eae6f4dc9dcf4c19936ae0544
5
5
  SHA512:
6
- metadata.gz: b57c37a0c6185b97b6b1b322c77970111086231d25a682f5e380dd4b5a3acfb54d9a873d46ed1adc9e6c47224afd46486bed780d58290c3034c69ee46c59cdee
7
- data.tar.gz: 6dd1fa7b71fc3fa11f676925301767ec78cc276e3a6325b2a4e0f2af3dbd7f9cc4164635b279ea8e0b7cc4e32a8586bc5f7bb8aaa5f66dd8c1c9da3cbb6c0722
6
+ metadata.gz: 027b918e0e3b766174ba3304a2fc59417966af4411adbc5ee3c24547db6e2901c53e11ac69064ddd3ed32495d1021686468c05b6e8b99628f0be4f7f3d5f32ce
7
+ data.tar.gz: 01f45b1170b512195d4672e5639ef9042d543c42916e8c7259df3d51885feef54e76500062ad89d8cb6d36e11a92a21ab1529e2006b7f25aa22313a883c871b0
@@ -0,0 +1,29 @@
1
+ name: Ruby Gem
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - '*'
7
+
8
+ jobs:
9
+ build:
10
+ name: Build + Publish
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - uses: actions/checkout@master
15
+ - name: Set up Ruby 2.6
16
+ uses: actions/setup-ruby@v1
17
+ with:
18
+ version: 2.6.x
19
+
20
+ - name: Publish to RubyGems
21
+ run: |
22
+ mkdir -p $HOME/.gem
23
+ touch $HOME/.gem/credentials
24
+ chmod 0600 $HOME/.gem/credentials
25
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
26
+ gem build *.gemspec
27
+ gem push *.gem
28
+ env:
29
+ GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
data/.gitignore CHANGED
@@ -46,4 +46,4 @@ bower.json
46
46
 
47
47
  # Ignore node_modules
48
48
  node_modules/
49
-
49
+ pkg/
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # WhereUnlessBlank
2
2
 
3
- The default behavior of "where" when querrying for a null value is include the statment and return rows with null value.
3
+ The behavior of "where" when querrying for a null value is include the statment and return rows with null value.
4
4
 
5
- This gem removes statements with null/blank values from query.
5
+ This gem creates a simple way to remove statements with null/blank values from query.
6
6
 
7
7
  Very usefull for search forms avoiding you to worry about unfilled fields.
8
8
 
@@ -33,9 +33,17 @@ Person.ilike_unless_blank(name: params[:name], surname: params[:surname])
33
33
  Person.like_unless_blank(name: params[:name], surname: params[:surname])
34
34
  ```
35
35
 
36
+ If u like short names u can use:
37
+
38
+ `wub` or `where_ub` for `where_unless_blank`
39
+
40
+ `iub` or `ilike_ub` for `ilike_unless_blank`
41
+
42
+ `lub` or `like_ub` for `like_unless_blank`
43
+
36
44
  If all params are blank it will behaivor like `all` method.
37
45
 
38
46
 
39
47
  ## Contributing
40
48
 
41
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/where_unless_blank.
49
+ Bug reports and pull requests are welcome on GitHub at https://github.com/platbr/where_unless_blank.
@@ -4,20 +4,34 @@ require "where_unless_blank/engine"
4
4
  module WhereUnlessBlank
5
5
  extend ActiveSupport::Concern
6
6
  included do
7
+
7
8
  def self.where_unless_blank(opts = :chain)
8
9
  opts.delete_if {|k,v| v.blank? } if opts.kind_of?(Hash)
9
10
  where(opts)
10
11
  end
12
+
11
13
  def self.ilike_unless_blank(opts = :chain)
12
14
  operator_unless_blank(opts, 'ilike', '%', '%')
13
15
  end
16
+
14
17
  def self.like_unless_blank(opts = :chain)
15
18
  operator_unless_blank(opts, 'like', '%', '%')
16
19
  end
20
+
17
21
  def self.operator_unless_blank(opts, operator = '=', prefix = '', sufix = '')
18
22
  where(WhereUnlessBlank.build_opts(opts, operator, prefix, sufix))
19
23
  end
24
+
25
+ class <<self
26
+ alias_method :wub, :where_unless_blank
27
+ alias_method :where_ub, :where_unless_blank
28
+ alias_method :iub, :ilike_unless_blank
29
+ alias_method :ilike_ub, :ilike_unless_blank
30
+ alias_method :lub, :like_unless_blank
31
+ alias_method :like_ub, :like_unless_blank
32
+ end
20
33
  end
34
+
21
35
  def self.build_opts(opts, operator = '=', prefix='', sufix='')
22
36
  opts.delete_if {|k,v| v.blank? } if opts.kind_of?(Hash)
23
37
  [opts.map{|k,v| "#{k} #{operator} ?"}.join(' AND '), opts.values.map{|v| "#{prefix}#{v}#{sufix}"}].flatten unless opts.blank?
@@ -1,3 +1,3 @@
1
1
  module WhereUnlessBlank
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -9,9 +9,10 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Wagner Caixeta"]
10
10
  spec.email = ["wagner.caixeta@al.go.leg.br"]
11
11
 
12
- spec.summary = %q{This gem removes statements with null/blank values from query.}
12
+ spec.summary = %q{This gem creates a simple way to remove statements with null/blank values from query.}
13
13
  spec.description = %q{
14
- This gem removes statements with null/blank values from query.
14
+ The behavior of "where" when querrying for a null value is include the statment and return rows with null value.
15
+ This gem creates a simple way to remove statements with null/blank values from query.
15
16
  Very usefull for search forms avoiding you to worry about unfilled fields.
16
17
  }
17
18
  spec.homepage = "https://github.com/platbr/where_unless_blank"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: where_unless_blank
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wagner Caixeta
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-27 00:00:00.000000000 Z
11
+ date: 2019-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,15 +52,17 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
- description: "\n This gem removes statements with null/blank values from query.\n
56
- \ Very usefull for search forms avoiding you to worry about unfilled fields.\n
57
- \ "
55
+ description: "\n The behavior of \"where\" when querrying for a null value is include
56
+ the statment and return rows with null value.\n This gem creates a simple way
57
+ to remove statements with null/blank values from query.\n Very usefull for search
58
+ forms avoiding you to worry about unfilled fields.\n "
58
59
  email:
59
60
  - wagner.caixeta@al.go.leg.br
60
61
  executables: []
61
62
  extensions: []
62
63
  extra_rdoc_files: []
63
64
  files:
65
+ - ".github/workflows/gempush.yml"
64
66
  - ".gitignore"
65
67
  - Gemfile
66
68
  - LICENSE
@@ -90,8 +92,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
92
  - !ruby/object:Gem::Version
91
93
  version: '0'
92
94
  requirements: []
93
- rubygems_version: 3.0.1
95
+ rubygems_version: 3.0.3
94
96
  signing_key:
95
97
  specification_version: 4
96
- summary: This gem removes statements with null/blank values from query.
98
+ summary: This gem creates a simple way to remove statements with null/blank values
99
+ from query.
97
100
  test_files: []