where_any 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9757fc6639c9875f9ab31bcae335740807d9c9f63fe0765dea00b2775080efa3
4
- data.tar.gz: 94089af17bba4a0b175b9cf23ce6d033eae826aa6c74f6f8086a891a3ed3359a
3
+ metadata.gz: 930a0740bda2d6e5ac5e38698b3d531e4017bbf49a6fa794289fbcdbc5ac4854
4
+ data.tar.gz: 44d486df6091aa20df8c27fcf58d28aa056af842b0ec913f7e417c29a711185b
5
5
  SHA512:
6
- metadata.gz: 36d5778b3983606cda22f424715bfbfc324619fe275730571274a26aef99459cbffefa8994784ac1f5b97be1537cedcf357aae216eb5d0256fd895cc65950c1d
7
- data.tar.gz: a5618216ea0d08d3e6a108bc3f8a78868ab6ecde769e7a32ee2d54503d92f3179dd2200cb1d17ab2857c79289296f1154ea5d8eeca9746e83b5df562ba880242
6
+ metadata.gz: 7136ed58fff6cb369e9ed58011923994472107fd6e5d02143f728aaea5741652463cdd8c2749472bdb569543e776346712968eea7e5c41d4f04a9586f645af2f
7
+ data.tar.gz: 973436a1caee3b0f06e2ba4ee67f3d55dd58fb845c9561dc05d118f4f17b9c570aa22a8f9aed958f89ffbd25e2f314671a88005809b2e42f2f503935b2dfa471
@@ -1,18 +1,56 @@
1
1
  name: Ruby
2
2
 
3
- on: [push,pull_request]
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ branches:
9
+ - master
10
+
11
+ env:
12
+ RAILS_ENV: test
4
13
 
5
14
  jobs:
6
15
  build:
7
16
  runs-on: ubuntu-latest
17
+ strategy:
18
+ matrix:
19
+ ruby:
20
+ - 2.6.10
21
+ - 2.7.8
22
+ - 3.0.7
23
+ - 3.1.6
24
+ - 3.2.7
25
+ - 3.3.7
26
+ - 3.4.2
27
+ services:
28
+ postgres:
29
+ image: postgres:latest
30
+ env:
31
+ POSTGRES_USER: postgres
32
+ POSTGRES_PASSWORD: postgres
33
+ POSTGRES_DB: where_any_test
34
+ ports:
35
+ - 5432:5432
36
+ options: >-
37
+ --health-cmd pg_isready
38
+ --health-interval 10s
39
+ --health-timeout 5s
40
+ --health-retries 5
8
41
  steps:
9
- - uses: actions/checkout@v2
42
+ - uses: actions/checkout@v4
10
43
  - name: Set up Ruby
11
44
  uses: ruby/setup-ruby@v1
12
45
  with:
13
- ruby-version: 3.0.1
46
+ ruby-version: ${{ matrix.ruby }}
14
47
  bundler-cache: true
15
48
  - name: Rubocop
16
49
  run: bin/rubocop
17
50
  - name: RSpec
51
+ env:
52
+ PGHOST: localhost
53
+ PGPORT: 5432
54
+ PGUSER: postgres
55
+ PGPASSWORD: postgres
18
56
  run: bin/rspec
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,11 +1,15 @@
1
1
  require:
2
+ - rubocop-performance
2
3
  - rubocop-rspec
3
4
 
4
5
  AllCops:
5
- TargetRubyVersion: 2.5
6
+ TargetRubyVersion: 2.6
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
 
@@ -19,3 +23,9 @@ Style/StringLiterals:
19
23
  Style/StringLiteralsInInterpolation:
20
24
  Enabled: true
21
25
  EnforcedStyle: double_quotes
26
+
27
+ RSpec/InstanceVariable:
28
+ Enabled: false
29
+
30
+ RSpec/BeforeAfterAll:
31
+ Enabled: false
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/README.md CHANGED
@@ -135,7 +135,7 @@ https://www.postgresql.org/docs/current/functions-subquery.html#FUNCTIONS-SUBQUE
135
135
 
136
136
  ## Development
137
137
 
138
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
138
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. Be aware that the test suite requires that PostgreSQL is installed and running locally. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
139
139
 
140
140
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
141
141
 
data/Rakefile CHANGED
@@ -3,7 +3,14 @@
3
3
  require 'bundler/gem_tasks'
4
4
  require 'rspec/core/rake_task'
5
5
 
6
- RSpec::Core::RakeTask.new(:spec)
6
+ namespace :db do
7
+ task :prepare do
8
+ system('dropdb where_any_test --if-exists')
9
+ system('createdb where_any_test')
10
+ end
11
+ end
12
+
13
+ RSpec::Core::RakeTask.new(spec: 'db:prepare')
7
14
 
8
15
  require 'rubocop/rake_task'
9
16
 
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.
@@ -0,0 +1,8 @@
1
+ default: &default
2
+ adapter: postgresql
3
+ encoding: unicode
4
+ prepared_statements: true
5
+
6
+ test: &test
7
+ <<: *default
8
+ database: where_any_test
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WhereAny
4
- VERSION = '0.1.1'
4
+ VERSION = '0.2.0'
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
@@ -11,7 +11,8 @@ Gem::Specification.new do |spec|
11
11
  spec.summary = 'Postgres ANY() and ALL() expressions for ActiveRecord.'
12
12
  spec.description = spec.summary
13
13
  spec.homepage = 'https://github.com/thriver/where_any'
14
- spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
14
+
15
+ spec.required_ruby_version = '>= 2.6.0'
15
16
 
16
17
  spec.metadata['allowed_push_host'] = 'https://rubygems.org/'
17
18
  spec.metadata['rubygems_mfa_required'] = 'true'
@@ -30,5 +31,14 @@ Gem::Specification.new do |spec|
30
31
  spec.require_paths = ['lib']
31
32
 
32
33
  # Uncomment to register a new dependency of your gem
33
- spec.add_dependency 'activerecord', '>= 5.2.0', '< 8'
34
+ spec.add_dependency 'activerecord', '>= 5.2.0', '< 8.1'
35
+
36
+ spec.add_development_dependency 'concurrent-ruby'
37
+ spec.add_development_dependency 'pg', '~> 1.5'
38
+ spec.add_development_dependency 'psych', '~> 5'
39
+ spec.add_development_dependency 'rake', '~> 13.0'
40
+ spec.add_development_dependency 'rspec', '~> 3.10'
41
+ spec.add_development_dependency 'rubocop', '~> 1.50.2'
42
+ spec.add_development_dependency 'rubocop-performance', '~> 1.17.1'
43
+ spec.add_development_dependency 'rubocop-rspec', '~> 2.20.0'
34
44
  end
metadata CHANGED
@@ -1,14 +1,13 @@
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.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minty Fresh
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2022-12-12 00:00:00.000000000 Z
10
+ date: 2025-03-13 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activerecord
@@ -19,7 +18,7 @@ dependencies:
19
18
  version: 5.2.0
20
19
  - - "<"
21
20
  - !ruby/object:Gem::Version
22
- version: '8'
21
+ version: '8.1'
23
22
  type: :runtime
24
23
  prerelease: false
25
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +28,119 @@ dependencies:
29
28
  version: 5.2.0
30
29
  - - "<"
31
30
  - !ruby/object:Gem::Version
32
- version: '8'
31
+ version: '8.1'
32
+ - !ruby/object:Gem::Dependency
33
+ name: concurrent-ruby
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ type: :development
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: pg
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '1.5'
53
+ type: :development
54
+ prerelease: false
55
+ version_requirements: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '1.5'
60
+ - !ruby/object:Gem::Dependency
61
+ name: psych
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '5'
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '5'
74
+ - !ruby/object:Gem::Dependency
75
+ name: rake
76
+ requirement: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: '13.0'
81
+ type: :development
82
+ prerelease: false
83
+ version_requirements: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '13.0'
88
+ - !ruby/object:Gem::Dependency
89
+ name: rspec
90
+ requirement: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - "~>"
93
+ - !ruby/object:Gem::Version
94
+ version: '3.10'
95
+ type: :development
96
+ prerelease: false
97
+ version_requirements: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '3.10'
102
+ - !ruby/object:Gem::Dependency
103
+ name: rubocop
104
+ requirement: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - "~>"
107
+ - !ruby/object:Gem::Version
108
+ version: 1.50.2
109
+ type: :development
110
+ prerelease: false
111
+ version_requirements: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - "~>"
114
+ - !ruby/object:Gem::Version
115
+ version: 1.50.2
116
+ - !ruby/object:Gem::Dependency
117
+ name: rubocop-performance
118
+ requirement: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - "~>"
121
+ - !ruby/object:Gem::Version
122
+ version: 1.17.1
123
+ type: :development
124
+ prerelease: false
125
+ version_requirements: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: 1.17.1
130
+ - !ruby/object:Gem::Dependency
131
+ name: rubocop-rspec
132
+ requirement: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - "~>"
135
+ - !ruby/object:Gem::Version
136
+ version: 2.20.0
137
+ type: :development
138
+ prerelease: false
139
+ version_requirements: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - "~>"
142
+ - !ruby/object:Gem::Version
143
+ version: 2.20.0
33
144
  description: Postgres ANY() and ALL() expressions for ActiveRecord.
34
145
  email:
35
146
  - 7896757+mintyfresh@users.noreply.github.com
@@ -42,13 +153,13 @@ files:
42
153
  - ".rspec"
43
154
  - ".rubocop.yml"
44
155
  - Gemfile
45
- - Gemfile.lock
46
156
  - README.md
47
157
  - Rakefile
48
158
  - bin/console
49
159
  - bin/rspec
50
160
  - bin/rubocop
51
161
  - bin/setup
162
+ - config/database.yml
52
163
  - lib/where_any.rb
53
164
  - lib/where_any/version.rb
54
165
  - where_any.gemspec
@@ -59,7 +170,6 @@ metadata:
59
170
  rubygems_mfa_required: 'true'
60
171
  homepage_uri: https://github.com/thriver/where_any
61
172
  source_code_uri: https://github.com/thriver/where_any
62
- post_install_message:
63
173
  rdoc_options: []
64
174
  require_paths:
65
175
  - lib
@@ -67,15 +177,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
67
177
  requirements:
68
178
  - - ">="
69
179
  - !ruby/object:Gem::Version
70
- version: 2.5.0
180
+ version: 2.6.0
71
181
  required_rubygems_version: !ruby/object:Gem::Requirement
72
182
  requirements:
73
183
  - - ">="
74
184
  - !ruby/object:Gem::Version
75
185
  version: '0'
76
186
  requirements: []
77
- rubygems_version: 3.3.7
78
- signing_key:
187
+ rubygems_version: 3.6.5
79
188
  specification_version: 4
80
189
  summary: Postgres ANY() and ALL() expressions for ActiveRecord.
81
190
  test_files: []
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