active_regulation 4.0.3 → 5.0.0
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/.reek +0 -20
- data/.rubocop.yml +0 -24
- data/Gemfile +2 -0
- data/README.md +0 -1
- data/Rakefile +2 -0
- data/active_regulation.gemspec +2 -2
- data/bin/console +1 -0
- data/bin/rake +2 -2
- data/lib/active_regulation.rb +2 -0
- data/lib/active_regulation/activation.rb +4 -2
- data/lib/active_regulation/containment.rb +4 -2
- data/lib/active_regulation/expiration.rb +6 -6
- data/lib/active_regulation/quarantine.rb +4 -2
- data/lib/active_regulation/suspension.rb +4 -2
- data/lib/active_regulation/version.rb +3 -1
- data/lib/active_regulation/visibility.rb +4 -2
- metadata +3 -32
- data/.coveralls.yml +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f21693392c7e564aad9720b8e4250b9653dc7cc
|
4
|
+
data.tar.gz: 8b8c1a12c580fc7afb8446edf83869321f4c74bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1d561a8372e00bab3bceb2b5771cf2b12ab86b2218d59334c493982ddc85bb4143d8c62e93cb1d4a24909aad0d324d8867f5c64ba8554acb5807ba86f46474f
|
7
|
+
data.tar.gz: 788549bad5c4c17edf5f9b625b73a8581c87b8605d72b3dbb4f2c16d54b703376b8b43635da9e4c35a13a421336d8e9894f082e60eab3af5a5ffe99e2ca5bac4
|
data/.reek
CHANGED
@@ -1,27 +1,7 @@
|
|
1
1
|
---
|
2
|
-
Attribute:
|
3
|
-
enabled: false
|
4
|
-
BooleanParameter:
|
5
|
-
enabled: false
|
6
|
-
ControlParameter:
|
7
|
-
enabled: false
|
8
|
-
FeatureEnvy:
|
9
|
-
enabled: false
|
10
2
|
IrresponsibleModule:
|
11
3
|
enabled: false
|
12
|
-
LongParameterList:
|
13
|
-
enabled: false
|
14
|
-
ManualDispatch:
|
15
|
-
enabled: false
|
16
|
-
NestedIterators:
|
17
|
-
max_allowed_nesting: 2
|
18
4
|
NilCheck:
|
19
5
|
enabled: false
|
20
|
-
PrimaDonnaMethod:
|
21
|
-
enabled: false
|
22
|
-
RepeatedConditional:
|
23
|
-
enabled: false
|
24
|
-
TooManyStatements:
|
25
|
-
max_statements: 10
|
26
6
|
UtilityFunction:
|
27
7
|
enabled: false
|
data/.rubocop.yml
CHANGED
@@ -4,37 +4,13 @@ AllCops:
|
|
4
4
|
TargetRubyVersion: 2.4
|
5
5
|
Exclude:
|
6
6
|
- 'spec/**/**/*'
|
7
|
-
Layout/ClosingParenthesisIndentation:
|
8
|
-
Enabled: false
|
9
|
-
Layout/EmptyLinesAroundBlockBody:
|
10
|
-
Enabled: false
|
11
7
|
Layout/EmptyLinesAroundClassBody:
|
12
8
|
Enabled: false
|
13
9
|
Layout/EmptyLinesAroundModuleBody:
|
14
10
|
Enabled: false
|
15
|
-
Layout/FirstParameterIndentation:
|
16
|
-
Enabled: false
|
17
|
-
Layout/MultilineMethodCallIndentation:
|
18
|
-
EnforcedStyle: aligned
|
19
11
|
LineLength:
|
20
12
|
Max: 100
|
21
13
|
Lint/ScriptPermission:
|
22
14
|
Enabled: false
|
23
|
-
Metrics/ClassLength:
|
24
|
-
Enabled: false
|
25
|
-
Metrics/ModuleLength:
|
26
|
-
Enabled: false
|
27
|
-
Style/Alias:
|
28
|
-
EnforcedStyle: prefer_alias_method
|
29
|
-
Style/BracesAroundHashParameters:
|
30
|
-
Enabled: false
|
31
15
|
Style/Documentation:
|
32
16
|
Enabled: false
|
33
|
-
Style/HashSyntax:
|
34
|
-
Enabled: false
|
35
|
-
Style/FrozenStringLiteralComment:
|
36
|
-
Enabled: false
|
37
|
-
Style/NumericLiterals:
|
38
|
-
Enabled: false
|
39
|
-
Style/RescueModifier:
|
40
|
-
Enabled: false
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
[](http://badge.fury.io/rb/active_regulation)
|
4
4
|
[](https://travis-ci.org/drexed/active_regulation)
|
5
|
-
[](https://coveralls.io/github/drexed/active_regulation?branch=master)
|
6
5
|
|
7
6
|
ActiveRegulation is a library for commonly used record states.
|
8
7
|
|
data/Rakefile
CHANGED
data/active_regulation.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# coding: utf-8
|
2
4
|
|
3
5
|
lib = File.expand_path('../lib', __FILE__)
|
@@ -21,10 +23,8 @@ Gem::Specification.new do |spec|
|
|
21
23
|
spec.require_paths = %w[lib support]
|
22
24
|
|
23
25
|
spec.add_runtime_dependency 'activerecord'
|
24
|
-
spec.add_runtime_dependency 'activesupport'
|
25
26
|
|
26
27
|
spec.add_development_dependency 'bundler'
|
27
|
-
spec.add_development_dependency 'coveralls'
|
28
28
|
spec.add_development_dependency 'rake'
|
29
29
|
spec.add_development_dependency 'rspec'
|
30
30
|
spec.add_development_dependency 'sqlite3'
|
data/bin/console
CHANGED
data/bin/rake
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
#
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
3
4
|
# This file was generated by Bundler.
|
4
5
|
#
|
5
6
|
# The application 'rake' is installed as part of a gem, and
|
6
7
|
# this file is here to facilitate running it.
|
7
|
-
#
|
8
8
|
|
9
9
|
require 'pathname'
|
10
10
|
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', Pathname.new(__FILE__).realpath)
|
data/lib/active_regulation.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRegulation
|
2
4
|
module Activation
|
3
5
|
extend ActiveSupport::Concern
|
@@ -12,7 +14,7 @@ module ActiveRegulation
|
|
12
14
|
end
|
13
15
|
|
14
16
|
def inactive!
|
15
|
-
update(inactivated_at: Time.
|
17
|
+
update(inactivated_at: Time.current) if active?
|
16
18
|
end
|
17
19
|
|
18
20
|
def active?
|
@@ -24,7 +26,7 @@ module ActiveRegulation
|
|
24
26
|
end
|
25
27
|
|
26
28
|
def inactivated_at_or_time
|
27
|
-
active? ? Time.
|
29
|
+
active? ? Time.current : inactivated_at
|
28
30
|
end
|
29
31
|
|
30
32
|
def to_activation
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRegulation
|
2
4
|
module Containment
|
3
5
|
extend ActiveSupport::Concern
|
@@ -8,7 +10,7 @@ module ActiveRegulation
|
|
8
10
|
end
|
9
11
|
|
10
12
|
def contain!
|
11
|
-
update(contained_at: Time.
|
13
|
+
update(contained_at: Time.current) if uncontained?
|
12
14
|
end
|
13
15
|
|
14
16
|
def uncontain!
|
@@ -24,7 +26,7 @@ module ActiveRegulation
|
|
24
26
|
end
|
25
27
|
|
26
28
|
def contained_at_or_time
|
27
|
-
uncontained? ? Time.
|
29
|
+
uncontained? ? Time.current : contained_at
|
28
30
|
end
|
29
31
|
|
30
32
|
def to_containment
|
@@ -1,12 +1,12 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ActiveRegulation
|
4
4
|
module Expiration
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
included do
|
8
|
-
scope :expired, -> { where('expires_at IS NULL OR expires_at < ?', Time.
|
9
|
-
scope :unexpired, -> { where('expires_at IS NOT NULL AND expires_at >= ?', Time.
|
8
|
+
scope :expired, -> { where('expires_at IS NULL OR expires_at < ?', Time.current) }
|
9
|
+
scope :unexpired, -> { where('expires_at IS NOT NULL AND expires_at >= ?', Time.current) }
|
10
10
|
end
|
11
11
|
|
12
12
|
def expire!
|
@@ -22,11 +22,11 @@ module ActiveRegulation
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def expired?
|
25
|
-
expires_at.nil? ? true : (Time.
|
25
|
+
expires_at.nil? ? true : (Time.current >= expires_at)
|
26
26
|
end
|
27
27
|
|
28
28
|
def unexpired?
|
29
|
-
expires_at.nil? ? false : (Time.
|
29
|
+
expires_at.nil? ? false : (Time.current < expires_at)
|
30
30
|
end
|
31
31
|
|
32
32
|
def expires_at_or_time(amount = nil)
|
@@ -42,7 +42,7 @@ module ActiveRegulation
|
|
42
42
|
def extension_date(time = nil)
|
43
43
|
time = 30 if time.nil?
|
44
44
|
|
45
|
-
time.is_a?(Integer) ? (
|
45
|
+
time.is_a?(Integer) ? (Time.current + time) : time
|
46
46
|
end
|
47
47
|
|
48
48
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRegulation
|
2
4
|
module Quarantine
|
3
5
|
extend ActiveSupport::Concern
|
@@ -8,7 +10,7 @@ module ActiveRegulation
|
|
8
10
|
end
|
9
11
|
|
10
12
|
def quarantine!
|
11
|
-
update(quarantined_at: Time.
|
13
|
+
update(quarantined_at: Time.current) if unquarantined?
|
12
14
|
end
|
13
15
|
|
14
16
|
def unquarantine!
|
@@ -24,7 +26,7 @@ module ActiveRegulation
|
|
24
26
|
end
|
25
27
|
|
26
28
|
def quarantined_at_or_time
|
27
|
-
unquarantined? ? Time.
|
29
|
+
unquarantined? ? Time.current : quarantined_at
|
28
30
|
end
|
29
31
|
|
30
32
|
def to_quarantine
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRegulation
|
2
4
|
module Suspension
|
3
5
|
extend ActiveSupport::Concern
|
@@ -8,7 +10,7 @@ module ActiveRegulation
|
|
8
10
|
end
|
9
11
|
|
10
12
|
def suspend!
|
11
|
-
update(suspended_at: Time.
|
13
|
+
update(suspended_at: Time.current) if unsuspended?
|
12
14
|
end
|
13
15
|
|
14
16
|
def unsuspend!
|
@@ -24,7 +26,7 @@ module ActiveRegulation
|
|
24
26
|
end
|
25
27
|
|
26
28
|
def suspended_at_or_time
|
27
|
-
suspended? ? Time.
|
29
|
+
suspended? ? Time.current : suspended_at
|
28
30
|
end
|
29
31
|
|
30
32
|
def to_suspension
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRegulation
|
2
4
|
module Visibility
|
3
5
|
extend ActiveSupport::Concern
|
@@ -8,7 +10,7 @@ module ActiveRegulation
|
|
8
10
|
end
|
9
11
|
|
10
12
|
def invisible!
|
11
|
-
update(invisible_at: Time.
|
13
|
+
update(invisible_at: Time.current) if visible?
|
12
14
|
end
|
13
15
|
|
14
16
|
def visible!
|
@@ -24,7 +26,7 @@ module ActiveRegulation
|
|
24
26
|
end
|
25
27
|
|
26
28
|
def invisible_at_or_time
|
27
|
-
visible? ? Time.
|
29
|
+
visible? ? Time.current : invisible_at
|
28
30
|
end
|
29
31
|
|
30
32
|
def to_visibility
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_regulation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.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: 2017-
|
11
|
+
date: 2017-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: activesupport
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: bundler
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,20 +38,6 @@ dependencies:
|
|
52
38
|
- - ">="
|
53
39
|
- !ruby/object:Gem::Version
|
54
40
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: coveralls
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
41
|
- !ruby/object:Gem::Dependency
|
70
42
|
name: rake
|
71
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -172,7 +144,6 @@ extensions: []
|
|
172
144
|
extra_rdoc_files: []
|
173
145
|
files:
|
174
146
|
- ".DS_Store"
|
175
|
-
- ".coveralls.yml"
|
176
147
|
- ".fasterer.yml"
|
177
148
|
- ".gitignore"
|
178
149
|
- ".reek"
|
@@ -217,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
188
|
version: '0'
|
218
189
|
requirements: []
|
219
190
|
rubyforge_project:
|
220
|
-
rubygems_version: 2.6.
|
191
|
+
rubygems_version: 2.6.13
|
221
192
|
signing_key:
|
222
193
|
specification_version: 4
|
223
194
|
summary: Gem for commonly used record states.
|
data/.coveralls.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
service_name: travis-ci
|