clone_kit 0.4.2 → 0.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c6c302894250fb88b745cb86ae6d329c24c8f601
4
- data.tar.gz: 691b3d3bbcff0db46980266e8818a644da0f8626
2
+ SHA256:
3
+ metadata.gz: 54f38bf7fecf535b3dbdd87575a9879e9ac3a4bf20c9819a96cf8a2d2580aae9
4
+ data.tar.gz: c0b05a28c7324fb8093b6be72701a22c718a77241500e44629577387d43b605c
5
5
  SHA512:
6
- metadata.gz: 6442ecee0507caa2d84382a296272f955340aac5e16837183e0c9f4adf8513b535afbf5384a87fe905bcc1c0c467973fce81f5ac5ae207c185805d696a91e5ee
7
- data.tar.gz: b38a06f98cf9b42a0005a7cc6b5a0cbd3d0ec7113b2d207e2508acfa9cb64786b2b148abfdb4392b1325090179402f22d59621be1e213e7b58d6ae19012c2049
6
+ metadata.gz: 61da8f03519e95a2cf1b8803461685a3f27d424b36b798c0ed6e803b8cc3d49dc8a848845ece7295a3469cdf39f4fc9af9c838cbc3c3ee4fcbd813e58fb6837f
7
+ data.tar.gz: f6e0be7ac84f4ca82719843965381a16958927176d671769951c6f46d220779d2a140db1f3a66796728c23caa22607cdea78fefffcf1fd7e4d20d9e4caced808
@@ -2,6 +2,9 @@
2
2
  All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
3
3
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
4
4
 
5
+ ## [0.5.0](https://github.com/kapost/clone_kit/compare/v0.4.2...v0.5.0) - 2018-11-20
6
+ - Allow Specification dependencies to be assigned a proc
7
+
5
8
  ## [0.4.2](https://github.com/kapost/clone_kit/compare/v0.4.1...v0.4.2) - 2018-11-14
6
9
  ### Added
7
10
  - CHANGELOG
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # CloneKit!
2
2
 
3
- An ActiveRecord-ish toolkit library for building database record cloning without the business logic and executing cloning operations, especially for multi-tenant applications using Mongoid.
3
+ An ActiveRecord-ish toolkit library for building database record cloning without the business logic and executing cloning operations, especially for multi-tenant applications using ActiveRecord or Mongoid.
4
4
 
5
5
  ## Why does cloning require a special toolkit?
6
6
 
@@ -25,19 +25,27 @@ end
25
25
  You can specify the dependency order of cloning, the scope of the operation, and the specific cloning behavior inside a specification:
26
26
 
27
27
  ```ruby
28
- CloneKit::Specification.new(BlogPost) do |spec|
29
- spec.dependencies = %w(Account BlogType) # Helps derive the cloning order
30
- spec.emitter = TenantEmitter.new(BlogPost) # The scope of the operation for this collection
31
- spec.cloner = CloneKit::Cloners::MongoidRulesetCloner.new( # The cloning behavior
32
- BlogPost,
33
- rules: [
34
- ReTenantRule.new,
35
- CloneKit::Rules::Remap.new("BlogPost", "Account" => "account_id", "BlogType" => "blog_type_id")
36
- ]
37
- )
38
- spec.after_operation do |operation|
39
- ...
40
- end
28
+ CloneKit::MongoSpecification.new(BlogPost) do |spec|
29
+ spec.dependencies = %w(Account BlogType) # Helps derive the cloning order
30
+ spec.emitter = TenantEmitter.new(BlogPost) # The scope of the operation for this collection
31
+ spec.cloner = CloneKit::Cloners::MongoidRulesetCloner.new( # The cloning behavior
32
+ BlogPost,
33
+ rules: [
34
+ ReTenantRule.new,
35
+ CloneKit::Rules::Remap.new("BlogPost", "Account" => "account_id", "BlogType" => "blog_type_id")
36
+ ]
37
+ )
38
+ spec.after_operation do |operation|
39
+ ...
40
+ end
41
+ end
42
+ ```
43
+
44
+ Dependencies can also be dynamically defined by using a proc or lambda:
45
+
46
+ ```ruby
47
+ CloneKit::MongoSpecification.new(BlogPost) do |spec|
48
+ spec.dependencies = ->{ env.test? ? %w(Foo) : %w(Bar) }
41
49
  end
42
50
  ```
43
51
 
@@ -61,12 +69,12 @@ class ActiveRecordEmitter
61
69
  self.klass = klass
62
70
  end
63
71
 
64
- def scope(*)
72
+ def scope(_args)
65
73
  klass.all # add any scope restrictions here
66
74
  end
67
75
 
68
- def emit_all # the method that will be used to pluck the record ids
69
- scope
76
+ def emit_all(args) # the method that will be used to pluck the record ids
77
+ scope(args)
70
78
  end
71
79
 
72
80
  private
@@ -36,6 +36,10 @@ module CloneKit
36
36
  self.after_operation_block = block
37
37
  end
38
38
 
39
+ def dependencies
40
+ @dependencies.respond_to?(:call) ? @dependencies.call : @dependencies
41
+ end
42
+
39
43
  protected
40
44
 
41
45
  def configure; end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CloneKit
4
- VERSION = "0.4.2"
4
+ VERSION = "0.5.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clone_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Croft
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-14 00:00:00.000000000 Z
11
+ date: 2018-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -314,7 +314,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
314
314
  version: '0'
315
315
  requirements: []
316
316
  rubyforge_project:
317
- rubygems_version: 2.5.2.2
317
+ rubygems_version: 2.7.6
318
318
  signing_key:
319
319
  specification_version: 4
320
320
  summary: A toolkit to assist in complex cloning operations