act_with_flags 0.2.4 → 3.1.1
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 +4 -4
- data/.github/workflows/rake.yml +9 -3
- data/.ruby-gemset +1 -1
- data/.ruby-version +1 -1
- data/.watchr +29 -16
- data/Appraisals +10 -6
- data/Gemfile +7 -6
- data/Gemfile.lock +133 -105
- data/MIT-LICENSE +1 -1
- data/README.md +118 -9
- data/Rakefile +5 -5
- data/act_with_flags.gemspec +20 -20
- data/gemfiles/rails_6.0.gemfile +2 -1
- data/gemfiles/rails_7.0.gemfile +15 -0
- data/lib/act_with_flags/admin.rb +7 -49
- data/lib/act_with_flags/clear.rb +30 -0
- data/lib/act_with_flags/define.rb +6 -35
- data/lib/act_with_flags/flags.rb +65 -0
- data/lib/act_with_flags/print.rb +23 -28
- data/lib/act_with_flags/utils.rb +41 -13
- data/lib/act_with_flags/version.rb +10 -7
- data/lib/act_with_flags.rb +63 -31
- data/test/any_all_none_test.rb +6 -9
- data/test/benchmark_test.rb +73 -0
- data/test/clear_test.rb +5 -7
- data/test/coding_check_add_test.rb +29 -0
- data/test/coding_coverage_test.rb +19 -0
- data/test/coding_mask2d_test.rb +25 -0
- data/test/coding_null_test.rb +29 -0
- data/test/coding_one_test.rb +26 -0
- data/test/coding_reset_test.rb +18 -0
- data/test/inheritance_any_test.rb +9 -33
- data/test/inheritance_test.rb +7 -10
- data/test/internal/app/controllers/orders_controller.rb +1 -3
- data/test/internal/app/models/order.rb +1 -5
- data/test/internal/config/routes.rb +1 -1
- data/test/internal/db/schema.rb +6 -7
- data/test/legacy_test.rb +8 -9
- data/test/mask_test.rb +6 -7
- data/test/null_test.rb +3 -5
- data/test/one_test.rb +7 -9
- data/test/origin_test.rb +7 -26
- data/test/origins_test.rb +57 -0
- data/test/range2_test.rb +59 -0
- data/test/range3_test.rb +37 -0
- data/test/range_test.rb +89 -0
- data/test/remove_from_test.rb +3 -4
- data/test/test_helper.rb +8 -8
- metadata +23 -41
- data/.rubocop.yml +0 -9
- data/test/internal_benchmark_test.rb +0 -52
- data/test/internal_check_add_test.rb +0 -36
- data/test/internal_null_test.rb +0 -29
- data/test/internal_one_test.rb +0 -27
- data/test/reset_test.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c995a59c8536ec6e012c9bf671e087b9f333c7a327512a42e1ffe725f0a12a0f
|
4
|
+
data.tar.gz: 63e16f84e582fd6427846d9391e3f02b3a528cda8cbdf16670c368c719af399e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e82dc33cbc493c8b849a3053c5d28e2d73522a9308bbb7d59fa698dfa8a58c7380b9c58df082aa3190010f112c32b51583356373a935064a6f8222cb449283d7
|
7
|
+
data.tar.gz: 2fe6db8a4d0177db3d679e57b3851d79559ddbbe741352b0144cd0a6bcaba717584241bccae242e862c60bf0109c32252ca8472acdab1591ca61b3aa579ee31e
|
data/.github/workflows/rake.yml
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# see also https://github.com/whitequark/parser/blob/master/.github/workflows/test.yml
|
1
2
|
name: Rake
|
2
3
|
|
3
4
|
#on: [push, pull_request]
|
@@ -12,7 +13,8 @@ jobs:
|
|
12
13
|
os: [ubuntu-latest]
|
13
14
|
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
|
14
15
|
# ruby: [2.5, 2.6, 2.7, '3.0', head, jruby, jruby-head, truffleruby, truffleruby-head]
|
15
|
-
ruby: [2.7]
|
16
|
+
ruby: ["2.7.2", "3.0.1", "3.1.2"]
|
17
|
+
test_command: ["bundle exec rake test"]
|
16
18
|
runs-on: ${{ matrix.os }}
|
17
19
|
|
18
20
|
steps:
|
@@ -20,5 +22,9 @@ jobs:
|
|
20
22
|
- uses: ruby/setup-ruby@v1
|
21
23
|
with:
|
22
24
|
ruby-version: ${{ matrix.ruby }}
|
23
|
-
|
24
|
-
|
25
|
+
- name: Bundle install
|
26
|
+
run: |
|
27
|
+
bundle config path /home/runner/bundle
|
28
|
+
bundle install
|
29
|
+
bundle update
|
30
|
+
- run: ${{ matrix.test_command }}
|
data/.ruby-gemset
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rails-
|
1
|
+
rails-7.0
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-
|
1
|
+
ruby-3.1.2
|
data/.watchr
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
TESTING = %w[test]
|
2
|
+
HH = "#" * 22 unless defined?(HH)
|
3
|
+
H = "#" * 5 unless defined?(H)
|
3
4
|
|
4
5
|
def usage
|
5
6
|
puts <<-EOS
|
@@ -14,35 +15,47 @@ def run(cmd)
|
|
14
15
|
system "/usr/bin/time --format '#{HH} Elapsed time %E' #{cmd}"
|
15
16
|
end
|
16
17
|
|
17
|
-
def run_it(type,
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
def run_it(type, files)
|
19
|
+
files.split(" ").flatten.each do |file|
|
20
|
+
case type
|
21
|
+
when "test" then run %(bundle exec ruby -I test #{file})
|
22
|
+
# when 'spec'; run %(rspec -X #{file})
|
23
|
+
else; puts "#{H} unknown type: #{type}, file: #{file}"
|
24
|
+
end
|
22
25
|
end
|
23
26
|
end
|
24
27
|
|
25
28
|
def run_all_tests
|
26
29
|
puts "\n#{HH} Running all tests #{HH}\n"
|
27
|
-
|
30
|
+
TESTING.each { |dir| run "bundle exec rake #{dir}" if File.exist?(dir) }
|
28
31
|
end
|
29
32
|
|
30
33
|
def run_matching_files(base)
|
31
|
-
base = base.split(
|
32
|
-
|
34
|
+
base = base.split("_").first
|
35
|
+
TESTING.each { |type|
|
33
36
|
files = Dir["#{type}/**/*.rb"].select { |file| file =~ /#{base}_.*\.rb/ }
|
34
|
-
run_it type, files.join(
|
37
|
+
run_it type, files.join(" ") unless files.empty?
|
35
38
|
}
|
36
39
|
end
|
37
40
|
|
38
|
-
|
41
|
+
TESTING.each { |type|
|
39
42
|
watch("#{type}/#{type}_helper\.rb") { run_all_tests }
|
40
|
-
watch(
|
41
|
-
watch("#{type}/.*/*_#{type}\.rb")
|
43
|
+
watch("lib/.*\.rb") { run_all_tests }
|
44
|
+
watch("#{type}/.*/*_#{type}\.rb") { |match| run_it type, match[0] }
|
45
|
+
watch("#{type}/data/(.*)\.rb") { |match|
|
46
|
+
m1 = match[1]
|
47
|
+
run_matching_files("#{type}/#{m1}/#{m1}_#{type}.rb")
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
%w[rb erb haml slim].each { |type|
|
52
|
+
watch("app/.*/(.*)\.#{type}") { |match|
|
53
|
+
run_matching_files(match[1])
|
54
|
+
}
|
42
55
|
}
|
43
56
|
|
44
57
|
# Ctrl-\ or ctrl-4
|
45
|
-
|
58
|
+
Signal.trap("QUIT") { run_all_tests }
|
46
59
|
# Ctrl-C
|
47
|
-
|
60
|
+
Signal.trap("INT") { abort("Interrupted\n") }
|
48
61
|
usage
|
data/Appraisals
CHANGED
@@ -1,11 +1,15 @@
|
|
1
|
-
appraise
|
2
|
-
gem
|
1
|
+
appraise "rails-7.0" do
|
2
|
+
gem "rails", "~> 7.0"
|
3
3
|
end
|
4
4
|
|
5
|
-
appraise
|
6
|
-
|
5
|
+
# appraise "rails-6.1" do
|
6
|
+
# gem "rails", "~> 6.0"
|
7
|
+
# end
|
8
|
+
|
9
|
+
appraise "rails-6.0" do
|
10
|
+
gem "rails", "~> 6.0.0"
|
7
11
|
end
|
8
12
|
|
9
|
-
#appraise 'rails-5.2' do
|
13
|
+
# appraise 'rails-5.2' do
|
10
14
|
# gem 'rails', '~> 5.2.0'
|
11
|
-
#end
|
15
|
+
# end
|
data/Gemfile
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
gemspec
|
3
3
|
|
4
|
-
gem
|
4
|
+
gem "rails"
|
5
5
|
|
6
6
|
group :test do
|
7
|
-
gem
|
8
|
-
gem
|
9
|
-
gem
|
10
|
-
gem
|
7
|
+
gem "observr"
|
8
|
+
gem "standardrb", require: false
|
9
|
+
gem "simplecov", require: false
|
10
|
+
gem "benchmark-ips"
|
11
|
+
gem "ricecream"
|
11
12
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,173 +1,200 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
act_with_flags (
|
4
|
+
act_with_flags (3.1.1)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
actioncable (
|
10
|
-
actionpack (=
|
11
|
-
activesupport (=
|
9
|
+
actioncable (7.0.3.1)
|
10
|
+
actionpack (= 7.0.3.1)
|
11
|
+
activesupport (= 7.0.3.1)
|
12
12
|
nio4r (~> 2.0)
|
13
13
|
websocket-driver (>= 0.6.1)
|
14
|
-
actionmailbox (
|
15
|
-
actionpack (=
|
16
|
-
activejob (=
|
17
|
-
activerecord (=
|
18
|
-
activestorage (=
|
19
|
-
activesupport (=
|
14
|
+
actionmailbox (7.0.3.1)
|
15
|
+
actionpack (= 7.0.3.1)
|
16
|
+
activejob (= 7.0.3.1)
|
17
|
+
activerecord (= 7.0.3.1)
|
18
|
+
activestorage (= 7.0.3.1)
|
19
|
+
activesupport (= 7.0.3.1)
|
20
20
|
mail (>= 2.7.1)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
net-imap
|
22
|
+
net-pop
|
23
|
+
net-smtp
|
24
|
+
actionmailer (7.0.3.1)
|
25
|
+
actionpack (= 7.0.3.1)
|
26
|
+
actionview (= 7.0.3.1)
|
27
|
+
activejob (= 7.0.3.1)
|
28
|
+
activesupport (= 7.0.3.1)
|
26
29
|
mail (~> 2.5, >= 2.5.4)
|
30
|
+
net-imap
|
31
|
+
net-pop
|
32
|
+
net-smtp
|
27
33
|
rails-dom-testing (~> 2.0)
|
28
|
-
actionpack (
|
29
|
-
actionview (=
|
30
|
-
activesupport (=
|
31
|
-
rack (~> 2.0, >= 2.0
|
34
|
+
actionpack (7.0.3.1)
|
35
|
+
actionview (= 7.0.3.1)
|
36
|
+
activesupport (= 7.0.3.1)
|
37
|
+
rack (~> 2.0, >= 2.2.0)
|
32
38
|
rack-test (>= 0.6.3)
|
33
39
|
rails-dom-testing (~> 2.0)
|
34
40
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
35
|
-
actiontext (
|
36
|
-
actionpack (=
|
37
|
-
activerecord (=
|
38
|
-
activestorage (=
|
39
|
-
activesupport (=
|
41
|
+
actiontext (7.0.3.1)
|
42
|
+
actionpack (= 7.0.3.1)
|
43
|
+
activerecord (= 7.0.3.1)
|
44
|
+
activestorage (= 7.0.3.1)
|
45
|
+
activesupport (= 7.0.3.1)
|
46
|
+
globalid (>= 0.6.0)
|
40
47
|
nokogiri (>= 1.8.5)
|
41
|
-
actionview (
|
42
|
-
activesupport (=
|
48
|
+
actionview (7.0.3.1)
|
49
|
+
activesupport (= 7.0.3.1)
|
43
50
|
builder (~> 3.1)
|
44
51
|
erubi (~> 1.4)
|
45
52
|
rails-dom-testing (~> 2.0)
|
46
53
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
47
|
-
activejob (
|
48
|
-
activesupport (=
|
54
|
+
activejob (7.0.3.1)
|
55
|
+
activesupport (= 7.0.3.1)
|
49
56
|
globalid (>= 0.3.6)
|
50
|
-
activemodel (
|
51
|
-
activesupport (=
|
52
|
-
activerecord (
|
53
|
-
activemodel (=
|
54
|
-
activesupport (=
|
55
|
-
activestorage (
|
56
|
-
actionpack (=
|
57
|
-
activejob (=
|
58
|
-
activerecord (=
|
59
|
-
activesupport (=
|
60
|
-
marcel (~> 1.0
|
61
|
-
mini_mime (
|
62
|
-
activesupport (
|
57
|
+
activemodel (7.0.3.1)
|
58
|
+
activesupport (= 7.0.3.1)
|
59
|
+
activerecord (7.0.3.1)
|
60
|
+
activemodel (= 7.0.3.1)
|
61
|
+
activesupport (= 7.0.3.1)
|
62
|
+
activestorage (7.0.3.1)
|
63
|
+
actionpack (= 7.0.3.1)
|
64
|
+
activejob (= 7.0.3.1)
|
65
|
+
activerecord (= 7.0.3.1)
|
66
|
+
activesupport (= 7.0.3.1)
|
67
|
+
marcel (~> 1.0)
|
68
|
+
mini_mime (>= 1.1.0)
|
69
|
+
activesupport (7.0.3.1)
|
63
70
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
64
71
|
i18n (>= 1.6, < 2)
|
65
72
|
minitest (>= 5.1)
|
66
73
|
tzinfo (~> 2.0)
|
67
|
-
|
68
|
-
appraisal (2.4.0)
|
74
|
+
appraisal (2.4.1)
|
69
75
|
bundler
|
70
76
|
rake
|
71
77
|
thor (>= 0.14.0)
|
72
78
|
ast (2.4.2)
|
73
|
-
benchmark-ips (2.
|
79
|
+
benchmark-ips (2.10.0)
|
74
80
|
builder (3.2.4)
|
75
|
-
combustion (1.3.
|
81
|
+
combustion (1.3.7)
|
76
82
|
activesupport (>= 3.0.0)
|
77
83
|
railties (>= 3.0.0)
|
78
84
|
thor (>= 0.14.6)
|
79
|
-
concurrent-ruby (1.1.
|
85
|
+
concurrent-ruby (1.1.10)
|
80
86
|
crass (1.0.6)
|
87
|
+
digest (3.1.0)
|
81
88
|
docile (1.4.0)
|
82
|
-
erubi (1.
|
83
|
-
globalid (0.
|
84
|
-
activesupport (>=
|
85
|
-
i18n (1.
|
89
|
+
erubi (1.11.0)
|
90
|
+
globalid (1.0.0)
|
91
|
+
activesupport (>= 5.0)
|
92
|
+
i18n (1.12.0)
|
86
93
|
concurrent-ruby (~> 1.0)
|
87
|
-
|
94
|
+
json (2.6.2)
|
95
|
+
loofah (2.18.0)
|
88
96
|
crass (~> 1.0.2)
|
89
97
|
nokogiri (>= 1.5.9)
|
90
98
|
mail (2.7.1)
|
91
99
|
mini_mime (>= 0.1.1)
|
92
|
-
marcel (1.0.
|
100
|
+
marcel (1.0.2)
|
93
101
|
method_source (1.0.0)
|
94
|
-
mini_mime (1.
|
95
|
-
minitest (5.
|
96
|
-
|
97
|
-
|
102
|
+
mini_mime (1.1.2)
|
103
|
+
minitest (5.16.3)
|
104
|
+
net-imap (0.2.3)
|
105
|
+
digest
|
106
|
+
net-protocol
|
107
|
+
strscan
|
108
|
+
net-pop (0.1.1)
|
109
|
+
digest
|
110
|
+
net-protocol
|
111
|
+
timeout
|
112
|
+
net-protocol (0.1.3)
|
113
|
+
timeout
|
114
|
+
net-smtp (0.3.1)
|
115
|
+
digest
|
116
|
+
net-protocol
|
117
|
+
timeout
|
118
|
+
nio4r (2.5.8)
|
119
|
+
nokogiri (1.13.8-x86_64-linux)
|
98
120
|
racc (~> 1.4)
|
99
121
|
observr (1.0.5)
|
100
|
-
parallel (1.
|
101
|
-
parser (3.
|
122
|
+
parallel (1.22.1)
|
123
|
+
parser (3.1.2.1)
|
102
124
|
ast (~> 2.4.1)
|
103
|
-
racc (1.
|
104
|
-
rack (2.2.
|
105
|
-
rack-test (
|
106
|
-
rack (>= 1.
|
107
|
-
rails (
|
108
|
-
actioncable (=
|
109
|
-
actionmailbox (=
|
110
|
-
actionmailer (=
|
111
|
-
actionpack (=
|
112
|
-
actiontext (=
|
113
|
-
actionview (=
|
114
|
-
activejob (=
|
115
|
-
activemodel (=
|
116
|
-
activerecord (=
|
117
|
-
activestorage (=
|
118
|
-
activesupport (=
|
125
|
+
racc (1.6.0)
|
126
|
+
rack (2.2.4)
|
127
|
+
rack-test (2.0.2)
|
128
|
+
rack (>= 1.3)
|
129
|
+
rails (7.0.3.1)
|
130
|
+
actioncable (= 7.0.3.1)
|
131
|
+
actionmailbox (= 7.0.3.1)
|
132
|
+
actionmailer (= 7.0.3.1)
|
133
|
+
actionpack (= 7.0.3.1)
|
134
|
+
actiontext (= 7.0.3.1)
|
135
|
+
actionview (= 7.0.3.1)
|
136
|
+
activejob (= 7.0.3.1)
|
137
|
+
activemodel (= 7.0.3.1)
|
138
|
+
activerecord (= 7.0.3.1)
|
139
|
+
activestorage (= 7.0.3.1)
|
140
|
+
activesupport (= 7.0.3.1)
|
119
141
|
bundler (>= 1.15.0)
|
120
|
-
railties (=
|
121
|
-
sprockets-rails (>= 2.0.0)
|
142
|
+
railties (= 7.0.3.1)
|
122
143
|
rails-dom-testing (2.0.3)
|
123
144
|
activesupport (>= 4.2.0)
|
124
145
|
nokogiri (>= 1.6)
|
125
|
-
rails-html-sanitizer (1.3
|
146
|
+
rails-html-sanitizer (1.4.3)
|
126
147
|
loofah (~> 2.3)
|
127
|
-
railties (
|
128
|
-
actionpack (=
|
129
|
-
activesupport (=
|
148
|
+
railties (7.0.3.1)
|
149
|
+
actionpack (= 7.0.3.1)
|
150
|
+
activesupport (= 7.0.3.1)
|
130
151
|
method_source
|
131
|
-
rake (>=
|
152
|
+
rake (>= 12.2)
|
132
153
|
thor (~> 1.0)
|
133
|
-
|
134
|
-
|
135
|
-
|
154
|
+
zeitwerk (~> 2.5)
|
155
|
+
rainbow (3.1.1)
|
156
|
+
rake (13.0.6)
|
157
|
+
regexp_parser (2.5.0)
|
136
158
|
rexml (3.2.5)
|
137
|
-
|
159
|
+
ricecream (0.2.1)
|
160
|
+
rubocop (1.35.1)
|
161
|
+
json (~> 2.3)
|
138
162
|
parallel (~> 1.10)
|
139
|
-
parser (>= 3.
|
163
|
+
parser (>= 3.1.2.1)
|
140
164
|
rainbow (>= 2.2.2, < 4.0)
|
141
165
|
regexp_parser (>= 1.8, < 3.0)
|
142
|
-
rexml
|
143
|
-
rubocop-ast (>= 1.
|
166
|
+
rexml (>= 3.2.5, < 4.0)
|
167
|
+
rubocop-ast (>= 1.20.1, < 2.0)
|
144
168
|
ruby-progressbar (~> 1.7)
|
145
169
|
unicode-display_width (>= 1.4.0, < 3.0)
|
146
|
-
rubocop-ast (1.
|
147
|
-
parser (>= 3.
|
170
|
+
rubocop-ast (1.21.0)
|
171
|
+
parser (>= 3.1.1.0)
|
172
|
+
rubocop-performance (1.14.3)
|
173
|
+
rubocop (>= 1.7.0, < 2.0)
|
174
|
+
rubocop-ast (>= 0.4.0)
|
148
175
|
ruby-progressbar (1.11.0)
|
149
176
|
simplecov (0.21.2)
|
150
177
|
docile (~> 1.1)
|
151
178
|
simplecov-html (~> 0.11)
|
152
179
|
simplecov_json_formatter (~> 0.1)
|
153
180
|
simplecov-html (0.12.3)
|
154
|
-
simplecov_json_formatter (0.1.
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
tzinfo (2.0.
|
181
|
+
simplecov_json_formatter (0.1.4)
|
182
|
+
sqlite3 (1.4.4)
|
183
|
+
standard (1.16.1)
|
184
|
+
rubocop (= 1.35.1)
|
185
|
+
rubocop-performance (= 1.14.3)
|
186
|
+
standardrb (1.0.1)
|
187
|
+
standard
|
188
|
+
strscan (3.0.4)
|
189
|
+
thor (1.2.1)
|
190
|
+
timeout (0.3.0)
|
191
|
+
tzinfo (2.0.5)
|
165
192
|
concurrent-ruby (~> 1.0)
|
166
|
-
unicode-display_width (2.
|
193
|
+
unicode-display_width (2.2.0)
|
167
194
|
websocket-driver (0.7.5)
|
168
195
|
websocket-extensions (>= 0.1.0)
|
169
196
|
websocket-extensions (0.1.5)
|
170
|
-
zeitwerk (2.
|
197
|
+
zeitwerk (2.6.0)
|
171
198
|
|
172
199
|
PLATFORMS
|
173
200
|
x86_64-linux
|
@@ -182,9 +209,10 @@ DEPENDENCIES
|
|
182
209
|
observr
|
183
210
|
rails
|
184
211
|
rake
|
185
|
-
|
212
|
+
ricecream
|
186
213
|
simplecov
|
187
214
|
sqlite3
|
215
|
+
standardrb
|
188
216
|
|
189
217
|
BUNDLED WITH
|
190
|
-
2.
|
218
|
+
2.3.14
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,26 +1,135 @@
|
|
1
1
|
# ActWithFlags
|
2
|
+
|
2
3
|
[](http://badge.fury.io/rb/act_with_flags)
|
3
4
|
|
4
|
-
|
5
|
+
A Rails gem required by key.matiq.
|
6
|
+
|
7
|
+
Handles booleans in "flags".
|
8
|
+
Defines setters and getters to access the booleans.
|
9
|
+
|
5
10
|
|
6
11
|
## Installation
|
7
12
|
|
8
|
-
|
13
|
+
As usual:
|
14
|
+
```ruby
|
15
|
+
# Gemfile
|
16
|
+
...
|
17
|
+
gem 'act_with_flags'
|
18
|
+
```
|
19
|
+
|
20
|
+
or manually:
|
21
|
+
```shell
|
22
|
+
$ gem install act_with_flags
|
23
|
+
```
|
24
|
+
|
25
|
+
|
26
|
+
## Version 3.1.1
|
27
|
+
|
28
|
+
Option "range" can be specified just once for all
|
29
|
+
"add_to_flags" for a specific "origin".
|
30
|
+
|
31
|
+
For example:
|
32
|
+
~~~ruby
|
33
|
+
Order.add_to_flags range: ..0
|
34
|
+
...
|
35
|
+
Order.add_to_flags :a
|
36
|
+
~~~
|
37
|
+
|
38
|
+
Same as:
|
39
|
+
~~~ruby
|
40
|
+
Order.add_to_flags :a
|
41
|
+
...
|
42
|
+
Order.add_to_flags range: ..0
|
43
|
+
~~~
|
44
|
+
|
45
|
+
or:
|
46
|
+
~~~ruby
|
47
|
+
Order.add_to_flags :a, range: ..0
|
48
|
+
~~~
|
49
|
+
|
50
|
+
Examples for "range":
|
51
|
+
~~~ruby
|
52
|
+
Order.add_to_flags range: 0..17 # legal flag position from 0 to 17
|
53
|
+
Order.add_to_flags range: ..17 # legal flag position from 0 to 17
|
54
|
+
Order.add_to_flags range: nil..17 # legal flag position from 0 to 17
|
55
|
+
Order.add_to_flags range: 3.. # legal flag position from 3 to big_number
|
56
|
+
Order.add_to_flags range: 3..nil # legal flag position from 3 to big_number
|
57
|
+
~~~
|
58
|
+
|
59
|
+
Invalid ranges:
|
60
|
+
~~~ruby
|
61
|
+
Order.add_to_flags range: -1..17 # range starting with a negative position
|
62
|
+
Order.add_to_flags range: :a..:z # invalid range
|
63
|
+
Order.add_to_flags range: "a".."z" # invalid range
|
64
|
+
~~~
|
65
|
+
|
66
|
+
|
67
|
+
## Version 3.1.0
|
68
|
+
|
69
|
+
Added option "range" limiting the position of flags.
|
70
|
+
|
71
|
+
An example:
|
72
|
+
```ruby
|
73
|
+
ii = 3
|
74
|
+
Order.add_to_flags range: (2..4), a: (ii += 1) # accepted
|
75
|
+
Order.add_to_flags range: (2..4), b: (ii += 1) # raises exception
|
76
|
+
```
|
77
|
+
|
78
|
+
Option "range" enables an early static check.
|
79
|
+
|
80
|
+
Option "range" does not replace the dynamic "validate" in models,
|
81
|
+
which is strongly recommended for complex applications.
|
82
|
+
Due to Ruby "act_with_flags" can handle a huge quantity
|
83
|
+
of booleans in an integer (or a string),
|
84
|
+
but your database may fail above a certain amount of bits.
|
85
|
+
|
86
|
+
The option ":max_bits" is deprecated.
|
87
|
+
|
88
|
+
|
89
|
+
## Version 3.0.x
|
90
|
+
|
91
|
+
As required by key.matiq an enhanced "origin:" has been implemented.
|
92
|
+
Act_with_flags now supports many "origin:"s
|
93
|
+
(not just renaming the default "flags").
|
94
|
+
|
95
|
+
An example:
|
96
|
+
```ruby
|
97
|
+
Order.add_to_flags :a # origin is :flags
|
98
|
+
Order.add_to_flags :b, b2: 63 # origin is :flags
|
99
|
+
Order.add_to_flags :c, origin: :origin1
|
100
|
+
Order.add_to_flags d: 3, origin: :origin2
|
101
|
+
Order.add_to_flags :d2, origin: :origin2
|
102
|
+
```
|
103
|
+
|
104
|
+
The default "origin:" continues to be "flags".
|
105
|
+
|
106
|
+
|
107
|
+
## Testing
|
108
|
+
|
109
|
+
As "Best Practice" a test coverage of 100% has been achieved
|
110
|
+
(and should be kept).
|
111
|
+
|
112
|
+
GitHub workflow enable tests for several configurations.
|
113
|
+
Please, feel free to inspect the corresponding file.
|
9
114
|
|
10
|
-
|
115
|
+
The "gem appraisal" is used for an additional set of configurations.
|
116
|
+
Feel free to inspect the corresponding file.
|
11
117
|
|
12
|
-
And then execute:
|
13
118
|
|
14
|
-
|
119
|
+
## Links
|
15
120
|
|
16
|
-
|
121
|
+
Further reading:
|
17
122
|
|
18
|
-
|
123
|
+
- [gem bitmask_attributes](https://github.com/joelmoss/bitmask_attributes)
|
124
|
+
- [gem bitfields](https://github.com/grosser/bitfields)
|
125
|
+
- [gem active_flag](https://github.com/kenn/active_flag)
|
126
|
+
- [gem has-bit-field](https://github.com/pjb3/has-bit-field)
|
127
|
+
- [gem bitfield_attribute](https://github.com/gzigzigzeo/bitfield_attribute)
|
19
128
|
|
20
129
|
|
21
130
|
## License MIT
|
22
131
|
|
23
|
-
|
24
|
-
is released under the MIT license:
|
132
|
+
Copyright (c) 2019-2022 [Dittmar Krall](matiq UG (haftungsbeschränkt))
|
133
|
+
and is released under the MIT license:
|
25
134
|
|
26
135
|
* https://opensource.org/licenses/MIT
|
data/Rakefile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require "rake/testtask"
|
2
2
|
|
3
|
-
desc
|
3
|
+
desc "Run the tests."
|
4
4
|
Rake::TestTask.new do |t|
|
5
|
-
t.libs <<
|
6
|
-
t.libs <<
|
7
|
-
t.pattern =
|
5
|
+
t.libs << "lib"
|
6
|
+
t.libs << "test"
|
7
|
+
t.pattern = "test/**/*_test.rb"
|
8
8
|
t.verbose = false
|
9
9
|
end
|
10
10
|
|