array_enum 1.4.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci-on-merge.yml +3 -3
- data/.github/workflows/ci.yml +6 -4
- data/.gitignore +2 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +30 -18
- data/array_enum.gemspec +23 -24
- data/lib/array_enum/version.rb +1 -1
- data/lib/array_enum.rb +9 -9
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa2a0e8f11b84fd107a5584e35661f3de42773fd4ff66891357007b0e40aab5f
|
4
|
+
data.tar.gz: d556a1dc708b23138e6d42b64add098b28ab76c838b1fbab501f0bd4411f8cde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc0ccf9ba1d8b104591b58bce03af29e6738c25e1fcadd5fee4d78293b614be5a289678f65a366843d94e5c234aeda43766e57da58909699f923ce9c45cb6891
|
7
|
+
data.tar.gz: 836ef949dd08e9729b51f0fa634dc7d5672fc3055f0c5cbae3bc61a0670c7fcd439ccab6db7321f825c482d8403a78bfe78730552d800dd412b19863d778ea2f
|
@@ -10,7 +10,7 @@ jobs:
|
|
10
10
|
runs-on: ubuntu-latest
|
11
11
|
strategy:
|
12
12
|
matrix:
|
13
|
-
ruby-version: [
|
13
|
+
ruby-version: [3.0, 3.1, 3.3]
|
14
14
|
|
15
15
|
services:
|
16
16
|
postgres:
|
@@ -40,10 +40,10 @@ jobs:
|
|
40
40
|
psql -c 'create database "array_enum_test";'
|
41
41
|
|
42
42
|
- name: Checkout code
|
43
|
-
uses: actions/checkout@
|
43
|
+
uses: actions/checkout@v4.1.1
|
44
44
|
|
45
45
|
- name : Ruby Setup
|
46
|
-
uses: ruby/setup-ruby@v1
|
46
|
+
uses: ruby/setup-ruby@v1.173.0
|
47
47
|
with:
|
48
48
|
ruby-version: ${{ matrix.ruby-version }}
|
49
49
|
bundler-cache: true
|
data/.github/workflows/ci.yml
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
name: CI
|
2
2
|
|
3
|
-
on:
|
3
|
+
on:
|
4
|
+
- pull_request
|
5
|
+
- push
|
4
6
|
|
5
7
|
jobs:
|
6
8
|
test:
|
7
9
|
runs-on: ubuntu-latest
|
8
10
|
strategy:
|
9
11
|
matrix:
|
10
|
-
ruby-version: [
|
12
|
+
ruby-version: [3.0, 3.1, 3.3]
|
11
13
|
|
12
14
|
services:
|
13
15
|
postgres:
|
@@ -37,10 +39,10 @@ jobs:
|
|
37
39
|
psql -c 'create database "array_enum_test";'
|
38
40
|
|
39
41
|
- name: Checkout code
|
40
|
-
uses: actions/checkout@
|
42
|
+
uses: actions/checkout@v4.1.1
|
41
43
|
|
42
44
|
- name : Ruby Setup
|
43
|
-
uses: ruby/setup-ruby@v1
|
45
|
+
uses: ruby/setup-ruby@v1.173.0
|
44
46
|
with:
|
45
47
|
ruby-version: ${{ matrix.ruby-version }}
|
46
48
|
bundler-cache: true
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,32 +1,44 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
array_enum (1.
|
4
|
+
array_enum (1.6.0)
|
5
5
|
activemodel
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (
|
11
|
-
activesupport (=
|
12
|
-
activerecord (
|
13
|
-
activemodel (=
|
14
|
-
activesupport (=
|
15
|
-
|
16
|
-
|
10
|
+
activemodel (7.2.0)
|
11
|
+
activesupport (= 7.2.0)
|
12
|
+
activerecord (7.2.0)
|
13
|
+
activemodel (= 7.2.0)
|
14
|
+
activesupport (= 7.2.0)
|
15
|
+
timeout (>= 0.4.0)
|
16
|
+
activesupport (7.2.0)
|
17
|
+
base64
|
18
|
+
bigdecimal
|
19
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
20
|
+
connection_pool (>= 2.2.5)
|
21
|
+
drb
|
17
22
|
i18n (>= 1.6, < 2)
|
23
|
+
logger (>= 1.4.2)
|
18
24
|
minitest (>= 5.1)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
25
|
+
securerandom (>= 0.3)
|
26
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
27
|
+
base64 (0.2.0)
|
28
|
+
bigdecimal (3.1.8)
|
29
|
+
concurrent-ruby (1.3.4)
|
30
|
+
connection_pool (2.4.1)
|
31
|
+
drb (2.2.1)
|
32
|
+
i18n (1.14.5)
|
23
33
|
concurrent-ruby (~> 1.0)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
34
|
+
logger (1.6.0)
|
35
|
+
minitest (5.25.1)
|
36
|
+
pg (1.5.6)
|
37
|
+
rake (13.2.0)
|
38
|
+
securerandom (0.3.1)
|
39
|
+
timeout (0.4.1)
|
40
|
+
tzinfo (2.0.6)
|
28
41
|
concurrent-ruby (~> 1.0)
|
29
|
-
zeitwerk (2.4.2)
|
30
42
|
|
31
43
|
PLATFORMS
|
32
44
|
ruby
|
@@ -40,4 +52,4 @@ DEPENDENCIES
|
|
40
52
|
rake (>= 10.0)
|
41
53
|
|
42
54
|
BUNDLED WITH
|
43
|
-
2.
|
55
|
+
2.5.6
|
data/array_enum.gemspec
CHANGED
@@ -1,45 +1,44 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
3
|
+
require 'array_enum/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
6
|
+
spec.name = 'array_enum'
|
8
7
|
spec.version = ArrayEnum::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
8
|
+
spec.authors = ['Wojciech Wnętrzak']
|
9
|
+
spec.email = ['w.wnetrzak@gmail.com', 'eng@freeletics.com']
|
11
10
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
11
|
+
spec.summary = 'String to integer mapping for PostgreSQL array columns.'
|
12
|
+
spec.description = 'Extension for ActiveRecord that adds support for PostgreSQL array columns, mapping string values to integers.'
|
13
|
+
spec.homepage = 'https://github.com/freeletics/array_enum'
|
14
|
+
spec.license = 'MIT'
|
16
15
|
|
17
16
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
17
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
18
|
if spec.respond_to?(:metadata)
|
20
|
-
spec.metadata[
|
21
|
-
spec.metadata[
|
19
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
20
|
+
spec.metadata['source_code_uri'] = 'https://github.com/freeletics/array_enum'
|
22
21
|
else
|
23
|
-
raise
|
24
|
-
|
22
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
23
|
+
'public gem pushes.'
|
25
24
|
end
|
26
25
|
|
27
26
|
# Specify which files should be added to the gem when it is released.
|
28
27
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
29
|
-
spec.files
|
28
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
30
29
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
31
30
|
end
|
32
|
-
spec.bindir =
|
31
|
+
spec.bindir = 'exe'
|
33
32
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
34
|
-
spec.require_paths = [
|
33
|
+
spec.require_paths = ['lib']
|
35
34
|
|
36
|
-
spec.required_ruby_version =
|
35
|
+
spec.required_ruby_version = '>= 3.0'
|
37
36
|
|
38
|
-
spec.add_dependency
|
37
|
+
spec.add_dependency 'activemodel'
|
39
38
|
|
40
|
-
spec.add_development_dependency
|
41
|
-
spec.add_development_dependency
|
42
|
-
spec.add_development_dependency
|
43
|
-
spec.add_development_dependency
|
44
|
-
spec.add_development_dependency
|
39
|
+
spec.add_development_dependency 'activerecord'
|
40
|
+
spec.add_development_dependency 'bundler', '>= 1.17'
|
41
|
+
spec.add_development_dependency 'minitest', '>= 5.0'
|
42
|
+
spec.add_development_dependency 'pg'
|
43
|
+
spec.add_development_dependency 'rake', '>= 10.0'
|
45
44
|
end
|
data/lib/array_enum/version.rb
CHANGED
data/lib/array_enum.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
require 'array_enum/version'
|
2
|
+
require 'array_enum/subset_validator'
|
3
|
+
require 'array_enum/railtie' if defined?(Rails::Railtie)
|
4
|
+
require 'active_support/hash_with_indifferent_access'
|
5
|
+
require 'active_support/core_ext/string/inflections'
|
6
6
|
|
7
7
|
module ArrayEnum
|
8
|
-
MISSING_VALUE_MESSAGE =
|
8
|
+
MISSING_VALUE_MESSAGE = '%<value>s is not a valid value for %<attr>s'.freeze
|
9
9
|
private_constant :MISSING_VALUE_MESSAGE
|
10
10
|
|
11
11
|
def array_enum(definitions)
|
@@ -24,9 +24,9 @@ module ArrayEnum
|
|
24
24
|
}.each do |method_name, comparison_operator|
|
25
25
|
define_singleton_method(method_name.to_sym) do |values|
|
26
26
|
db_values = Array(values).map do |value|
|
27
|
-
mapping_hash[value] || raise(ArgumentError, MISSING_VALUE_MESSAGE
|
27
|
+
mapping_hash[value] || raise(ArgumentError, format(MISSING_VALUE_MESSAGE, value: value, attr: attr_name))
|
28
28
|
end
|
29
|
-
where("#{attr_name} #{comparison_operator} ARRAY[:db_values]", db_values: db_values)
|
29
|
+
where("#{table_name}.#{attr_name} #{comparison_operator} ARRAY[:db_values]::integer[]", db_values: db_values)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -36,7 +36,7 @@ module ArrayEnum
|
|
36
36
|
|
37
37
|
define_method("#{attr_name}=".to_sym) do |values|
|
38
38
|
self[attr_symbol] = Array(values).map do |value|
|
39
|
-
mapping_hash[value] || raise(ArgumentError, MISSING_VALUE_MESSAGE
|
39
|
+
mapping_hash[value] || raise(ArgumentError, format(MISSING_VALUE_MESSAGE, value: value, attr: attr_name))
|
40
40
|
end.uniq
|
41
41
|
end
|
42
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: array_enum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wojciech Wnętrzak
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -39,61 +39,61 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '1.17'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '1.17'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: minitest
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '5.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '5.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: pg
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '10.0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '10.0'
|
97
97
|
description: Extension for ActiveRecord that adds support for PostgreSQL array columns,
|
98
98
|
mapping string values to integers.
|
99
99
|
email:
|
@@ -132,14 +132,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
132
132
|
requirements:
|
133
133
|
- - ">="
|
134
134
|
- !ruby/object:Gem::Version
|
135
|
-
version: '
|
135
|
+
version: '3.0'
|
136
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
137
|
requirements:
|
138
138
|
- - ">="
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
version: '0'
|
141
141
|
requirements: []
|
142
|
-
rubygems_version: 3.
|
142
|
+
rubygems_version: 3.5.3
|
143
143
|
signing_key:
|
144
144
|
specification_version: 4
|
145
145
|
summary: String to integer mapping for PostgreSQL array columns.
|