active_regulation 3.0.0 → 4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a6a7533f1dfd24d8beec4f436456a2e9cda15f81
4
- data.tar.gz: e30b757d5bb1cded248a455f006c13060b1911e9
3
+ metadata.gz: 8e7a0c19c6117f65aac59511995935748d9b5c87
4
+ data.tar.gz: 9f17c2f73de10abf7235f787a4de4aee274e57fd
5
5
  SHA512:
6
- metadata.gz: d15e03a90a9fcd19d803eb208a5cb9bdf3cfc332ccaada9f393852586d77da8b01271b80877a98af6ee14ba38b855d90401b8639136bd189845f279f328aa5e2
7
- data.tar.gz: 12cbb4125d8c30d6b8a4644dd67242e2bfd1eeb2dbc47a0b6ffb6b4a2b0397efbdeb65fd8ba0c8420fa3632d813903301ab03cce8e479f63eb31fe1fac53485b
6
+ metadata.gz: be3cccf34c5dd15aed77b9608dcccc18948c32418ca2b3a78cb0d4450889dee2fc7ec24cad223ac0949bda2782eb6cc5313a72ab9765d7b4958e51a350fd7074
7
+ data.tar.gz: 7c0fc3e4ae367827d349637e5af31c0c293496321c2b2e3503759915e59776596949ea9b221f6a7e7e3f69fc516acdfdc43e8c3ef2588f8ea0566df8cd59ac51
data/.DS_Store ADDED
Binary file
data/.fasterer.yml ADDED
@@ -0,0 +1,19 @@
1
+ speedups:
2
+ rescue_vs_respond_to: true
3
+ module_eval: true
4
+ shuffle_first_vs_sample: true
5
+ for_loop_vs_each: true
6
+ each_with_index_vs_while: false
7
+ map_flatten_vs_flat_map: true
8
+ reverse_each_vs_reverse_each: true
9
+ select_first_vs_detect: true
10
+ sort_vs_sort_by: true
11
+ fetch_with_argument_vs_block: true
12
+ keys_each_vs_each_key: true
13
+ hash_merge_bang_vs_hash_brackets: true
14
+ block_vs_symbol_to_proc: true
15
+ proc_call_vs_yield: true
16
+ gsub_vs_tr: true
17
+ select_last_vs_reverse_detect: true
18
+ getter_vs_attr_reader: true
19
+ setter_vs_attr_writer: true
data/.reek ADDED
@@ -0,0 +1,27 @@
1
+ ---
2
+ Attribute:
3
+ enabled: false
4
+ BooleanParameter:
5
+ enabled: false
6
+ ControlParameter:
7
+ enabled: false
8
+ FeatureEnvy:
9
+ enabled: false
10
+ IrresponsibleModule:
11
+ enabled: false
12
+ LongParameterList:
13
+ enabled: false
14
+ ManualDispatch:
15
+ enabled: false
16
+ NestedIterators:
17
+ max_allowed_nesting: 2
18
+ NilCheck:
19
+ enabled: false
20
+ PrimaDonnaMethod:
21
+ enabled: false
22
+ RepeatedConditional:
23
+ enabled: false
24
+ TooManyStatements:
25
+ max_statements: 10
26
+ UtilityFunction:
27
+ enabled: false
data/.rubocop.yml ADDED
@@ -0,0 +1,38 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+ DisplayStyleGuide: true
4
+ TargetRubyVersion: 2.3
5
+ Exclude:
6
+ - 'spec/**/**/*'
7
+ LineLength:
8
+ Max: 100
9
+ Metrics/ClassLength:
10
+ Enabled: false
11
+ Metrics/ModuleLength:
12
+ Enabled: false
13
+ Style/Alias:
14
+ EnforcedStyle: prefer_alias_method
15
+ Style/BracesAroundHashParameters:
16
+ Enabled: false
17
+ Style/ClosingParenthesisIndentation:
18
+ Enabled: false
19
+ Style/Documentation:
20
+ Enabled: false
21
+ Style/EmptyLinesAroundBlockBody:
22
+ Enabled: false
23
+ Style/EmptyLinesAroundClassBody:
24
+ Enabled: false
25
+ Style/EmptyLinesAroundModuleBody:
26
+ Enabled: false
27
+ Style/HashSyntax:
28
+ Enabled: false
29
+ Style/FirstParameterIndentation:
30
+ Enabled: false
31
+ Style/FrozenStringLiteralComment:
32
+ Enabled: false
33
+ Style/MultilineMethodCallIndentation:
34
+ EnforcedStyle: aligned
35
+ Style/NumericLiterals:
36
+ Enabled: false
37
+ Style/RescueModifier:
38
+ Enabled: false
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
4
  gemspec
data/README.md CHANGED
@@ -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:
@@ -30,20 +30,20 @@ Or install it yourself as:
30
30
  ## Methods
31
31
 
32
32
  **Modules:**
33
- * activation
34
- * containment
35
- * expiration
36
- * quarantine
37
- * suspension
38
- * visibility
33
+ * `activation`
34
+ * `containment`
35
+ * `expiration`
36
+ * `quarantine`
37
+ * `suspension`
38
+ * `visibility`
39
39
 
40
40
  **Attributes:**
41
- * :inactivated_at
42
- * :contained_at
43
- * :expires_at
44
- * :invisible_at
45
- * :quarantined_at
46
- * :suspended_at
41
+ * `:inactivated_at`
42
+ * `:contained_at`
43
+ * `:expires_at`
44
+ * `:invisible_at`
45
+ * `:quarantined_at`
46
+ * `:suspended_at`
47
47
 
48
48
  ```ruby
49
49
  class User < ActiveRecord::Base
data/Rakefile CHANGED
@@ -1,3 +1,3 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
2
 
3
3
  task default: :spec
@@ -1,31 +1,34 @@
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"
7
+ spec.name = 'active_regulation'
8
8
  spec.version = ActiveRegulation::VERSION
9
- spec.authors = ["Juan Gomez"]
10
- spec.email = ["j.gomez@drexed.com"]
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 = "http://drexed.github.io/active_regulation"
15
- spec.license = "MIT"
12
+ spec.summary = 'Gem for commonly used record states.'
13
+ spec.description = '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
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = "exe"
18
+ spec.bindir = 'exe'
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib", "support"]
20
+ spec.require_paths = %w(lib support)
21
21
 
22
- spec.add_runtime_dependency "activerecord"
23
- spec.add_runtime_dependency "activesupport"
22
+ spec.add_runtime_dependency 'activerecord'
23
+ spec.add_runtime_dependency 'activesupport'
24
24
 
25
- spec.add_development_dependency "bundler"
26
- spec.add_development_dependency "coveralls"
27
- spec.add_development_dependency "rake"
28
- spec.add_development_dependency "rspec"
29
- spec.add_development_dependency "sqlite3"
30
- spec.add_development_dependency "database_cleaner"
25
+ spec.add_development_dependency 'bundler'
26
+ spec.add_development_dependency 'coveralls'
27
+ spec.add_development_dependency 'rake'
28
+ spec.add_development_dependency 'rspec'
29
+ spec.add_development_dependency 'sqlite3'
30
+ spec.add_development_dependency 'database_cleaner'
31
+ spec.add_development_dependency 'fasterer'
32
+ spec.add_development_dependency 'reek'
33
+ spec.add_development_dependency 'rubocop'
31
34
  end
data/bin/console CHANGED
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "active_regulation"
3
+ require 'bundler/setup'
4
+ require 'active_regulation'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
8
8
 
9
9
  # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
10
+ # require 'pry'
11
11
  # Pry.start
12
12
 
13
- require "irb"
13
+ require 'irb'
14
14
  IRB.start
data/bin/rake CHANGED
@@ -2,15 +2,14 @@
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",
11
- Pathname.new(__FILE__).realpath)
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', Pathname.new(__FILE__).realpath)
12
11
 
13
- require "rubygems"
14
- require "bundler/setup"
12
+ require 'rubygems'
13
+ require 'bundler/setup'
15
14
 
16
- load Gem.bin_path("rake", "rake")
15
+ load Gem.bin_path('rake', 'rake')
@@ -1,20 +1,20 @@
1
1
  en:
2
2
  active_regulation:
3
3
  activation:
4
- active: "Active"
5
- inactive: "Inactive"
4
+ active: 'Active'
5
+ inactive: 'Inactive'
6
6
  containment:
7
- contained: "Contained"
8
- uncontained: "Uncontained"
7
+ contained: 'Contained'
8
+ uncontained: 'Uncontained'
9
9
  expiration:
10
- expired: "Expired"
11
- unexpired: "Unexpired"
10
+ expired: 'Expired'
11
+ unexpired: 'Unexpired'
12
12
  quarantine:
13
- quarantined: "Quarantined"
14
- unquarantined: "Unquarantined"
13
+ quarantined: 'Quarantined'
14
+ unquarantined: 'Unquarantined'
15
15
  suspension:
16
- suspended: "Suspended"
17
- unsuspended: "Unsuspended"
16
+ suspended: 'Suspended'
17
+ unsuspended: 'Unsuspended'
18
18
  visibility:
19
- invisible: "Invisible"
20
- visible: "Visible"
19
+ invisible: 'Invisible'
20
+ visible: 'Visible'
@@ -5,15 +5,15 @@ 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) }
9
- scope :unexpired, -> { where("expires_at IS NOT NULL AND expires_at >= ?".freeze, Time.now) }
8
+ scope :expired, -> { where('expires_at IS NULL OR expires_at < ?', Time.now) }
9
+ scope :unexpired, -> { where('expires_at IS NOT NULL AND expires_at >= ?', Time.now) }
10
10
  end
11
11
 
12
12
  def expire!
13
13
  update(expires_at: nil) unless expires_at.nil?
14
14
  end
15
15
 
16
- def extend!(amount=nil)
16
+ def extend!(amount = nil)
17
17
  update(expires_at: extension_date(amount))
18
18
  end
19
19
 
@@ -29,7 +29,7 @@ module ActiveRegulation
29
29
  expires_at.nil? ? false : (Time.now < expires_at)
30
30
  end
31
31
 
32
- def expires_at_or_time(amount=nil)
32
+ def expires_at_or_time(amount = nil)
33
33
  expired? ? extension_date(amount) : expires_at
34
34
  end
35
35
 
@@ -39,7 +39,7 @@ module ActiveRegulation
39
39
 
40
40
  private
41
41
 
42
- def extension_date(time=nil)
42
+ def extension_date(time = nil)
43
43
  time = 30 if time.nil?
44
44
 
45
45
  time.is_a?(Integer) ? (DateTime.now + time) : time
@@ -0,0 +1,21 @@
1
+ if defined?(Rails)
2
+ module ActiveRegulation
3
+ class Railtie < ::Rails::Railtie
4
+
5
+ initializer 'active_regulation' do |app|
6
+ ActiveRegulation::Railtie.instance_eval do
7
+ [app.config.i18n.available_locales].flatten.each do |locale|
8
+ (I18n.load_path << path(locale)) if File.file?(path(locale))
9
+ end
10
+ end
11
+ end
12
+
13
+ protected
14
+
15
+ def path(locale)
16
+ File.expand_path("../../config/locales/#{locale}.yml", __FILE__)
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module ActiveRegulation
2
- VERSION = "3.0.0"
2
+ VERSION = '4.0.0'.freeze
3
3
  end
@@ -1,31 +1,3 @@
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"
8
-
9
- if defined?(Rails)
10
- require "rails"
11
-
12
- module ActiveRegulation
13
- class Railtie < ::Rails::Railtie
14
-
15
- initializer "active_regulation" do |app|
16
- ActiveRegulation::Railtie.instance_eval do
17
- [app.config.i18n.available_locales].flatten.each do |locale|
18
- (I18n.load_path << path(locale)) if File.file?(path(locale))
19
- end
20
- end
21
- end
22
-
23
- protected
24
-
25
- def self.path(locale)
26
- File.expand_path("../../config/locales/#{locale}.yml", __FILE__)
27
- end
28
-
29
- end
30
- end
1
+ %w(version activation containment expiration quarantine suspension visibility).each do |file_name|
2
+ require "active_regulation/#{file_name}"
31
3
  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: 3.0.0
4
+ version: 4.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-06-02 00:00:00.000000000 Z
11
+ date: 2016-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -122,6 +122,48 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: fasterer
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: reek
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
125
167
  description: Manage the states of records by commonly used attributes.
126
168
  email:
127
169
  - j.gomez@drexed.com
@@ -129,9 +171,13 @@ executables: []
129
171
  extensions: []
130
172
  extra_rdoc_files: []
131
173
  files:
174
+ - ".DS_Store"
132
175
  - ".coveralls.yml"
176
+ - ".fasterer.yml"
133
177
  - ".gitignore"
178
+ - ".reek"
134
179
  - ".rspec"
180
+ - ".rubocop.yml"
135
181
  - ".travis.yml"
136
182
  - CODE_OF_CONDUCT.md
137
183
  - Gemfile
@@ -147,6 +193,7 @@ files:
147
193
  - lib/active_regulation/containment.rb
148
194
  - lib/active_regulation/expiration.rb
149
195
  - lib/active_regulation/quarantine.rb
196
+ - lib/active_regulation/railtie.rb
150
197
  - lib/active_regulation/suspension.rb
151
198
  - lib/active_regulation/version.rb
152
199
  - lib/active_regulation/visibility.rb