soft_delete-workbar 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a45431d48db7b19ddbfff8a9601f00ff86753b05
4
+ data.tar.gz: c3b2d9025e5216aec4d6025f6a19f511536efb00
5
+ SHA512:
6
+ metadata.gz: a3a96839d726ae2e0fc57c60c5b4dd36d7887b9068e961ff97b03bc4c092c31fcafbbe401c887cb1615bfce3b3eb000326cfdb070f4715418decb153f76bd413
7
+ data.tar.gz: 2311bd738138c3beb81a2d049cfea8b9a9a9615faf36fa0a82547c81c112de1f3794783d7147676cbe82e7d78853f88fa1fed8ceb13daa44722112604a1e65cb
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ Gemfile.lock
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.3
5
+ before_install: gem install bundler -v 1.16.1
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in soft_delete.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Riki Konikoff
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,45 @@
1
+ ## Installation
2
+
3
+ Add this line to your application's Gemfile:
4
+
5
+ ```ruby
6
+ gem "soft_delete-workbar", require: "soft_delete"
7
+ ```
8
+
9
+ And then execute:
10
+
11
+ $ bundle
12
+
13
+ Or install it yourself as:
14
+
15
+ $ gem install soft_delete-workbar
16
+
17
+ ## Usage
18
+
19
+ Safely "delete" records from your database without losing them permanently.
20
+
21
+ * Add SoftDelete to a model
22
+ ```
23
+ class MyModel
24
+ include SoftDelete
25
+ end
26
+ ```
27
+ * Add a `deleted_at` column to the model's database table
28
+ ```
29
+ rails g migration AddSoftDeleteToMyModels deleted_at:timestamp
30
+ ```
31
+ * Safely call `MyModel#delete` without losing the record forever
32
+
33
+ ## Development
34
+
35
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
36
+
37
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
38
+
39
+ ## Contributing
40
+
41
+ Bug reports and pull requests are welcome on GitHub at https://github.com/workbar-dev/soft_delete.
42
+
43
+ ## License
44
+
45
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "soft_delete"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,46 @@
1
+ require "soft_delete/version"
2
+ require "active_support"
3
+
4
+ module SoftDelete
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ scope :not_deleted, -> { where(deleted_at: nil) }
9
+ scope :deleted, -> { where("#{table_name}.deleted_at IS NOT NULL").
10
+ references(table_name.to_sym) }
11
+ end
12
+
13
+ # "remove" record from database but don't run callbacks
14
+ def delete(type = :soft)
15
+ if type == :soft
16
+ touch(:deleted_at)
17
+ elsif type == :hard
18
+ super()
19
+ end
20
+ end
21
+
22
+ def delete!
23
+ delete(:hard)
24
+ end
25
+
26
+ def deleted?
27
+ deleted_at.present?
28
+ end
29
+
30
+ # "remove" record from database and run callbacks
31
+ def destroy(type = :soft)
32
+ if type == :soft
33
+ touch(:deleted_at)
34
+ elsif type == :hard
35
+ super()
36
+ end
37
+ end
38
+
39
+ def destroy!
40
+ destroy(:hard)
41
+ end
42
+
43
+ def restore
44
+ update_attributes(deleted_at: nil)
45
+ end
46
+ end
@@ -0,0 +1,3 @@
1
+ module SoftDelete
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,31 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "soft_delete/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "soft_delete-workbar"
8
+ spec.version = SoftDelete::VERSION
9
+ spec.authors = ["Richard Davis", "Riki Konikoff"]
10
+ spec.email = ["riki@workbar.com"]
11
+
12
+ spec.summary = "A no-frills implementation of soft delete for Rails"
13
+ spec.description = File.read("README.md")
14
+ spec.homepage = "https://github.com/workbar-dev/soft_delete.git"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_runtime_dependency "activesupport", ">= 3.2", "< 6.0"
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.16"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rspec", "~> 3.0"
29
+ spec.add_development_dependency "sqlite3", "~> 1.3"
30
+ spec.add_development_dependency "rails", "~> 4.0"
31
+ end
metadata ADDED
@@ -0,0 +1,192 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: soft_delete-workbar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Richard Davis
8
+ - Riki Konikoff
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2018-02-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '3.2'
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '6.0'
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ version: '3.2'
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '6.0'
34
+ - !ruby/object:Gem::Dependency
35
+ name: bundler
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.16'
41
+ type: :development
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.16'
48
+ - !ruby/object:Gem::Dependency
49
+ name: rake
50
+ requirement: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ type: :development
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ - !ruby/object:Gem::Dependency
77
+ name: sqlite3
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.3'
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.3'
90
+ - !ruby/object:Gem::Dependency
91
+ name: rails
92
+ requirement: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '4.0'
97
+ type: :development
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '4.0'
104
+ description: |
105
+ ## Installation
106
+
107
+ Add this line to your application's Gemfile:
108
+
109
+ ```ruby
110
+ gem "soft_delete-workbar", require: "soft_delete"
111
+ ```
112
+
113
+ And then execute:
114
+
115
+ $ bundle
116
+
117
+ Or install it yourself as:
118
+
119
+ $ gem install soft_delete-workbar
120
+
121
+ ## Usage
122
+
123
+ Safely "delete" records from your database without losing them permanently.
124
+
125
+ * Add SoftDelete to a model
126
+ ```
127
+ class MyModel
128
+ include SoftDelete
129
+ end
130
+ ```
131
+ * Add a `deleted_at` column to the model's database table
132
+ ```
133
+ rails g migration AddSoftDeleteToMyModels deleted_at:timestamp
134
+ ```
135
+ * Safely call `MyModel#delete` without losing the record forever
136
+
137
+ ## Development
138
+
139
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
140
+
141
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
142
+
143
+ ## Contributing
144
+
145
+ Bug reports and pull requests are welcome on GitHub at https://github.com/workbar-dev/soft_delete.
146
+
147
+ ## License
148
+
149
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
150
+ email:
151
+ - riki@workbar.com
152
+ executables: []
153
+ extensions: []
154
+ extra_rdoc_files: []
155
+ files:
156
+ - ".gitignore"
157
+ - ".rspec"
158
+ - ".travis.yml"
159
+ - Gemfile
160
+ - LICENSE.txt
161
+ - README.md
162
+ - Rakefile
163
+ - bin/console
164
+ - bin/setup
165
+ - lib/soft_delete.rb
166
+ - lib/soft_delete/version.rb
167
+ - soft_delete-workbar.gemspec
168
+ homepage: https://github.com/workbar-dev/soft_delete.git
169
+ licenses:
170
+ - MIT
171
+ metadata: {}
172
+ post_install_message:
173
+ rdoc_options: []
174
+ require_paths:
175
+ - lib
176
+ required_ruby_version: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ required_rubygems_version: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
186
+ requirements: []
187
+ rubyforge_project:
188
+ rubygems_version: 2.6.14
189
+ signing_key:
190
+ specification_version: 4
191
+ summary: A no-frills implementation of soft delete for Rails
192
+ test_files: []