active_flag 1.6.0 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/ci.yml +28 -0
- data/.gitignore +1 -0
- data/README.md +1 -1
- data/active_flag.gemspec +4 -1
- data/gemfiles/6.1.gemfile +5 -0
- data/gemfiles/7.2.gemfile +5 -0
- data/lib/active_flag/version.rb +1 -1
- data/lib/active_flag.rb +7 -12
- metadata +53 -15
- data/.travis.yml +0 -11
- data/gemfiles/5.0.gemfile +0 -12
- data/gemfiles/5.1.gemfile +0 -12
- data/gemfiles/5.2.gemfile +0 -12
- data/gemfiles/6.0.gemfile +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95bb29c60494f354cd2030f43a1661d8bf470761e6c72a55f36fa67bd58a6ca0
|
4
|
+
data.tar.gz: b21537f0466989d7ba6ec4e9dd1508a81a2965dc25dd70fcd7c18569f54b3cce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92731cf866d6be1d7165ce0ceea4cfccc60503933cc4d1a1b829e027e391fb778703c3b4c62290bbd49546315010208e896bfdab38b45b62eb2e0638d64bddf0
|
7
|
+
data.tar.gz: 6a44c95b29b5ed5f1c8c214ff6c2facc2c164b6bc48e219c3ca0f68c3e5e5fb9cd971a008e4bcd4b608d0ab4a6a158df07f7706b402a9eefffab0387fca9eb84
|
@@ -0,0 +1,28 @@
|
|
1
|
+
name: ci
|
2
|
+
on: [pull_request, push]
|
3
|
+
jobs:
|
4
|
+
test:
|
5
|
+
strategy:
|
6
|
+
fail-fast: false
|
7
|
+
matrix:
|
8
|
+
include:
|
9
|
+
- ruby: ruby-head
|
10
|
+
rails_version: '7.2'
|
11
|
+
- ruby: '3.3'
|
12
|
+
rails_version: '7.2'
|
13
|
+
- ruby: '3.2'
|
14
|
+
rails_version: '7.2'
|
15
|
+
- ruby: '3.1'
|
16
|
+
rails_version: '7.2'
|
17
|
+
- ruby: '3.1'
|
18
|
+
rails_version: '6.1'
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
env:
|
21
|
+
BUNDLE_GEMFILE: gemfiles/${{ matrix.rails_version }}.gemfile
|
22
|
+
steps:
|
23
|
+
- uses: actions/checkout@v4
|
24
|
+
- uses: ruby/setup-ruby@v1
|
25
|
+
with:
|
26
|
+
ruby-version: ${{ matrix.ruby }}
|
27
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
28
|
+
- run: bundle exec rake
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# ActiveFlag - Bit array for ActiveRecord
|
2
2
|
|
3
|
-
|
3
|
+
![Build Status](https://github.com/kenn/active_flag/actions/workflows/ci.yml/badge.svg)
|
4
4
|
|
5
5
|
Store up to 64 multiple flags ([bit array](https://en.wikipedia.org/wiki/Bit_array)) in a single integer column with ActiveRecord. From a UI standpoint, it can be used as a multi-select checkbox storage.
|
6
6
|
|
data/active_flag.gemspec
CHANGED
@@ -20,8 +20,11 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
22
|
spec.add_runtime_dependency 'activerecord', '>= 5'
|
23
|
+
spec.add_runtime_dependency 'logger'
|
24
|
+
spec.add_runtime_dependency 'mutex_m'
|
25
|
+
spec.add_runtime_dependency 'bigdecimal'
|
23
26
|
spec.add_development_dependency 'bundler'
|
24
27
|
spec.add_development_dependency 'rake'
|
25
28
|
spec.add_development_dependency 'minitest'
|
26
|
-
spec.add_development_dependency 'sqlite3'
|
29
|
+
spec.add_development_dependency 'sqlite3', '< 2'
|
27
30
|
end
|
data/lib/active_flag/version.rb
CHANGED
data/lib/active_flag.rb
CHANGED
@@ -35,35 +35,30 @@ module ActiveFlag
|
|
35
35
|
|
36
36
|
# Scopes
|
37
37
|
define_singleton_method "where_#{column}" do |*args|
|
38
|
-
|
39
|
-
|
40
|
-
ActiveSupport::Deprecation.warn('op: :and is deprecated, use where_all instead')
|
41
|
-
where("#{column_name} & #{integer} = #{integer}")
|
42
|
-
else
|
43
|
-
where("#{column_name} & #{integer} > 0")
|
44
|
-
end
|
38
|
+
integer, column_name = send("_where_#{column}", *args)
|
39
|
+
where("#{column_name} & #{integer} > 0")
|
45
40
|
end
|
46
41
|
|
47
42
|
define_singleton_method "where_all_#{column}" do |*args|
|
48
|
-
|
43
|
+
integer, column_name = send("_where_#{column}", *args)
|
49
44
|
where("#{column_name} & #{integer} = #{integer}")
|
50
45
|
end
|
51
46
|
|
52
47
|
define_singleton_method "where_not_#{column}" do |*args|
|
53
|
-
|
48
|
+
integer, column_name = send("_where_#{column}", *args)
|
54
49
|
where("#{column_name} & #{integer} = 0")
|
55
50
|
end
|
56
51
|
|
57
52
|
define_singleton_method "where_not_all_#{column}" do |*args|
|
58
|
-
|
53
|
+
integer, column_name = send("_where_#{column}", *args)
|
59
54
|
where("#{column_name} & #{integer} < #{integer}")
|
60
55
|
end
|
61
56
|
|
57
|
+
# utility method to extract parameters
|
62
58
|
define_singleton_method "_where_#{column}" do |*args|
|
63
59
|
return [
|
64
|
-
args.extract_options!,
|
65
60
|
active_flags[column].to_i(args),
|
66
|
-
connection.
|
61
|
+
"#{connection.quote_table_name(table_name)}.#{connection.quote_column_name(column)}"
|
67
62
|
]
|
68
63
|
end
|
69
64
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_flag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenn Ejima
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2024-09-04 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: activerecord
|
@@ -24,6 +23,48 @@ dependencies:
|
|
24
23
|
- - ">="
|
25
24
|
- !ruby/object:Gem::Version
|
26
25
|
version: '5'
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: logger
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: mutex_m
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
type: :runtime
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: bigdecimal
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
type: :runtime
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
27
68
|
- !ruby/object:Gem::Dependency
|
28
69
|
name: bundler
|
29
70
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,16 +111,16 @@ dependencies:
|
|
70
111
|
name: sqlite3
|
71
112
|
requirement: !ruby/object:Gem::Requirement
|
72
113
|
requirements:
|
73
|
-
- - "
|
114
|
+
- - "<"
|
74
115
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
116
|
+
version: '2'
|
76
117
|
type: :development
|
77
118
|
prerelease: false
|
78
119
|
version_requirements: !ruby/object:Gem::Requirement
|
79
120
|
requirements:
|
80
|
-
- - "
|
121
|
+
- - "<"
|
81
122
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
123
|
+
version: '2'
|
83
124
|
description: Bit array for ActiveRecord
|
84
125
|
email:
|
85
126
|
- kenn.ejima@gmail.com
|
@@ -87,8 +128,9 @@ executables: []
|
|
87
128
|
extensions: []
|
88
129
|
extra_rdoc_files: []
|
89
130
|
files:
|
131
|
+
- ".github/dependabot.yml"
|
132
|
+
- ".github/workflows/ci.yml"
|
90
133
|
- ".gitignore"
|
91
|
-
- ".travis.yml"
|
92
134
|
- Gemfile
|
93
135
|
- LICENSE
|
94
136
|
- README.md
|
@@ -96,10 +138,8 @@ files:
|
|
96
138
|
- active_flag.gemspec
|
97
139
|
- bin/console
|
98
140
|
- bin/setup
|
99
|
-
- gemfiles/
|
100
|
-
- gemfiles/
|
101
|
-
- gemfiles/5.2.gemfile
|
102
|
-
- gemfiles/6.0.gemfile
|
141
|
+
- gemfiles/6.1.gemfile
|
142
|
+
- gemfiles/7.2.gemfile
|
103
143
|
- lib/active_flag.rb
|
104
144
|
- lib/active_flag/definition.rb
|
105
145
|
- lib/active_flag/railtie.rb
|
@@ -108,7 +148,6 @@ files:
|
|
108
148
|
homepage: https://github.com/kenn/active_flag
|
109
149
|
licenses: []
|
110
150
|
metadata: {}
|
111
|
-
post_install_message:
|
112
151
|
rdoc_options: []
|
113
152
|
require_paths:
|
114
153
|
- lib
|
@@ -123,8 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
162
|
- !ruby/object:Gem::Version
|
124
163
|
version: '0'
|
125
164
|
requirements: []
|
126
|
-
rubygems_version: 3.0.
|
127
|
-
signing_key:
|
165
|
+
rubygems_version: 3.6.0.dev
|
128
166
|
specification_version: 4
|
129
167
|
summary: Bit array for ActiveRecord
|
130
168
|
test_files: []
|
data/.travis.yml
DELETED
data/gemfiles/5.0.gemfile
DELETED
data/gemfiles/5.1.gemfile
DELETED
data/gemfiles/5.2.gemfile
DELETED