acts_as_removable 1.1.0 → 3.1.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
- SHA1:
3
- metadata.gz: cca8b02fea9945ffb1dd7187efafbe16fd788dc6
4
- data.tar.gz: b98900fca9e10a29296ca8efd5bf2deb62695797
2
+ SHA256:
3
+ metadata.gz: 40034410cd08fcf4834c5887a8f376acc3a014eed7e2d3d97337f96008c72084
4
+ data.tar.gz: 1374f4b5cd4da3d0acb5127cdeed92993bfe726e383ffc7f99fef1bc6b4a6634
5
5
  SHA512:
6
- metadata.gz: c1669f514ae58f35ee1bb4d1a1e9f3329381c4ef1a24efe6eef1b5ed8ce7bb97c99bec40a4eba31b362ed13459718a7482b97f099933bf64acdd00d83fe64ed4
7
- data.tar.gz: 3a1704d88c080ecc6420f9e754ae66489c4c0a8374662ff6e3e61f65fd773b879197ea78a101fe1aee9898d7fcf8fda1a6f674abc68cacc07d878108c7aef098
6
+ metadata.gz: f8836c4e7faeb99e54f04c6d021b9d06848557d73b9f7d61c3a5cf6e069a771867a4c29b753bea462fbd16c0094000df48dcc2ccd0757f3b5beb50abacddae38
7
+ data.tar.gz: e615ea16131b0e0584366a89c23a644b2066068cf4d49fdd0c32685ee3a0b3ae5da13d2b318ad7dcee1c49e79ed7ebcc3ffef2950ac9edd90c205073b1ccb7de
@@ -0,0 +1,24 @@
1
+ require:
2
+ - rubocop-performance
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.4
6
+
7
+ Layout/AlignHash:
8
+ EnforcedHashRocketStyle: table
9
+ EnforcedColonStyle: table
10
+
11
+ Metrics/LineLength:
12
+ Max: 120
13
+
14
+ Metrics/AbcSize:
15
+ Enabled: false
16
+
17
+ Metrics/MethodLength:
18
+ Enabled: false
19
+
20
+ Metrics/BlockLength:
21
+ Enabled: false
22
+
23
+ Style/Documentation:
24
+ Enabled: false
@@ -1,7 +1,28 @@
1
+ sudo: false
2
+
1
3
  language: ruby
4
+
2
5
  rvm:
3
- - 1.9.3
4
- - 2.0.0
5
- - 2.1.0
6
- - 2.1.1
7
- - 2.1.2
6
+ - 2.5.8
7
+ - 2.6.6
8
+ - 2.7.2
9
+ - 3.0.0
10
+
11
+ gemfile:
12
+ - gemfiles/rails52
13
+ - gemfiles/rails60
14
+ - gemfiles/rails61
15
+
16
+ matrix:
17
+ exclude:
18
+ - rvm: 2.5.8
19
+ gemfile: gemfiles/rails61
20
+ - rvm: 2.7.2
21
+ gemfile: gemfiles/rails52
22
+ - rvm: 3.0.0
23
+ gemfile: gemfiles/rails52
24
+
25
+ script: bundle exec rake spec
26
+
27
+ before_install:
28
+ - gem install bundler -v '~> 2.0'
@@ -0,0 +1,24 @@
1
+ Changelog
2
+ ===
3
+
4
+ #### Unreleased
5
+
6
+ #### 3.1.1 (2021-01-08)
7
+ * Add workaround for new argument handling in ruby 3
8
+
9
+ #### 3.1.0 (2020-12-10)
10
+ * Support for Rails 6.1.0
11
+ * Update travis config
12
+ * Reduce travis build matrix to save time and speed up CI
13
+
14
+ #### 3.0.1 (2019-11-06)
15
+ * Fix support for Rails 6.0.X patch level releases
16
+
17
+ #### 3.0.0 (2019-08-26)
18
+ * Support for Rails 6.0.0
19
+ * Drop support for Rails < 5.0.0
20
+ * Unpin bundler gem (development dependency)
21
+ * Cleanup gemspec
22
+ * Remove .ruby-version file
23
+ * Update copyright
24
+ * Add this Changelog
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in acts_as_removable.gemspec
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 SIC! Software GmbH
1
+ Copyright (c) 2019 SIC! Software GmbH
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -37,13 +37,6 @@ class MyModel < ActiveRecord::Base
37
37
  end
38
38
  ```
39
39
 
40
- It's possible to add a default scope with the active (not removed) records:
41
- ```ruby
42
- class MyModel < ActiveRecord::Base
43
- acts_as_removable with_default_scope: true
44
- end
45
- ```
46
-
47
40
  And you can use callbacks:
48
41
  ```ruby
49
42
  class MyModel < ActiveRecord::Base
data/Rakefile CHANGED
@@ -1,7 +1,9 @@
1
- require "bundler/gem_tasks"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
2
4
 
3
5
  require 'rspec/core'
4
6
  require 'rspec/core/rake_task'
5
7
  RSpec::Core::RakeTask.new(:spec)
6
8
 
7
- task :default => :spec
9
+ task default: :spec
@@ -1,28 +1,32 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'English'
4
6
  require 'acts_as_removable/version'
5
7
 
6
8
  Gem::Specification.new do |spec|
7
- spec.name = "acts_as_removable"
9
+ spec.name = 'acts_as_removable'
8
10
  spec.version = ActsAsRemovable::VERSION
9
- spec.authors = ["Florian Schwab", "Erik Ernst"]
10
- spec.email = ["florian.schwab@sic-software.com"]
11
- spec.description = %q{Simplifies handling of pseudo removed records}
12
- spec.summary = %q{Simplifies handling of pseudo removed records}
13
- spec.homepage = "https://github.com/SICSoftwareGmbH/acts_as_removable"
14
- spec.license = "MIT"
11
+ spec.authors = ['Florian Schwab', 'Erik-B. Ernst']
12
+ spec.email = ['florian.schwab@sic.software', 'erik.ernst@sic.software']
13
+ spec.description = 'Simplifies handling of pseudo removed records.'
14
+ spec.summary = 'Simplifies handling of pseudo removed records.'
15
+ spec.homepage = 'https://github.com/SICSoftwareGmbH/acts_as_removable'
16
+ spec.license = 'MIT'
15
17
 
16
- spec.files = `git ls-files`.split($/)
18
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
19
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
20
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
21
+ spec.require_paths = ['lib']
20
22
 
21
- spec.add_dependency 'activesupport', '> 4.0.0'
22
- spec.add_dependency 'activerecord', '> 4.0.0'
23
+ spec.add_dependency 'activerecord', '>= 5.0', '< 6.2'
24
+ spec.add_dependency 'activesupport', '>= 5.0', '< 6.2'
23
25
 
24
- spec.add_development_dependency 'bundler', '~> 1.3'
26
+ spec.add_development_dependency 'bundler', '~> 2.0'
25
27
  spec.add_development_dependency 'rake'
26
28
  spec.add_development_dependency 'rspec'
29
+ spec.add_development_dependency 'rubocop'
30
+ spec.add_development_dependency 'rubocop-performance'
27
31
  spec.add_development_dependency 'sqlite3'
28
32
  end
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rails-menu-manager.gemspec
4
+ gemspec path: '..'
5
+
6
+
7
+ gem 'railties', '~> 5.2'
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rails-menu-manager.gemspec
4
+ gemspec path: '..'
5
+
6
+
7
+ gem 'railties', '~> 6.0'
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rails-menu-manager.gemspec
4
+ gemspec path: '..'
5
+
6
+
7
+ gem 'railties', '~> 6.1'
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support/concern'
2
4
  require 'active_record'
3
- require "acts_as_removable/version"
5
+ require 'acts_as_removable/version'
4
6
 
5
7
  module ActsAsRemovable
6
8
  extend ActiveSupport::Concern
@@ -10,29 +12,21 @@ module ActsAsRemovable
10
12
  #
11
13
  # acts_as_removable
12
14
  # acts_as_removable column_name: 'other_column_name'
13
- # acts_as_removable with_default_scope: true
14
15
  #
15
16
  # ===== Options
16
17
  #
17
18
  # * <tt>:column_name</tt> - A symbol or string with the column to use for removal timestamp.
18
- # * <tt>:with_default_scope</tt> - A boolean indicating to set a default scope with only active (not removed) records
19
19
  def acts_as_removable(options = {})
20
20
  _acts_as_removable_options.merge!(options)
21
21
 
22
- scope :removed, -> {
23
- removed_at_column_name = _acts_as_removable_options[:column_name]
24
- query = where(all.table[removed_at_column_name].not_eq(nil).to_sql)
25
- _removable_where_values(query, removed_at_column_name, all.table[removed_at_column_name].eq(nil).to_sql)
22
+ scope :removed, lambda {
23
+ where(all.table[_acts_as_removable_options[:column_name]].not_eq(nil).to_sql)
26
24
  }
27
25
 
28
- scope :actives, -> {
29
- removed_at_column_name = _acts_as_removable_options[:column_name]
30
- query = where(all.table[removed_at_column_name].eq(nil).to_sql)
31
- _removable_where_values(query, removed_at_column_name, all.table[removed_at_column_name].not_eq(nil).to_sql)
26
+ scope :actives, lambda {
27
+ where(all.table[_acts_as_removable_options[:column_name]].eq(nil).to_sql)
32
28
  }
33
29
 
34
- default_scope -> {where(all.table[_acts_as_removable_options[:column_name]].eq(nil).to_sql)} if _acts_as_removable_options[:with_default_scope]
35
-
36
30
  define_model_callbacks :remove, :unremove
37
31
 
38
32
  class_eval do
@@ -76,7 +70,13 @@ module ActsAsRemovable
76
70
  self.class.transaction do
77
71
  run_callbacks callback.to_sym do
78
72
  send("#{self.class._acts_as_removable_options[:column_name]}=", value)
79
- with_bang ? save!(options) : save(options)
73
+
74
+ # workaround for new argument handling
75
+ if RUBY_VERSION.to_i < 3
76
+ with_bang ? save!(options) : save(options)
77
+ else
78
+ with_bang ? save!(**options) : save(**options)
79
+ end
80
80
  end
81
81
  end
82
82
  end
@@ -84,16 +84,7 @@ module ActsAsRemovable
84
84
  end
85
85
 
86
86
  def _acts_as_removable_options
87
- @_acts_as_removable_options ||= {
88
- column_name: 'removed_at'
89
- }
90
- end
91
-
92
- # Delete where statements from query
93
- def _removable_where_values(query, column_name, remove_where)
94
- query = query.with_default_scope if query.respond_to?(:with_default_scope)
95
- query.where_values.delete(remove_where)
96
- query
87
+ @_acts_as_removable_options ||= { column_name: 'removed_at' }
97
88
  end
98
89
  end
99
90
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActsAsRemovable
2
- VERSION = '1.1.0'
4
+ VERSION = '3.1.1'
3
5
  end
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe 'acts_as_removable' do
4
6
  class MyModel < ActiveRecord::Base
5
- acts_as_removable with_default_scope: true
7
+ acts_as_removable
6
8
  attr_accessor :callback_before_remove, :callback_after_remove, :callback_before_unremove, :callback_after_unremove
7
9
  before_remove do |r|
8
10
  r.callback_before_remove = true
@@ -26,10 +28,10 @@ describe 'acts_as_removable' do
26
28
  before do
27
29
  # setup database
28
30
  db_file = File.expand_path(File.join(File.dirname(__FILE__), '..', 'tmp', 'acts_as_removable.db'))
29
- Dir::mkdir(File.dirname(db_file)) unless File.exists?(File.dirname(db_file))
31
+ Dir.mkdir(File.dirname(db_file)) unless File.exist?(File.dirname(db_file))
30
32
  ActiveRecord::Base.establish_connection(
31
- :adapter => 'sqlite3',
32
- :database => "#{File.expand_path(File.join(File.dirname(__FILE__), '..'))}/tmp/acts_as_removable.db"
33
+ adapter: 'sqlite3',
34
+ database: "#{File.expand_path(File.join(File.dirname(__FILE__), '..'))}/tmp/acts_as_removable.db"
33
35
  )
34
36
  ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS 'my_models'")
35
37
  ActiveRecord::Base.connection.create_table(:my_models) do |t|
@@ -62,7 +64,7 @@ describe 'acts_as_removable' do
62
64
  MySecondModel.create!
63
65
  MySecondModel.create!.remove!
64
66
 
65
- expect(MyModel.count).to be(1)
67
+ expect(MyModel.count).to be(2)
66
68
  expect(MyModel.actives.count).to be(1)
67
69
  expect(MyModel.removed.count).to be(1)
68
70
  expect(MyModel.unscoped.count).to be(2)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rubygems'
2
4
  require 'bundler/setup'
3
5
 
metadata CHANGED
@@ -1,58 +1,70 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_removable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Schwab
8
- - Erik Ernst
8
+ - Erik-B. Ernst
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-20 00:00:00.000000000 Z
12
+ date: 2021-01-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: activesupport
15
+ name: activerecord
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ">"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 4.0.0
20
+ version: '5.0'
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '6.2'
21
24
  type: :runtime
22
25
  prerelease: false
23
26
  version_requirements: !ruby/object:Gem::Requirement
24
27
  requirements:
25
- - - ">"
28
+ - - ">="
26
29
  - !ruby/object:Gem::Version
27
- version: 4.0.0
30
+ version: '5.0'
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '6.2'
28
34
  - !ruby/object:Gem::Dependency
29
- name: activerecord
35
+ name: activesupport
30
36
  requirement: !ruby/object:Gem::Requirement
31
37
  requirements:
32
- - - ">"
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '5.0'
41
+ - - "<"
33
42
  - !ruby/object:Gem::Version
34
- version: 4.0.0
43
+ version: '6.2'
35
44
  type: :runtime
36
45
  prerelease: false
37
46
  version_requirements: !ruby/object:Gem::Requirement
38
47
  requirements:
39
- - - ">"
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '5.0'
51
+ - - "<"
40
52
  - !ruby/object:Gem::Version
41
- version: 4.0.0
53
+ version: '6.2'
42
54
  - !ruby/object:Gem::Dependency
43
55
  name: bundler
44
56
  requirement: !ruby/object:Gem::Requirement
45
57
  requirements:
46
58
  - - "~>"
47
59
  - !ruby/object:Gem::Version
48
- version: '1.3'
60
+ version: '2.0'
49
61
  type: :development
50
62
  prerelease: false
51
63
  version_requirements: !ruby/object:Gem::Requirement
52
64
  requirements:
53
65
  - - "~>"
54
66
  - !ruby/object:Gem::Version
55
- version: '1.3'
67
+ version: '2.0'
56
68
  - !ruby/object:Gem::Dependency
57
69
  name: rake
58
70
  requirement: !ruby/object:Gem::Requirement
@@ -81,6 +93,34 @@ dependencies:
81
93
  - - ">="
82
94
  - !ruby/object:Gem::Version
83
95
  version: '0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: rubocop
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rubocop-performance
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ type: :development
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
84
124
  - !ruby/object:Gem::Dependency
85
125
  name: sqlite3
86
126
  requirement: !ruby/object:Gem::Requirement
@@ -95,21 +135,26 @@ dependencies:
95
135
  - - ">="
96
136
  - !ruby/object:Gem::Version
97
137
  version: '0'
98
- description: Simplifies handling of pseudo removed records
138
+ description: Simplifies handling of pseudo removed records.
99
139
  email:
100
- - florian.schwab@sic-software.com
140
+ - florian.schwab@sic.software
141
+ - erik.ernst@sic.software
101
142
  executables: []
102
143
  extensions: []
103
144
  extra_rdoc_files: []
104
145
  files:
105
146
  - ".gitignore"
106
- - ".ruby-version"
147
+ - ".rubocop.yml"
107
148
  - ".travis.yml"
149
+ - Changelog.md
108
150
  - Gemfile
109
151
  - LICENSE
110
152
  - README.md
111
153
  - Rakefile
112
154
  - acts_as_removable.gemspec
155
+ - gemfiles/rails52
156
+ - gemfiles/rails60
157
+ - gemfiles/rails61
113
158
  - lib/acts_as_removable.rb
114
159
  - lib/acts_as_removable/version.rb
115
160
  - spec/acts_as_removable_spec.rb
@@ -133,12 +178,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
178
  - !ruby/object:Gem::Version
134
179
  version: '0'
135
180
  requirements: []
136
- rubyforge_project:
137
- rubygems_version: 2.4.6
181
+ rubygems_version: 3.2.3
138
182
  signing_key:
139
183
  specification_version: 4
140
- summary: Simplifies handling of pseudo removed records
184
+ summary: Simplifies handling of pseudo removed records.
141
185
  test_files:
142
186
  - spec/acts_as_removable_spec.rb
143
187
  - spec/spec_helper.rb
144
- has_rdoc:
@@ -1 +0,0 @@
1
- ruby-2.0.0