active_regulation 2.4.0 → 3.0.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
  SHA1:
3
- metadata.gz: 5195ebe294a620a67c5f79b0722d00563aa2fcff
4
- data.tar.gz: ab46c77d0f502a228fbe6a6659eaff0a96020af0
3
+ metadata.gz: a6a7533f1dfd24d8beec4f436456a2e9cda15f81
4
+ data.tar.gz: e30b757d5bb1cded248a455f006c13060b1911e9
5
5
  SHA512:
6
- metadata.gz: 4819aa728fe9b7352b4de1e073fa1f792bb21f9ade6d042707a09e41cad2886e3af9de337d85de5be3862ae18953ccc155f776834860fc8017090d889372dcf8
7
- data.tar.gz: d2c9dd5dc6683006325b317618ee13284f64a93c526bb1e498216b00291ca2d5a2b0df4a965eb4df4227caa80727ca9963a4de94e8974a0b63b86b87f8b8e742
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
@@ -6,4 +6,4 @@
6
6
  /doc/
7
7
  /pkg/
8
8
  /spec/reports/
9
- /tmp/
9
+ /tmp/
data/.rspec CHANGED
@@ -1,4 +1,4 @@
1
1
  --backtrace
2
2
  --color
3
3
  --format progress
4
- --order random
4
+ --order random
data/.travis.yml CHANGED
@@ -10,4 +10,4 @@ notifications:
10
10
  on_success: never
11
11
  rvm:
12
12
  - ruby-head
13
- script: 'bundle exec rake'
13
+ script: 'bundle exec rake'
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
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in active_regulation.gemspec
4
- gemspec
4
+ gemspec
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/active_regulation.svg)](http://badge.fury.io/rb/active_regulation)
4
4
  [![Build Status](https://travis-ci.org/drexed/active_regulation.svg?branch=master)](https://travis-ci.org/drexed/active_regulation)
5
- [![Coverage Status](https://coveralls.io/repos/drexed/active_regulation/badge.png)](https://coveralls.io/r/drexed/active_regulation)
5
+ [![Coverage Status](https://coveralls.io/repos/github/drexed/active_regulation/badge.svg?branch=master)](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 'active_regulation'
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
- 1. Fork it ( https://github.com/[my-github-username]/active_regulation/fork )
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 'Add some feature'`)
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 a new Pull Request
84
+ 5. Create new Pull Request
data/Rakefile CHANGED
@@ -1,3 +1,3 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
- task default: :spec
3
+ task default: :spec
@@ -1,22 +1,22 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'active_regulation/version'
4
+ require "active_regulation/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "active_regulation"
8
- spec.version = ActiveRegulation::VERSION
9
- spec.authors = ["Juan Gomez"]
10
- spec.email = ["j.gomez@drexed.com"]
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 = %q{Gem for commonly used record states.}
13
- spec.description = %q{Manage the states of records by commonly used attributes.}
14
- spec.homepage = "https://github.com/drexed/active_regulation"
15
- spec.license = "MIT"
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 = `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) }
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
@@ -11,4 +11,4 @@ require "active_regulation"
11
11
  # Pry.start
12
12
 
13
13
  require "irb"
14
- IRB.start
14
+ IRB.start
data/bin/rake CHANGED
@@ -2,15 +2,15 @@
2
2
  #
3
3
  # This file was generated by Bundler.
4
4
  #
5
- # The application 'rake' is installed as part of a gem, and
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 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
9
+ require "pathname"
10
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
11
11
  Pathname.new(__FILE__).realpath)
12
12
 
13
- require 'rubygems'
14
- require 'bundler/setup'
13
+ require "rubygems"
14
+ require "bundler/setup"
15
15
 
16
- load Gem.bin_path('rake', 'rake')
16
+ load Gem.bin_path("rake", "rake")
data/bin/setup CHANGED
@@ -4,4 +4,4 @@ IFS=$'\n\t'
4
4
 
5
5
  bundle install
6
6
 
7
- # Do any other automated setup that you need to do here
7
+ # Do any other automated setup that you need to do here
@@ -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, -> { where(inactivated_at: nil) }
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, -> { where.not(contained_at: nil) }
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, -> { where("expires_at IS NULL OR expires_at < ?".freeze, Time.now) }
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 = "2.4.0"
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, -> { where(invisible_at: nil) }
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
@@ -1,16 +1,18 @@
1
- require 'active_regulation/version'
2
- require 'active_regulation/activation'
3
- require 'active_regulation/containment'
4
- require 'active_regulation/expiration'
5
- require 'active_regulation/visibility'
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 'rails'
10
+ require "rails"
9
11
 
10
12
  module ActiveRegulation
11
13
  class Railtie < ::Rails::Railtie
12
14
 
13
- initializer 'active_regulation' do |app|
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: 2.4.0
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-01-07 00:00:00.000000000 Z
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: https://github.com/drexed/active_regulation
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.5.1
174
+ rubygems_version: 2.6.4
173
175
  signing_key:
174
176
  specification_version: 4
175
177
  summary: Gem for commonly used record states.