active_archive 4.0.0 → 4.0.1

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: 870fb2643b79b471095f5e3c621c56019628cf93
4
- data.tar.gz: 5811d3442ada47fc1ddafea1f2acab79212d584d
3
+ metadata.gz: 726842f1049b5fc85b6b45b9f8413b232d50b84d
4
+ data.tar.gz: efde2e4235ae487258d60dde82a95dfb289f5252
5
5
  SHA512:
6
- metadata.gz: 213c9daf7f511404a5f92eea6f31a1e978feeb03cbcb32e0b5da70c93906f48332f8c02e2359aa71a8d0611071b6ebdea24049d56ff013f709c7b6cf27c9f29e
7
- data.tar.gz: af77de6275006aa877d1326f695fb161b72ce46986c6e39fa5554b7455bf41513a1cc9f69b0bc40b7e9a7331e6b0bf9522446b594e775e6587f30c20035495d3
6
+ metadata.gz: 2e0694e823e05e21e6844fc67c50f498a83ae71a335dbda1f47544fdbb454b57a1d2301a1cc29dee8784e2763ccac8fe9daef275e996c9c13ff6f20fcaee378e
7
+ data.tar.gz: e0d91693520e3da56a6e1f7c2c7144d276361b1d49ee66ceb6066f93fb345b4de92ea13956083968d8be5ba91d76f52574afdd78204e44ef5bcc169939c6d24e
data/.DS_Store ADDED
Binary file
data/.reek CHANGED
@@ -1,9 +1,12 @@
1
1
  ---
2
2
  Attribute:
3
3
  enabled: false
4
+ BooleanParameter:
5
+ enabled: false
6
+ ControlParameter:
7
+ enabled: false
4
8
  FeatureEnvy:
5
- exclude:
6
- - 'ActiveArchive::Base#retrieve_dependent_records'
9
+ enabled: false
7
10
  IrresponsibleModule:
8
11
  enabled: false
9
12
  NilCheck:
@@ -12,6 +15,8 @@ ManualDispatch:
12
15
  enabled: false
13
16
  NestedIterators:
14
17
  max_allowed_nesting: 2
18
+ PrimaDonnaMethod:
19
+ enabled: false
15
20
  TooManyStatements:
16
21
  max_statements: 10
17
22
  exclude:
data/.rubocop.yml CHANGED
@@ -2,11 +2,11 @@ AllCops:
2
2
  DisplayCopNames: true
3
3
  DisplayStyleGuide: true
4
4
  TargetRubyVersion: 2.3
5
+ Exclude:
6
+ - 'spec/**/**/*'
5
7
  LineLength:
6
- Max: 120
7
- Rails/Delegate:
8
- Enabled: false
9
- Rails/Output:
8
+ Max: 100
9
+ Metrics/ModuleLength:
10
10
  Enabled: false
11
11
  Style/Alias:
12
12
  EnforcedStyle: prefer_alias_method
@@ -22,11 +22,15 @@ Style/EmptyLinesAroundClassBody:
22
22
  Enabled: false
23
23
  Style/EmptyLinesAroundModuleBody:
24
24
  Enabled: false
25
+ Style/HashSyntax:
26
+ Enabled: false
25
27
  Style/FirstParameterIndentation:
26
28
  Enabled: false
27
29
  Style/FrozenStringLiteralComment:
28
30
  Enabled: false
29
31
  Style/MultilineMethodCallIndentation:
30
32
  EnforcedStyle: aligned
33
+ Style/NumericLiterals:
34
+ Enabled: false
31
35
  Style/RescueModifier:
32
36
  Enabled: false
data/README.md CHANGED
@@ -30,15 +30,10 @@ Or install it yourself as:
30
30
 
31
31
  ## Configurations
32
32
 
33
- **Options:**
34
- * all_records_archivable
35
- * dependent_record_window
36
-
37
- `rails generate active_archive:install` will generate the following `active_archive.rb` file:
33
+ `rails generate active_archive:install` will generate the following file:
34
+ `../config/initalizers/active_archive.rb`
38
35
 
39
36
  ```ruby
40
- # Path: ../config/initalizers/active_archive.rb
41
-
42
37
  ActiveArchive::Settings.configure do |config|
43
38
  config.all_records_archivable = false
44
39
  config.dependent_record_window = 3.seconds
@@ -48,42 +43,42 @@ end
48
43
  ## Methods
49
44
 
50
45
  **Options:**
51
- * archive
52
- * destroy
53
- * destroy_all
54
- * delete
55
- * delete_all
56
- * unarchive
57
- * unarchive_all
46
+ * `archive`
47
+ * `destroy`
48
+ * `destroy_all`
49
+ * `delete`
50
+ * `delete_all`
51
+ * `unarchive`
52
+ * `unarchive_all`
58
53
 
59
54
  ```ruby
60
- User.first.archive #=> archives User record and dependents
61
- User.first.destroy #=> archives User record and dependents
62
- User.first.delete #=> deletes User record and dependents
63
- User.first.unarchive #=> unarchives User record and dependents
55
+ User.first.archive #=> archives User record and dependents
56
+ User.first.destroy #=> archives User record and dependents
57
+ User.first.delete #=> deletes User record and dependents
58
+ User.first.unarchive #=> unarchives User record and dependents
64
59
 
65
- User.first.to_archival #=> returns archival state string
60
+ User.first.to_archival #=> returns archival state string
66
61
 
67
- User.first.archive(:force) #=> destroys User record and dependents
68
- User.first.destroy(:force) #=> destroys User record and dependents
62
+ User.first.archive(:force) #=> destroys User record and dependents
63
+ User.first.destroy(:force) #=> destroys User record and dependents
69
64
 
70
- User.archive_all #=> archives all User records and dependents
71
- User.destroy_all #=> archives all User records and dependents
72
- User.delete_all #=> deletes all User records and dependents
73
- User.unarchive_all #=> unarchives all User record and dependents
65
+ User.archive_all #=> archives all User records and dependents
66
+ User.destroy_all #=> archives all User records and dependents
67
+ User.delete_all #=> deletes all User records and dependents
68
+ User.unarchive_all #=> unarchives all User record and dependents
74
69
  ```
75
70
 
76
71
  ## Scopes
77
72
 
78
73
  **Options:**
79
- * default
80
- * archived
81
- * unarchived
74
+ * `default`
75
+ * `archived`
76
+ * `unarchived`
82
77
 
83
78
  ```ruby
84
- User.all #=> returns all records
85
- User.archived.all #=> returns only archived record
86
- User.unarchived.all #=> returns only unarchived record
79
+ User.all #=> returns all records
80
+ User.archived.all #=> returns only archived record
81
+ User.unarchived.all #=> returns only unarchived record
87
82
  ```
88
83
 
89
84
  ## Contributing
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
17
  spec.bindir = 'exe'
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
- spec.require_paths = %w(lib support)
19
+ spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_runtime_dependency 'rails'
22
22
  spec.add_runtime_dependency 'dry-configurable'
@@ -29,7 +29,6 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency 'database_cleaner'
30
30
  spec.add_development_dependency 'generator_spec'
31
31
  spec.add_development_dependency 'fasterer'
32
- spec.add_development_dependency 'flay'
33
32
  spec.add_development_dependency 'reek'
34
33
  spec.add_development_dependency 'rubocop'
35
34
  end
data/lib/.DS_Store ADDED
Binary file
Binary file
@@ -35,7 +35,9 @@ module ActiveArchive
35
35
 
36
36
  def unarchive(opts = nil)
37
37
  with_transaction_returning_status do
38
- (should_unarchive_parent_first?(opts) ? unarchival.reverse : unarchival).each { |record| record.call(opts) }
38
+ records = should_unarchive_parent_first?(opts) ? unarchival.reverse : unarchival
39
+ records.each { |record| record.call(opts) }
40
+
39
41
  self
40
42
  end
41
43
  end
@@ -69,6 +71,7 @@ module ActiveArchive
69
71
  self.class.unscoped.find(id)
70
72
  end
71
73
 
74
+ # rubocop:disable Metrics/AbcSize
72
75
  def retrieve_dependent_records
73
76
  dependent_records = {}
74
77
 
@@ -85,6 +88,7 @@ module ActiveArchive
85
88
 
86
89
  dependent_records
87
90
  end
91
+ # rubocop:enable Metrics/AbcSize
88
92
 
89
93
  def permanently_delete_records(dependent_records)
90
94
  dependent_records.each do |klass, ids|
@@ -131,9 +135,9 @@ module ActiveArchive
131
135
 
132
136
  def unarchive_destroyed_dependent_records(force = nil)
133
137
  self.class.reflections
134
- .select { |_, reflection| 'destroy' == reflection.options[:dependent].to_s && reflection.klass.archivable? }
135
- .each do |name, reflection|
136
- dependent_records_for_unarchival(name, reflection).each { |record| record.unarchive(force) }
138
+ .select { |_, ref| 'destroy' == ref.options[:dependent].to_s && ref.klass.archivable? }
139
+ .each do |name, ref|
140
+ dependent_records_for_unarchival(name, ref).each { |record| record.unarchive(force) }
137
141
  end
138
142
  end
139
143
 
@@ -155,12 +159,10 @@ module ActiveArchive
155
159
  quoted_table_name = reflection.quoted_table_name
156
160
  window = ActiveArchive::Settings.config.dependent_record_window
157
161
 
162
+ query = "#{quoted_table_name}.archived_at > ? AND #{quoted_table_name}.archived_at < ?"
163
+
158
164
  send(name).unscope(where: :archived_at)
159
- .where([
160
- "#{quoted_table_name}.archived_at > ? AND #{quoted_table_name}.archived_at < ?",
161
- archived_at - window,
162
- archived_at + window
163
- ])
165
+ .where([query, archived_at - window, archived_at + window])
164
166
  end
165
167
 
166
168
  def should_force_destroy?(force)
@@ -1,3 +1,3 @@
1
1
  module ActiveArchive
2
- VERSION = '4.0.0'.freeze
2
+ VERSION = '4.0.1'.freeze
3
3
  end
@@ -1,9 +1,7 @@
1
1
  require 'rails'
2
- require 'active_archive/version'
3
- require 'active_archive/railtie'
4
- require 'active_archive/settings'
5
- require 'active_archive/table_definition'
6
- require 'active_archive/methods'
7
- require 'active_archive/scopes'
8
- require 'active_archive/base'
2
+
3
+ %w(version railtie settings table_definition methods scopes base).each do |file_name|
4
+ require "active_archive/#{file_name}"
5
+ end
6
+
9
7
  require 'generators/active_archive/install_generator'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_archive
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.0.1
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-08-30 00:00:00.000000000 Z
11
+ date: 2016-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -150,20 +150,6 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
- - !ruby/object:Gem::Dependency
154
- name: flay
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'
167
153
  - !ruby/object:Gem::Dependency
168
154
  name: reek
169
155
  requirement: !ruby/object:Gem::Requirement
@@ -199,9 +185,9 @@ executables: []
199
185
  extensions: []
200
186
  extra_rdoc_files: []
201
187
  files:
188
+ - ".DS_Store"
202
189
  - ".coveralls.yml"
203
190
  - ".fasterer.yml"
204
- - ".flayignore"
205
191
  - ".gitignore"
206
192
  - ".reek"
207
193
  - ".rspec"
@@ -216,7 +202,9 @@ files:
216
202
  - bin/rake
217
203
  - bin/setup
218
204
  - config/locales/en.yml
205
+ - lib/.DS_Store
219
206
  - lib/active_archive.rb
207
+ - lib/active_archive/.DS_Store
220
208
  - lib/active_archive/base.rb
221
209
  - lib/active_archive/methods.rb
222
210
  - lib/active_archive/railtie.rb
@@ -233,7 +221,6 @@ post_install_message:
233
221
  rdoc_options: []
234
222
  require_paths:
235
223
  - lib
236
- - support
237
224
  required_ruby_version: !ruby/object:Gem::Requirement
238
225
  requirements:
239
226
  - - ">="
data/.flayignore DELETED
@@ -1,2 +0,0 @@
1
- ./spec/lib/active_archive/*.rb
2
- ./spec/support/db/*.rb