lite-regulations 1.1.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -2
- data/CHANGELOG.md +6 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +78 -76
- data/README.md +2 -9
- data/Rakefile +2 -2
- data/bin/console +3 -3
- data/docs/ACTIVATION.md +5 -8
- data/docs/CONTAINMENT.md +5 -8
- data/docs/EXPIRATION.md +5 -9
- data/docs/QUARANTINE.md +5 -8
- data/docs/SUSPENSION.md +5 -8
- data/docs/VISIBILITY.md +5 -8
- data/lib/lite/regulations/activation.rb +1 -1
- data/lib/lite/regulations/base.rb +3 -1
- data/lib/lite/regulations/containment.rb +1 -1
- data/lib/lite/regulations/expiration.rb +12 -11
- data/lib/lite/regulations/quarantine.rb +1 -1
- data/lib/lite/regulations/railtie.rb +1 -1
- data/lib/lite/regulations/suspension.rb +1 -1
- data/lib/lite/regulations/version.rb +1 -1
- data/lib/lite/regulations/visibility.rb +1 -1
- data/lib/lite/regulations.rb +11 -11
- data/lite-regulations.gemspec +27 -33
- metadata +9 -5
- data/.travis.yml +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33c8795e89e6b7a233584cdd3bbb77f05cc376e455d9b6702c375c88011fa1f0
|
4
|
+
data.tar.gz: b618b1976cfcd64e8d38ebe525237ff1fbc9e1549b0814355657c29ec5206ce8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8c6105ed70726c146273a31a28c5541c3ab7ac316f91ab1ccd6f849b3cd245182d5962718b23e0da40e1738479a34679f669a34610aa925150ff0ffa6055cc3
|
7
|
+
data.tar.gz: f12b952e771ad20e5284abc219ee1e38f285ff651a175f0696ecac0e2a81b6c613ba3441ecbc9ce2ec55019d737777cbd2561a862fc8b98336bba818716cfffa
|
data/.rubocop.yml
CHANGED
@@ -2,7 +2,6 @@ require:
|
|
2
2
|
- rubocop-performance
|
3
3
|
- rubocop-rspec
|
4
4
|
AllCops:
|
5
|
-
TargetRubyVersion: 3.0
|
6
5
|
NewCops: enable
|
7
6
|
DisplayCopNames: true
|
8
7
|
DisplayStyleGuide: true
|
@@ -18,7 +17,7 @@ Layout/EmptyLinesAroundClassBody:
|
|
18
17
|
Layout/EmptyLinesAroundModuleBody:
|
19
18
|
EnforcedStyle: empty_lines_except_namespace
|
20
19
|
Layout/LineLength:
|
21
|
-
|
20
|
+
Enabled: false
|
22
21
|
Layout/SpaceAroundMethodCallOperator:
|
23
22
|
Enabled: true
|
24
23
|
Lint/RaiseException:
|
@@ -35,3 +34,7 @@ Style/Documentation:
|
|
35
34
|
Enabled: false
|
36
35
|
Style/ExpandPathArguments:
|
37
36
|
Enabled: false
|
37
|
+
Style/HashSyntax:
|
38
|
+
EnforcedShorthandSyntax: never
|
39
|
+
Style/StringLiterals:
|
40
|
+
EnforcedStyle: double_quotes
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [1.2.0] - 2022-11-19
|
10
|
+
### Changed
|
11
|
+
- Improved docs
|
12
|
+
- Improved internal setup
|
13
|
+
- Improved rubocop setup
|
14
|
+
|
9
15
|
## [1.1.2] - 2021-07-22
|
10
16
|
### Changed
|
11
17
|
- Improved setup
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,41 +1,40 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
lite-regulations (1.
|
4
|
+
lite-regulations (1.2.0)
|
5
5
|
activerecord
|
6
6
|
activesupport
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
actionpack (
|
12
|
-
actionview (=
|
13
|
-
activesupport (=
|
14
|
-
rack (~> 2.0, >= 2.0
|
11
|
+
actionpack (7.0.4)
|
12
|
+
actionview (= 7.0.4)
|
13
|
+
activesupport (= 7.0.4)
|
14
|
+
rack (~> 2.0, >= 2.2.0)
|
15
15
|
rack-test (>= 0.6.3)
|
16
16
|
rails-dom-testing (~> 2.0)
|
17
17
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
18
|
-
actionview (
|
19
|
-
activesupport (=
|
18
|
+
actionview (7.0.4)
|
19
|
+
activesupport (= 7.0.4)
|
20
20
|
builder (~> 3.1)
|
21
21
|
erubi (~> 1.4)
|
22
22
|
rails-dom-testing (~> 2.0)
|
23
23
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
24
|
-
activemodel (
|
25
|
-
activesupport (=
|
26
|
-
activerecord (
|
27
|
-
activemodel (=
|
28
|
-
activesupport (=
|
29
|
-
activesupport (
|
24
|
+
activemodel (7.0.4)
|
25
|
+
activesupport (= 7.0.4)
|
26
|
+
activerecord (7.0.4)
|
27
|
+
activemodel (= 7.0.4)
|
28
|
+
activesupport (= 7.0.4)
|
29
|
+
activesupport (7.0.4)
|
30
30
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
31
31
|
i18n (>= 1.6, < 2)
|
32
32
|
minitest (>= 5.1)
|
33
33
|
tzinfo (~> 2.0)
|
34
|
-
zeitwerk (~> 2.3)
|
35
34
|
ast (2.4.2)
|
36
35
|
builder (3.2.4)
|
37
36
|
colorize (0.8.1)
|
38
|
-
concurrent-ruby (1.1.
|
37
|
+
concurrent-ruby (1.1.10)
|
39
38
|
crass (1.0.6)
|
40
39
|
database_cleaner (2.0.1)
|
41
40
|
database_cleaner-active_record (~> 2.0.0)
|
@@ -43,94 +42,97 @@ GEM
|
|
43
42
|
activerecord (>= 5.a)
|
44
43
|
database_cleaner-core (~> 2.0.0)
|
45
44
|
database_cleaner-core (2.0.1)
|
46
|
-
diff-lcs (1.
|
47
|
-
erubi (1.
|
48
|
-
fasterer (0.
|
45
|
+
diff-lcs (1.5.0)
|
46
|
+
erubi (1.11.0)
|
47
|
+
fasterer (0.10.0)
|
49
48
|
colorize (~> 0.7)
|
50
|
-
ruby_parser (>= 3.
|
51
|
-
i18n (1.
|
49
|
+
ruby_parser (>= 3.19.1)
|
50
|
+
i18n (1.12.0)
|
52
51
|
concurrent-ruby (~> 1.0)
|
53
|
-
|
52
|
+
json (2.6.2)
|
53
|
+
loofah (2.19.0)
|
54
54
|
crass (~> 1.0.2)
|
55
55
|
nokogiri (>= 1.5.9)
|
56
56
|
method_source (1.0.0)
|
57
|
-
mini_portile2 (2.
|
58
|
-
minitest (5.
|
59
|
-
nokogiri (1.
|
60
|
-
mini_portile2 (~> 2.
|
57
|
+
mini_portile2 (2.8.0)
|
58
|
+
minitest (5.16.3)
|
59
|
+
nokogiri (1.13.9)
|
60
|
+
mini_portile2 (~> 2.8.0)
|
61
61
|
racc (~> 1.4)
|
62
|
-
parallel (1.
|
63
|
-
parser (3.
|
62
|
+
parallel (1.22.1)
|
63
|
+
parser (3.1.2.1)
|
64
64
|
ast (~> 2.4.1)
|
65
|
-
racc (1.
|
66
|
-
rack (2.2.
|
67
|
-
rack-test (
|
68
|
-
rack (>= 1.
|
65
|
+
racc (1.6.0)
|
66
|
+
rack (2.2.4)
|
67
|
+
rack-test (2.0.2)
|
68
|
+
rack (>= 1.3)
|
69
69
|
rails-dom-testing (2.0.3)
|
70
70
|
activesupport (>= 4.2.0)
|
71
71
|
nokogiri (>= 1.6)
|
72
|
-
rails-html-sanitizer (1.3
|
72
|
+
rails-html-sanitizer (1.4.3)
|
73
73
|
loofah (~> 2.3)
|
74
|
-
railties (
|
75
|
-
actionpack (=
|
76
|
-
activesupport (=
|
74
|
+
railties (7.0.4)
|
75
|
+
actionpack (= 7.0.4)
|
76
|
+
activesupport (= 7.0.4)
|
77
77
|
method_source
|
78
|
-
rake (>=
|
78
|
+
rake (>= 12.2)
|
79
79
|
thor (~> 1.0)
|
80
|
-
|
80
|
+
zeitwerk (~> 2.5)
|
81
|
+
rainbow (3.1.1)
|
81
82
|
rake (13.0.6)
|
82
|
-
regexp_parser (2.
|
83
|
+
regexp_parser (2.6.1)
|
83
84
|
rexml (3.2.5)
|
84
|
-
rspec (3.
|
85
|
-
rspec-core (~> 3.
|
86
|
-
rspec-expectations (~> 3.
|
87
|
-
rspec-mocks (~> 3.
|
88
|
-
rspec-core (3.
|
89
|
-
rspec-support (~> 3.
|
90
|
-
rspec-expectations (3.
|
85
|
+
rspec (3.12.0)
|
86
|
+
rspec-core (~> 3.12.0)
|
87
|
+
rspec-expectations (~> 3.12.0)
|
88
|
+
rspec-mocks (~> 3.12.0)
|
89
|
+
rspec-core (3.12.0)
|
90
|
+
rspec-support (~> 3.12.0)
|
91
|
+
rspec-expectations (3.12.0)
|
91
92
|
diff-lcs (>= 1.2.0, < 2.0)
|
92
|
-
rspec-support (~> 3.
|
93
|
-
rspec-mocks (3.
|
93
|
+
rspec-support (~> 3.12.0)
|
94
|
+
rspec-mocks (3.12.0)
|
94
95
|
diff-lcs (>= 1.2.0, < 2.0)
|
95
|
-
rspec-support (~> 3.
|
96
|
-
rspec-rails (
|
97
|
-
actionpack (>=
|
98
|
-
activesupport (>=
|
99
|
-
railties (>=
|
100
|
-
rspec-core (~> 3.
|
101
|
-
rspec-expectations (~> 3.
|
102
|
-
rspec-mocks (~> 3.
|
103
|
-
rspec-support (~> 3.
|
104
|
-
rspec-support (3.
|
105
|
-
rubocop (1.
|
96
|
+
rspec-support (~> 3.12.0)
|
97
|
+
rspec-rails (6.0.1)
|
98
|
+
actionpack (>= 6.1)
|
99
|
+
activesupport (>= 6.1)
|
100
|
+
railties (>= 6.1)
|
101
|
+
rspec-core (~> 3.11)
|
102
|
+
rspec-expectations (~> 3.11)
|
103
|
+
rspec-mocks (~> 3.11)
|
104
|
+
rspec-support (~> 3.11)
|
105
|
+
rspec-support (3.12.0)
|
106
|
+
rubocop (1.39.0)
|
107
|
+
json (~> 2.3)
|
106
108
|
parallel (~> 1.10)
|
107
|
-
parser (>= 3.
|
109
|
+
parser (>= 3.1.2.1)
|
108
110
|
rainbow (>= 2.2.2, < 4.0)
|
109
111
|
regexp_parser (>= 1.8, < 3.0)
|
110
|
-
rexml
|
111
|
-
rubocop-ast (>= 1.
|
112
|
+
rexml (>= 3.2.5, < 4.0)
|
113
|
+
rubocop-ast (>= 1.23.0, < 2.0)
|
112
114
|
ruby-progressbar (~> 1.7)
|
113
115
|
unicode-display_width (>= 1.4.0, < 3.0)
|
114
|
-
rubocop-ast (1.
|
115
|
-
parser (>= 3.
|
116
|
-
rubocop-performance (1.
|
116
|
+
rubocop-ast (1.23.0)
|
117
|
+
parser (>= 3.1.1.0)
|
118
|
+
rubocop-performance (1.15.1)
|
117
119
|
rubocop (>= 1.7.0, < 2.0)
|
118
120
|
rubocop-ast (>= 0.4.0)
|
119
121
|
rubocop-rake (0.6.0)
|
120
122
|
rubocop (~> 1.0)
|
121
|
-
rubocop-rspec (2.
|
122
|
-
rubocop (~> 1.
|
123
|
-
rubocop-ast (>= 1.1.0)
|
123
|
+
rubocop-rspec (2.15.0)
|
124
|
+
rubocop (~> 1.33)
|
124
125
|
ruby-progressbar (1.11.0)
|
125
|
-
ruby_parser (3.
|
126
|
-
sexp_processor (~> 4.
|
127
|
-
sexp_processor (4.
|
128
|
-
sqlite3 (1.4
|
129
|
-
|
130
|
-
|
126
|
+
ruby_parser (3.19.1)
|
127
|
+
sexp_processor (~> 4.16)
|
128
|
+
sexp_processor (4.16.1)
|
129
|
+
sqlite3 (1.5.4)
|
130
|
+
mini_portile2 (~> 2.8.0)
|
131
|
+
thor (1.2.1)
|
132
|
+
tzinfo (2.0.5)
|
131
133
|
concurrent-ruby (~> 1.0)
|
132
|
-
unicode-display_width (2.
|
133
|
-
zeitwerk (2.
|
134
|
+
unicode-display_width (2.3.0)
|
135
|
+
zeitwerk (2.6.6)
|
134
136
|
|
135
137
|
PLATFORMS
|
136
138
|
ruby
|
@@ -150,4 +152,4 @@ DEPENDENCIES
|
|
150
152
|
sqlite3
|
151
153
|
|
152
154
|
BUNDLED WITH
|
153
|
-
2.
|
155
|
+
2.3.26
|
data/README.md
CHANGED
@@ -5,8 +5,6 @@
|
|
5
5
|
|
6
6
|
Lite::Regulations is a collection of mixins to control the state of a database record.
|
7
7
|
|
8
|
-
**NOTE:** If you are coming from `ActiveRegulation`, please read the [port](#port) section.
|
9
|
-
|
10
8
|
## Installation
|
11
9
|
|
12
10
|
Add this line to your application's Gemfile:
|
@@ -26,7 +24,6 @@ Or install it yourself as:
|
|
26
24
|
## Table of Contents
|
27
25
|
|
28
26
|
* [Regulators](#regulators)
|
29
|
-
* [Port](#port)
|
30
27
|
|
31
28
|
## Regulators
|
32
29
|
|
@@ -37,10 +34,6 @@ Or install it yourself as:
|
|
37
34
|
* [Suspension](https://github.com/drexed/lite-regulations/blob/master/docs/SUSPENSION.md)
|
38
35
|
* [Visibility](https://github.com/drexed/lite-regulations/blob/master/docs/VISIBILITY.md)
|
39
36
|
|
40
|
-
## Port
|
41
|
-
|
42
|
-
`Lite::Regulations` is a compatible port of [ActiveRegulation](https://github.com/drexed/active_regulation).
|
43
|
-
|
44
37
|
## Development
|
45
38
|
|
46
39
|
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.
|
@@ -49,7 +42,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
49
42
|
|
50
43
|
## Contributing
|
51
44
|
|
52
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
45
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/drexed/lite-regulations. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
53
46
|
|
54
47
|
## License
|
55
48
|
|
@@ -57,4 +50,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
57
50
|
|
58
51
|
## Code of Conduct
|
59
52
|
|
60
|
-
Everyone interacting in the Lite::Regulations project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
53
|
+
Everyone interacting in the Lite::Regulations project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/drexed/lite-regulations/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
4
|
+
require "bundler/setup"
|
5
|
+
require "lite/regulations"
|
6
6
|
|
7
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
8
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -11,5 +11,5 @@ require 'lite/regulations'
|
|
11
11
|
# require "pry"
|
12
12
|
# Pry.start
|
13
13
|
|
14
|
-
require
|
14
|
+
require "irb"
|
15
15
|
IRB.start(__FILE__)
|
data/docs/ACTIVATION.md
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
# Activation
|
2
2
|
|
3
|
-
####
|
3
|
+
#### Table
|
4
4
|
|
5
5
|
```ruby
|
6
|
-
# 1. Add column to table
|
7
6
|
class AddRegulationsTimestampColumn < ActiveRecord::Migration
|
8
7
|
def change
|
9
8
|
t.datetime :inactivated_at
|
10
|
-
|
11
|
-
# - or -
|
12
|
-
|
13
9
|
add_column :your_model, :inactivated_at, :datetime
|
14
10
|
end
|
15
11
|
end
|
12
|
+
```
|
13
|
+
|
14
|
+
#### Model
|
16
15
|
|
17
|
-
|
16
|
+
```ruby
|
18
17
|
class User < ActiveRecord::Base
|
19
18
|
include Lite::Regulations::Activation
|
20
19
|
end
|
@@ -26,10 +25,8 @@ end
|
|
26
25
|
user = User.first
|
27
26
|
user.inactive!
|
28
27
|
user.inactive? #=> true
|
29
|
-
|
30
28
|
user.active!
|
31
29
|
user.active? #=> true
|
32
|
-
|
33
30
|
user.to_activation #=> Returns the visibility state locale string (ex: Active)
|
34
31
|
```
|
35
32
|
|
data/docs/CONTAINMENT.md
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
# Containment
|
2
2
|
|
3
|
-
####
|
3
|
+
#### Table
|
4
4
|
|
5
5
|
```ruby
|
6
|
-
# 1. Add column to table
|
7
6
|
class AddRegulationsTimestampColumn < ActiveRecord::Migration
|
8
7
|
def change
|
9
8
|
t.datetime :contained_at
|
10
|
-
|
11
|
-
# - or -
|
12
|
-
|
13
9
|
add_column :your_model, :contained_at, :datetime
|
14
10
|
end
|
15
11
|
end
|
12
|
+
```
|
16
13
|
|
17
|
-
|
14
|
+
#### Usage
|
15
|
+
|
16
|
+
```ruby
|
18
17
|
class User < ActiveRecord::Base
|
19
18
|
include Lite::Regulations::Containment
|
20
19
|
end
|
@@ -26,10 +25,8 @@ end
|
|
26
25
|
user = User.first
|
27
26
|
user.uncontain!
|
28
27
|
user.uncontained? #=> true
|
29
|
-
|
30
28
|
user.contain!
|
31
29
|
user.contained? #=> true
|
32
|
-
|
33
30
|
user.to_containment #=> Returns the visibility state locale string (ex: Contained)
|
34
31
|
```
|
35
32
|
|
data/docs/EXPIRATION.md
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
# Expiration
|
2
2
|
|
3
|
-
####
|
3
|
+
#### Table
|
4
4
|
|
5
5
|
```ruby
|
6
|
-
# 1. Add column to table
|
7
6
|
class AddRegulationsTimestampColumn < ActiveRecord::Migration
|
8
7
|
def change
|
9
8
|
t.datetime :expires_at
|
10
|
-
|
11
|
-
# - or -
|
12
|
-
|
13
9
|
add_column :your_model, :expires_at, :datetime
|
14
10
|
end
|
15
11
|
end
|
12
|
+
```
|
13
|
+
|
14
|
+
#### Usage
|
16
15
|
|
17
|
-
|
16
|
+
```ruby
|
18
17
|
class User < ActiveRecord::Base
|
19
18
|
include Lite::Regulations::Expiration
|
20
19
|
end
|
@@ -26,14 +25,11 @@ end
|
|
26
25
|
user = User.first
|
27
26
|
user.unexpire!
|
28
27
|
user.unexpired? #=> true
|
29
|
-
|
30
28
|
user.expire!
|
31
29
|
user.expired? #=> true
|
32
|
-
|
33
30
|
user.extend!
|
34
31
|
user.extend!(20.days)
|
35
32
|
user.expired? #=> false
|
36
|
-
|
37
33
|
user.to_expiration #=> Returns the visibility state locale string (ex: Expired)
|
38
34
|
```
|
39
35
|
|
data/docs/QUARANTINE.md
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
# Quarantine
|
2
2
|
|
3
|
-
####
|
3
|
+
#### Table
|
4
4
|
|
5
5
|
```ruby
|
6
|
-
# 1. Add column to table
|
7
6
|
class AddRegulationsTimestampColumn < ActiveRecord::Migration
|
8
7
|
def change
|
9
8
|
t.datetime :quarantined_at
|
10
|
-
|
11
|
-
# - or -
|
12
|
-
|
13
9
|
add_column :your_model, :quarantined_at, :datetime
|
14
10
|
end
|
15
11
|
end
|
12
|
+
```
|
16
13
|
|
17
|
-
|
14
|
+
#### Usage
|
15
|
+
|
16
|
+
```ruby
|
18
17
|
class User < ActiveRecord::Base
|
19
18
|
include Lite::Regulations::Quarantine
|
20
19
|
end
|
@@ -26,10 +25,8 @@ end
|
|
26
25
|
user = User.first
|
27
26
|
user.unquarantine!
|
28
27
|
user.unquarantined? #=> true
|
29
|
-
|
30
28
|
user.quarantine!
|
31
29
|
user.quarantined? #=> true
|
32
|
-
|
33
30
|
user.to_quarantine #=> Returns the visibility state locale string (ex: Quarantined)
|
34
31
|
```
|
35
32
|
|
data/docs/SUSPENSION.md
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
# Suspension
|
2
2
|
|
3
|
-
####
|
3
|
+
#### Table
|
4
4
|
|
5
5
|
```ruby
|
6
|
-
# 1. Add column to table
|
7
6
|
class AddRegulationsTimestampColumn < ActiveRecord::Migration
|
8
7
|
def change
|
9
8
|
t.datetime :suspended_at
|
10
|
-
|
11
|
-
# - or -
|
12
|
-
|
13
9
|
add_column :your_model, :suspended_at, :datetime
|
14
10
|
end
|
15
11
|
end
|
12
|
+
```
|
16
13
|
|
17
|
-
|
14
|
+
#### Usage
|
15
|
+
|
16
|
+
```ruby
|
18
17
|
class User < ActiveRecord::Base
|
19
18
|
include Lite::Regulations::Suspension
|
20
19
|
end
|
@@ -26,10 +25,8 @@ end
|
|
26
25
|
user = User.first
|
27
26
|
user.unsuspend!
|
28
27
|
user.unsuspended? #=> true
|
29
|
-
|
30
28
|
user.suspend!
|
31
29
|
user.suspended? #=> true
|
32
|
-
|
33
30
|
user.to_suspension #=> Returns the visibility state locale string (ex: Suspended)
|
34
31
|
```
|
35
32
|
|
data/docs/VISIBILITY.md
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
# Visibility
|
2
2
|
|
3
|
-
####
|
3
|
+
#### Table
|
4
4
|
|
5
5
|
```ruby
|
6
|
-
# 1. Add column to table
|
7
6
|
class AddRegulationsTimestampColumn < ActiveRecord::Migration
|
8
7
|
def change
|
9
8
|
t.datetime :invisible_at
|
10
|
-
|
11
|
-
# - or -
|
12
|
-
|
13
9
|
add_column :your_model, :invisible_at, :datetime
|
14
10
|
end
|
15
11
|
end
|
12
|
+
```
|
16
13
|
|
17
|
-
|
14
|
+
#### Usage
|
15
|
+
|
16
|
+
```ruby
|
18
17
|
class User < ActiveRecord::Base
|
19
18
|
include Lite::Regulations::Visibility
|
20
19
|
end
|
@@ -26,10 +25,8 @@ end
|
|
26
25
|
user = User.first
|
27
26
|
user.invisible!
|
28
27
|
user.invisible? #=> true
|
29
|
-
|
30
28
|
user.visible!
|
31
29
|
user.visible? #=> true
|
32
|
-
|
33
30
|
user.to_visibility #=> Returns the visibility state locale string (ex: Visible)
|
34
31
|
```
|
35
32
|
|
@@ -9,14 +9,18 @@ module Lite
|
|
9
9
|
# rubocop:disable Style/Lambda
|
10
10
|
included do
|
11
11
|
scope :expired, -> do
|
12
|
-
where(
|
12
|
+
where("expires_at IS NULL OR expires_at < ?", Lite::Regulations::Base.timestamp)
|
13
13
|
end
|
14
14
|
scope :unexpired, -> do
|
15
|
-
where(
|
15
|
+
where("expires_at IS NOT NULL AND expires_at >= ?", Lite::Regulations::Base.timestamp)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
# rubocop:enable Style/Lambda
|
19
19
|
|
20
|
+
def default_expires_in
|
21
|
+
30.minutes
|
22
|
+
end
|
23
|
+
|
20
24
|
def expire!
|
21
25
|
return true if expires_at.nil?
|
22
26
|
|
@@ -29,8 +33,8 @@ module Lite
|
|
29
33
|
Lite::Regulations::Base.timestamp >= expires_at
|
30
34
|
end
|
31
35
|
|
32
|
-
def extend!(
|
33
|
-
update(expires_at: extension_date(
|
36
|
+
def extend!(expires_in = nil)
|
37
|
+
update(expires_at: extension_date(expires_in))
|
34
38
|
end
|
35
39
|
|
36
40
|
def unexpire!
|
@@ -45,10 +49,10 @@ module Lite
|
|
45
49
|
Lite::Regulations::Base.timestamp < expires_at
|
46
50
|
end
|
47
51
|
|
48
|
-
def expires_at_or_time(
|
52
|
+
def expires_at_or_time(expires_in = nil)
|
49
53
|
return expires_at if unexpired?
|
50
54
|
|
51
|
-
extension_date(
|
55
|
+
extension_date(expires_in)
|
52
56
|
end
|
53
57
|
|
54
58
|
def to_expiration
|
@@ -57,11 +61,8 @@ module Lite
|
|
57
61
|
|
58
62
|
private
|
59
63
|
|
60
|
-
def extension_date(
|
61
|
-
|
62
|
-
return amount unless amount.is_a?(Integer)
|
63
|
-
|
64
|
-
Lite::Regulations::Base.timestamp + amount
|
64
|
+
def extension_date(expires_in = nil)
|
65
|
+
Lite::Regulations::Base.timestamp + (expires_in || default_expires_in).to_i
|
65
66
|
end
|
66
67
|
|
67
68
|
end
|
@@ -4,7 +4,7 @@ module Lite
|
|
4
4
|
module Regulations
|
5
5
|
class Railtie < Rails::Railtie
|
6
6
|
|
7
|
-
initializer
|
7
|
+
initializer "lite-regulations.configure_locales" do |app|
|
8
8
|
Array(app.config.i18n.available_locales).each do |locale|
|
9
9
|
path = File.expand_path("../../../locales/#{locale}.yml", __FILE__)
|
10
10
|
next unless File.file?(path)
|
data/lib/lite/regulations.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "active_record" unless defined?(ActiveRecord)
|
4
|
+
require "active_support" unless defined?(ActiveSupport)
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
6
|
+
require "lite/regulations/railtie" if defined?(Rails::Railtie)
|
7
|
+
require "lite/regulations/version"
|
8
|
+
require "lite/regulations/base"
|
9
|
+
require "lite/regulations/activation"
|
10
|
+
require "lite/regulations/containment"
|
11
|
+
require "lite/regulations/expiration"
|
12
|
+
require "lite/regulations/quarantine"
|
13
|
+
require "lite/regulations/suspension"
|
14
|
+
require "lite/regulations/visibility"
|
data/lite-regulations.gemspec
CHANGED
@@ -1,54 +1,48 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
lib = File.expand_path(
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require
|
5
|
+
require "lite/regulations/version"
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name =
|
8
|
+
spec.name = "lite-regulations"
|
9
9
|
spec.version = Lite::Regulations::VERSION
|
10
|
-
spec.authors = [
|
10
|
+
spec.authors = ["Juan Gomez"]
|
11
11
|
spec.email = %w[j.gomez@drexed.com]
|
12
12
|
|
13
|
-
spec.summary =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
13
|
+
spec.summary = "Collection of mixins to control the state of a database record"
|
14
|
+
spec.homepage = "http://drexed.github.io/lite-regulations"
|
15
|
+
spec.license = "MIT"
|
16
16
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
18
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
'source_code_uri' => 'https://github.com/drexed/lite-regulations'
|
25
|
-
)
|
26
|
-
else
|
27
|
-
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
28
|
-
'public gem pushes.'
|
29
|
-
end
|
19
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
20
|
+
spec.metadata["changelog_uri"] = "https://github.com/drexed/lite-regulations/blob/master/CHANGELOG.md"
|
21
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
22
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
23
|
+
spec.metadata["source_code_uri"] = "https://github.com/drexed/lite-regulations"
|
30
24
|
|
31
25
|
# Specify which files should be added to the gem when it is released.
|
32
26
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
33
|
-
spec.files = Dir.chdir(File.expand_path(
|
27
|
+
spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
|
34
28
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
35
29
|
end
|
36
|
-
spec.bindir =
|
30
|
+
spec.bindir = "exe"
|
37
31
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
38
32
|
spec.require_paths = %w[lib]
|
39
33
|
|
40
|
-
spec.add_runtime_dependency
|
41
|
-
spec.add_runtime_dependency
|
34
|
+
spec.add_runtime_dependency "activerecord"
|
35
|
+
spec.add_runtime_dependency "activesupport"
|
42
36
|
|
43
|
-
spec.add_development_dependency
|
44
|
-
spec.add_development_dependency
|
45
|
-
spec.add_development_dependency
|
46
|
-
spec.add_development_dependency
|
47
|
-
spec.add_development_dependency
|
48
|
-
spec.add_development_dependency
|
49
|
-
spec.add_development_dependency
|
50
|
-
spec.add_development_dependency
|
51
|
-
spec.add_development_dependency
|
52
|
-
spec.add_development_dependency
|
53
|
-
spec.add_development_dependency
|
37
|
+
spec.add_development_dependency "bundler"
|
38
|
+
spec.add_development_dependency "database_cleaner"
|
39
|
+
spec.add_development_dependency "fasterer"
|
40
|
+
spec.add_development_dependency "rake"
|
41
|
+
spec.add_development_dependency "rspec"
|
42
|
+
spec.add_development_dependency "rspec-rails"
|
43
|
+
spec.add_development_dependency "rubocop"
|
44
|
+
spec.add_development_dependency "rubocop-performance"
|
45
|
+
spec.add_development_dependency "rubocop-rake"
|
46
|
+
spec.add_development_dependency "rubocop-rspec"
|
47
|
+
spec.add_development_dependency "sqlite3"
|
54
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lite-regulations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -204,7 +204,6 @@ files:
|
|
204
204
|
- ".gitignore"
|
205
205
|
- ".rspec"
|
206
206
|
- ".rubocop.yml"
|
207
|
-
- ".travis.yml"
|
208
207
|
- CHANGELOG.md
|
209
208
|
- CODE_OF_CONDUCT.md
|
210
209
|
- Gemfile
|
@@ -236,7 +235,12 @@ files:
|
|
236
235
|
homepage: http://drexed.github.io/lite-regulations
|
237
236
|
licenses:
|
238
237
|
- MIT
|
239
|
-
metadata:
|
238
|
+
metadata:
|
239
|
+
allowed_push_host: https://rubygems.org
|
240
|
+
changelog_uri: https://github.com/drexed/lite-regulations/blob/master/CHANGELOG.md
|
241
|
+
homepage_uri: http://drexed.github.io/lite-regulations
|
242
|
+
rubygems_mfa_required: 'true'
|
243
|
+
source_code_uri: https://github.com/drexed/lite-regulations
|
240
244
|
post_install_message:
|
241
245
|
rdoc_options: []
|
242
246
|
require_paths:
|
@@ -252,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
252
256
|
- !ruby/object:Gem::Version
|
253
257
|
version: '0'
|
254
258
|
requirements: []
|
255
|
-
rubygems_version: 3.
|
259
|
+
rubygems_version: 3.3.26
|
256
260
|
signing_key:
|
257
261
|
specification_version: 4
|
258
262
|
summary: Collection of mixins to control the state of a database record
|
data/.travis.yml
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
language: ruby
|
3
|
-
cache: bundler
|
4
|
-
rvm:
|
5
|
-
- 2.5
|
6
|
-
- 2.6
|
7
|
-
- 2.7
|
8
|
-
- ruby-head
|
9
|
-
matrix:
|
10
|
-
fast_finish: true
|
11
|
-
allow_failures:
|
12
|
-
- rvm: ruby-head
|
13
|
-
before_install:
|
14
|
-
- gem update --system
|
15
|
-
- gem install bundler
|
16
|
-
install:
|
17
|
-
- bundle install --jobs=3 --retry=3
|
18
|
-
script:
|
19
|
-
- bundle exec rspec
|
20
|
-
- bundle exec rubocop
|
21
|
-
- bundle exec fasterer
|
22
|
-
notifications:
|
23
|
-
email: false
|
24
|
-
slack:
|
25
|
-
secure: Jn7h124NhPPnz7fH5YuqBcHxNBnzUvahtV5bjidZWQXYIBK1qAreJOOMEYrLu3Jupv3AW76aQvEvgxRg0ijYy0DCH6XEsET2rBWgcbRLU4geFgNwgXE0GE70X1ar7uY8yUDnNbaznFCDAYtUE+Gs/88U22rSxjIq9cjNtZweswDWML2VVpGjNF65aufLyVOU6IL/Hn700yblfBPKltoJwAjLTj7haUhRWB7yKeWenzsRcKlTmdY7A8mFQ1XTYsYsIG/wnakwi3sjSGRGtbpc9Q9CoLVmhWpOzzJkOu5XmY1ny4cNrEMP8levN/0GiqyEp1j9RBzVYuoZRg55DOa28hE2dzwORaSC1+KQgdQBfVATSmNBy8/QPCpPdACy92iZLi9KmATiRYE4My4Ksm6Dti+lZMiraiIDH4P1e2e0G0iFseOqy3YcR9JEfJoJsT4Nem4twOeevpTUZ+hJ0nPkwDu1EFDXIw9xf0C6nY/zkP8yspqrrmDVR1xDwHBN9APVbNgwK97yqjl8cSwOAQqn4uONhJKWqW+nfMs5+a942bP/z7xj6DdrhTv5fqqjU0ghNB+Yrysj4wvBkI+nlqVD+y4ZhsVCPrmQPwSrpfkct6CON2rP64GSitX/wGI+4TP6UY2Fi0UIpNdKs/FW5DpKibq/JKgpb53eRvoG8TnhXBI=
|