permanent_records 4.2.7 → 4.2.8

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
- SHA1:
3
- metadata.gz: 4bdca6f3d0ced279ab4cad8b9d83bd23cb2e2725
4
- data.tar.gz: c9c53f6405d8a4146872ec0f52bee8f8b8741ea0
2
+ SHA256:
3
+ metadata.gz: 2a557f2f7f287f2cbd1990950e869d2a943e5c8593df0dbd41520790d049f3b0
4
+ data.tar.gz: 8ebc139901710c0599e36873217a70ad936918a1dbf93520797099b2c7e8e40d
5
5
  SHA512:
6
- metadata.gz: c672b6118fbc111d523d6f3e5a252610383a9a9c8ffb3e047920c4c9c3dcb0d68a418f87c27c4b5c6891f4107f77d95a8612e343f64df80bd31b4ee388a3f311
7
- data.tar.gz: 61e651908d6acf7674661c5fd3e0b3b2140efd89686ee1e089a7664a5dcc4da1019a5d9beb3ebd9add1a13b0de392557e733a367e1df2e7e694c743109f4a4ec
6
+ metadata.gz: 0d547b27a573c1abdc3a85c7803d56452f95c8a8a6f485476f52e18d2173ad67e25e5b9904ad4b9fe6a22fdecaf9ba57b1866a432f940917841202ace3fc9c0a
7
+ data.tar.gz: e4a8d014f056e37ef0e941cc52251c63acc935051e5103822dd7f8942ce9c086bbad6fc0a20ce687c0f8e35d5d48b12dd2affbf859baab89e83318c6c49f6ca1
data/.rubocop.yml CHANGED
@@ -1,6 +1,12 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
1
3
  AllCops:
2
4
  Exclude:
3
5
  - bin/*
6
+ TargetRubyVersion: 2.0
7
+
8
+ Metrics/BlockLength:
9
+ Enabled: false
4
10
 
5
11
  Metrics/LineLength:
6
12
  Max: 120
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,12 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2019-10-09 11:48:30 +0200 using RuboCop version 0.50.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 15
10
+ Lint/AmbiguousBlockAssociation:
11
+ Exclude:
12
+ - 'spec/permanent_records_spec.rb'
data/.travis.yml CHANGED
@@ -1,8 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
4
- - 2.2.2
5
- - 2.3.0
3
+ - 2.0.0-p648
4
+ - 2.2.10
5
+ - 2.3.8
6
6
  env:
7
7
  - AR_TEST_VERSION: 4.2.0
8
- - AR_TEST_VERSION: 4.2.5
8
+ - AR_TEST_VERSION: 4.2.11.1
@@ -0,0 +1,46 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ ## Our Standards
8
+
9
+ Examples of behavior that contributes to creating a positive environment include:
10
+
11
+ * Using welcoming and inclusive language
12
+ * Being respectful of differing viewpoints and experiences
13
+ * Gracefully accepting constructive criticism
14
+ * Focusing on what is best for the community
15
+ * Showing empathy towards other community members
16
+
17
+ Examples of unacceptable behavior by participants include:
18
+
19
+ * The use of sexualized language or imagery and unwelcome sexual attention or advances
20
+ * Trolling, insulting/derogatory comments, and personal or political attacks
21
+ * Public or private harassment
22
+ * Publishing others' private information, such as a physical or electronic address, without explicit permission
23
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
24
+
25
+ ## Our Responsibilities
26
+
27
+ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
+
29
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30
+
31
+ ## Scope
32
+
33
+ This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34
+
35
+ ## Enforcement
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at permanentrecords@jackcanty.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
+
39
+ Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40
+
41
+ ## Attribution
42
+
43
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44
+
45
+ [homepage]: http://contributor-covenant.org
46
+ [version]: http://contributor-covenant.org/version/1/4/
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # PermanentRecords (Rails 3.1+)
1
+ # PermanentRecords (Rails 4.2)
2
2
 
3
3
  [http://github.com/JackDanger/permanent_records/](http://github.com/JackDanger/permanent_records/)
4
4
 
data/README.rst ADDED
@@ -0,0 +1,115 @@
1
+ PermanentRecords (Rails 4.2)
2
+ =============================
3
+
4
+ http://github.com/JackDanger/permanent_records/
5
+
6
+ This gem prevents any of your ActiveRecord data from being destroyed.
7
+ Any model that you've given a "deleted\_at" datetime column will have
8
+ that column set rather than let the record be deleted.
9
+
10
+ What methods does it give me?
11
+ -----------------------------
12
+
13
+ .. code:: ruby
14
+
15
+ User.find(3).destroy # Sets the 'deleted_at' attribute to Time.now
16
+ # and returns a frozen record. If halted by a
17
+ # before_destroy callback it returns false instead
18
+
19
+ User.find(3).destroy(:force) # Executes the real destroy method, the record
20
+ # will be removed from the database.
21
+
22
+ User.destroy_all # Soft-deletes all User records.
23
+
24
+ User.delete_all # bye bye everything (no soft-deleting here)
25
+
26
+ There are also two scopes provided for easily searching deleted and not
27
+ deleted records:
28
+
29
+ .. code:: ruby
30
+
31
+ User.deleted.find(...) # Only returns deleted records.
32
+
33
+ User.not_deleted.find(...) # Only returns non-deleted records.
34
+
35
+ Note: Your normal finds will, by default, *include* deleted records.
36
+ You'll have to manually use the ``not_deleted`` scope to avoid this:
37
+
38
+ .. code:: ruby
39
+
40
+ User.find(1) # Will find record number 1, even if it's deleted.
41
+
42
+ User.not_deleted.find(1) # This is probably what you want, it doesn't find deleted records.
43
+
44
+ Can I easily undelete records?
45
+ ------------------------------
46
+
47
+ Yes. All you need to do is call the 'revive' method.
48
+
49
+ .. code:: ruby
50
+
51
+ User.find(3).destroy # The user is now deleted.
52
+
53
+ User.find(3).revive # The user is back to it's original state.
54
+
55
+ And if you had dependent records that were set to be destroyed along
56
+ with the parent record:
57
+
58
+ .. code:: ruby
59
+
60
+ class User < ActiveRecord::Base
61
+ has_many :comments, :dependent => :destroy
62
+ end
63
+
64
+ User.find(3).destroy # All the comments are destroyed as well.
65
+
66
+ User.find(3).revive # All the comments that were just destroyed
67
+ # are now back in pristine condition.
68
+
69
+ Forcing deletion works the same way: if you hard delete a record, its
70
+ dependent records will also be hard deleted.
71
+
72
+ Can I use default scopes?
73
+ -------------------------
74
+
75
+ .. code:: ruby
76
+
77
+ default_scope where(:deleted_at => nil)
78
+
79
+ If you use such a default scope, you will need to simulate the
80
+ ``deleted`` scope with a method
81
+
82
+ .. code:: ruby
83
+
84
+ def self.deleted
85
+ self.unscoped.where('deleted_at IS NOT NULL')
86
+ end
87
+
88
+ Is Everything Automated?
89
+ ------------------------
90
+
91
+ Yes. You don't have to change ANY of your code to get permanent
92
+ archiving of all your data with this gem. When you call ``destroy`` on
93
+ any record (or ``destroy_all`` on a class or association) your records
94
+ will all have a deleted\_at timestamp set on them.
95
+
96
+ Upgrading from 3.x
97
+ ------------------
98
+
99
+ The behaviour of the ``destroy`` method has been updated so that it now
100
+ returns ``false`` when halted by a before\_destroy callback. This is in
101
+ line with behaviour of ActiveRecord. For more information see
102
+ `#47 <https://github.com/JackDanger/permanent_records/issues/47>`__.
103
+
104
+ Productionizing
105
+ ---------------
106
+
107
+ If you operate a system where destroying or reviving a record takes more
108
+ than about 3 seconds then you'll want to customize
109
+ ``PermanentRecords.dependent_record_window = 10.seconds`` or some other
110
+ value that works for you.
111
+
112
+ Patches welcome, forks celebrated.
113
+
114
+ Copyright 2015 Jack Danger Canty @ https://jdanger.com released under
115
+ the MIT license
data/Rakefile CHANGED
@@ -33,7 +33,11 @@ RSpec::Core::RakeTask.new(:rspec) do |t|
33
33
  t.rspec_opts = '-f d -c'
34
34
  end
35
35
 
36
- task publish: [:rubocop, :rspec] do
36
+ task :pandoc do
37
+ system('pandoc -s -r markdown -w rst README.md -o README.rst')
38
+ end
39
+
40
+ task publish: %i[pandoc rubocop rspec] do
37
41
  # Ensure the gem builds
38
42
  system('gem build permanent_records.gemspec') &&
39
43
  # And we didn't leave anything (aside from the gem) uncommitted
@@ -42,4 +46,4 @@ task publish: [:rubocop, :rspec] do
42
46
  system("gem push permanent_records-#{version}.gem")
43
47
  end
44
48
 
45
- task default: [:rspec, :rubocop]
49
+ task default: %i[rspec rubocop]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.2.7
1
+ 4.2.8
@@ -22,7 +22,7 @@ module PermanentRecords
22
22
  end
23
23
  end
24
24
 
25
- def is_permanent? # rubocop:disable Style/PredicateName
25
+ def is_permanent? # rubocop:disable Naming/PredicateName
26
26
  respond_to?(:deleted_at)
27
27
  end
28
28
 
@@ -76,11 +76,12 @@ module PermanentRecords
76
76
  ]
77
77
  end
78
78
 
79
- def get_deleted_record # rubocop:disable Style/AccessorMethodName
79
+ def get_deleted_record # rubocop:disable Naming/AccessorMethodName
80
80
  self.class.unscoped.find(id)
81
81
  end
82
82
 
83
83
  # rubocop:disable Metrics/MethodLength
84
+ # rubocop:disable Lint/RescueWithoutErrorClass
84
85
  def set_deleted_at(value, force = nil)
85
86
  return self unless is_permanent?
86
87
  record = get_deleted_record
@@ -104,10 +105,12 @@ module PermanentRecords
104
105
  raise e
105
106
  end
106
107
  end
108
+ # rubocop:enable Lint/RescueWithoutErrorClass
109
+ # rubocop:enable Metrics/MethodLength
107
110
 
108
111
  def each_counter_cache
109
112
  _reflections.each do |name, reflection|
110
- association = send(name.to_sym)
113
+ association = respond_to?(name.to_sym) ? send(name.to_sym) : nil
111
114
  next if association.nil?
112
115
  next unless reflection.belongs_to? && reflection.counter_cache_column
113
116
 
@@ -119,6 +122,7 @@ module PermanentRecords
119
122
  end
120
123
  end
121
124
 
125
+ # rubocop:disable Metrics/MethodLength
122
126
  def destroy_with_permanent_records(force = nil)
123
127
  run_callbacks(:destroy) do
124
128
  if deleted? || new_record?
@@ -134,6 +138,7 @@ module PermanentRecords
134
138
  end
135
139
  deleted? ? self : false
136
140
  end
141
+ # rubocop:enable Metrics/MethodLength
137
142
 
138
143
  def add_record_window(_request, name, reflection)
139
144
  send(name).unscope(where: :deleted_at).where(
@@ -157,6 +162,7 @@ module PermanentRecords
157
162
  reload
158
163
  end
159
164
 
165
+ # rubocop:disable Metrics/MethodLength
160
166
  def destroyed_dependent_relations
161
167
  PermanentRecords.dependent_permanent_reflections(self.class).map do |name, relation|
162
168
  cardinality = relation.macro.to_s.gsub('has_', '').to_sym
@@ -172,6 +178,7 @@ module PermanentRecords
172
178
  end
173
179
  end
174
180
  end
181
+ # rubocop:enable Metrics/MethodLength
175
182
 
176
183
  def attempt_notifying_observers(callback)
177
184
  notify_observers(callback)
@@ -231,8 +238,8 @@ module PermanentRecords
231
238
 
232
239
  # Included into ActiveRecord for all models
233
240
  module IsPermanent
234
- def is_permanent? # rubocop:disable Style/PredicateName
235
- columns.detect { |c| 'deleted_at' == c.name }
241
+ def is_permanent? # rubocop:disable Naming/PredicateName
242
+ columns.detect { |c| c.name == 'deleted_at' }
236
243
  end
237
244
  end
238
245
 
@@ -240,16 +247,16 @@ module PermanentRecords
240
247
  if force.is_a?(Hash)
241
248
  force[:force]
242
249
  else
243
- :force == force
250
+ force == :force
244
251
  end
245
252
  end
246
253
 
247
254
  def self.should_revive_parent_first?(order)
248
- order.is_a?(Hash) && true == order[:reverse]
255
+ order.is_a?(Hash) && order[:reverse] == true
249
256
  end
250
257
 
251
258
  def self.should_ignore_validations?(force)
252
- force.is_a?(Hash) && false == force[:validate]
259
+ force.is_a?(Hash) && force[:validate] == false
253
260
  end
254
261
 
255
262
  def self.dependent_record_window
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  Gem::Specification.new do |s|
3
2
  s.name = 'permanent_records'
4
3
  s.version = File.read('VERSION')
@@ -8,10 +7,10 @@ Gem::Specification.new do |s|
8
7
  'Trond Arve Nordheim', 'Josh Teneycke', 'Maximilian Herold',
9
8
  'Hugh Evans', 'Sergey Gnuskov', 'aq', 'Joel AZEMAR']
10
9
  s.summary = 'Soft-delete your ActiveRecord records'
11
- s.description = <<-EOS
12
- Never Lose Data. Rather than deleting rows this sets Record#deleted_at and
13
- gives you all the scopes you need to work with your data.
14
- EOS
10
+ s.description = <<-DESCRIPTION
11
+ Never Lose Data. Rather than deleting rows this sets Record#deleted_at and
12
+ gives you all the scopes you need to work with your data.
13
+ DESCRIPTION
15
14
  s.email = 'github@jackcanty.com'
16
15
  s.extra_rdoc_files = [
17
16
  'LICENSE',
@@ -27,12 +26,12 @@ EOS
27
26
  ver = ENV['AR_TEST_VERSION']
28
27
  ver = ver.dup.chomp if ver
29
28
 
30
- s.add_runtime_dependency('activerecord', ver || '>= 4.2.0')
31
- s.add_runtime_dependency('activesupport', ver || '>= 4.2.0')
32
- s.add_development_dependency('database_cleaner', '>= 1.5.1')
33
- s.add_development_dependency('pry-byebug')
34
- s.add_development_dependency('rake') # For Travis-ci
35
- s.add_development_dependency('rspec', '~> 3.5.0')
36
- s.add_development_dependency('rubocop', '0.42.0')
37
- s.add_development_dependency('sqlite3')
29
+ s.add_runtime_dependency 'activerecord', ver || '>= 4.2.0'
30
+ s.add_runtime_dependency 'activesupport', ver || '>= 4.2.0'
31
+ s.add_development_dependency 'database_cleaner', '>= 1.5.1'
32
+ s.add_development_dependency 'pry-byebug'
33
+ s.add_development_dependency 'rake' # For Travis-ci
34
+ s.add_development_dependency 'rspec', '>= 3.5.0'
35
+ s.add_development_dependency 'rubocop', '~> 0.50.0' # freeze to ensure ruby 2.0 compatibility
36
+ s.add_development_dependency 'sqlite3', '~> 1.3.6' # freeze to ensure specs are working
38
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: permanent_records
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.7
4
+ version: 4.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Danger Canty
@@ -17,36 +17,36 @@ authors:
17
17
  autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
- date: 2016-09-22 00:00:00.000000000 Z
20
+ date: 2019-10-15 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: activerecord
24
24
  requirement: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - ">="
26
+ - - '='
27
27
  - !ruby/object:Gem::Version
28
- version: 4.2.0
28
+ version: 4.2.11.1
29
29
  type: :runtime
30
30
  prerelease: false
31
31
  version_requirements: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - ">="
33
+ - - '='
34
34
  - !ruby/object:Gem::Version
35
- version: 4.2.0
35
+ version: 4.2.11.1
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: activesupport
38
38
  requirement: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - ">="
40
+ - - '='
41
41
  - !ruby/object:Gem::Version
42
- version: 4.2.0
42
+ version: 4.2.11.1
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - ">="
47
+ - - '='
48
48
  - !ruby/object:Gem::Version
49
- version: 4.2.0
49
+ version: 4.2.11.1
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: database_cleaner
52
52
  requirement: !ruby/object:Gem::Requirement
@@ -93,47 +93,47 @@ dependencies:
93
93
  name: rspec
94
94
  requirement: !ruby/object:Gem::Requirement
95
95
  requirements:
96
- - - "~>"
96
+ - - ">="
97
97
  - !ruby/object:Gem::Version
98
98
  version: 3.5.0
99
99
  type: :development
100
100
  prerelease: false
101
101
  version_requirements: !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - "~>"
103
+ - - ">="
104
104
  - !ruby/object:Gem::Version
105
105
  version: 3.5.0
106
106
  - !ruby/object:Gem::Dependency
107
107
  name: rubocop
108
108
  requirement: !ruby/object:Gem::Requirement
109
109
  requirements:
110
- - - '='
110
+ - - "~>"
111
111
  - !ruby/object:Gem::Version
112
- version: 0.42.0
112
+ version: 0.50.0
113
113
  type: :development
114
114
  prerelease: false
115
115
  version_requirements: !ruby/object:Gem::Requirement
116
116
  requirements:
117
- - - '='
117
+ - - "~>"
118
118
  - !ruby/object:Gem::Version
119
- version: 0.42.0
119
+ version: 0.50.0
120
120
  - !ruby/object:Gem::Dependency
121
121
  name: sqlite3
122
122
  requirement: !ruby/object:Gem::Requirement
123
123
  requirements:
124
- - - ">="
124
+ - - "~>"
125
125
  - !ruby/object:Gem::Version
126
- version: '0'
126
+ version: 1.3.6
127
127
  type: :development
128
128
  prerelease: false
129
129
  version_requirements: !ruby/object:Gem::Requirement
130
130
  requirements:
131
- - - ">="
131
+ - - "~>"
132
132
  - !ruby/object:Gem::Version
133
- version: '0'
134
- description: |
135
- Never Lose Data. Rather than deleting rows this sets Record#deleted_at and
136
- gives you all the scopes you need to work with your data.
133
+ version: 1.3.6
134
+ description: |2
135
+ Never Lose Data. Rather than deleting rows this sets Record#deleted_at and
136
+ gives you all the scopes you need to work with your data.
137
137
  email: github@jackcanty.com
138
138
  executables: []
139
139
  extensions: []
@@ -144,11 +144,14 @@ files:
144
144
  - ".document"
145
145
  - ".gitignore"
146
146
  - ".rubocop.yml"
147
+ - ".rubocop_todo.yml"
147
148
  - ".travis.yml"
149
+ - CODE_OF_CONDUCT.md
148
150
  - CONTRIBUTORS.md
149
151
  - Gemfile
150
152
  - LICENSE
151
153
  - README.md
154
+ - README.rst
152
155
  - Rakefile
153
156
  - VERSION
154
157
  - bin/rspec
@@ -174,10 +177,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
177
  - !ruby/object:Gem::Version
175
178
  version: '0'
176
179
  requirements: []
177
- rubyforge_project:
178
- rubygems_version: 2.5.1
180
+ rubygems_version: 3.0.3
179
181
  signing_key:
180
182
  specification_version: 4
181
183
  summary: Soft-delete your ActiveRecord records
182
184
  test_files: []
183
- has_rdoc: