where_any 0.1.1 → 0.1.2

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: 9757fc6639c9875f9ab31bcae335740807d9c9f63fe0765dea00b2775080efa3
4
- data.tar.gz: 94089af17bba4a0b175b9cf23ce6d033eae826aa6c74f6f8086a891a3ed3359a
3
+ metadata.gz: 2660b55e57253d50a6351dfdefc6d71c799d16f3526dd08eda9a47b5673f6370
4
+ data.tar.gz: 68c89d9bb75abf508d7ea9acb17651533787c795d1db4342cfabae5fdbe74a88
5
5
  SHA512:
6
- metadata.gz: 36d5778b3983606cda22f424715bfbfc324619fe275730571274a26aef99459cbffefa8994784ac1f5b97be1537cedcf357aae216eb5d0256fd895cc65950c1d
7
- data.tar.gz: a5618216ea0d08d3e6a108bc3f8a78868ab6ecde769e7a32ee2d54503d92f3179dd2200cb1d17ab2857c79289296f1154ea5d8eeca9746e83b5df562ba880242
6
+ metadata.gz: 9fe3bed82bfed43c3e564651883fe1bee31f863e38cb3a3e76ebb3d62ff6146c9c91add1dfc707437ecfcd4dcbba7db590f1355c8ec21469d4bcbd39f864b398
7
+ data.tar.gz: e7e87fde492f824c7d4d4778beb2ee85cc8faf262cf539e68a1e0557875675162ce3429a4caf7afef7c313ca448d3d335d1c53e6d225036fea650ed415c117af
@@ -10,7 +10,7 @@ jobs:
10
10
  - name: Set up Ruby
11
11
  uses: ruby/setup-ruby@v1
12
12
  with:
13
- ruby-version: 3.0.1
13
+ ruby-version: 3.1.2
14
14
  bundler-cache: true
15
15
  - name: Rubocop
16
16
  run: bin/rubocop
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ /Gemfile.lock
9
10
 
10
11
  # rspec failure tracking
11
12
  .rspec_status
data/.rubocop.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  require:
2
+ - rubocop-performance
2
3
  - rubocop-rspec
3
4
 
4
5
  AllCops:
@@ -6,6 +7,9 @@ AllCops:
6
7
  NewCops: enable
7
8
  SuggestExtensions: false
8
9
 
10
+ Gemspec/DevelopmentDependencies:
11
+ EnforcedStyle: gemspec
12
+
9
13
  Layout/LineLength:
10
14
  Max: 120
11
15
 
data/Gemfile CHANGED
@@ -4,8 +4,3 @@ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in where_any_of.gemspec
6
6
  gemspec
7
-
8
- gem 'rake', '~> 13.0'
9
- gem 'rspec', '~> 3.0'
10
- gem 'rubocop', '~> 1.23'
11
- gem 'rubocop-rspec', '~> 2.6'
data/bin/rspec CHANGED
@@ -15,7 +15,7 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
15
15
  bundle_binstub = File.expand_path('bundle', __dir__)
16
16
 
17
17
  if File.file?(bundle_binstub)
18
- if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
18
+ if File.read(bundle_binstub, 300).include?('This file was generated by Bundler')
19
19
  load(bundle_binstub)
20
20
  else
21
21
  abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
data/bin/rubocop CHANGED
@@ -15,7 +15,7 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
15
15
  bundle_binstub = File.expand_path('bundle', __dir__)
16
16
 
17
17
  if File.file?(bundle_binstub)
18
- if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
18
+ if File.read(bundle_binstub, 300).include?('This file was generated by Bundler')
19
19
  load(bundle_binstub)
20
20
  else
21
21
  abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WhereAny
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
data/lib/where_any.rb CHANGED
@@ -42,10 +42,18 @@ module WhereAny
42
42
  def where_any(column, values)
43
43
  return none if values.blank?
44
44
 
45
+ if (includes_null = values.include?(nil))
46
+ values = values.compact
47
+ return where(column => nil) if values.empty?
48
+ end
49
+
45
50
  arel_column = arel_table[column]
46
51
  any_of_values = Arel::Nodes::NamedFunction.new('ANY', [bind_array(column, values)])
47
52
 
48
- where(arel_column.eq(any_of_values))
53
+ scope = where(arel_column.eq(any_of_values))
54
+ scope = scope.or(where(column => nil)) if includes_null
55
+
56
+ scope
49
57
  end
50
58
 
51
59
  # @param column [String, Symbol]
@@ -54,9 +62,17 @@ module WhereAny
54
62
  def where_none(column, values)
55
63
  return all if values.blank?
56
64
 
65
+ if (includes_null = values.include?(nil))
66
+ values = values.compact
67
+ return where.not(column => nil) if values.empty?
68
+ end
69
+
57
70
  arel_column = arel_table[column]
58
71
  all_of_values = Arel::Nodes::NamedFunction.new('ALL', [bind_array(column, values)])
59
72
 
60
- where(arel_column.not_eq(all_of_values))
73
+ scope = where(arel_column.not_eq(all_of_values))
74
+ scope = scope.where.not(column => nil) if includes_null
75
+
76
+ scope
61
77
  end
62
78
  end
data/where_any.gemspec CHANGED
@@ -31,4 +31,10 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  # Uncomment to register a new dependency of your gem
33
33
  spec.add_dependency 'activerecord', '>= 5.2.0', '< 8'
34
+
35
+ spec.add_development_dependency 'rake', '~> 13.0'
36
+ spec.add_development_dependency 'rspec', '~> 3.10'
37
+ spec.add_development_dependency 'rubocop', '~> 1.23'
38
+ spec.add_development_dependency 'rubocop-performance', '~> 1.19'
39
+ spec.add_development_dependency 'rubocop-rspec', '~> 2.6'
34
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: where_any
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minty Fresh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-12 00:00:00.000000000 Z
11
+ date: 2023-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -30,6 +30,76 @@ dependencies:
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '8'
33
+ - !ruby/object:Gem::Dependency
34
+ name: rake
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '13.0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '13.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.10'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '3.10'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rubocop
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.23'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '1.23'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rubocop-performance
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '1.19'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '1.19'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rubocop-rspec
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '2.6'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '2.6'
33
103
  description: Postgres ANY() and ALL() expressions for ActiveRecord.
34
104
  email:
35
105
  - 7896757+mintyfresh@users.noreply.github.com
@@ -42,7 +112,6 @@ files:
42
112
  - ".rspec"
43
113
  - ".rubocop.yml"
44
114
  - Gemfile
45
- - Gemfile.lock
46
115
  - README.md
47
116
  - Rakefile
48
117
  - bin/console
@@ -74,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
143
  - !ruby/object:Gem::Version
75
144
  version: '0'
76
145
  requirements: []
77
- rubygems_version: 3.3.7
146
+ rubygems_version: 3.4.13
78
147
  signing_key:
79
148
  specification_version: 4
80
149
  summary: Postgres ANY() and ALL() expressions for ActiveRecord.
data/Gemfile.lock DELETED
@@ -1,75 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- where_any (0.1.1)
5
- activerecord (>= 5.2.0, < 8)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activemodel (7.0.4)
11
- activesupport (= 7.0.4)
12
- activerecord (7.0.4)
13
- activemodel (= 7.0.4)
14
- activesupport (= 7.0.4)
15
- activesupport (7.0.4)
16
- concurrent-ruby (~> 1.0, >= 1.0.2)
17
- i18n (>= 1.6, < 2)
18
- minitest (>= 5.1)
19
- tzinfo (~> 2.0)
20
- ast (2.4.2)
21
- concurrent-ruby (1.1.10)
22
- diff-lcs (1.4.4)
23
- i18n (1.12.0)
24
- concurrent-ruby (~> 1.0)
25
- minitest (5.16.3)
26
- parallel (1.21.0)
27
- parser (3.0.3.2)
28
- ast (~> 2.4.1)
29
- rainbow (3.0.0)
30
- rake (13.0.6)
31
- regexp_parser (2.2.0)
32
- rexml (3.2.5)
33
- rspec (3.10.0)
34
- rspec-core (~> 3.10.0)
35
- rspec-expectations (~> 3.10.0)
36
- rspec-mocks (~> 3.10.0)
37
- rspec-core (3.10.1)
38
- rspec-support (~> 3.10.0)
39
- rspec-expectations (3.10.1)
40
- diff-lcs (>= 1.2.0, < 2.0)
41
- rspec-support (~> 3.10.0)
42
- rspec-mocks (3.10.2)
43
- diff-lcs (>= 1.2.0, < 2.0)
44
- rspec-support (~> 3.10.0)
45
- rspec-support (3.10.3)
46
- rubocop (1.23.0)
47
- parallel (~> 1.10)
48
- parser (>= 3.0.0.0)
49
- rainbow (>= 2.2.2, < 4.0)
50
- regexp_parser (>= 1.8, < 3.0)
51
- rexml
52
- rubocop-ast (>= 1.12.0, < 2.0)
53
- ruby-progressbar (~> 1.7)
54
- unicode-display_width (>= 1.4.0, < 3.0)
55
- rubocop-ast (1.15.0)
56
- parser (>= 3.0.1.1)
57
- rubocop-rspec (2.6.0)
58
- rubocop (~> 1.19)
59
- ruby-progressbar (1.11.0)
60
- tzinfo (2.0.5)
61
- concurrent-ruby (~> 1.0)
62
- unicode-display_width (2.1.0)
63
-
64
- PLATFORMS
65
- x86_64-linux
66
-
67
- DEPENDENCIES
68
- rake (~> 13.0)
69
- rspec (~> 3.0)
70
- rubocop (~> 1.23)
71
- rubocop-rspec (~> 2.6)
72
- where_any!
73
-
74
- BUNDLED WITH
75
- 2.2.17