replication 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/README.md +5 -0
- data/lib/replication/config.rb +1 -1
- data/lib/replication/modules/semi_conservative.rb +6 -1
- data/lib/replication/version.rb +1 -1
- data/lib/replication.rb +5 -2
- data/test/replication/modules/semi_conservative_test.rb +23 -2
- data/test/test_helper.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af7f89d66290f3a6e85b44aa53a710af654de579
|
4
|
+
data.tar.gz: 1e4068b2e2debd7567d283e8c0a56c3606004239
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17a772115a1e9a9f53f4c8570fb1f6e78c72a940f159199333eb6d7f157f792c71d825066ca788de3b959b3174f4dad0005bf353ff314d9ecb6cab890eaad252
|
7
|
+
data.tar.gz: 46ec1398c27134b0db676e1d45a88449b39e0252659a191f88dd3286e6516333d6da949ac158a37f89bb853caec9a6b40aa04d429483dc183631a6887f2a7db9
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -50,6 +50,11 @@ class Model
|
|
50
50
|
end
|
51
51
|
```
|
52
52
|
|
53
|
+
You can whitelist an array of attributes. They'll be replicated in the new strand.
|
54
|
+
```ruby
|
55
|
+
can_replicate only: [:some_column, :other_column]
|
56
|
+
```
|
57
|
+
|
53
58
|
You can blacklist an array of attributes. They'll not be replicated in the new strand.
|
54
59
|
```ruby
|
55
60
|
can_replicate except: [:id, :name]
|
data/lib/replication/config.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'active_support/core_ext/hash/except'
|
2
|
+
require 'active_support/core_ext/hash/slice'
|
3
|
+
|
1
4
|
module Replication
|
2
5
|
module Modules
|
3
6
|
module SemiConservative
|
@@ -19,7 +22,9 @@ module Replication
|
|
19
22
|
end
|
20
23
|
|
21
24
|
def strand_attributes
|
22
|
-
_strand_attributes
|
25
|
+
@strand_attributes = _strand_attributes
|
26
|
+
@strand_attributes = @strand_attributes.slice(*replication_config.only) unless replication_config.only.empty?
|
27
|
+
@strand_attributes = @strand_attributes.except(*replication_config.except) unless replication_config.except.empty?
|
23
28
|
end
|
24
29
|
end
|
25
30
|
end
|
data/lib/replication/version.rb
CHANGED
data/lib/replication.rb
CHANGED
@@ -16,8 +16,11 @@ module Replication
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.defaults
|
19
|
-
defaults = {
|
20
|
-
|
19
|
+
defaults = {
|
20
|
+
only: [],
|
21
|
+
except: []
|
22
|
+
}
|
23
|
+
defaults.merge!({
|
21
24
|
strand_class: ::Replication::ActiveRecord::Strand,
|
22
25
|
except: [:id, :created_at, :updated_at]
|
23
26
|
}) if defined?(ActiveRecord)
|
@@ -6,9 +6,13 @@ class Replication::Modules::SemiConservativeTest < ActiveSupport::TestCase
|
|
6
6
|
Organism.extend Replication::Process
|
7
7
|
end
|
8
8
|
|
9
|
+
def organism_object
|
10
|
+
Organism.new(name: 'Bacteria', number_of_legs: 1, birth_date: Time.now)
|
11
|
+
end
|
12
|
+
|
9
13
|
test "unwound with default options" do
|
10
14
|
Organism.can_replicate
|
11
|
-
organism =
|
15
|
+
organism = organism_object
|
12
16
|
strand = organism.unwound(name: 'First bacteria')
|
13
17
|
|
14
18
|
assert_equal organism.strand_attributes, strand.pairs
|
@@ -16,9 +20,26 @@ class Replication::Modules::SemiConservativeTest < ActiveSupport::TestCase
|
|
16
20
|
|
17
21
|
test "replicate with default options" do
|
18
22
|
Organism.can_replicate
|
19
|
-
organism =
|
23
|
+
organism = organism_object
|
20
24
|
strand = organism.replicate(name: 'First bacteria')
|
21
25
|
|
22
26
|
assert_equal organism.strand_attributes, strand.pairs
|
23
27
|
end
|
28
|
+
|
29
|
+
test "unwound with whitelist" do
|
30
|
+
Organism.can_replicate only: [:name]
|
31
|
+
organism = organism_object
|
32
|
+
strand = organism.replicate(name: 'First bacteria')
|
33
|
+
|
34
|
+
assert_equal ({ name: 'Bacteria' }), strand.pairs
|
35
|
+
end
|
36
|
+
|
37
|
+
test "unwound with blacklist" do
|
38
|
+
Organism.can_replicate except: [:id, :number_of_legs, :birth_date, :created_at, :updated_at]
|
39
|
+
organism = organism_object
|
40
|
+
strand = organism.replicate(name: 'First bacteria')
|
41
|
+
|
42
|
+
assert_equal ({ name: 'Bacteria' }), strand.pairs
|
43
|
+
end
|
44
|
+
|
24
45
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: replication
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rodrigo DeAlmeida
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|