active_regulation 2.4.0 → 3.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/.coveralls.yml +1 -1
- data/.gitignore +1 -1
- data/.rspec +1 -1
- data/.travis.yml +1 -1
- data/CODE_OF_CONDUCT.md +1 -1
- data/Gemfile +2 -2
- data/README.md +11 -5
- data/Rakefile +1 -1
- data/active_regulation.gemspec +14 -14
- data/bin/console +1 -1
- data/bin/rake +6 -6
- data/bin/setup +1 -1
- data/config/locales/en.yml +7 -1
- data/lib/active_regulation/activation.rb +2 -2
- data/lib/active_regulation/containment.rb +2 -2
- data/lib/active_regulation/expiration.rb +2 -2
- data/lib/active_regulation/quarantine.rb +35 -0
- data/lib/active_regulation/suspension.rb +35 -0
- data/lib/active_regulation/version.rb +2 -2
- data/lib/active_regulation/visibility.rb +4 -4
- data/lib/active_regulation.rb +10 -8
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6a7533f1dfd24d8beec4f436456a2e9cda15f81
|
4
|
+
data.tar.gz: e30b757d5bb1cded248a455f006c13060b1911e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d15e03a90a9fcd19d803eb208a5cb9bdf3cfc332ccaada9f393852586d77da8b01271b80877a98af6ee14ba38b855d90401b8639136bd189845f279f328aa5e2
|
7
|
+
data.tar.gz: 12cbb4125d8c30d6b8a4644dd67242e2bfd1eeb2dbc47a0b6ffb6b4a2b0397efbdeb65fd8ba0c8420fa3632d813903301ab03cce8e479f63eb31fe1fac53485b
|
data/.coveralls.yml
CHANGED
@@ -1 +1 @@
|
|
1
|
-
service_name: travis-ci
|
1
|
+
service_name: travis-ci
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/.travis.yml
CHANGED
data/CODE_OF_CONDUCT.md
CHANGED
@@ -10,4 +10,4 @@ Project maintainers have the right and responsibility to remove, edit, or reject
|
|
10
10
|
|
11
11
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
12
|
|
13
|
-
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
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
6
|
|
7
7
|
ActiveRegulation is a library for commonly used record states.
|
8
8
|
|
@@ -11,7 +11,7 @@ ActiveRegulation is a library for commonly used record states.
|
|
11
11
|
Add this line to your application's Gemfile:
|
12
12
|
|
13
13
|
```ruby
|
14
|
-
gem
|
14
|
+
gem "active_regulation"
|
15
15
|
```
|
16
16
|
|
17
17
|
And then execute:
|
@@ -33,6 +33,8 @@ Or install it yourself as:
|
|
33
33
|
* activation
|
34
34
|
* containment
|
35
35
|
* expiration
|
36
|
+
* quarantine
|
37
|
+
* suspension
|
36
38
|
* visibility
|
37
39
|
|
38
40
|
**Attributes:**
|
@@ -40,6 +42,8 @@ Or install it yourself as:
|
|
40
42
|
* :contained_at
|
41
43
|
* :expires_at
|
42
44
|
* :invisible_at
|
45
|
+
* :quarantined_at
|
46
|
+
* :suspended_at
|
43
47
|
|
44
48
|
```ruby
|
45
49
|
class User < ActiveRecord::Base
|
@@ -71,8 +75,10 @@ User.inactive #=> retrieves all inactive records
|
|
71
75
|
|
72
76
|
## Contributing
|
73
77
|
|
74
|
-
|
78
|
+
Your contribution is welcome.
|
79
|
+
|
80
|
+
1. Fork it
|
75
81
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
76
|
-
3. Commit your changes (`git commit -am '
|
82
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
77
83
|
4. Push to the branch (`git push origin my-new-feature`)
|
78
|
-
5. Create
|
84
|
+
5. Create new Pull Request
|
data/Rakefile
CHANGED
data/active_regulation.gemspec
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
lib = File.expand_path(
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
4
|
+
require "active_regulation/version"
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name
|
8
|
-
spec.version
|
9
|
-
spec.authors
|
10
|
-
spec.email
|
7
|
+
spec.name = "active_regulation"
|
8
|
+
spec.version = ActiveRegulation::VERSION
|
9
|
+
spec.authors = ["Juan Gomez"]
|
10
|
+
spec.email = ["j.gomez@drexed.com"]
|
11
11
|
|
12
|
-
spec.summary
|
13
|
-
spec.description
|
14
|
-
spec.homepage
|
15
|
-
spec.license
|
12
|
+
spec.summary = %q{Gem for commonly used record states.}
|
13
|
+
spec.description = %q{Manage the states of records by commonly used attributes.}
|
14
|
+
spec.homepage = "http://drexed.github.io/active_regulation"
|
15
|
+
spec.license = "MIT"
|
16
16
|
|
17
|
-
spec.files
|
18
|
-
spec.bindir
|
19
|
-
spec.executables
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib", "support"]
|
21
21
|
|
22
22
|
spec.add_runtime_dependency "activerecord"
|
@@ -28,4 +28,4 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_development_dependency "rspec"
|
29
29
|
spec.add_development_dependency "sqlite3"
|
30
30
|
spec.add_development_dependency "database_cleaner"
|
31
|
-
end
|
31
|
+
end
|
data/bin/console
CHANGED
data/bin/rake
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
#
|
3
3
|
# This file was generated by Bundler.
|
4
4
|
#
|
5
|
-
# The application
|
5
|
+
# The application "rake" is installed as part of a gem, and
|
6
6
|
# this file is here to facilitate running it.
|
7
7
|
#
|
8
8
|
|
9
|
-
require
|
10
|
-
ENV[
|
9
|
+
require "pathname"
|
10
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
11
11
|
Pathname.new(__FILE__).realpath)
|
12
12
|
|
13
|
-
require
|
14
|
-
require
|
13
|
+
require "rubygems"
|
14
|
+
require "bundler/setup"
|
15
15
|
|
16
|
-
load Gem.bin_path(
|
16
|
+
load Gem.bin_path("rake", "rake")
|
data/bin/setup
CHANGED
data/config/locales/en.yml
CHANGED
@@ -9,6 +9,12 @@ en:
|
|
9
9
|
expiration:
|
10
10
|
expired: "Expired"
|
11
11
|
unexpired: "Unexpired"
|
12
|
+
quarantine:
|
13
|
+
quarantined: "Quarantined"
|
14
|
+
unquarantined: "Unquarantined"
|
15
|
+
suspension:
|
16
|
+
suspended: "Suspended"
|
17
|
+
unsuspended: "Unsuspended"
|
12
18
|
visibility:
|
13
19
|
invisible: "Invisible"
|
14
|
-
visible: "Visible"
|
20
|
+
visible: "Visible"
|
@@ -3,7 +3,7 @@ module ActiveRegulation
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
-
scope :active,
|
6
|
+
scope :active, -> { where(inactivated_at: nil) }
|
7
7
|
scope :inactive, -> { where.not(inactivated_at: nil) }
|
8
8
|
end
|
9
9
|
|
@@ -32,4 +32,4 @@ module ActiveRegulation
|
|
32
32
|
end
|
33
33
|
|
34
34
|
end
|
35
|
-
end
|
35
|
+
end
|
@@ -3,7 +3,7 @@ module ActiveRegulation
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
-
scope :contained,
|
6
|
+
scope :contained, -> { where.not(contained_at: nil) }
|
7
7
|
scope :uncontained, -> { where(contained_at: nil) }
|
8
8
|
end
|
9
9
|
|
@@ -32,4 +32,4 @@ module ActiveRegulation
|
|
32
32
|
end
|
33
33
|
|
34
34
|
end
|
35
|
-
end
|
35
|
+
end
|
@@ -5,7 +5,7 @@ module ActiveRegulation
|
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
included do
|
8
|
-
scope :expired,
|
8
|
+
scope :expired, -> { where("expires_at IS NULL OR expires_at < ?".freeze, Time.now) }
|
9
9
|
scope :unexpired, -> { where("expires_at IS NOT NULL AND expires_at >= ?".freeze, Time.now) }
|
10
10
|
end
|
11
11
|
|
@@ -46,4 +46,4 @@ module ActiveRegulation
|
|
46
46
|
end
|
47
47
|
|
48
48
|
end
|
49
|
-
end
|
49
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module ActiveRegulation
|
2
|
+
module Quarantine
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
scope :quarantined, -> { where.not(quarantined_at: nil) }
|
7
|
+
scope :unquarantined, -> { where(quarantined_at: nil) }
|
8
|
+
end
|
9
|
+
|
10
|
+
def quarantine!
|
11
|
+
update(quarantined_at: Time.now) if unquarantined?
|
12
|
+
end
|
13
|
+
|
14
|
+
def unquarantine!
|
15
|
+
update(quarantined_at: nil) if quarantined?
|
16
|
+
end
|
17
|
+
|
18
|
+
def quarantined?
|
19
|
+
!unquarantined?
|
20
|
+
end
|
21
|
+
|
22
|
+
def unquarantined?
|
23
|
+
quarantined_at.nil?
|
24
|
+
end
|
25
|
+
|
26
|
+
def quarantined_at_or_time
|
27
|
+
unquarantined? ? Time.now : quarantined_at
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_quarantine
|
31
|
+
I18n.t("active_regulation.quarantine.#{unquarantined? ? :unquarantined : :quarantined}")
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module ActiveRegulation
|
2
|
+
module Suspension
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
scope :suspended, -> { where.not(suspended_at: nil) }
|
7
|
+
scope :unsuspended, -> { where(suspended_at: nil) }
|
8
|
+
end
|
9
|
+
|
10
|
+
def suspend!
|
11
|
+
update(suspended_at: Time.now) if unsuspended?
|
12
|
+
end
|
13
|
+
|
14
|
+
def unsuspend!
|
15
|
+
update(suspended_at: nil) if suspended?
|
16
|
+
end
|
17
|
+
|
18
|
+
def suspended?
|
19
|
+
!unsuspended?
|
20
|
+
end
|
21
|
+
|
22
|
+
def unsuspended?
|
23
|
+
suspended_at.nil?
|
24
|
+
end
|
25
|
+
|
26
|
+
def suspended_at_or_time
|
27
|
+
suspended? ? Time.now : suspended_at
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_suspension
|
31
|
+
I18n.t("active_regulation.suspension.#{suspended? ? :suspended : :unsuspended}")
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -1,3 +1,3 @@
|
|
1
1
|
module ActiveRegulation
|
2
|
-
VERSION = "
|
3
|
-
end
|
2
|
+
VERSION = "3.0.0"
|
3
|
+
end
|
@@ -3,16 +3,16 @@ module ActiveRegulation
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
-
scope :visible,
|
6
|
+
scope :visible, -> { where(invisible_at: nil) }
|
7
7
|
scope :invisible, -> { where.not(invisible_at: nil) }
|
8
8
|
end
|
9
9
|
|
10
10
|
def invisible!
|
11
|
-
update(invisible_at: Time.now)
|
11
|
+
update(invisible_at: Time.now) if visible?
|
12
12
|
end
|
13
13
|
|
14
14
|
def visible!
|
15
|
-
update(invisible_at: nil)
|
15
|
+
update(invisible_at: nil) if invisible?
|
16
16
|
end
|
17
17
|
|
18
18
|
def invisible?
|
@@ -32,4 +32,4 @@ module ActiveRegulation
|
|
32
32
|
end
|
33
33
|
|
34
34
|
end
|
35
|
-
end
|
35
|
+
end
|
data/lib/active_regulation.rb
CHANGED
@@ -1,16 +1,18 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
require "active_regulation/version"
|
2
|
+
require "active_regulation/activation"
|
3
|
+
require "active_regulation/containment"
|
4
|
+
require "active_regulation/expiration"
|
5
|
+
require "active_regulation/quarantine"
|
6
|
+
require "active_regulation/suspension"
|
7
|
+
require "active_regulation/visibility"
|
6
8
|
|
7
9
|
if defined?(Rails)
|
8
|
-
require
|
10
|
+
require "rails"
|
9
11
|
|
10
12
|
module ActiveRegulation
|
11
13
|
class Railtie < ::Rails::Railtie
|
12
14
|
|
13
|
-
initializer
|
15
|
+
initializer "active_regulation" do |app|
|
14
16
|
ActiveRegulation::Railtie.instance_eval do
|
15
17
|
[app.config.i18n.available_locales].flatten.each do |locale|
|
16
18
|
(I18n.load_path << path(locale)) if File.file?(path(locale))
|
@@ -26,4 +28,4 @@ if defined?(Rails)
|
|
26
28
|
|
27
29
|
end
|
28
30
|
end
|
29
|
-
end
|
31
|
+
end
|
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: 3.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: 2016-
|
11
|
+
date: 2016-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -146,9 +146,11 @@ files:
|
|
146
146
|
- lib/active_regulation/activation.rb
|
147
147
|
- lib/active_regulation/containment.rb
|
148
148
|
- lib/active_regulation/expiration.rb
|
149
|
+
- lib/active_regulation/quarantine.rb
|
150
|
+
- lib/active_regulation/suspension.rb
|
149
151
|
- lib/active_regulation/version.rb
|
150
152
|
- lib/active_regulation/visibility.rb
|
151
|
-
homepage:
|
153
|
+
homepage: http://drexed.github.io/active_regulation
|
152
154
|
licenses:
|
153
155
|
- MIT
|
154
156
|
metadata: {}
|
@@ -169,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
171
|
version: '0'
|
170
172
|
requirements: []
|
171
173
|
rubyforge_project:
|
172
|
-
rubygems_version: 2.
|
174
|
+
rubygems_version: 2.6.4
|
173
175
|
signing_key:
|
174
176
|
specification_version: 4
|
175
177
|
summary: Gem for commonly used record states.
|