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 +5 -5
- data/CHANGELOG.md +3 -0
- data/README.md +25 -17
- data/lib/clone_kit/specification.rb +4 -0
- data/lib/clone_kit/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 54f38bf7fecf535b3dbdd87575a9879e9ac3a4bf20c9819a96cf8a2d2580aae9
|
4
|
+
data.tar.gz: c0b05a28c7324fb8093b6be72701a22c718a77241500e44629577387d43b605c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61da8f03519e95a2cf1b8803461685a3f27d424b36b798c0ed6e803b8cc3d49dc8a848845ece7295a3469cdf39f4fc9af9c838cbc3c3ee4fcbd813e58fb6837f
|
7
|
+
data.tar.gz: f6e0be7ac84f4ca82719843965381a16958927176d671769951c6f46d220779d2a140db1f3a66796728c23caa22607cdea78fefffcf1fd7e4d20d9e4caced808
|
data/CHANGELOG.md
CHANGED
@@ -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::
|
29
|
-
spec.dependencies = %w(Account BlogType)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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
|
data/lib/clone_kit/version.rb
CHANGED
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
|
+
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-
|
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.
|
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
|