act_with_flags 0.2.0 → 3.0.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.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +30 -0
  3. data/.ruby-gemset +1 -1
  4. data/.ruby-version +1 -1
  5. data/.watchr +27 -19
  6. data/Appraisals +12 -4
  7. data/Gemfile +7 -4
  8. data/Gemfile.lock +152 -110
  9. data/MIT-LICENSE +20 -0
  10. data/README.md +30 -4
  11. data/Rakefile +6 -7
  12. data/TODO +21 -0
  13. data/act_with_flags.gemspec +20 -21
  14. data/gemfiles/rails_6.0.gemfile +4 -1
  15. data/gemfiles/{rails_5.2.gemfile → rails_6.1.gemfile} +3 -1
  16. data/gemfiles/rails_7.0.gemfile +15 -0
  17. data/lib/act_with_flags/admin.rb +5 -48
  18. data/lib/act_with_flags/clear.rb +30 -0
  19. data/lib/act_with_flags/define.rb +6 -35
  20. data/lib/act_with_flags/flags.rb +67 -0
  21. data/lib/act_with_flags/print.rb +21 -27
  22. data/lib/act_with_flags/utils.rb +25 -13
  23. data/lib/act_with_flags/version.rb +8 -9
  24. data/lib/act_with_flags.rb +14 -25
  25. data/test/any_all_none_test.rb +6 -9
  26. data/test/benchmark_test.rb +73 -0
  27. data/test/clear_test.rb +5 -7
  28. data/test/coding_check_add_test.rb +29 -0
  29. data/test/coding_coverage_test.rb +19 -0
  30. data/test/coding_mask2d_test.rb +25 -0
  31. data/test/coding_null_test.rb +29 -0
  32. data/test/coding_one_test.rb +26 -0
  33. data/test/coding_reset_test.rb +18 -0
  34. data/test/inheritance_any_test.rb +9 -33
  35. data/test/inheritance_test.rb +7 -10
  36. data/test/internal/app/assets/config/manifest.js +1 -0
  37. data/test/internal/app/controllers/orders_controller.rb +1 -3
  38. data/test/internal/app/models/order.rb +1 -5
  39. data/test/internal/config/routes.rb +1 -1
  40. data/test/internal/db/schema.rb +6 -7
  41. data/test/legacy_test.rb +8 -9
  42. data/test/mask_test.rb +6 -7
  43. data/test/null_test.rb +3 -5
  44. data/test/one_test.rb +7 -9
  45. data/test/origin_test.rb +7 -26
  46. data/test/origins_test.rb +57 -0
  47. data/test/remove_from_test.rb +3 -4
  48. data/test/test_helper.rb +12 -9
  49. metadata +25 -57
  50. data/.rubocop.yml +0 -79
  51. data/.travis.yml +0 -21
  52. data/LICENSE +0 -21
  53. data/test/internal_benchmark_test.rb +0 -52
  54. data/test/internal_check_add_test.rb +0 -36
  55. data/test/internal_null_test.rb +0 -29
  56. data/test/internal_one_test.rb +0 -27
  57. data/test/reset_test.rb +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0139e71c0c0d7efea1532b6a8060e6d0e5239a18c7505cc7df33a5b1be317127'
4
- data.tar.gz: e7e35eb32b20726610efdc96bf2c4a345a0e8f691805070bc6f2878bdf352849
3
+ metadata.gz: 743598329586132b56037a7f83e282e0a23f7f7ebcf33c0281ca29ac9285b50f
4
+ data.tar.gz: 108e19ed8834782c421e247e76713bc4129113bef80a3389cb469a69d7fc8982
5
5
  SHA512:
6
- metadata.gz: 42871f19d453f0ff4723c0ee6d4d1007e3a74ff877dc99df4c828b8f2fc1782b8dda10efbc52d5062ba16631d5428865b611ae1374d2db2e7e8eb64b75ce3f4d
7
- data.tar.gz: 49c4c7ef6e451b5593b0d4da6f2446c70696cf1514defaa586f712bcba0d87842ba52eb950f6223e2def12201b461fa101e5a3a9abcc3ec2b2b029ccb6520fbc
6
+ metadata.gz: c37311aab7060cf9f57063e5e60c74840042180aea327a5a3d224b62e687bee59b31876d9367ecb44978cf868df93e778f760fe6a74f8fd6610df9e44bc451cb
7
+ data.tar.gz: 040b721cbc34321535dbdf281c3778fed4876c4f9cfe074c0c36ef38c9bd1b64ec5a3ae13db7b67517f396bdc826d0146e1acd88cc074845952fbd0e55c0a27c
@@ -0,0 +1,30 @@
1
+ # see also https://github.com/whitequark/parser/blob/master/.github/workflows/test.yml
2
+ name: Rake
3
+
4
+ #on: [push, pull_request]
5
+ on: [push]
6
+
7
+ jobs:
8
+ test:
9
+ strategy:
10
+ fail-fast: false
11
+ matrix:
12
+ # os: [ubuntu-latest, macos-latest]
13
+ os: [ubuntu-latest]
14
+ # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
15
+ # ruby: [2.5, 2.6, 2.7, '3.0', head, jruby, jruby-head, truffleruby, truffleruby-head]
16
+ ruby: ["2.7.2", "3.0.1", "3.1.2"]
17
+ test_command: ["bundle exec rake test"]
18
+ runs-on: ${{ matrix.os }}
19
+
20
+ steps:
21
+ - uses: actions/checkout@v2
22
+ - uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
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-6.0
1
+ rails-7.0
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.6.4
1
+ ruby-3.1.2
data/.watchr CHANGED
@@ -1,5 +1,6 @@
1
- HH = '#' * 22 unless defined?(HH)
2
- H = '#' * 5 unless defined?(H)
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,40 +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, file)
18
- case type
19
- when 'test'; run %Q{ruby -I"lib:test" -r rubygems #{file}}
20
- # when 'test'; run %Q{rails test #{file}}
21
- # when 'spec'; run %Q{rspec -X #{file}}
22
- else; puts "#{H} unknown type: #{type}, file: #{file}"
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
23
25
  end
24
26
  end
25
27
 
26
28
  def run_all_tests
27
29
  puts "\n#{HH} Running all tests #{HH}\n"
28
- %w{test spec}.each { |dir| run "rake #{dir} RAILS_ENV=test" if File.exists?(dir) }
30
+ TESTING.each { |dir| run "bundle exec rake #{dir}" if File.exist?(dir) }
29
31
  end
30
32
 
31
33
  def run_matching_files(base)
32
- base = base.split('_').first
33
- %w{test spec}.each { |type|
34
+ base = base.split("_").first
35
+ TESTING.each { |type|
34
36
  files = Dir["#{type}/**/*.rb"].select { |file| file =~ /#{base}_.*\.rb/ }
35
- run_it type, files.join(' ') unless files.empty?
37
+ run_it type, files.join(" ") unless files.empty?
36
38
  }
37
39
  end
38
40
 
39
- %w{test spec}.each { |type|
41
+ TESTING.each { |type|
40
42
  watch("#{type}/#{type}_helper\.rb") { run_all_tests }
41
- watch("#{type}/.*/*_#{type}\.rb") { |match| run_it type, match[0] }
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
+ }
42
49
  }
43
- %w{rb erb haml slim}.each { |type|
44
- watch("app/.*/.*\.#{type}") { |m|
45
- run_matching_files("#{m[0].split('/').at(2).split('.').first}")
50
+
51
+ %w[rb erb haml slim].each { |type|
52
+ watch("app/.*/(.*)\.#{type}") { |match|
53
+ run_matching_files(match[1])
46
54
  }
47
55
  }
48
56
 
49
57
  # Ctrl-\ or ctrl-4
50
- Signal.trap('QUIT') { run_all_tests }
58
+ Signal.trap("QUIT") { run_all_tests }
51
59
  # Ctrl-C
52
- Signal.trap('INT') { abort("Interrupted\n") }
60
+ Signal.trap("INT") { abort("Interrupted\n") }
53
61
  usage
data/Appraisals CHANGED
@@ -1,7 +1,15 @@
1
- appraise 'rails-6.0' do
2
- gem 'rails', '~> 6.0.0'
1
+ appraise "rails-7.0" do
2
+ gem "rails", "~> 7.0"
3
3
  end
4
4
 
5
- appraise 'rails-5.2' do
6
- gem 'rails', '~> 5.2.0'
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
12
+
13
+ # appraise 'rails-5.2' do
14
+ # gem 'rails', '~> 5.2.0'
15
+ # end
data/Gemfile CHANGED
@@ -1,9 +1,12 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
  gemspec
3
3
 
4
- gem 'rails'
4
+ gem "rails"
5
5
 
6
6
  group :test do
7
- gem 'observr'
8
- gem 'benchmark-ips'
7
+ gem "observr"
8
+ gem "rubocop", require: false
9
+ gem "simplecov", require: false
10
+ gem "benchmark-ips"
11
+ gem "ricecream"
9
12
  end
data/Gemfile.lock CHANGED
@@ -1,155 +1,195 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- act_with_flags (0.1.0)
4
+ act_with_flags (3.0.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- actioncable (6.0.0)
10
- actionpack (= 6.0.0)
9
+ actioncable (7.0.3.1)
10
+ actionpack (= 7.0.3.1)
11
+ activesupport (= 7.0.3.1)
11
12
  nio4r (~> 2.0)
12
13
  websocket-driver (>= 0.6.1)
13
- actionmailbox (6.0.0)
14
- actionpack (= 6.0.0)
15
- activejob (= 6.0.0)
16
- activerecord (= 6.0.0)
17
- activestorage (= 6.0.0)
18
- activesupport (= 6.0.0)
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)
19
20
  mail (>= 2.7.1)
20
- actionmailer (6.0.0)
21
- actionpack (= 6.0.0)
22
- actionview (= 6.0.0)
23
- activejob (= 6.0.0)
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)
24
29
  mail (~> 2.5, >= 2.5.4)
30
+ net-imap
31
+ net-pop
32
+ net-smtp
25
33
  rails-dom-testing (~> 2.0)
26
- actionpack (6.0.0)
27
- actionview (= 6.0.0)
28
- activesupport (= 6.0.0)
29
- rack (~> 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)
30
38
  rack-test (>= 0.6.3)
31
39
  rails-dom-testing (~> 2.0)
32
40
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
33
- actiontext (6.0.0)
34
- actionpack (= 6.0.0)
35
- activerecord (= 6.0.0)
36
- activestorage (= 6.0.0)
37
- activesupport (= 6.0.0)
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)
38
47
  nokogiri (>= 1.8.5)
39
- actionview (6.0.0)
40
- activesupport (= 6.0.0)
48
+ actionview (7.0.3.1)
49
+ activesupport (= 7.0.3.1)
41
50
  builder (~> 3.1)
42
51
  erubi (~> 1.4)
43
52
  rails-dom-testing (~> 2.0)
44
53
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
45
- activejob (6.0.0)
46
- activesupport (= 6.0.0)
54
+ activejob (7.0.3.1)
55
+ activesupport (= 7.0.3.1)
47
56
  globalid (>= 0.3.6)
48
- activemodel (6.0.0)
49
- activesupport (= 6.0.0)
50
- activerecord (6.0.0)
51
- activemodel (= 6.0.0)
52
- activesupport (= 6.0.0)
53
- activestorage (6.0.0)
54
- actionpack (= 6.0.0)
55
- activejob (= 6.0.0)
56
- activerecord (= 6.0.0)
57
- marcel (~> 0.3.1)
58
- activesupport (6.0.0)
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)
59
70
  concurrent-ruby (~> 1.0, >= 1.0.2)
60
- i18n (>= 0.7, < 2)
61
- minitest (~> 5.1)
62
- tzinfo (~> 1.1)
63
- zeitwerk (~> 2.1, >= 2.1.8)
64
- appraisal (2.2.0)
71
+ i18n (>= 1.6, < 2)
72
+ minitest (>= 5.1)
73
+ tzinfo (~> 2.0)
74
+ appraisal (2.4.1)
65
75
  bundler
66
76
  rake
67
77
  thor (>= 0.14.0)
68
- benchmark-ips (2.7.2)
69
- builder (3.2.3)
70
- combustion (1.1.1)
78
+ ast (2.4.2)
79
+ benchmark-ips (2.10.0)
80
+ builder (3.2.4)
81
+ combustion (1.3.7)
71
82
  activesupport (>= 3.0.0)
72
83
  railties (>= 3.0.0)
73
84
  thor (>= 0.14.6)
74
- concurrent-ruby (1.1.5)
75
- crass (1.0.4)
76
- docile (1.3.2)
77
- erubi (1.9.0)
78
- globalid (0.4.2)
79
- activesupport (>= 4.2.0)
80
- i18n (1.7.0)
85
+ concurrent-ruby (1.1.10)
86
+ crass (1.0.6)
87
+ digest (3.1.0)
88
+ docile (1.4.0)
89
+ erubi (1.11.0)
90
+ globalid (1.0.0)
91
+ activesupport (>= 5.0)
92
+ i18n (1.12.0)
81
93
  concurrent-ruby (~> 1.0)
82
- json (2.2.0)
83
- loofah (2.3.0)
94
+ json (2.6.2)
95
+ loofah (2.18.0)
84
96
  crass (~> 1.0.2)
85
97
  nokogiri (>= 1.5.9)
86
98
  mail (2.7.1)
87
99
  mini_mime (>= 0.1.1)
88
- marcel (0.3.3)
89
- mimemagic (~> 0.3.2)
90
- method_source (0.9.2)
91
- mimemagic (0.3.3)
92
- mini_mime (1.0.2)
93
- mini_portile2 (2.4.0)
94
- minitest (5.12.2)
95
- nio4r (2.5.2)
96
- nokogiri (1.10.4)
97
- mini_portile2 (~> 2.4.0)
100
+ marcel (1.0.2)
101
+ method_source (1.0.0)
102
+ mini_mime (1.1.2)
103
+ minitest (5.16.2)
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)
120
+ racc (~> 1.4)
98
121
  observr (1.0.5)
99
- rack (2.0.7)
100
- rack-test (1.1.0)
101
- rack (>= 1.0, < 3)
102
- rails (6.0.0)
103
- actioncable (= 6.0.0)
104
- actionmailbox (= 6.0.0)
105
- actionmailer (= 6.0.0)
106
- actionpack (= 6.0.0)
107
- actiontext (= 6.0.0)
108
- actionview (= 6.0.0)
109
- activejob (= 6.0.0)
110
- activemodel (= 6.0.0)
111
- activerecord (= 6.0.0)
112
- activestorage (= 6.0.0)
113
- activesupport (= 6.0.0)
114
- bundler (>= 1.3.0)
115
- railties (= 6.0.0)
116
- sprockets-rails (>= 2.0.0)
122
+ parallel (1.22.1)
123
+ parser (3.1.2.0)
124
+ ast (~> 2.4.1)
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)
141
+ bundler (>= 1.15.0)
142
+ railties (= 7.0.3.1)
117
143
  rails-dom-testing (2.0.3)
118
144
  activesupport (>= 4.2.0)
119
145
  nokogiri (>= 1.6)
120
- rails-html-sanitizer (1.2.0)
121
- loofah (~> 2.2, >= 2.2.2)
122
- railties (6.0.0)
123
- actionpack (= 6.0.0)
124
- activesupport (= 6.0.0)
146
+ rails-html-sanitizer (1.4.3)
147
+ loofah (~> 2.3)
148
+ railties (7.0.3.1)
149
+ actionpack (= 7.0.3.1)
150
+ activesupport (= 7.0.3.1)
125
151
  method_source
126
- rake (>= 0.8.7)
127
- thor (>= 0.20.3, < 2.0)
128
- rake (13.0.0)
129
- simplecov (0.17.1)
152
+ rake (>= 12.2)
153
+ thor (~> 1.0)
154
+ zeitwerk (~> 2.5)
155
+ rainbow (3.1.1)
156
+ rake (13.0.6)
157
+ regexp_parser (2.5.0)
158
+ rexml (3.2.5)
159
+ ricecream (0.2.1)
160
+ rubocop (1.33.0)
161
+ json (~> 2.3)
162
+ parallel (~> 1.10)
163
+ parser (>= 3.1.0.0)
164
+ rainbow (>= 2.2.2, < 4.0)
165
+ regexp_parser (>= 1.8, < 3.0)
166
+ rexml (>= 3.2.5, < 4.0)
167
+ rubocop-ast (>= 1.19.1, < 2.0)
168
+ ruby-progressbar (~> 1.7)
169
+ unicode-display_width (>= 1.4.0, < 3.0)
170
+ rubocop-ast (1.19.1)
171
+ parser (>= 3.1.1.0)
172
+ ruby-progressbar (1.11.0)
173
+ simplecov (0.21.2)
130
174
  docile (~> 1.1)
131
- json (>= 1.8, < 3)
132
- simplecov-html (~> 0.10.0)
133
- simplecov-html (0.10.2)
134
- sprockets (3.7.2)
175
+ simplecov-html (~> 0.11)
176
+ simplecov_json_formatter (~> 0.1)
177
+ simplecov-html (0.12.3)
178
+ simplecov_json_formatter (0.1.4)
179
+ sqlite3 (1.4.4)
180
+ strscan (3.0.4)
181
+ thor (1.2.1)
182
+ timeout (0.3.0)
183
+ tzinfo (2.0.5)
135
184
  concurrent-ruby (~> 1.0)
136
- rack (> 1, < 3)
137
- sprockets-rails (3.2.1)
138
- actionpack (>= 4.0)
139
- activesupport (>= 4.0)
140
- sprockets (>= 3.0.0)
141
- sqlite3 (1.4.1)
142
- thor (0.20.3)
143
- thread_safe (0.3.6)
144
- tzinfo (1.2.5)
145
- thread_safe (~> 0.1)
146
- websocket-driver (0.7.1)
185
+ unicode-display_width (2.2.0)
186
+ websocket-driver (0.7.5)
147
187
  websocket-extensions (>= 0.1.0)
148
- websocket-extensions (0.1.4)
149
- zeitwerk (2.1.10)
188
+ websocket-extensions (0.1.5)
189
+ zeitwerk (2.6.0)
150
190
 
151
191
  PLATFORMS
152
- ruby
192
+ x86_64-linux
153
193
 
154
194
  DEPENDENCIES
155
195
  act_with_flags!
@@ -161,8 +201,10 @@ DEPENDENCIES
161
201
  observr
162
202
  rails
163
203
  rake
204
+ ricecream
205
+ rubocop
164
206
  simplecov
165
207
  sqlite3
166
208
 
167
209
  BUNDLED WITH
168
- 2.0.2
210
+ 2.3.14
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2019-2022 Dittmar Krall - www.matiq.com
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # ActWithFlags
2
2
  [![Gem Version](https://badge.fury.io/rb/act_with_flags.png)](http://badge.fury.io/rb/act_with_flags)
3
- [![Build Status](https://travis-ci.org/matique/act_with_flags.png?branch=master)](https://travis-ci.org/matique/act_with_flags)
4
3
 
5
- Required by key.matique.
4
+ Required by key.matiq.
6
5
 
7
6
  ## Installation
8
7
 
@@ -12,16 +11,43 @@ Add this line to your application's Gemfile:
12
11
 
13
12
  And then execute:
14
13
 
15
- $ bundle
14
+ $ bundle install
16
15
 
17
16
  Or install it yourself as:
18
17
 
19
18
  $ gem install act_with_flags
20
19
 
20
+ ## Version 3.x
21
+
22
+ As required by key.matiq an enhanced "origin:" has been implemented.
23
+ Act_with_flags now supports many "origin:"s
24
+ (not just renaming the default "flags").
25
+
26
+ An example:
27
+
28
+ ~~~
29
+ Order.add_to_flags :a # origin is :flags
30
+ Order.add_to_flags :b, b2: 63 # origin is :flags
31
+ Order.add_to_flags :c, origin: :origin1
32
+ Order.add_to_flags d: 3, origin: :origin2
33
+ Order.add_to_flags :d2, origin: :origin2
34
+ ~~~
35
+
36
+ The default "origin:" continues to be "flags".
37
+
38
+ ## Links
39
+
40
+ Further reading:
41
+
42
+ - [gem bitmask_attributes](https://github.com/joelmoss/bitmask_attributes)
43
+ - [gem bitfields](https://github.com/grosser/bitfields)
44
+ - [gem active_flag](https://github.com/kenn/active_flag)
45
+ - [gem has-bit-field](https://github.com/pjb3/has-bit-field)
46
+ - [gem bitfield_attribute](https://github.com/gzigzigzeo/bitfield_attribute)
21
47
 
22
48
  ## License MIT
23
49
 
24
- ActWithFlags is Copyright (c) 2019 [Dittmar Krall](matique.com UG) and
50
+ Copyright (c) 2019-2022 [Dittmar Krall](matiq.com UG) and
25
51
  is released under the MIT license:
26
52
 
27
53
  * https://opensource.org/licenses/MIT
data/Rakefile CHANGED
@@ -1,11 +1,10 @@
1
- require 'bundler/setup'
1
+ require "rake/testtask"
2
2
 
3
- require 'rake/testtask'
4
-
5
- Rake::TestTask.new(:test) do |t|
6
- t.libs << 'lib'
7
- t.libs << 'test'
8
- t.pattern = 'test/**/*_test.rb'
3
+ desc "Run the tests."
4
+ Rake::TestTask.new do |t|
5
+ t.libs << "lib"
6
+ t.libs << "test"
7
+ t.pattern = "test/**/*_test.rb"
9
8
  t.verbose = false
10
9
  end
11
10
 
data/TODO ADDED
@@ -0,0 +1,21 @@
1
+ # max_bits
2
+
3
+ add_to_flags(
4
+ ...
5
+ max_bits: 63
6
+ )
7
+
8
+ Sinn und Zweck von :max_bits. Beispiel ein bigint Feld von PostgreSQL hat
9
+ 64 Bits. Das Bit 2**63 ist allerdings nur bei negativen Zahlen gesetzt.
10
+ Damit stehen für add_to_flags bei solch einem Feld nur 63 Bits also
11
+ höchstens das Bit 2**62 zur Verfügung. Die Option max_bits: 62 würde sichern,
12
+ dass kein höheres Bit verwendet wird. Falls doch würde bereits bei
13
+ add_to_flags eine Exception bereits beim Start der Rails-Web-App geworfen und
14
+ nicht erst bei der Verwendung des Bits.
15
+
16
+ ## Solution
17
+
18
+ Rails supports already "validate" which is, IMHO,
19
+ the right way to limit values to be stored in the database.
20
+ Furthermore, invalid values, stored by equivocation,
21
+ are detected by "validate".
@@ -1,29 +1,28 @@
1
- lib = File.expand_path('lib', __dir__)
1
+ lib = File.expand_path("lib", __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'act_with_flags/version'
3
+ require "act_with_flags/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
- s.name = 'act_with_flags'
7
- s.version = ActWithFlags::VERSION
8
- s.summary = %(act_with_flags gem)
9
- s.description = %(Handles flags in a Rails model instance)
10
- s.authors = ['Dittmar Krall']
11
- s.email = ['dittmar.krall@matique.de']
12
- s.homepage = 'http://matique.de'
6
+ s.name = "act_with_flags"
7
+ s.version = ActWithFlags::VERSION
8
+ s.summary = %(act_with_flags gem)
9
+ s.description = %(Handles flags/booleans in a Rails model instance)
10
+ s.authors = ["Dittmar Krall"]
11
+ s.email = ["dittmar.krall@matiq.com"]
12
+ s.homepage = "http://matiq.com"
13
13
 
14
- s.license = 'MIT'
15
- s.platform = Gem::Platform::RUBY
14
+ s.license = "MIT"
15
+ s.platform = Gem::Platform::RUBY
16
+ s.metadata["source_code_uri"] = "https://github.com/matique/act_with_flags"
16
17
 
17
- s.files = `git ls-files -z`.split("\x0")
18
- s.test_files = s.files.grep(%r{^(test|spec|features)/})
19
- s.require_paths = ['lib']
18
+ s.files = `git ls-files -z`.split("\x0")
19
+ s.require_paths = ["lib"]
20
20
 
21
- s.add_development_dependency 'bundler'
22
- s.add_development_dependency 'rake'
23
- s.add_development_dependency 'appraisal'
24
- s.add_development_dependency 'combustion'
21
+ s.add_development_dependency "bundler"
22
+ s.add_development_dependency "rake"
23
+ s.add_development_dependency "appraisal"
24
+ s.add_development_dependency "combustion"
25
25
 
26
- s.add_development_dependency 'minitest'
27
- s.add_development_dependency 'simplecov'
28
- s.add_development_dependency 'sqlite3'
26
+ s.add_development_dependency "minitest"
27
+ s.add_development_dependency "sqlite3"
29
28
  end
@@ -6,7 +6,10 @@ gem "rails", "~> 6.0.0"
6
6
 
7
7
  group :test do
8
8
  gem "observr"
9
- gem "benchmark-ips"
9
+ gem "rubocop", require: false
10
+ gem "simplecov", require: false
11
+ gem "benchmark-ips", require: false
12
+ gem "ricecream", require: false
10
13
  end
11
14
 
12
15
  gemspec path: "../"