lite-regulations 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6acbbef86579433a77664ff0bcd047b9425afbce5883b676b3bad427d24b9c87
4
- data.tar.gz: e77daf09160432da89a91c178a7bffb340c3e1e096fb453c2f8eb4c3f53074db
3
+ metadata.gz: 33c8795e89e6b7a233584cdd3bbb77f05cc376e455d9b6702c375c88011fa1f0
4
+ data.tar.gz: b618b1976cfcd64e8d38ebe525237ff1fbc9e1549b0814355657c29ec5206ce8
5
5
  SHA512:
6
- metadata.gz: 58dcf0493ba2cb0448bdd06910fb099a77bb9dee27a1ad81fb6471e1d2072dbc75b4f61e73816a14e4aa5c78e9c763566d7fb9dd448a2dd8942370f967e0718e
7
- data.tar.gz: ba0d5cac1e383674a0b7b4910d5e9bfa796356c29ab393cacd7488dabe65b71fb33a92b98d1af85f7f499df31a29bc538287c22fc0bbc70f858c4e6b5c467214
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
- Max: 100
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,16 @@ 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
+
15
+ ## [1.1.2] - 2021-07-22
16
+ ### Changed
17
+ - Improved setup
18
+
9
19
  ## [1.1.1] - 2021-07-21
10
20
  ### Changed
11
21
  - Improved Railtie support
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'https://rubygems.org'
3
+ source "https://rubygems.org"
4
4
 
5
5
  # Specify your gem's dependencies in lite-regulations.gemspec
6
6
  gemspec
data/Gemfile.lock CHANGED
@@ -1,41 +1,40 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-regulations (1.1.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 (6.1.4)
12
- actionview (= 6.1.4)
13
- activesupport (= 6.1.4)
14
- rack (~> 2.0, >= 2.0.9)
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 (6.1.4)
19
- activesupport (= 6.1.4)
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 (6.1.4)
25
- activesupport (= 6.1.4)
26
- activerecord (6.1.4)
27
- activemodel (= 6.1.4)
28
- activesupport (= 6.1.4)
29
- activesupport (6.1.4)
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.9)
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.4.4)
47
- erubi (1.10.0)
48
- fasterer (0.9.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.14.1)
51
- i18n (1.8.10)
49
+ ruby_parser (>= 3.19.1)
50
+ i18n (1.12.0)
52
51
  concurrent-ruby (~> 1.0)
53
- loofah (2.10.0)
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.5.3)
58
- minitest (5.14.4)
59
- nokogiri (1.11.7)
60
- mini_portile2 (~> 2.5.0)
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.20.1)
63
- parser (3.0.2.0)
62
+ parallel (1.22.1)
63
+ parser (3.1.2.1)
64
64
  ast (~> 2.4.1)
65
- racc (1.5.2)
66
- rack (2.2.3)
67
- rack-test (1.1.0)
68
- rack (>= 1.0, < 3)
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.0)
72
+ rails-html-sanitizer (1.4.3)
73
73
  loofah (~> 2.3)
74
- railties (6.1.4)
75
- actionpack (= 6.1.4)
76
- activesupport (= 6.1.4)
74
+ railties (7.0.4)
75
+ actionpack (= 7.0.4)
76
+ activesupport (= 7.0.4)
77
77
  method_source
78
- rake (>= 0.13)
78
+ rake (>= 12.2)
79
79
  thor (~> 1.0)
80
- rainbow (3.0.0)
80
+ zeitwerk (~> 2.5)
81
+ rainbow (3.1.1)
81
82
  rake (13.0.6)
82
- regexp_parser (2.1.1)
83
+ regexp_parser (2.6.1)
83
84
  rexml (3.2.5)
84
- rspec (3.10.0)
85
- rspec-core (~> 3.10.0)
86
- rspec-expectations (~> 3.10.0)
87
- rspec-mocks (~> 3.10.0)
88
- rspec-core (3.10.1)
89
- rspec-support (~> 3.10.0)
90
- rspec-expectations (3.10.1)
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.10.0)
93
- rspec-mocks (3.10.2)
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.10.0)
96
- rspec-rails (5.0.1)
97
- actionpack (>= 5.2)
98
- activesupport (>= 5.2)
99
- railties (>= 5.2)
100
- rspec-core (~> 3.10)
101
- rspec-expectations (~> 3.10)
102
- rspec-mocks (~> 3.10)
103
- rspec-support (~> 3.10)
104
- rspec-support (3.10.2)
105
- rubocop (1.18.3)
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.0.0.0)
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.7.0, < 2.0)
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.8.0)
115
- parser (>= 3.0.1.1)
116
- rubocop-performance (1.11.4)
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.4.0)
122
- rubocop (~> 1.0)
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.16.0)
126
- sexp_processor (~> 4.15, >= 4.15.1)
127
- sexp_processor (4.15.3)
128
- sqlite3 (1.4.2)
129
- thor (1.1.0)
130
- tzinfo (2.0.4)
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.0.0)
133
- zeitwerk (2.4.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.2.24
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/[USERNAME]/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.
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/[USERNAME]/lite-regulations/blob/master/CODE_OF_CONDUCT.md).
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
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
data/bin/console CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'bundler/setup'
5
- require 'lite/regulations'
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 'irb'
14
+ require "irb"
15
15
  IRB.start(__FILE__)
data/docs/ACTIVATION.md CHANGED
@@ -1,20 +1,19 @@
1
1
  # Activation
2
2
 
3
- #### Usage
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
- # 2. Include module
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
- #### Usage
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
- # 2. Include module
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
- #### Usage
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
- # 2. Include module
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
- #### Usage
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
- # 2. Include module
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
- #### Usage
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
- # 2. Include module
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
- #### Usage
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
- # 2. Include module
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
 
@@ -24,7 +24,7 @@ module Lite
24
24
  def inactive!
25
25
  return true if inactive?
26
26
 
27
- update(inactivated_at: Time.current)
27
+ update(inactivated_at: Lite::Regulations::Base.timestamp)
28
28
  end
29
29
 
30
30
  def inactive?
@@ -4,7 +4,9 @@ module Lite
4
4
  module Regulations
5
5
  module Base
6
6
 
7
- def self.timestamp
7
+ module_function
8
+
9
+ def timestamp
8
10
  Time.respond_to?(:current) ? Time.current : Time.now
9
11
  end
10
12
 
@@ -14,7 +14,7 @@ module Lite
14
14
  def contain!
15
15
  return true if contained?
16
16
 
17
- update(contained_at: Time.current)
17
+ update(contained_at: Lite::Regulations::Base.timestamp)
18
18
  end
19
19
 
20
20
  def contained?
@@ -9,14 +9,18 @@ module Lite
9
9
  # rubocop:disable Style/Lambda
10
10
  included do
11
11
  scope :expired, -> do
12
- where('expires_at IS NULL OR expires_at < ?', Lite::Regulations::Base.timestamp)
12
+ where("expires_at IS NULL OR expires_at < ?", Lite::Regulations::Base.timestamp)
13
13
  end
14
14
  scope :unexpired, -> do
15
- where('expires_at IS NOT NULL AND expires_at >= ?', Lite::Regulations::Base.timestamp)
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!(amount = nil)
33
- update(expires_at: extension_date(amount))
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(amount = nil)
52
+ def expires_at_or_time(expires_in = nil)
49
53
  return expires_at if unexpired?
50
54
 
51
- extension_date(amount)
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(amount = nil)
61
- amount ||= 30
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
@@ -14,7 +14,7 @@ module Lite
14
14
  def quarantine!
15
15
  return true if quarantined?
16
16
 
17
- update(quarantined_at: Time.current)
17
+ update(quarantined_at: Lite::Regulations::Base.timestamp)
18
18
  end
19
19
 
20
20
  def quarantined?
@@ -4,9 +4,9 @@ module Lite
4
4
  module Regulations
5
5
  class Railtie < Rails::Railtie
6
6
 
7
- initializer 'lite-regulations.configure_locales' do |app|
7
+ initializer "lite-regulations.configure_locales" do |app|
8
8
  Array(app.config.i18n.available_locales).each do |locale|
9
- path = File.expand_path("../locales/#{locale}.yml", __FILE__)
9
+ path = File.expand_path("../../../locales/#{locale}.yml", __FILE__)
10
10
  next unless File.file?(path)
11
11
 
12
12
  I18n.load_path << path
@@ -14,7 +14,7 @@ module Lite
14
14
  def suspend!
15
15
  return true if suspended?
16
16
 
17
- update(suspended_at: Time.current)
17
+ update(suspended_at: Lite::Regulations::Base.timestamp)
18
18
  end
19
19
 
20
20
  def suspended?
@@ -3,7 +3,7 @@
3
3
  module Lite
4
4
  module Regulations
5
5
 
6
- VERSION = '1.1.1'
6
+ VERSION = "1.2.0"
7
7
 
8
8
  end
9
9
  end
@@ -14,7 +14,7 @@ module Lite
14
14
  def invisible!
15
15
  return true if invisible?
16
16
 
17
- update(invisible_at: Time.current)
17
+ update(invisible_at: Lite::Regulations::Base.timestamp)
18
18
  end
19
19
 
20
20
  def visible!
@@ -1,11 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_record' unless defined?(ActiveRecord)
4
- require 'active_support' unless defined?(ActiveSupport)
3
+ require "active_record" unless defined?(ActiveRecord)
4
+ require "active_support" unless defined?(ActiveSupport)
5
5
 
6
- require 'lite/regulations/railtie' if defined?(Rails::Railtie)
7
- require 'lite/regulations/version'
8
-
9
- %w[base activation containment expiration quarantine suspension visibility].each do |name|
10
- require "lite/regulations/#{name}"
11
- end
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"
File without changes
@@ -1,54 +1,48 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('../lib', __FILE__)
3
+ lib = File.expand_path("../lib", __FILE__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'lite/regulations/version'
5
+ require "lite/regulations/version"
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.name = 'lite-regulations'
8
+ spec.name = "lite-regulations"
9
9
  spec.version = Lite::Regulations::VERSION
10
- spec.authors = ['Juan Gomez']
10
+ spec.authors = ["Juan Gomez"]
11
11
  spec.email = %w[j.gomez@drexed.com]
12
12
 
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'
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
- if spec.respond_to?(:metadata)
20
- spec.metadata.merge(
21
- 'allowed_push_host' => 'https://rubygems.org',
22
- 'changelog_uri' => 'https://github.com/drexed/lite-regulations/blob/master/CHANGELOG.md',
23
- 'homepage_uri' => spec.homepage,
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('..', __FILE__)) do
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 = 'exe'
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 'activerecord'
41
- spec.add_runtime_dependency 'activesupport'
34
+ spec.add_runtime_dependency "activerecord"
35
+ spec.add_runtime_dependency "activesupport"
42
36
 
43
- spec.add_development_dependency 'bundler'
44
- spec.add_development_dependency 'database_cleaner'
45
- spec.add_development_dependency 'fasterer'
46
- spec.add_development_dependency 'rake'
47
- spec.add_development_dependency 'rspec'
48
- spec.add_development_dependency 'rspec-rails'
49
- spec.add_development_dependency 'rubocop'
50
- spec.add_development_dependency 'rubocop-performance'
51
- spec.add_development_dependency 'rubocop-rake'
52
- spec.add_development_dependency 'rubocop-rspec'
53
- spec.add_development_dependency 'sqlite3'
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.1.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: 2021-07-22 00:00:00.000000000 Z
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
@@ -226,17 +225,22 @@ files:
226
225
  - lib/lite/regulations/base.rb
227
226
  - lib/lite/regulations/containment.rb
228
227
  - lib/lite/regulations/expiration.rb
229
- - lib/lite/regulations/locales/en.yml
230
228
  - lib/lite/regulations/quarantine.rb
231
229
  - lib/lite/regulations/railtie.rb
232
230
  - lib/lite/regulations/suspension.rb
233
231
  - lib/lite/regulations/version.rb
234
232
  - lib/lite/regulations/visibility.rb
233
+ - lib/locales/en.yml
235
234
  - lite-regulations.gemspec
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.2.24
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=