vandal 0.0.1 → 0.0.2

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: fece4c65b959612f8fb5faac683c5e8bbd83d857
4
- data.tar.gz: a51419ed4045344409cfe60bae47b7911f538d8c
3
+ metadata.gz: 8afec3eb69eafc34cf100faa3150ea9ce304d64b
4
+ data.tar.gz: d5266ad3fca523193a9db0bf2da3b7dffa3feb1a
5
5
  SHA512:
6
- metadata.gz: 23b0d2fa48fc9d920edead140b2f74a14537d50b19c1dea56722925c55f04d38a71acede6b68f975677bc877b3055d38926ba659ba153475007768e1a2d6b9b0
7
- data.tar.gz: 101e90b49be4619b669c87a7a0ee52f0bc9d76fd297731beffc7ee633d80822c2571cdaff86e4a1a729b2aff11b4c2b4b5db41e824075c9db508303c80b1377e
6
+ metadata.gz: d19727ab4794d6615f263e4cf25266dc9752e404fca5b4e13d532e604f5b8a06a28f64f651bf63b3b6150b3561225ccb4eed15c3120a5691b00d9edd0931affb
7
+ data.tar.gz: f1ebff9f9312782e4e93f1ea68a6273939ae86424e3c5b7155d410e97674a7fba31bfbab3aacf2181555cf10b9f885739bdbdc91d3864a3891a0774afdac6ec5
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ .byebug_history
data/.rspec CHANGED
@@ -1,3 +1,3 @@
1
- --format documentation
2
1
  --color
3
2
  --require spec_helper
3
+ -f d
@@ -1,27 +1,117 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vandal (0.1.0)
4
+ vandal (0.0.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
+ actioncable (5.2.3)
10
+ actionpack (= 5.2.3)
11
+ nio4r (~> 2.0)
12
+ websocket-driver (>= 0.6.1)
13
+ actionmailer (5.2.3)
14
+ actionpack (= 5.2.3)
15
+ actionview (= 5.2.3)
16
+ activejob (= 5.2.3)
17
+ mail (~> 2.5, >= 2.5.4)
18
+ rails-dom-testing (~> 2.0)
19
+ actionpack (5.2.3)
20
+ actionview (= 5.2.3)
21
+ activesupport (= 5.2.3)
22
+ rack (~> 2.0)
23
+ rack-test (>= 0.6.3)
24
+ rails-dom-testing (~> 2.0)
25
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
26
+ actionview (5.2.3)
27
+ activesupport (= 5.2.3)
28
+ builder (~> 3.1)
29
+ erubi (~> 1.4)
30
+ rails-dom-testing (~> 2.0)
31
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
32
+ activejob (5.2.3)
33
+ activesupport (= 5.2.3)
34
+ globalid (>= 0.3.6)
35
+ activemodel (5.2.3)
36
+ activesupport (= 5.2.3)
37
+ activerecord (5.2.3)
38
+ activemodel (= 5.2.3)
39
+ activesupport (= 5.2.3)
40
+ arel (>= 9.0)
41
+ activestorage (5.2.3)
42
+ actionpack (= 5.2.3)
43
+ activerecord (= 5.2.3)
44
+ marcel (~> 0.3.1)
45
+ activesupport (5.2.3)
46
+ concurrent-ruby (~> 1.0, >= 1.0.2)
47
+ i18n (>= 0.7, < 2)
48
+ minitest (~> 5.1)
49
+ tzinfo (~> 1.1)
50
+ arel (9.0.0)
9
51
  ast (2.4.0)
52
+ builder (3.2.3)
10
53
  byebug (10.0.2)
11
- coderay (1.1.2)
54
+ concurrent-ruby (1.1.5)
55
+ crass (1.0.4)
56
+ database_cleaner (1.7.0)
12
57
  diff-lcs (1.3)
58
+ erubi (1.8.0)
59
+ factory_bot (5.0.2)
60
+ activesupport (>= 4.2.0)
61
+ factory_bot_rails (5.0.2)
62
+ factory_bot (~> 5.0.2)
63
+ railties (>= 4.2.0)
64
+ globalid (0.4.2)
65
+ activesupport (>= 4.2.0)
66
+ i18n (1.6.0)
67
+ concurrent-ruby (~> 1.0)
13
68
  jaro_winkler (1.5.1)
69
+ loofah (2.2.3)
70
+ crass (~> 1.0.2)
71
+ nokogiri (>= 1.5.9)
72
+ mail (2.7.1)
73
+ mini_mime (>= 0.1.1)
74
+ marcel (0.3.3)
75
+ mimemagic (~> 0.3.2)
14
76
  method_source (0.9.1)
77
+ mimemagic (0.3.3)
78
+ mini_mime (1.0.1)
79
+ mini_portile2 (2.4.0)
80
+ minitest (5.11.3)
81
+ nio4r (2.3.1)
82
+ nokogiri (1.10.3)
83
+ mini_portile2 (~> 2.4.0)
15
84
  parallel (1.12.1)
16
85
  parser (2.5.3.0)
17
86
  ast (~> 2.4.0)
18
87
  powerpack (0.1.2)
19
- pry (0.12.0)
20
- coderay (~> 1.1.0)
21
- method_source (~> 0.9.0)
22
- pry-byebug (3.6.0)
23
- byebug (~> 10.0)
24
- pry (~> 0.10)
88
+ rack (2.0.7)
89
+ rack-test (1.1.0)
90
+ rack (>= 1.0, < 3)
91
+ rails (5.2.3)
92
+ actioncable (= 5.2.3)
93
+ actionmailer (= 5.2.3)
94
+ actionpack (= 5.2.3)
95
+ actionview (= 5.2.3)
96
+ activejob (= 5.2.3)
97
+ activemodel (= 5.2.3)
98
+ activerecord (= 5.2.3)
99
+ activestorage (= 5.2.3)
100
+ activesupport (= 5.2.3)
101
+ bundler (>= 1.3.0)
102
+ railties (= 5.2.3)
103
+ sprockets-rails (>= 2.0.0)
104
+ rails-dom-testing (2.0.3)
105
+ activesupport (>= 4.2.0)
106
+ nokogiri (>= 1.6)
107
+ rails-html-sanitizer (1.0.4)
108
+ loofah (~> 2.2, >= 2.2.2)
109
+ railties (5.2.3)
110
+ actionpack (= 5.2.3)
111
+ activesupport (= 5.2.3)
112
+ method_source
113
+ rake (>= 0.8.7)
114
+ thor (>= 0.19.0, < 2.0)
25
115
  rainbow (3.0.0)
26
116
  rake (12.3.1)
27
117
  rspec (3.8.0)
@@ -36,6 +126,14 @@ GEM
36
126
  rspec-mocks (3.8.0)
37
127
  diff-lcs (>= 1.2.0, < 2.0)
38
128
  rspec-support (~> 3.8.0)
129
+ rspec-rails (3.8.2)
130
+ actionpack (>= 3.0)
131
+ activesupport (>= 3.0)
132
+ railties (>= 3.0)
133
+ rspec-core (~> 3.8.0)
134
+ rspec-expectations (~> 3.8.0)
135
+ rspec-mocks (~> 3.8.0)
136
+ rspec-support (~> 3.8.0)
39
137
  rspec-support (3.8.0)
40
138
  rubocop (0.60.0)
41
139
  jaro_winkler (~> 1.5.1)
@@ -46,17 +144,38 @@ GEM
46
144
  ruby-progressbar (~> 1.7)
47
145
  unicode-display_width (~> 1.4.0)
48
146
  ruby-progressbar (1.10.0)
147
+ sprockets (3.7.2)
148
+ concurrent-ruby (~> 1.0)
149
+ rack (> 1, < 3)
150
+ sprockets-rails (3.2.1)
151
+ actionpack (>= 4.0)
152
+ activesupport (>= 4.0)
153
+ sprockets (>= 3.0.0)
154
+ sqlite3 (1.4.1)
155
+ thor (0.20.3)
156
+ thread_safe (0.3.6)
157
+ tzinfo (1.2.5)
158
+ thread_safe (~> 0.1)
49
159
  unicode-display_width (1.4.0)
160
+ websocket-driver (0.7.0)
161
+ websocket-extensions (>= 0.1.0)
162
+ websocket-extensions (0.1.3)
50
163
 
51
164
  PLATFORMS
52
165
  ruby
53
166
 
54
167
  DEPENDENCIES
55
168
  bundler
56
- pry-byebug
169
+ byebug
170
+ database_cleaner
171
+ factory_bot
172
+ factory_bot_rails
173
+ rails
57
174
  rake
58
175
  rspec
176
+ rspec-rails
59
177
  rubocop
178
+ sqlite3
60
179
  vandal!
61
180
 
62
181
  BUNDLED WITH
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
- # Vandal
1
+ <p align="center">
2
+ <img src="https://github.com/kirillshevch/vandal/raw/master/vandal.jpg?sanitize=true" width="65%" alt="Vandal Logo"/>
3
+ </p>
2
4
 
3
5
  A small gem that help to *delete an ActiveRecord instance or collection with associations* (skipping callbacks or validations)
4
6
 
@@ -14,26 +16,26 @@ gem 'vandal'
14
16
 
15
17
  Vandal gem adds 2 methods to `ActiveRecord::Base`
16
18
 
17
- ## #vandal_destroy!
19
+ ## #vandal_destroy
18
20
 
19
21
  Delete an ActiveRecord instance with associations even if the callbacks return false or rescue error.
20
22
 
21
23
  ```ruby
22
24
  class User
23
- has_many :followers # Does not contain dependent: :destroy
25
+ has_many :followers # Does not even contain dependent: :destroy
24
26
  end
25
27
 
26
- User.find_by(id: 1).vandal_destroy!
28
+ User.find_by(id: 1).vandal_destroy
27
29
  ```
28
30
 
29
31
  Followers will deleted along with `User`.
30
32
 
31
- ## #vandal_destroy_all!
33
+ ## #vandal_destroy_all
32
34
 
33
35
  Applies `vandal_destroy!` for ActiveRecord collection
34
36
 
35
37
  ```ruby
36
- User.all.vandal_destroy_all!
38
+ User.all.vandal_destroy_all
37
39
  ```
38
40
 
39
41
  ## Contributing
@@ -1,37 +1,33 @@
1
1
  require 'vandal/version'
2
- require 'pry-byebug'
3
2
 
4
3
  module Vandal
5
4
  module Destroy
6
5
  extend ::ActiveSupport::Concern
7
- DELETE_OPTIONS = [:destroy, :delete, :delete_all]
8
6
 
9
7
  def vandal_destroy
10
- begin
11
- @destroying ||= false
12
- return if @destroying
13
- @destroying = true
14
- self.class.transaction do
15
- self.class.related_associations.each do |association|
16
- related = self.send(association[:name])
17
- related.send("vandal_destroy#{association[:collection] ? '_all': ''}") if related.present?
18
- end
19
- self.delete
8
+ @destroying ||= false
9
+ return if @destroying
10
+ @destroying = true
11
+ self.class.transaction do
12
+ self.class.related_associations.each do |association|
13
+ related = send(association[:name])
14
+ related.send("vandal_destroy#{association[:collection] ? '_all' : ''}") if related.present?
20
15
  end
21
- ensure
22
- @destroying = false
16
+ delete
23
17
  end
18
+ ensure
19
+ @destroying = false
24
20
  end
25
21
 
26
22
  module ClassMethods
27
23
  def vandal_destroy_all
28
- transaction { find_each { |r| r.vandal_destroy! } }
24
+ transaction { find_each { |r| r.vandal_destroy } }
29
25
  end
30
26
 
31
27
  def related_associations
32
- @related_associations ||= reflections.select do |name, association|
33
- association.options[:dependent].in?(DELETE_OPTIONS)
34
- end.collect { |name, association| { name: name, collection: association.collection? } }
28
+ @related_associations ||= reflections.collect do |name, association|
29
+ { name: name, collection: association.collection? }
30
+ end
35
31
  end
36
32
  end
37
33
  end
@@ -1,3 +1,3 @@
1
1
  module Vandal
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ['Kirill Shevchenko']
9
9
  spec.email = ['hello@kirillshevch.com']
10
10
 
11
- spec.summary = 'ActiveRecord force destroy records with associations'
11
+ spec.summary = 'ActiveRecord force destroy records with all related associations'
12
12
  spec.description = spec.summary
13
13
  spec.homepage = 'https://github.com/kirillshevch/vandal'
14
14
  spec.license = 'MIT'
@@ -23,5 +23,11 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency 'rake'
24
24
  spec.add_development_dependency 'rspec'
25
25
  spec.add_development_dependency 'rubocop'
26
- spec.add_development_dependency 'pry-byebug'
26
+ spec.add_development_dependency 'byebug'
27
+ spec.add_development_dependency 'rspec-rails'
28
+ spec.add_development_dependency 'factory_bot'
29
+ spec.add_development_dependency 'factory_bot_rails'
30
+ spec.add_development_dependency 'database_cleaner'
31
+ spec.add_development_dependency 'rails'
32
+ spec.add_development_dependency 'sqlite3'
27
33
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vandal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Shevchenko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-27 00:00:00.000000000 Z
11
+ date: 2019-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: pry-byebug
70
+ name: byebug
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -80,7 +80,91 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- description: ActiveRecord force destroy records with associations
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec-rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: factory_bot
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: factory_bot_rails
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: database_cleaner
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rails
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: sqlite3
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
+ description: ActiveRecord force destroy records with all related associations
84
168
  email:
85
169
  - hello@kirillshevch.com
86
170
  executables: []
@@ -101,6 +185,7 @@ files:
101
185
  - lib/vandal.rb
102
186
  - lib/vandal/version.rb
103
187
  - vandal.gemspec
188
+ - vandal.jpg
104
189
  homepage: https://github.com/kirillshevch/vandal
105
190
  licenses:
106
191
  - MIT
@@ -124,5 +209,5 @@ rubyforge_project:
124
209
  rubygems_version: 2.6.13
125
210
  signing_key:
126
211
  specification_version: 4
127
- summary: ActiveRecord force destroy records with associations
212
+ summary: ActiveRecord force destroy records with all related associations
128
213
  test_files: []