discard 1.2.0 → 1.4.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
  SHA256:
3
- metadata.gz: 1aa5617487d7e2fed08d3afbe5e88e92aaef5371c1678a7f3c4acf532341ab56
4
- data.tar.gz: 4f4da23a43a04274325db950a05bbfb3ff478430bea166c5c9d941fb2181769e
3
+ metadata.gz: 0626ecc4ddd0c4d8e9fb8c9c0edbd42aa664576cbea51403d904c58cb4857c2b
4
+ data.tar.gz: 8ec497ce993f3fe49c5ea802021e45b8c04c43b97b5ebd5bc19deb5e91da8843
5
5
  SHA512:
6
- metadata.gz: 96650925ee2f6dd7c348059f17320decf4f26e6b4c942d046440d99bc23307059f48e2fc5792389bafc6cfa0594ff1382c671cc0f4e6ad5c312d83e964872a61
7
- data.tar.gz: 2299ad7c8cdd56eddf50497351e2a654732aa72caca5d319cf6218185323a7cf9769113d0f62185ae7927acbbbeb4bec98b4963e5062590aadcc379b5581ec4a
6
+ metadata.gz: 10c74db9ce658b50d0b2112e34c901a06e69db789d74842400e4b9a9c32ae92b390a67ed6fc189b262d82de8eddeea3e71d85048ce43fbb7a223d758af768b40
7
+ data.tar.gz: bb82e531e3098c835bfcbbf1aabf8d06b1356346b1eeee361f01080b4c0d5c3d682f0987c1959588c84fea44769f32f4da6db4916430f656516d4872951b1a53
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
@@ -11,20 +11,41 @@ on:
11
11
  jobs:
12
12
  build:
13
13
  runs-on: ubuntu-latest
14
- name: Test on Rails ${{ matrix.rails_version }}
14
+ name: Test on Rails ${{ matrix.rails_version }} and Ruby ${{ matrix.ruby_version }}
15
15
  strategy:
16
+ fail-fast: false
16
17
  matrix:
17
- rails_version:
18
- - ~> 5.1.0
19
- - ~> 5.2.0
20
- - ~> 6.0.0
21
- container: docker://ruby
18
+ include:
19
+ - rails_version: 8.0.0.rc1
20
+ ruby_version: '3.3'
21
+ sqlite_version: ~> 2.0
22
+ - rails_version: ~> 7.2.0
23
+ ruby_version: '3.3'
24
+ sqlite_version: ~> 2.0
25
+ - rails_version: ~> 7.2.0
26
+ ruby_version: '3.2'
27
+ sqlite_version: ~> 2.0
28
+ - rails_version: ~> 7.2.0
29
+ ruby_version: '3.1'
30
+ sqlite_version: ~> 2.0
31
+ - rails_version: ~> 7.1.0
32
+ ruby_version: '3.3'
33
+ sqlite_version: ~> 1.0
34
+ - rails_version: ~> 7.0.0
35
+ ruby_version: '3.2'
36
+ sqlite_version: ~> 1.0
37
+ - rails_version: ~> 6.1.0
38
+ ruby_version: '3.0'
39
+ sqlite_version: ~> 1.0
40
+ env:
41
+ RAILS_VERSION: ${{ matrix.rails_version }}
42
+ SQLITE_VERSION: ${{ matrix.sqlite_version }}
22
43
  steps:
23
- - uses: actions/checkout@v1
24
- - name: Build and test
25
- run: |
26
- gem install bundler
27
- bundle install --jobs 4 --retry 3
28
- bundle exec rake
29
- env:
30
- RAILS_VERSION: ${{ matrix.rails_version }}
44
+ - uses: actions/checkout@v4
45
+ - uses: ruby/setup-ruby@v1
46
+ with:
47
+ ruby-version: ${{ matrix.ruby_version }}
48
+ - name: Bundle install
49
+ run: bundle install
50
+ - name: Test
51
+ run: bundle exec rake
data/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  ### Unreleased
2
2
 
3
+ ### Version 1.4.0
4
+ Release date: 2024-11-05
5
+
6
+ * Support Rails 8.0 and 8.1 (#110, #111)
7
+
8
+ * More descriptive error messages (#108)
9
+
10
+ ### Version 1.3.0
11
+ Release date: 2023-08-17
12
+
13
+ * Fix `undiscard` so it returns false instead of nil when the record isn't
14
+ discarded (#95, #96)
15
+
16
+ ### Version 1.2.1
17
+ Release date: 2021-12-16
18
+
19
+ * Support for ActiveRecord 7
20
+
21
+ ### Version 1.2.0
22
+ Release date: 2020-02-17
23
+
3
24
  * Add `discard_all!` and `undiscard_all!`
4
25
  * Add `undiscarded?` and `kept?` to match the scopes of the same names
5
26
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Discard [![Build Status](https://travis-ci.org/jhawthorn/discard.svg?branch=master)](https://travis-ci.org/jhawthorn/discard)
1
+ # Discard [![Test](https://github.com/jhawthorn/discard/actions/workflows/test.yml/badge.svg)](https://github.com/jhawthorn/discard/actions/workflows/test.yml)
2
2
 
3
3
  Soft deletes for ActiveRecord done right.
4
4
 
@@ -13,7 +13,7 @@ A simple ActiveRecord mixin to add conventions for flagging records as discarded
13
13
  Add this line to your application's Gemfile:
14
14
 
15
15
  ```ruby
16
- gem 'discard', '~> 1.2'
16
+ gem 'discard', '~> 1.4'
17
17
  ```
18
18
 
19
19
  And then execute:
@@ -265,6 +265,8 @@ Discard takes a different approach. It doesn't override any ActiveRecord
265
265
  methods and instead simply provides convenience methods and scopes for
266
266
  discarding (hiding), restoring, and querying records.
267
267
 
268
+ You can find more information about the history and purpose of Discard in [this blog post](https://supergood.software/introduction-to-discard/).
269
+
268
270
  ## Development
269
271
 
270
272
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/discard.gemspec CHANGED
@@ -22,9 +22,9 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ["lib"]
24
24
 
25
- spec.add_dependency "activerecord", ">= 4.2", "< 7"
25
+ spec.add_dependency "activerecord", ">= 4.2", "< 9.0"
26
26
  spec.add_development_dependency "bundler"
27
- spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rake", ">= 10.0"
28
28
  spec.add_development_dependency "rspec", "~> 3.5.0"
29
29
  spec.add_development_dependency "database_cleaner", "~> 1.5"
30
30
  spec.add_development_dependency "with_model", "~> 2.0"
data/lib/discard/model.rb CHANGED
@@ -138,13 +138,13 @@ module Discard
138
138
  #
139
139
  # @return [Boolean] true if successful, otherwise false
140
140
  def undiscard
141
- return unless discarded?
141
+ return false unless discarded?
142
142
  run_callbacks(:undiscard) do
143
143
  update_attribute(self.class.discard_column, nil)
144
144
  end
145
145
  end
146
146
 
147
- # Discard the record in the database
147
+ # Undiscard the record in the database
148
148
  #
149
149
  # There's a series of callbacks associated with #undiscard!. If the
150
150
  # <tt>before_undiscard</tt> callback throws +:abort+ the action is cancelled
@@ -159,11 +159,23 @@ module Discard
159
159
  private
160
160
 
161
161
  def _raise_record_not_discarded
162
- raise ::Discard::RecordNotDiscarded.new("Failed to discard the record", self)
162
+ raise ::Discard::RecordNotDiscarded.new(discarded_fail_message, self)
163
163
  end
164
164
 
165
165
  def _raise_record_not_undiscarded
166
- raise ::Discard::RecordNotUndiscarded.new("Failed to undiscard the record", self)
166
+ raise ::Discard::RecordNotUndiscarded.new(undiscarded_fail_message, self)
167
+ end
168
+
169
+ def discarded_fail_message
170
+ return "A discarded record cannot be discarded" if discarded?
171
+
172
+ "Failed to discard the record"
173
+ end
174
+
175
+ def undiscarded_fail_message
176
+ return "An undiscarded record cannot be undiscarded" if undiscarded?
177
+
178
+ "Failed to undiscard the record"
167
179
  end
168
180
  end
169
181
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Discard
4
4
  # Discard version
5
- VERSION = "1.2.0".freeze
5
+ VERSION = "1.4.0".freeze
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discard
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Hawthorn
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-17 00:00:00.000000000 Z
11
+ date: 2024-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '4.2'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '7'
22
+ version: '9.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '4.2'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '7'
32
+ version: '9.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: bundler
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -48,14 +48,14 @@ dependencies:
48
48
  name: rake
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - "~>"
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: '10.0'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - "~>"
58
+ - - ">="
59
59
  - !ruby/object:Gem::Version
60
60
  version: '10.0'
61
61
  - !ruby/object:Gem::Dependency
@@ -124,10 +124,10 @@ extra_rdoc_files: []
124
124
  files:
125
125
  - ".github/ISSUE_TEMPLATE/bug-report.md"
126
126
  - ".github/ISSUE_TEMPLATE/feature-proposal.md"
127
+ - ".github/dependabot.yml"
127
128
  - ".github/workflows/test.yml"
128
129
  - ".gitignore"
129
130
  - ".rspec"
130
- - ".travis.yml"
131
131
  - ".yardopts"
132
132
  - CHANGELOG.md
133
133
  - CODE_OF_CONDUCT.md
@@ -146,7 +146,7 @@ homepage: https://github.com/jhawthorn/discard
146
146
  licenses:
147
147
  - MIT
148
148
  metadata: {}
149
- post_install_message:
149
+ post_install_message:
150
150
  rdoc_options: []
151
151
  require_paths:
152
152
  - lib
@@ -161,8 +161,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
161
  - !ruby/object:Gem::Version
162
162
  version: '0'
163
163
  requirements: []
164
- rubygems_version: 3.1.0.pre2
165
- signing_key:
164
+ rubygems_version: 3.5.16
165
+ signing_key:
166
166
  specification_version: 4
167
167
  summary: ActiveRecord soft-deletes done right
168
168
  test_files: []
data/.travis.yml DELETED
@@ -1,28 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- rvm:
4
- - 2.2
5
- - 2.3
6
- - 2.4
7
- - 2.5
8
- - 2.6
9
- - 2.7
10
- env:
11
- matrix:
12
- - RAILS_VERSION='~> 4.2.0' SQLITE_VERSION='~> 1.3.6'
13
- - RAILS_VERSION='~> 5.0.0' SQLITE_VERSION='~> 1.3.6'
14
- - RAILS_VERSION='~> 5.1.0'
15
- - RAILS_VERSION='~> 5.2.0'
16
- - RAILS_VERSION='~> 6.0.0'
17
-
18
- matrix:
19
- exclude:
20
- - rvm: 2.2
21
- env: RAILS_VERSION='~> 6.0.0'
22
- - rvm: 2.3
23
- env: RAILS_VERSION='~> 6.0.0'
24
- - rvm: 2.4
25
- env: RAILS_VERSION='~> 6.0.0'
26
- # Rails 4.2 uses BigDecimal.new, which Ruby 2.7 removed
27
- - rvm: 2.7
28
- env: RAILS_VERSION='~> 4.2.0' SQLITE_VERSION='~> 1.3.6'