amoeba 3.3.0 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/activerecord_head.yml +26 -0
  3. data/.github/workflows/jruby.yml +4 -1
  4. data/.github/workflows/rspec.yml +49 -0
  5. data/.github/workflows/rubocop.yml +20 -0
  6. data/.gitignore +1 -0
  7. data/.rubocop.yml +2 -2
  8. data/.rubocop_todo.yml +64 -35
  9. data/Appraisals +25 -15
  10. data/CHANGELOG.md +54 -0
  11. data/Gemfile +1 -0
  12. data/README.md +26 -1
  13. data/amoeba.gemspec +10 -12
  14. data/docs/contributing.md +19 -0
  15. data/docs/test_refactor.md +20 -0
  16. data/gemfiles/activerecord_6.1.gemfile +8 -0
  17. data/gemfiles/activerecord_7.0.gemfile +3 -0
  18. data/gemfiles/{activerecord_6.0.gemfile → activerecord_7.1.gemfile} +3 -1
  19. data/gemfiles/{activerecord_5.2.gemfile → activerecord_8.0.gemfile} +4 -2
  20. data/gemfiles/activerecord_8.1.gemfile +21 -0
  21. data/gemfiles/activerecord_head.gemfile +3 -1
  22. data/gemfiles/jruby_activerecord_7.0.gemfile +2 -2
  23. data/gemfiles/jruby_activerecord_head.gemfile +2 -0
  24. data/lib/amoeba/cloner.rb +4 -2
  25. data/lib/amoeba/config.rb +8 -3
  26. data/lib/amoeba/version.rb +1 -1
  27. data/spec/lib/amoeba_spec.rb +405 -225
  28. data/spec/spec_helper.rb +3 -1
  29. data/spec/support/data.rb +2 -0
  30. data/spec/support/models.rb +11 -2
  31. data/spec/support/schema.rb +2 -0
  32. metadata +26 -43
  33. data/.github/workflows/ruby_25.yml +0 -30
  34. data/.github/workflows/ruby_26.yml +0 -30
  35. data/.github/workflows/ruby_27.yml +0 -30
  36. data/.github/workflows/ruby_30.yml +0 -34
  37. data/.github/workflows/ruby_31.yml +0 -34
  38. data/.github/workflows/ruby_32.yml +0 -34
  39. data/.github/workflows/ruby_head.yml +0 -34
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file was generated by Appraisal
4
+
5
+ source 'https://rubygems.org'
6
+
7
+ gem 'activerecord', '~> 8.1.0'
8
+
9
+ group :development, :test do
10
+ gem 'rake'
11
+ gem 'simplecov', '~> 0.21.2'
12
+ gem 'simplecov-lcov', '~> 0.8.0'
13
+ gem 'sqlite3', '~> 2.1.0'
14
+ end
15
+
16
+ group :local_development do
17
+ gem 'appraisal'
18
+ gem 'pry'
19
+ end
20
+
21
+ gemspec path: '../'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file was generated by Appraisal
2
4
 
3
5
  source 'https://rubygems.org'
@@ -10,7 +12,7 @@ group :development, :test do
10
12
  gem 'rake'
11
13
  gem 'simplecov', '~> 0.21.2'
12
14
  gem 'simplecov-lcov', '~> 0.8.0'
13
- gem 'sqlite3', '~> 1.6.0'
15
+ gem 'sqlite3', '~> 2.1.0'
14
16
  end
15
17
 
16
18
  group :local_development do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file was generated by Appraisal
2
4
 
3
5
  source 'https://rubygems.org'
@@ -5,8 +7,6 @@ source 'https://rubygems.org'
5
7
  gem 'activerecord', '~> 7.0.0'
6
8
 
7
9
  group :development, :test do
8
- gem 'activerecord-jdbc-adapter', '~> 70.1'
9
- gem 'activerecord-jdbcsqlite3-adapter', '~> 70.1'
10
10
  gem 'rake'
11
11
  gem 'simplecov', '~> 0.21.2'
12
12
  gem 'simplecov-lcov', '~> 0.8.0'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file was generated by Appraisal
2
4
 
3
5
  source 'https://rubygems.org'
data/lib/amoeba/cloner.rb CHANGED
@@ -52,7 +52,7 @@ module Amoeba
52
52
  return unless _parent_amoeba.inherit
53
53
  return unless %w[strict relaxed submissive].include?(parenting_style.to_s)
54
54
 
55
- __send__("inherit_#{parenting_style}_parent_settings".to_sym)
55
+ __send__(:"inherit_#{parenting_style}_parent_settings")
56
56
  end
57
57
 
58
58
  def apply_clones
@@ -127,7 +127,9 @@ module Amoeba
127
127
 
128
128
  def process_null_fields
129
129
  # nullify any fields the user has configured
130
- amoeba.null_fields.each do |field_key|
130
+ amoeba.null_fields.each do |field_key, options|
131
+ next if options[:if] && !@old_object.send(options[:if])
132
+
131
133
  @new_object[field_key] = nil
132
134
  end
133
135
  end
data/lib/amoeba/config.rb CHANGED
@@ -15,7 +15,7 @@ module Amoeba
15
15
  clones: [],
16
16
  customizations: [],
17
17
  overrides: [],
18
- null_fields: [],
18
+ null_fields: {},
19
19
  coercions: {},
20
20
  prefixes: {},
21
21
  suffixes: {},
@@ -123,8 +123,7 @@ module Amoeba
123
123
  push_value_to_array(value, :known_macros)
124
124
  end
125
125
 
126
- { override: 'overrides', customize: 'customizations',
127
- nullify: 'null_fields' }.each do |method, key|
126
+ { override: 'overrides', customize: 'customizations' }.each do |method, key|
128
127
  class_eval <<-EOS, __FILE__, __LINE__ + 1
129
128
  def #{method}(value = nil) # def override(value = nil)
130
129
  @config[:do_preproc] = true # @config[:do_preproc] = true
@@ -133,6 +132,12 @@ module Amoeba
133
132
  EOS
134
133
  end
135
134
 
135
+ def nullify(value = nil, options = {})
136
+ @config[:do_preproc] = true
137
+ @config[:null_fields] = {} if value.is_a?(::Array)
138
+ push_value_to_hash(Array(value).to_h { |field| [field, options] }, :null_fields)
139
+ end
140
+
136
141
  { set: 'coercions', prepend: 'prefixes',
137
142
  append: 'suffixes', regex: 'regexes' }.each do |method, key|
138
143
  class_eval <<-EOS, __FILE__, __LINE__ + 1
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Amoeba
4
- VERSION = '3.3.0'
4
+ VERSION = '3.4.0'
5
5
  end