amoeba 3.1.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +98 -8
- data/Appraisals +63 -7
- data/README.md +2 -2
- data/amoeba.gemspec +8 -8
- data/gemfiles/activerecord_4.2.gemfile +3 -2
- data/gemfiles/{activerecord_4.0.gemfile → activerecord_5.0.gemfile} +4 -3
- data/gemfiles/{activerecord_4.1.gemfile → activerecord_5.1.gemfile} +4 -3
- data/gemfiles/activerecord_5.2.gemfile +18 -0
- data/gemfiles/activerecord_6.0.gemfile +18 -0
- data/gemfiles/activerecord_6.1.gemfile +18 -0
- data/gemfiles/activerecord_head.gemfile +4 -3
- data/gemfiles/jruby_activerecord_6.1.gemfile +19 -0
- data/gemfiles/jruby_activerecord_head.gemfile +28 -0
- data/lib/amoeba/config.rb +4 -2
- data/lib/amoeba/version.rb +1 -1
- data/spec/lib/amoeba_spec.rb +35 -7
- data/spec/spec_helper.rb +2 -2
- metadata +20 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4ae461133565a412e2338cfa8b4f2fd8cbed8fa5a4b5bd56724c8f583888312c
|
4
|
+
data.tar.gz: 127513d887e21e276b1511c0b6556d311832df82d781f9bd46bac708d4a830d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5e8515376b4a6cb533630fb17980bc72ba46b916e40a8bd66e99944e31dd5603d63a5a33d4fc5aeed09ea59e4750f94a8a70ded31c2d0b596c82ca290603947
|
7
|
+
data.tar.gz: dd2e5f454c30535c68a704b1488a8de0e33bfe237130a79a57584cd5ae4bb1437ba99fef0f5e1dd1784750d64a9a8ac753c1064d35cdb4ea8a635dcdfbafec0c
|
data/.travis.yml
CHANGED
@@ -1,20 +1,110 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.0.0
|
4
|
-
- 2.1
|
5
3
|
- 2.2
|
6
4
|
- 2.3
|
5
|
+
- 2.4
|
6
|
+
- 2.5
|
7
|
+
- 2.6
|
8
|
+
- 2.7
|
9
|
+
- 3.0
|
7
10
|
- ruby-head
|
8
|
-
- jruby
|
9
|
-
- rbx-2
|
11
|
+
- jruby
|
10
12
|
gemfile:
|
11
|
-
- gemfiles/activerecord_4.0.gemfile
|
12
|
-
- gemfiles/activerecord_4.1.gemfile
|
13
13
|
- gemfiles/activerecord_4.2.gemfile
|
14
|
+
- gemfiles/activerecord_5.0.gemfile
|
15
|
+
- gemfiles/activerecord_5.1.gemfile
|
16
|
+
- gemfiles/activerecord_5.2.gemfile
|
17
|
+
- gemfiles/activerecord_6.0.gemfile
|
18
|
+
- gemfiles/activerecord_6.1.gemfile
|
19
|
+
- gemfiles/jruby_activerecord_6.1.gemfile
|
14
20
|
- gemfiles/activerecord_head.gemfile
|
21
|
+
- gemfiles/jruby_activerecord_head.gemfile
|
15
22
|
matrix:
|
16
23
|
allow_failures:
|
17
24
|
- rvm: ruby-head
|
18
|
-
- rvm: jruby
|
25
|
+
- rvm: jruby
|
26
|
+
# These may work if there is a new version of sqlite3 1.3.x supporting
|
27
|
+
# Ruby 3.0
|
28
|
+
- rvm: 3.0
|
29
|
+
gemfile: gemfiles/activerecord_5.0.gemfile
|
30
|
+
- rvm: 3.0
|
31
|
+
gemfile: gemfiles/activerecord_5.1.gemfile
|
32
|
+
- rvm: 3.0
|
33
|
+
gemfile: gemfiles/activerecord_5.2.gemfile
|
34
|
+
exclude:
|
35
|
+
- rvm: 2.2
|
36
|
+
gemfile: gemfiles/activerecord_6.0.gemfile
|
37
|
+
- rvm: 2.2
|
38
|
+
gemfile: gemfiles/activerecord_6.1.gemfile
|
39
|
+
- rvm: 2.2
|
40
|
+
gemfile: gemfiles/activerecord_head.gemfile
|
41
|
+
- rvm: 2.2
|
42
|
+
gemfile: gemfiles/jruby_activerecord_6.1.gemfile
|
43
|
+
- rvm: 2.2
|
44
|
+
gemfile: gemfiles/jruby_activerecord_head.gemfile
|
45
|
+
- rvm: 2.3
|
46
|
+
gemfile: gemfiles/activerecord_6.0.gemfile
|
47
|
+
- rvm: 2.3
|
48
|
+
gemfile: gemfiles/activerecord_6.1.gemfile
|
49
|
+
- rvm: 2.3
|
50
|
+
gemfile: gemfiles/activerecord_head.gemfile
|
51
|
+
- rvm: 2.3
|
52
|
+
gemfile: gemfiles/jruby_activerecord_6.1.gemfile
|
53
|
+
- rvm: 2.3
|
54
|
+
gemfile: gemfiles/jruby_activerecord_head.gemfile
|
55
|
+
- rvm: 2.4
|
56
|
+
gemfile: gemfiles/activerecord_6.0.gemfile
|
57
|
+
- rvm: 2.4
|
58
|
+
gemfile: gemfiles/activerecord_6.1.gemfile
|
59
|
+
- rvm: 2.4
|
60
|
+
gemfile: gemfiles/activerecord_head.gemfile
|
61
|
+
- rvm: 2.4
|
62
|
+
gemfile: gemfiles/jruby_activerecord_6.1.gemfile
|
63
|
+
- rvm: 2.4
|
64
|
+
gemfile: gemfiles/jruby_activerecord_head.gemfile
|
65
|
+
- rvm: 2.5
|
66
|
+
gemfile: gemfiles/activerecord_head.gemfile
|
67
|
+
- rvm: 2.5
|
68
|
+
gemfile: gemfiles/jruby_activerecord_6.1.gemfile
|
69
|
+
- rvm: 2.5
|
70
|
+
gemfile: gemfiles/jruby_activerecord_head.gemfile
|
71
|
+
- rvm: 2.6
|
72
|
+
gemfile: gemfiles/activerecord_head.gemfile
|
73
|
+
- rvm: 2.6
|
74
|
+
gemfile: gemfiles/jruby_activerecord_6.1.gemfile
|
75
|
+
- rvm: 2.6
|
76
|
+
gemfile: gemfiles/jruby_activerecord_head.gemfile
|
77
|
+
- rvm: 2.7
|
78
|
+
gemfile: gemfiles/activerecord_4.2.gemfile
|
79
|
+
- rvm: 2.7
|
80
|
+
gemfile: gemfiles/jruby_activerecord_6.1.gemfile
|
81
|
+
- rvm: 2.7
|
82
|
+
gemfile: gemfiles/jruby_activerecord_head.gemfile
|
83
|
+
- rvm: 3.0
|
84
|
+
gemfile: gemfiles/activerecord_4.2.gemfile
|
85
|
+
- rvm: 3.0
|
86
|
+
gemfile: gemfiles/jruby_activerecord_6.1.gemfile
|
87
|
+
- rvm: 3.0
|
88
|
+
gemfile: gemfiles/jruby_activerecord_head.gemfile
|
89
|
+
- rvm: ruby-head
|
90
|
+
gemfile: gemfiles/activerecord_4.2.gemfile
|
91
|
+
- rvm: ruby-head
|
92
|
+
gemfile: gemfiles/jruby_activerecord_6.1.gemfile
|
93
|
+
- rvm: ruby-head
|
94
|
+
gemfile: gemfiles/jruby_activerecord_head.gemfile
|
95
|
+
- rvm: jruby
|
96
|
+
gemfile: gemfiles/activerecord_4.2.gemfile
|
97
|
+
- rvm: jruby
|
98
|
+
gemfile: gemfiles/activerecord_5.0.gemfile
|
99
|
+
- rvm: jruby
|
100
|
+
gemfile: gemfiles/activerecord_5.1.gemfile
|
101
|
+
- rvm: jruby
|
102
|
+
gemfile: gemfiles/activerecord_5.2.gemfile
|
103
|
+
- rvm: jruby
|
104
|
+
gemfile: gemfiles/activerecord_6.0.gemfile
|
105
|
+
- rvm: jruby
|
106
|
+
gemfile: gemfiles/activerecord_6.1.gemfile
|
107
|
+
- rvm: jruby
|
108
|
+
gemfile: gemfiles/activerecord_head.gemfile
|
19
109
|
bundler_args: --without local_development
|
20
|
-
before_install: gem install bundler
|
110
|
+
before_install: gem install bundler -v 1.17.3
|
data/Appraisals
CHANGED
@@ -1,20 +1,76 @@
|
|
1
|
-
appraise 'activerecord-4.
|
2
|
-
gem 'activerecord', '~> 4.
|
1
|
+
appraise 'activerecord-4.2' do
|
2
|
+
gem 'activerecord', '~> 4.2.0'
|
3
|
+
group :development, :test do
|
4
|
+
gem "sqlite3", "~> 1.3.0"
|
5
|
+
end
|
3
6
|
end
|
4
7
|
|
5
|
-
appraise 'activerecord-
|
6
|
-
gem 'activerecord', '~>
|
8
|
+
appraise 'activerecord-5.0' do
|
9
|
+
gem 'activerecord', '~> 5.0.0'
|
10
|
+
group :development, :test do
|
11
|
+
gem "sqlite3", "~> 1.3.0"
|
12
|
+
end
|
7
13
|
end
|
8
14
|
|
9
|
-
appraise 'activerecord-
|
10
|
-
gem 'activerecord', '~>
|
15
|
+
appraise 'activerecord-5.1' do
|
16
|
+
gem 'activerecord', '~> 5.1.0'
|
17
|
+
group :development, :test do
|
18
|
+
gem "sqlite3", "~> 1.3.0"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
appraise 'activerecord-5.2' do
|
23
|
+
gem 'activerecord', '~> 5.2.0'
|
24
|
+
group :development, :test do
|
25
|
+
gem "sqlite3", "~> 1.3.0"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
appraise 'activerecord-6.0' do
|
30
|
+
gem 'activerecord', '~> 6.0.0'
|
31
|
+
group :development, :test do
|
32
|
+
gem "sqlite3", "~> 1.4.0"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
appraise 'activerecord-6.1' do
|
37
|
+
gem 'activerecord', '~> 6.1.0'
|
38
|
+
group :development, :test do
|
39
|
+
gem "sqlite3", "~> 1.4.0"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
appraise 'jruby-activerecord-6.1' do
|
44
|
+
gem 'activerecord', '~> 6.1.0'
|
45
|
+
group :development, :test do
|
46
|
+
gem 'activerecord-jdbc-adapter', '~> 61.0'
|
47
|
+
gem 'activerecord-jdbcsqlite3-adapter', '~> 61.0'
|
48
|
+
end
|
11
49
|
end
|
12
50
|
|
13
51
|
appraise 'activerecord-head' do
|
14
52
|
git 'git://github.com/rails/arel.git' do
|
15
53
|
gem 'arel'
|
16
54
|
end
|
17
|
-
git 'git://github.com/rails/rails.git' do
|
55
|
+
git 'git://github.com/rails/rails.git', branch: 'main' do
|
56
|
+
gem 'activerecord'
|
57
|
+
end
|
58
|
+
group :development, :test do
|
59
|
+
gem "sqlite3", "~> 1.4.0"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
appraise 'jruby-activerecord-head' do
|
64
|
+
git 'git://github.com/rails/arel.git' do
|
65
|
+
gem 'arel'
|
66
|
+
end
|
67
|
+
git 'git://github.com/rails/rails.git', branch: 'main' do
|
18
68
|
gem 'activerecord'
|
19
69
|
end
|
70
|
+
group :development, :test do
|
71
|
+
git 'git://github.com/jruby/activerecord-jdbc-adapter' do
|
72
|
+
gem 'activerecord-jdbc-adapter'
|
73
|
+
gem 'activerecord-jdbcsqlite3-adapter', glob: 'activerecord-jdbcsqlite3-adapter/activerecord-jdbcsqlite3-adapter.gemspec'
|
74
|
+
end
|
75
|
+
end
|
20
76
|
end
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Easy cloning of active_record objects including associations and several operations under associations and attributes.
|
4
4
|
|
5
|
-
[![
|
5
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/d4809ae57ca999fff022/maintainability)](https://codeclimate.com/github/amoeba-rb/amoeba/maintainability)
|
6
6
|
[![Gem Version](https://badge.fury.io/rb/amoeba.svg)](http://badge.fury.io/rb/amoeba)
|
7
7
|
[![Build Status](https://travis-ci.org/amoeba-rb/amoeba.svg?branch=master)](https://travis-ci.org/amoeba-rb/amoeba)
|
8
8
|
|
@@ -16,7 +16,7 @@ This gem is named "Amoeba" because amoebas are (small life forms that are) good
|
|
16
16
|
|
17
17
|
An ActiveRecord extension gem to allow the duplication of associated child record objects when duplicating an active record model.
|
18
18
|
|
19
|
-
Rails
|
19
|
+
Rails 4.x, 5.0, 5.1, 5.2, 6.0, 6.1 compatible.
|
20
20
|
|
21
21
|
### Features
|
22
22
|
|
data/amoeba.gemspec
CHANGED
@@ -5,11 +5,11 @@ require 'amoeba/version'
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = 'amoeba'
|
7
7
|
s.version = Amoeba::VERSION
|
8
|
-
s.authors = ['Vaughn Draughon']
|
9
|
-
s.email = '
|
10
|
-
s.homepage = 'http://github.com/
|
8
|
+
s.authors = ['Vaughn Draughon', 'Oleksandr Simonov']
|
9
|
+
s.email = 'alex@simonov.me'
|
10
|
+
s.homepage = 'http://github.com/amoeba-rb/amoeba'
|
11
11
|
s.license = 'BSD'
|
12
|
-
s.summary = 'Easy copying of rails models and their child associations.
|
12
|
+
s.summary = 'Easy copying of rails models and their child associations.'
|
13
13
|
|
14
14
|
s.description = <<-EOF
|
15
15
|
An extension to ActiveRecord to allow the duplication method to also copy associated children, with recursive support for nested of grandchildren. The behavior is controllable with a simple DSL both on your rails models and on the fly, i.e. per instance. Numerous configuration styles and preprocessing directives are included for power and flexibility. Supports preprocessing of field values to prepend strings such as "Copy of ", to nullify or process field values with regular expressions. Supports most association types including has_one :through and has_many :through.
|
@@ -29,11 +29,11 @@ EOF
|
|
29
29
|
s.add_development_dependency 'rspec', '>= 3.0.0'
|
30
30
|
|
31
31
|
if RUBY_PLATFORM == 'java'
|
32
|
-
s.add_development_dependency 'activerecord-jdbc-adapter', '~>
|
33
|
-
s.add_development_dependency 'activerecord-jdbcsqlite3-adapter', '~>
|
32
|
+
s.add_development_dependency 'activerecord-jdbc-adapter', '~> 61.0'
|
33
|
+
s.add_development_dependency 'activerecord-jdbcsqlite3-adapter', '~> 61.0'
|
34
34
|
else
|
35
|
-
s.add_development_dependency 'sqlite3'
|
35
|
+
s.add_development_dependency 'sqlite3', '>= 1.3'
|
36
36
|
end
|
37
37
|
|
38
|
-
s.add_dependency 'activerecord', '>=
|
38
|
+
s.add_dependency 'activerecord', '>= 4.2.0'
|
39
39
|
end
|
@@ -6,7 +6,8 @@ gem "activerecord", "~> 4.2.0"
|
|
6
6
|
|
7
7
|
group :development, :test do
|
8
8
|
gem "rake"
|
9
|
-
gem "coveralls", :
|
9
|
+
gem "coveralls", require: false
|
10
|
+
gem "sqlite3", "~> 1.3.0"
|
10
11
|
end
|
11
12
|
|
12
13
|
group :local_development do
|
@@ -14,4 +15,4 @@ group :local_development do
|
|
14
15
|
gem "appraisal"
|
15
16
|
end
|
16
17
|
|
17
|
-
gemspec :
|
18
|
+
gemspec path: "../"
|
@@ -2,11 +2,12 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "activerecord", "~>
|
5
|
+
gem "activerecord", "~> 5.0.0"
|
6
6
|
|
7
7
|
group :development, :test do
|
8
8
|
gem "rake"
|
9
|
-
gem "coveralls", :
|
9
|
+
gem "coveralls", require: false
|
10
|
+
gem "sqlite3", "~> 1.3.0"
|
10
11
|
end
|
11
12
|
|
12
13
|
group :local_development do
|
@@ -14,4 +15,4 @@ group :local_development do
|
|
14
15
|
gem "appraisal"
|
15
16
|
end
|
16
17
|
|
17
|
-
gemspec :
|
18
|
+
gemspec path: "../"
|
@@ -2,11 +2,12 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "activerecord", "~>
|
5
|
+
gem "activerecord", "~> 5.1.0"
|
6
6
|
|
7
7
|
group :development, :test do
|
8
8
|
gem "rake"
|
9
|
-
gem "coveralls", :
|
9
|
+
gem "coveralls", require: false
|
10
|
+
gem "sqlite3", "~> 1.3.0"
|
10
11
|
end
|
11
12
|
|
12
13
|
group :local_development do
|
@@ -14,4 +15,4 @@ group :local_development do
|
|
14
15
|
gem "appraisal"
|
15
16
|
end
|
16
17
|
|
17
|
-
gemspec :
|
18
|
+
gemspec path: "../"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "activerecord", "~> 5.2.0"
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem "rake"
|
9
|
+
gem "coveralls", require: false
|
10
|
+
gem "sqlite3", "~> 1.3.0"
|
11
|
+
end
|
12
|
+
|
13
|
+
group :local_development do
|
14
|
+
gem "pry"
|
15
|
+
gem "appraisal"
|
16
|
+
end
|
17
|
+
|
18
|
+
gemspec path: "../"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "activerecord", "~> 6.0.0"
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem "rake"
|
9
|
+
gem "coveralls", require: false
|
10
|
+
gem "sqlite3", "~> 1.4.0"
|
11
|
+
end
|
12
|
+
|
13
|
+
group :local_development do
|
14
|
+
gem "pry"
|
15
|
+
gem "appraisal"
|
16
|
+
end
|
17
|
+
|
18
|
+
gemspec path: "../"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "activerecord", "~> 6.1.0"
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem "rake"
|
9
|
+
gem "coveralls", require: false
|
10
|
+
gem "sqlite3", "~> 1.4.0"
|
11
|
+
end
|
12
|
+
|
13
|
+
group :local_development do
|
14
|
+
gem "pry"
|
15
|
+
gem "appraisal"
|
16
|
+
end
|
17
|
+
|
18
|
+
gemspec path: "../"
|
@@ -6,13 +6,14 @@ git "git://github.com/rails/arel.git" do
|
|
6
6
|
gem "arel"
|
7
7
|
end
|
8
8
|
|
9
|
-
git "git://github.com/rails/rails.git" do
|
9
|
+
git "git://github.com/rails/rails.git", branch: "main" do
|
10
10
|
gem "activerecord"
|
11
11
|
end
|
12
12
|
|
13
13
|
group :development, :test do
|
14
14
|
gem "rake"
|
15
|
-
gem "coveralls", :
|
15
|
+
gem "coveralls", require: false
|
16
|
+
gem "sqlite3", "~> 1.4.0"
|
16
17
|
end
|
17
18
|
|
18
19
|
group :local_development do
|
@@ -20,4 +21,4 @@ group :local_development do
|
|
20
21
|
gem "appraisal"
|
21
22
|
end
|
22
23
|
|
23
|
-
gemspec :
|
24
|
+
gemspec path: "../"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "activerecord", "~> 6.1.0"
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem "rake"
|
9
|
+
gem "coveralls", require: false
|
10
|
+
gem "activerecord-jdbc-adapter", "~> 61.0"
|
11
|
+
gem "activerecord-jdbcsqlite3-adapter", "~> 61.0"
|
12
|
+
end
|
13
|
+
|
14
|
+
group :local_development do
|
15
|
+
gem "pry"
|
16
|
+
gem "appraisal"
|
17
|
+
end
|
18
|
+
|
19
|
+
gemspec path: "../"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
git "git://github.com/rails/arel.git" do
|
6
|
+
gem "arel"
|
7
|
+
end
|
8
|
+
|
9
|
+
git "git://github.com/rails/rails.git", branch: "main" do
|
10
|
+
gem "activerecord"
|
11
|
+
end
|
12
|
+
|
13
|
+
group :development, :test do
|
14
|
+
git "git://github.com/jruby/activerecord-jdbc-adapter" do
|
15
|
+
gem "activerecord-jdbc-adapter"
|
16
|
+
gem "activerecord-jdbcsqlite3-adapter", glob: "activerecord-jdbcsqlite3-adapter/activerecord-jdbcsqlite3-adapter.gemspec"
|
17
|
+
end
|
18
|
+
|
19
|
+
gem "rake"
|
20
|
+
gem "coveralls", require: false
|
21
|
+
end
|
22
|
+
|
23
|
+
group :local_development do
|
24
|
+
gem "pry"
|
25
|
+
gem "appraisal"
|
26
|
+
end
|
27
|
+
|
28
|
+
gemspec path: "../"
|
data/lib/amoeba/config.rb
CHANGED
@@ -110,7 +110,8 @@ module Amoeba
|
|
110
110
|
def include_association(value = nil, options = {})
|
111
111
|
enable
|
112
112
|
@config[:excludes] = {}
|
113
|
-
|
113
|
+
value = value.is_a?(Array) ? Hash[value.map! { |v| [v, options] }] : { value => options }
|
114
|
+
push_value_to_hash(value, :includes)
|
114
115
|
end
|
115
116
|
|
116
117
|
def include_associations(*values)
|
@@ -126,7 +127,8 @@ module Amoeba
|
|
126
127
|
def exclude_association(value = nil, options = {})
|
127
128
|
enable
|
128
129
|
@config[:includes] = {}
|
129
|
-
|
130
|
+
value = value.is_a?(Array) ? Hash[value.map! { |v| [v, options] }] : { value => options }
|
131
|
+
push_value_to_hash(value, :excludes)
|
130
132
|
end
|
131
133
|
|
132
134
|
def exclude_associations(*values)
|
data/lib/amoeba/version.rb
CHANGED
data/spec/lib/amoeba_spec.rb
CHANGED
@@ -176,7 +176,7 @@ describe 'amoeba' do
|
|
176
176
|
end
|
177
177
|
end
|
178
178
|
|
179
|
-
context '
|
179
|
+
context 'Using a if condition' do
|
180
180
|
before(:all) do
|
181
181
|
require ::File.dirname(__FILE__) + '/../support/data.rb'
|
182
182
|
end
|
@@ -185,33 +185,61 @@ describe 'amoeba' do
|
|
185
185
|
subject { post.amoeba_dup.save! }
|
186
186
|
let(:post) { Post.first }
|
187
187
|
|
188
|
-
it 'includes
|
188
|
+
it 'includes an association with truthy condition' do
|
189
189
|
::Post.amoeba do
|
190
190
|
include_association :comments, if: :truthy?
|
191
191
|
end
|
192
192
|
expect { subject }.to change { Comment.count }.by(3)
|
193
193
|
end
|
194
194
|
|
195
|
-
it 'does not include
|
195
|
+
it 'does not include an association with a falsey condition' do
|
196
196
|
::Post.amoeba do
|
197
197
|
include_association :comments, if: :falsey?
|
198
198
|
end
|
199
199
|
expect { subject }.not_to change { Comment.count }
|
200
200
|
end
|
201
201
|
|
202
|
-
it 'excludes
|
202
|
+
it 'excludes an association with a truthy condition' do
|
203
203
|
::Post.amoeba do
|
204
204
|
exclude_association :comments, if: :truthy?
|
205
205
|
end
|
206
206
|
expect { subject }.not_to change { Comment.count }
|
207
207
|
end
|
208
208
|
|
209
|
-
it 'does not exclude
|
209
|
+
it 'does not exclude an association with a falsey condition' do
|
210
210
|
::Post.amoeba do
|
211
211
|
exclude_association :comments, if: :falsey?
|
212
212
|
end
|
213
213
|
expect { subject }.to change { Comment.count }.by(3)
|
214
214
|
end
|
215
|
+
|
216
|
+
it 'includes associations from a given array with a truthy condition' do
|
217
|
+
::Post.amoeba do
|
218
|
+
include_association [:comments], if: :truthy?
|
219
|
+
end
|
220
|
+
expect { subject }.to change { Comment.count }.by(3)
|
221
|
+
end
|
222
|
+
|
223
|
+
it 'does not include associations from a given array with a falsey condition' do
|
224
|
+
::Post.amoeba do
|
225
|
+
include_association [:comments], if: :falsey?
|
226
|
+
end
|
227
|
+
expect { subject }.not_to change { Comment.count }
|
228
|
+
end
|
229
|
+
|
230
|
+
it 'does exclude associations from a given array with a truthy condition' do
|
231
|
+
::Post.amoeba do
|
232
|
+
exclude_association [:comments], if: :truthy?
|
233
|
+
end
|
234
|
+
expect { subject }.not_to change { Comment.count }
|
235
|
+
end
|
236
|
+
|
237
|
+
it 'does not exclude associations from a given array with a falsey condition' do
|
238
|
+
::Post.amoeba do
|
239
|
+
exclude_association [:comments], if: :falsey?
|
240
|
+
end
|
241
|
+
expect { subject }.to change { Comment.count }.by(3)
|
242
|
+
end
|
215
243
|
end
|
216
244
|
|
217
245
|
context 'override' do
|
@@ -301,7 +329,7 @@ describe 'amoeba' do
|
|
301
329
|
it 'does not fail with a deep inheritance' do
|
302
330
|
sub_sub_product = BoxSubSubProduct.create(title: 'Awesome shoes')
|
303
331
|
another_product = BoxAnotherProduct.create(title: 'Cleaning product')
|
304
|
-
sub_sub_product.
|
332
|
+
sub_sub_product.update(box: box, another_product: another_product)
|
305
333
|
expect(box.sub_products.first.another_product.title).to eq('Cleaning product')
|
306
334
|
expect(box.amoeba_dup.sub_products.first.another_product.title).to eq('Cleaning product')
|
307
335
|
end
|
@@ -320,7 +348,7 @@ describe 'amoeba' do
|
|
320
348
|
|
321
349
|
subject { stage.amoeba_dup }
|
322
350
|
|
323
|
-
it
|
351
|
+
it 'contains parent association and own associations', :aggregate_failures do
|
324
352
|
subject
|
325
353
|
expect { subject.save! }.to change(Listener, :count).by(2).
|
326
354
|
and change(Specialist, :count).by(1).
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'simplecov'
|
2
2
|
require 'coveralls'
|
3
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
3
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
|
4
4
|
SimpleCov::Formatter::HTMLFormatter,
|
5
5
|
Coveralls::SimpleCov::Formatter
|
6
|
-
]
|
6
|
+
])
|
7
7
|
SimpleCov.start do
|
8
8
|
add_filter 'spec'
|
9
9
|
minimum_coverage(76)
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amoeba
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vaughn Draughon
|
8
|
-
|
8
|
+
- Oleksandr Simonov
|
9
|
+
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2021-06-30 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
@@ -44,33 +45,33 @@ dependencies:
|
|
44
45
|
requirements:
|
45
46
|
- - ">="
|
46
47
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
48
|
+
version: '1.3'
|
48
49
|
type: :development
|
49
50
|
prerelease: false
|
50
51
|
version_requirements: !ruby/object:Gem::Requirement
|
51
52
|
requirements:
|
52
53
|
- - ">="
|
53
54
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
+
version: '1.3'
|
55
56
|
- !ruby/object:Gem::Dependency
|
56
57
|
name: activerecord
|
57
58
|
requirement: !ruby/object:Gem::Requirement
|
58
59
|
requirements:
|
59
60
|
- - ">="
|
60
61
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
62
|
+
version: 4.2.0
|
62
63
|
type: :runtime
|
63
64
|
prerelease: false
|
64
65
|
version_requirements: !ruby/object:Gem::Requirement
|
65
66
|
requirements:
|
66
67
|
- - ">="
|
67
68
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
69
|
+
version: 4.2.0
|
69
70
|
description: |
|
70
71
|
An extension to ActiveRecord to allow the duplication method to also copy associated children, with recursive support for nested of grandchildren. The behavior is controllable with a simple DSL both on your rails models and on the fly, i.e. per instance. Numerous configuration styles and preprocessing directives are included for power and flexibility. Supports preprocessing of field values to prepend strings such as "Copy of ", to nullify or process field values with regular expressions. Supports most association types including has_one :through and has_many :through.
|
71
72
|
|
72
73
|
Tags: copy child associations, copy nested children, copy associated child records, nested copy, copy associations, copy relations, copy relationships, duplicate associations, duplicate associated records, duplicate child records, duplicate children, copy all, duplicate all, clone child associations, clone nested children, clone associated child records, nested clone, clone associations, clone relations, clone relationships, cloning child associations, cloning nested children, cloning associated child records, deep_cloning, nested cloning, cloning associations, cloning relations, cloning relationships, cloning child associations, cloning nested children, cloning associated child records, nested cloning, cloning associations, cloning relations, cloning relationships, cloning child associations, cloning nested children, cloning associated child records, deep_cloning, nested cloning, cloning associations, cloning relations, cloning relationships, duplicate child associations, duplicate nested children, duplicate associated child records, nested duplicate, duplicate associations, duplicate relations, duplicate relationships, duplicate child associations, duplicate nested children, duplicate associated child records, deep_duplicate, nested duplicate, duplicate associations, duplicate relations, duplicate relationships, deep_copy, deep_clone, deep_cloning, deep clone, deep cloning, has_one, has_many, has_and_belongs_to_many
|
73
|
-
email:
|
74
|
+
email: alex@simonov.me
|
74
75
|
executables: []
|
75
76
|
extensions: []
|
76
77
|
extra_rdoc_files: []
|
@@ -86,10 +87,15 @@ files:
|
|
86
87
|
- Rakefile
|
87
88
|
- amoeba.gemspec
|
88
89
|
- defaults.reek
|
89
|
-
- gemfiles/activerecord_4.0.gemfile
|
90
|
-
- gemfiles/activerecord_4.1.gemfile
|
91
90
|
- gemfiles/activerecord_4.2.gemfile
|
91
|
+
- gemfiles/activerecord_5.0.gemfile
|
92
|
+
- gemfiles/activerecord_5.1.gemfile
|
93
|
+
- gemfiles/activerecord_5.2.gemfile
|
94
|
+
- gemfiles/activerecord_6.0.gemfile
|
95
|
+
- gemfiles/activerecord_6.1.gemfile
|
92
96
|
- gemfiles/activerecord_head.gemfile
|
97
|
+
- gemfiles/jruby_activerecord_6.1.gemfile
|
98
|
+
- gemfiles/jruby_activerecord_head.gemfile
|
93
99
|
- lib/amoeba.rb
|
94
100
|
- lib/amoeba/class_methods.rb
|
95
101
|
- lib/amoeba/cloner.rb
|
@@ -106,11 +112,11 @@ files:
|
|
106
112
|
- spec/support/data.rb
|
107
113
|
- spec/support/models.rb
|
108
114
|
- spec/support/schema.rb
|
109
|
-
homepage: http://github.com/
|
115
|
+
homepage: http://github.com/amoeba-rb/amoeba
|
110
116
|
licenses:
|
111
117
|
- BSD
|
112
118
|
metadata: {}
|
113
|
-
post_install_message:
|
119
|
+
post_install_message:
|
114
120
|
rdoc_options: []
|
115
121
|
require_paths:
|
116
122
|
- lib
|
@@ -125,9 +131,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
131
|
- !ruby/object:Gem::Version
|
126
132
|
version: '0'
|
127
133
|
requirements: []
|
128
|
-
|
129
|
-
|
130
|
-
signing_key:
|
134
|
+
rubygems_version: 3.2.17
|
135
|
+
signing_key:
|
131
136
|
specification_version: 4
|
132
137
|
summary: Easy copying of rails models and their child associations.
|
133
138
|
test_files:
|