replication 0.1.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 +7 -0
- data/.gitignore +22 -0
- data/Gemfile +14 -0
- data/LICENSE.txt +22 -0
- data/README.md +120 -0
- data/Rakefile +13 -0
- data/db/migrate/714417722_replication_migration.rb +15 -0
- data/lib/replication/active_record/strand.rb +13 -0
- data/lib/replication/config.rb +21 -0
- data/lib/replication/engine.rb +5 -0
- data/lib/replication/modules/proofreading.rb +27 -0
- data/lib/replication/modules/semi_conservative.rb +35 -0
- data/lib/replication/process.rb +57 -0
- data/lib/replication/strand_methods.rb +16 -0
- data/lib/replication/version.rb +3 -0
- data/lib/replication.rb +27 -0
- data/replication.gemspec +24 -0
- data/test/orm/active_record.rb +10 -0
- data/test/rails_app/Rakefile +6 -0
- data/test/rails_app/app/models/.keep +0 -0
- data/test/rails_app/app/models/concerns/.keep +0 -0
- data/test/rails_app/app/models/organism.rb +3 -0
- data/test/rails_app/config/application.rb +34 -0
- data/test/rails_app/config/boot.rb +3 -0
- data/test/rails_app/config/database.yml +22 -0
- data/test/rails_app/config/environment.rb +5 -0
- data/test/rails_app/config/environments/test.rb +37 -0
- data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails_app/config/initializers/cookies_serializer.rb +3 -0
- data/test/rails_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/rails_app/config/initializers/inflections.rb +16 -0
- data/test/rails_app/config/initializers/mime_types.rb +4 -0
- data/test/rails_app/config/initializers/session_store.rb +3 -0
- data/test/rails_app/config/initializers/wrap_parameters.rb +14 -0
- data/test/rails_app/config/routes.rb +56 -0
- data/test/rails_app/config/secrets.yml +22 -0
- data/test/rails_app/config.ru +4 -0
- data/test/rails_app/db/migrate/830335961_organism_migration.rb +15 -0
- data/test/rails_app/log/test.log +1476 -0
- data/test/replication/modules/proofreading_test.rb +22 -0
- data/test/replication/modules/semi_conservative_test.rb +24 -0
- data/test/replication/process_test.rb +51 -0
- data/test/replication_test.rb +9 -0
- data/test/test_helper.rb +11 -0
- metadata +142 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class Replication::Modules::ProofreadingTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
Organism.extend Replication::Process
|
7
|
+
Organism.can_replicate with: :proofreading
|
8
|
+
end
|
9
|
+
|
10
|
+
test "unwound with proofreading" do
|
11
|
+
organism = Organism.new(number_of_legs: 1, birth_date: Time.now) # invalid (needs name)
|
12
|
+
strand = organism.unwound(name: 'First bacteria')
|
13
|
+
|
14
|
+
assert_nil strand
|
15
|
+
end
|
16
|
+
|
17
|
+
test "replicate with proofreading" do
|
18
|
+
organism = Organism.new(number_of_legs: 1, birth_date: Time.now) # invalid (needs name)
|
19
|
+
|
20
|
+
assert_raises(Replication::UnwoundError) { organism.replicate(name: 'First bacteria') }
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class Replication::Modules::SemiConservativeTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
Organism.extend Replication::Process
|
7
|
+
end
|
8
|
+
|
9
|
+
test "unwound with default options" do
|
10
|
+
Organism.can_replicate
|
11
|
+
organism = Organism.new(name: 'Bacteria', number_of_legs: 1, birth_date: Time.now)
|
12
|
+
strand = organism.unwound(name: 'First bacteria')
|
13
|
+
|
14
|
+
assert_equal organism.strand_attributes, strand.pairs
|
15
|
+
end
|
16
|
+
|
17
|
+
test "replicate with default options" do
|
18
|
+
Organism.can_replicate
|
19
|
+
organism = Organism.new(name: 'Bacteria', number_of_legs: 1, birth_date: Time.now)
|
20
|
+
strand = organism.replicate(name: 'First bacteria')
|
21
|
+
|
22
|
+
assert_equal organism.strand_attributes, strand.pairs
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class Replication::ProcessTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
Organism.extend Replication::Process
|
7
|
+
end
|
8
|
+
|
9
|
+
test "extending provide can_replicate method" do
|
10
|
+
assert_equal true, Organism.respond_to?(:can_replicate)
|
11
|
+
end
|
12
|
+
|
13
|
+
test "extending provide new_from_strand method" do
|
14
|
+
assert_equal true, Organism.respond_to?(:new_from_strand)
|
15
|
+
end
|
16
|
+
|
17
|
+
test "can_replicate with default options" do
|
18
|
+
Organism.can_replicate
|
19
|
+
|
20
|
+
assert_equal true, Organism.new.respond_to?(:unwound) # provided by default module
|
21
|
+
end
|
22
|
+
|
23
|
+
test "can_replicate with other attributes method" do
|
24
|
+
Organism.can_replicate :attributes_alias
|
25
|
+
|
26
|
+
assert_equal :attributes_alias, Organism.new.replication_config.pairs_method
|
27
|
+
end
|
28
|
+
|
29
|
+
test "can_replicate with other strand class" do
|
30
|
+
WeirdStrandClass = Struct.new(:name, :pairs, :origin)
|
31
|
+
Organism.can_replicate strand_class: WeirdStrandClass
|
32
|
+
|
33
|
+
assert_equal WeirdStrandClass, Organism.new.strand_class
|
34
|
+
end
|
35
|
+
|
36
|
+
test "new_from_strand with id" do
|
37
|
+
Organism.can_replicate
|
38
|
+
original = Organism.create(name: 'Bacteria', number_of_legs: 3, birth_date: Time.now)
|
39
|
+
strand = original.replicate(name: 'Original Bacteria')
|
40
|
+
|
41
|
+
assert_instance_of Organism, Organism.new_from_strand(strand.id)
|
42
|
+
end
|
43
|
+
|
44
|
+
test "new_from_strand with name" do
|
45
|
+
Organism.can_replicate
|
46
|
+
original = Organism.create(name: 'Bacteria', number_of_legs: 3, birth_date: Time.now)
|
47
|
+
strand = original.replicate(name: 'Original Bacteria')
|
48
|
+
|
49
|
+
assert_instance_of Organism, Organism.new_from_strand(name: 'Original Bacteria')
|
50
|
+
end
|
51
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
2
|
+
REPLICATION_ORM = (ENV["REPLICATION_ORM"] || :active_record).to_sym
|
3
|
+
|
4
|
+
$:.unshift File.dirname(__FILE__)
|
5
|
+
|
6
|
+
require "rails_app/config/environment"
|
7
|
+
require "rails/test_help"
|
8
|
+
require "orm/#{REPLICATION_ORM}"
|
9
|
+
|
10
|
+
require "minitest/reporters"
|
11
|
+
Minitest::Reporters.use!
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: replication
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rodrigo DeAlmeida
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Data replication as templates for Ruby ORMs
|
42
|
+
email:
|
43
|
+
- rodrigoddalmeida@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- db/migrate/714417722_replication_migration.rb
|
54
|
+
- lib/replication.rb
|
55
|
+
- lib/replication/active_record/strand.rb
|
56
|
+
- lib/replication/config.rb
|
57
|
+
- lib/replication/engine.rb
|
58
|
+
- lib/replication/modules/proofreading.rb
|
59
|
+
- lib/replication/modules/semi_conservative.rb
|
60
|
+
- lib/replication/process.rb
|
61
|
+
- lib/replication/strand_methods.rb
|
62
|
+
- lib/replication/version.rb
|
63
|
+
- replication.gemspec
|
64
|
+
- test/orm/active_record.rb
|
65
|
+
- test/rails_app/Rakefile
|
66
|
+
- test/rails_app/app/models/.keep
|
67
|
+
- test/rails_app/app/models/concerns/.keep
|
68
|
+
- test/rails_app/app/models/organism.rb
|
69
|
+
- test/rails_app/config.ru
|
70
|
+
- test/rails_app/config/application.rb
|
71
|
+
- test/rails_app/config/boot.rb
|
72
|
+
- test/rails_app/config/database.yml
|
73
|
+
- test/rails_app/config/environment.rb
|
74
|
+
- test/rails_app/config/environments/test.rb
|
75
|
+
- test/rails_app/config/initializers/backtrace_silencers.rb
|
76
|
+
- test/rails_app/config/initializers/cookies_serializer.rb
|
77
|
+
- test/rails_app/config/initializers/filter_parameter_logging.rb
|
78
|
+
- test/rails_app/config/initializers/inflections.rb
|
79
|
+
- test/rails_app/config/initializers/mime_types.rb
|
80
|
+
- test/rails_app/config/initializers/session_store.rb
|
81
|
+
- test/rails_app/config/initializers/wrap_parameters.rb
|
82
|
+
- test/rails_app/config/routes.rb
|
83
|
+
- test/rails_app/config/secrets.yml
|
84
|
+
- test/rails_app/db/migrate/830335961_organism_migration.rb
|
85
|
+
- test/rails_app/log/test.log
|
86
|
+
- test/replication/modules/proofreading_test.rb
|
87
|
+
- test/replication/modules/semi_conservative_test.rb
|
88
|
+
- test/replication/process_test.rb
|
89
|
+
- test/replication_test.rb
|
90
|
+
- test/test_helper.rb
|
91
|
+
homepage: ''
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.2.2
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Data replication as templates for Ruby ORMs
|
115
|
+
test_files:
|
116
|
+
- test/orm/active_record.rb
|
117
|
+
- test/rails_app/Rakefile
|
118
|
+
- test/rails_app/app/models/.keep
|
119
|
+
- test/rails_app/app/models/concerns/.keep
|
120
|
+
- test/rails_app/app/models/organism.rb
|
121
|
+
- test/rails_app/config.ru
|
122
|
+
- test/rails_app/config/application.rb
|
123
|
+
- test/rails_app/config/boot.rb
|
124
|
+
- test/rails_app/config/database.yml
|
125
|
+
- test/rails_app/config/environment.rb
|
126
|
+
- test/rails_app/config/environments/test.rb
|
127
|
+
- test/rails_app/config/initializers/backtrace_silencers.rb
|
128
|
+
- test/rails_app/config/initializers/cookies_serializer.rb
|
129
|
+
- test/rails_app/config/initializers/filter_parameter_logging.rb
|
130
|
+
- test/rails_app/config/initializers/inflections.rb
|
131
|
+
- test/rails_app/config/initializers/mime_types.rb
|
132
|
+
- test/rails_app/config/initializers/session_store.rb
|
133
|
+
- test/rails_app/config/initializers/wrap_parameters.rb
|
134
|
+
- test/rails_app/config/routes.rb
|
135
|
+
- test/rails_app/config/secrets.yml
|
136
|
+
- test/rails_app/db/migrate/830335961_organism_migration.rb
|
137
|
+
- test/rails_app/log/test.log
|
138
|
+
- test/replication/modules/proofreading_test.rb
|
139
|
+
- test/replication/modules/semi_conservative_test.rb
|
140
|
+
- test/replication/process_test.rb
|
141
|
+
- test/replication_test.rb
|
142
|
+
- test/test_helper.rb
|