vorpal 0.1.0.rc1 → 0.1.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +13 -0
- data/lib/vorpal/configs.rb +4 -1
- data/lib/vorpal/db_driver.rb +2 -2
- data/lib/vorpal/{config_builder.rb → dsl/config_builder.rb} +14 -51
- data/lib/vorpal/{configuration.rb → dsl/configuration.rb} +4 -2
- data/lib/vorpal/dsl/defaults_generator.rb +45 -0
- data/lib/vorpal/exceptions.rb +3 -1
- data/lib/vorpal/version.rb +1 -1
- data/lib/vorpal.rb +2 -2
- data/spec/vorpal/acceptance/aggregate_mapper_spec.rb +1 -1
- data/spec/vorpal/integration/db_driver_spec.rb +16 -0
- data/spec/vorpal/performance/performance_spec.rb +47 -40
- data/spec/vorpal/unit/configs_spec.rb +11 -1
- data/spec/vorpal/unit/dsl/config_builder_spec.rb +19 -0
- data/spec/vorpal/unit/dsl/defaults_generator_spec.rb +75 -0
- metadata +12 -6
- data/spec/vorpal/unit/config_builder_spec.rb +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69f36cf61329620f00d5afc82600cb4827072f34
|
4
|
+
data.tar.gz: 2d750d2d81bc23bab69d7491842815bc3a528662
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05c571066a636c8ac35e802ed6f27385af70ab22973c10641216e64f122f5c1e9d8776acace14693f4ed559dc1c6ad74d9566449385f7a697b471c786761866a
|
7
|
+
data.tar.gz: 61e7fdb650dfc01c9ec66e59d388ee60fd52411bbe190fd8e79df62ea35340acd3ad63c8f967374a03068ef2cbb0beb6839720bbbd0187a8ab4d60a18a518676
|
data/.editorconfig
ADDED
data/lib/vorpal/configs.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'vorpal/util/hash_initialization'
|
2
|
+
require 'vorpal/exceptions'
|
2
3
|
require 'equalizer'
|
3
4
|
|
4
5
|
module Vorpal
|
@@ -10,7 +11,9 @@ module Vorpal
|
|
10
11
|
end
|
11
12
|
|
12
13
|
def config_for(clazz)
|
13
|
-
@class_configs.detect { |conf| conf.domain_class == clazz }
|
14
|
+
config = @class_configs.detect { |conf| conf.domain_class == clazz }
|
15
|
+
raise Vorpal::ConfigurationNotFound.new("No configuration found for #{clazz}") unless config
|
16
|
+
config
|
14
17
|
end
|
15
18
|
|
16
19
|
def config_for_db_object(db_object)
|
data/lib/vorpal/db_driver.rb
CHANGED
@@ -68,7 +68,7 @@ module Vorpal
|
|
68
68
|
# slow. https://bugs.ruby-lang.org/issues/11119
|
69
69
|
# Remove this override once #2 has been fixed!
|
70
70
|
def self.name
|
71
|
-
@name ||= "
|
71
|
+
@name ||= "Vorpal_Generated_ActiveRecord_Base_Class_for_#{table_name}_Object_ID_#{object_id}"
|
72
72
|
end
|
73
73
|
|
74
74
|
# Overridden because, like #name, the default implementation for anonymous classes is very,
|
@@ -132,4 +132,4 @@ module Vorpal
|
|
132
132
|
end
|
133
133
|
end
|
134
134
|
end
|
135
|
-
end
|
135
|
+
end
|
@@ -1,21 +1,19 @@
|
|
1
|
-
require 'simple_serializer/serializer'
|
2
|
-
require 'simple_serializer/deserializer'
|
3
1
|
require 'vorpal/configs'
|
4
|
-
require '
|
5
|
-
require 'active_support/core_ext/module/introspection'
|
2
|
+
require 'vorpal/dsl/defaults_generator'
|
6
3
|
|
7
4
|
module Vorpal
|
5
|
+
module Dsl
|
8
6
|
class ConfigBuilder
|
9
7
|
|
10
8
|
# @private
|
11
9
|
def initialize(clazz, options, db_driver)
|
12
10
|
@domain_class = clazz
|
13
11
|
@class_options = options
|
14
|
-
@db_driver = db_driver
|
15
12
|
@has_manys = []
|
16
13
|
@has_ones = []
|
17
14
|
@belongs_tos = []
|
18
15
|
@attributes = []
|
16
|
+
@defaults_generator = DefaultsGenerator.new(clazz, db_driver)
|
19
17
|
end
|
20
18
|
|
21
19
|
# Maps the given attributes to and from the domain object and the DB. Not needed
|
@@ -80,28 +78,14 @@ module Vorpal
|
|
80
78
|
[:id].concat @attributes
|
81
79
|
end
|
82
80
|
|
83
|
-
# @private
|
84
|
-
def table_name
|
85
|
-
@class_options[:table_name] || ActiveSupport::Inflector.tableize(@domain_class.name)
|
86
|
-
end
|
87
|
-
|
88
|
-
# @private
|
89
|
-
def build_db_class
|
90
|
-
@db_driver.build_db_class(table_name)
|
91
|
-
end
|
92
|
-
|
93
81
|
private
|
94
82
|
|
95
|
-
def db_class_name
|
96
|
-
ActiveSupport::Inflector.demodulize(@domain_class.name) + 'DB'
|
97
|
-
end
|
98
|
-
|
99
83
|
def build_class_config
|
100
84
|
Vorpal::ClassConfig.new(
|
101
85
|
domain_class: @domain_class,
|
102
|
-
db_class: @class_options[:to] || build_db_class,
|
103
|
-
serializer: @class_options[:serializer] || serializer(attributes_with_id),
|
104
|
-
deserializer: @class_options[:deserializer] || deserializer(attributes_with_id),
|
86
|
+
db_class: @class_options[:to] || @defaults_generator.build_db_class(@class_options[:table_name]),
|
87
|
+
serializer: @class_options[:serializer] || @defaults_generator.serializer(attributes_with_id),
|
88
|
+
deserializer: @class_options[:deserializer] || @defaults_generator.deserializer(attributes_with_id),
|
105
89
|
)
|
106
90
|
end
|
107
91
|
|
@@ -110,29 +94,19 @@ module Vorpal
|
|
110
94
|
end
|
111
95
|
|
112
96
|
def build_has_many(options)
|
113
|
-
options[:child_class] ||= child_class(options[:name])
|
114
|
-
options[:fk] ||= foreign_key(@domain_class.name)
|
97
|
+
options[:child_class] ||= @defaults_generator.child_class(options[:name])
|
98
|
+
options[:fk] ||= @defaults_generator.foreign_key(@domain_class.name)
|
115
99
|
options[:owned] = options.fetch(:owned, true)
|
116
100
|
Vorpal::HasManyConfig.new(options)
|
117
101
|
end
|
118
102
|
|
119
|
-
def foreign_key(name)
|
120
|
-
ActiveSupport::Inflector.foreign_key(name.to_s)
|
121
|
-
end
|
122
|
-
|
123
|
-
def child_class(association_name)
|
124
|
-
# Module#parent comes from 'active_support/core_ext/module/introspection'
|
125
|
-
parent_module = @domain_class.parent
|
126
|
-
parent_module.const_get(ActiveSupport::Inflector.classify(association_name.to_s))
|
127
|
-
end
|
128
|
-
|
129
103
|
def build_has_ones
|
130
104
|
@has_ones.map { |options| build_has_one(options) }
|
131
105
|
end
|
132
106
|
|
133
107
|
def build_has_one(options)
|
134
|
-
options[:child_class] ||= child_class(options[:name])
|
135
|
-
options[:fk] ||= foreign_key(@domain_class.name)
|
108
|
+
options[:child_class] ||= @defaults_generator.child_class(options[:name])
|
109
|
+
options[:fk] ||= @defaults_generator.foreign_key(@domain_class.name)
|
136
110
|
options[:owned] = options.fetch(:owned, true)
|
137
111
|
Vorpal::HasOneConfig.new(options)
|
138
112
|
end
|
@@ -142,23 +116,12 @@ module Vorpal
|
|
142
116
|
end
|
143
117
|
|
144
118
|
def build_belongs_to(options)
|
145
|
-
child_class = options[:child_classes] || options[:child_class] || child_class(options[:name])
|
119
|
+
child_class = options[:child_classes] || options[:child_class] || @defaults_generator.child_class(options[:name])
|
146
120
|
options[:child_classes] = Array(child_class)
|
147
|
-
options[:fk] ||= foreign_key(options[:name])
|
121
|
+
options[:fk] ||= @defaults_generator.foreign_key(options[:name])
|
148
122
|
options[:owned] = options.fetch(:owned, true)
|
149
123
|
Vorpal::BelongsToConfig.new(options)
|
150
124
|
end
|
151
|
-
|
152
|
-
def serializer(attrs)
|
153
|
-
Class.new(SimpleSerializer::Serializer) do
|
154
|
-
hash_attributes *attrs
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
def deserializer(attrs)
|
159
|
-
Class.new(SimpleSerializer::Deserializer) do
|
160
|
-
object_attributes *attrs
|
161
|
-
end
|
162
|
-
end
|
163
125
|
end
|
164
|
-
end
|
126
|
+
end
|
127
|
+
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'vorpal/engine'
|
2
|
-
require 'vorpal/config_builder'
|
2
|
+
require 'vorpal/dsl/config_builder'
|
3
3
|
|
4
4
|
module Vorpal
|
5
|
+
module Dsl
|
5
6
|
module Configuration
|
6
7
|
|
7
8
|
# Configures and creates a {Engine} instance.
|
@@ -51,4 +52,5 @@ module Vorpal
|
|
51
52
|
MasterConfig.new(@class_configs)
|
52
53
|
end
|
53
54
|
end
|
54
|
-
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'simple_serializer/serializer'
|
2
|
+
require 'simple_serializer/deserializer'
|
3
|
+
require 'active_support/inflector/methods'
|
4
|
+
require 'active_support/core_ext/module/introspection'
|
5
|
+
|
6
|
+
module Vorpal
|
7
|
+
module Dsl
|
8
|
+
class DefaultsGenerator
|
9
|
+
def initialize(domain_class, db_driver)
|
10
|
+
@domain_class = domain_class
|
11
|
+
@db_driver = db_driver
|
12
|
+
end
|
13
|
+
|
14
|
+
def build_db_class(user_table_name)
|
15
|
+
@db_driver.build_db_class(user_table_name || table_name)
|
16
|
+
end
|
17
|
+
|
18
|
+
def table_name
|
19
|
+
ActiveSupport::Inflector.tableize(@domain_class.name)
|
20
|
+
end
|
21
|
+
|
22
|
+
def serializer(attrs)
|
23
|
+
Class.new(SimpleSerializer::Serializer) do
|
24
|
+
hash_attributes *attrs
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def deserializer(attrs)
|
29
|
+
Class.new(SimpleSerializer::Deserializer) do
|
30
|
+
object_attributes *attrs
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def foreign_key(name)
|
35
|
+
ActiveSupport::Inflector.foreign_key(name.to_s)
|
36
|
+
end
|
37
|
+
|
38
|
+
def child_class(association_name)
|
39
|
+
# Module#parent comes from 'active_support/core_ext/module/introspection'
|
40
|
+
parent_module = @domain_class.parent
|
41
|
+
parent_module.const_get(ActiveSupport::Inflector.classify(association_name.to_s))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/vorpal/exceptions.rb
CHANGED
data/lib/vorpal/version.rb
CHANGED
data/lib/vorpal.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require "vorpal/version"
|
2
|
-
require "vorpal/configuration"
|
2
|
+
require "vorpal/dsl/configuration"
|
3
3
|
|
4
4
|
# Allows easy creation of {Vorpal::Engine} instances.
|
5
5
|
#
|
@@ -25,5 +25,5 @@ require "vorpal/configuration"
|
|
25
25
|
# mapper = engine.mapper_for(Tree)
|
26
26
|
# ```
|
27
27
|
module Vorpal
|
28
|
-
extend Vorpal::Configuration
|
28
|
+
extend Vorpal::Dsl::Configuration
|
29
29
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'integration_spec_helper'
|
2
|
+
require 'vorpal'
|
3
|
+
|
4
|
+
describe Vorpal::DbDriver do
|
5
|
+
describe '#build_db_class' do
|
6
|
+
let(:db_class) { subject.build_db_class('example') }
|
7
|
+
|
8
|
+
it 'generates a vald class name so that rails auto-reloading works' do
|
9
|
+
expect { Vorpal.const_defined?(db_class.name) }.to_not raise_error
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'does not let the user access the generated class' do
|
13
|
+
expect { Vorpal.const_get(db_class.name) }.to raise_error(NameError)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -83,6 +83,13 @@ describe 'performance' do
|
|
83
83
|
# update 2.240000 0.180000 2.420000 ( 2.745321)
|
84
84
|
# load 2.130000 0.020000 2.150000 ( 2.223182)
|
85
85
|
# destroy 0.930000 0.010000 0.940000 ( 1.038624)
|
86
|
+
#
|
87
|
+
# Vorpal 0.1.0:
|
88
|
+
# user system total real
|
89
|
+
# create 0.870000 0.100000 0.970000 ( 1.320534)
|
90
|
+
# update 1.820000 0.210000 2.030000 ( 2.351518)
|
91
|
+
# load 1.310000 0.010000 1.320000 ( 1.394192)
|
92
|
+
# destroy 0.930000 0.010000 0.940000 ( 1.030910)
|
86
93
|
it 'benchmarks all operations' do
|
87
94
|
trees = build_trees(1000)
|
88
95
|
Benchmark.bm(7) do |x|
|
@@ -93,46 +100,46 @@ describe 'performance' do
|
|
93
100
|
end
|
94
101
|
end
|
95
102
|
|
96
|
-
it '
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
end
|
104
|
-
|
105
|
-
it 'updates aggregates quickly' do
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
end
|
115
|
-
|
116
|
-
it 'loads aggregates quickly' do
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
end
|
126
|
-
|
127
|
-
it 'destroys aggregates quickly' do
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
end
|
103
|
+
# it 'creates aggregates quickly' do
|
104
|
+
# trees = build_trees(1000)
|
105
|
+
#
|
106
|
+
# puts 'starting persistence benchmark'
|
107
|
+
# puts Benchmark.measure {
|
108
|
+
# tree_mapper.persist(trees)
|
109
|
+
# }
|
110
|
+
# end
|
111
|
+
#
|
112
|
+
# it 'updates aggregates quickly' do
|
113
|
+
# trees = build_trees(1000)
|
114
|
+
#
|
115
|
+
# tree_mapper.persist(trees)
|
116
|
+
#
|
117
|
+
# puts 'starting update benchmark'
|
118
|
+
# puts Benchmark.measure {
|
119
|
+
# tree_mapper.persist(trees)
|
120
|
+
# }
|
121
|
+
# end
|
122
|
+
#
|
123
|
+
# it 'loads aggregates quickly' do
|
124
|
+
# trees = build_trees(1000)
|
125
|
+
# tree_mapper.persist(trees)
|
126
|
+
# ids = trees.map(&:id)
|
127
|
+
#
|
128
|
+
# puts 'starting loading benchmark'
|
129
|
+
# puts Benchmark.measure {
|
130
|
+
# tree_mapper.query.where(id: ids).load_many
|
131
|
+
# }
|
132
|
+
# end
|
133
|
+
#
|
134
|
+
# it 'destroys aggregates quickly' do
|
135
|
+
# trees = build_trees(1000)
|
136
|
+
# tree_mapper.persist(trees)
|
137
|
+
#
|
138
|
+
# puts 'starting destruction benchmark'
|
139
|
+
# puts Benchmark.measure {
|
140
|
+
# tree_mapper.destroy(trees)
|
141
|
+
# }
|
142
|
+
# end
|
136
143
|
|
137
144
|
def build_trees(count)
|
138
145
|
(1..count).map do |i|
|
@@ -49,6 +49,16 @@ describe Vorpal::MasterConfig do
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
describe 'nice user feedback' do
|
53
|
+
it 'lets the user know what the problem is when a configuration is missing' do
|
54
|
+
master_config = Vorpal::MasterConfig.new([])
|
55
|
+
|
56
|
+
expect {
|
57
|
+
master_config.config_for(String)
|
58
|
+
}.to raise_error(Vorpal::ConfigurationNotFound, "No configuration found for String")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
52
62
|
describe Vorpal::AssociationConfig do
|
53
63
|
describe 'associate' do
|
54
64
|
let(:post) { Post.new }
|
@@ -104,4 +114,4 @@ describe Vorpal::MasterConfig do
|
|
104
114
|
end
|
105
115
|
end
|
106
116
|
end
|
107
|
-
end
|
117
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'unit_spec_helper'
|
2
|
+
|
3
|
+
require 'vorpal/dsl/config_builder'
|
4
|
+
require 'vorpal/db_driver'
|
5
|
+
|
6
|
+
describe Vorpal::Dsl::ConfigBuilder do
|
7
|
+
class Tester; end
|
8
|
+
|
9
|
+
let(:builder) { Vorpal::Dsl::ConfigBuilder.new(Tester, {}, nil) }
|
10
|
+
|
11
|
+
describe 'mapping attributes' do
|
12
|
+
it 'allows the \'attributes\' method to be called multiple times' do
|
13
|
+
builder.attributes :first
|
14
|
+
builder.attributes :second
|
15
|
+
|
16
|
+
expect(builder.attributes_with_id).to eq([:id, :first, :second])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'unit_spec_helper'
|
2
|
+
|
3
|
+
require 'vorpal/dsl/defaults_generator'
|
4
|
+
require 'vorpal/db_driver'
|
5
|
+
|
6
|
+
describe Vorpal::Dsl::DefaultsGenerator do
|
7
|
+
class Tester; end
|
8
|
+
class Author; end
|
9
|
+
module Namespace
|
10
|
+
class Tester; end
|
11
|
+
class Author; end
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:db_driver) { instance_double(Vorpal::DbDriver)}
|
15
|
+
|
16
|
+
describe '#build_db_class' do
|
17
|
+
it 'derives the table_name from the domain class name' do
|
18
|
+
generator = build_generator(Tester)
|
19
|
+
expect(db_driver).to receive(:build_db_class).with("testers")
|
20
|
+
|
21
|
+
generator.build_db_class(nil)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'specifies the table_name manually' do
|
25
|
+
generator = build_generator(Tester)
|
26
|
+
expect(db_driver).to receive(:build_db_class).with("override")
|
27
|
+
|
28
|
+
generator.build_db_class("override")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#table_name' do
|
33
|
+
it 'namespaces the table name' do
|
34
|
+
generator = build_generator(Namespace::Tester)
|
35
|
+
|
36
|
+
expect(generator.table_name).to eq("namespace/testers")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#child_class' do
|
41
|
+
it 'resolves the associated class' do
|
42
|
+
generator = build_generator(Tester)
|
43
|
+
clazz = generator.child_class("author")
|
44
|
+
|
45
|
+
expect(clazz.name).to eq("Author")
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'resolves the associated class in the same namespace as the owning class' do
|
49
|
+
generator = build_generator(Namespace::Tester)
|
50
|
+
clazz = generator.child_class("author")
|
51
|
+
|
52
|
+
expect(clazz.name).to eq("Namespace::Author")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#foreign_key' do
|
57
|
+
it 'generates a foreign key from an association name' do
|
58
|
+
generator = build_generator(Tester)
|
59
|
+
fk_name = generator.foreign_key("author")
|
60
|
+
|
61
|
+
expect(fk_name).to eq("author_id")
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'generates a foreign key from an association name regardless of the namespace of the owning class' do
|
65
|
+
generator = build_generator(Namespace::Tester)
|
66
|
+
fk_name = generator.foreign_key("author")
|
67
|
+
|
68
|
+
expect(fk_name).to eq("author_id")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def build_generator(domain_clazz)
|
73
|
+
Vorpal::Dsl::DefaultsGenerator.new(domain_clazz, db_driver)
|
74
|
+
end
|
75
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vorpal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Kirby
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simple_serializer
|
@@ -144,6 +144,7 @@ executables: []
|
|
144
144
|
extensions: []
|
145
145
|
extra_rdoc_files: []
|
146
146
|
files:
|
147
|
+
- ".editorconfig"
|
147
148
|
- ".gitignore"
|
148
149
|
- ".rspec"
|
149
150
|
- ".ruby-version"
|
@@ -157,11 +158,12 @@ files:
|
|
157
158
|
- lib/vorpal/aggregate_mapper.rb
|
158
159
|
- lib/vorpal/aggregate_traversal.rb
|
159
160
|
- lib/vorpal/aggregate_utils.rb
|
160
|
-
- lib/vorpal/config_builder.rb
|
161
161
|
- lib/vorpal/configs.rb
|
162
|
-
- lib/vorpal/configuration.rb
|
163
162
|
- lib/vorpal/db_driver.rb
|
164
163
|
- lib/vorpal/db_loader.rb
|
164
|
+
- lib/vorpal/dsl/config_builder.rb
|
165
|
+
- lib/vorpal/dsl/configuration.rb
|
166
|
+
- lib/vorpal/dsl/defaults_generator.rb
|
165
167
|
- lib/vorpal/engine.rb
|
166
168
|
- lib/vorpal/exceptions.rb
|
167
169
|
- lib/vorpal/identity_map.rb
|
@@ -174,10 +176,12 @@ files:
|
|
174
176
|
- spec/integration_spec_helper.rb
|
175
177
|
- spec/unit_spec_helper.rb
|
176
178
|
- spec/vorpal/acceptance/aggregate_mapper_spec.rb
|
179
|
+
- spec/vorpal/integration/db_driver_spec.rb
|
177
180
|
- spec/vorpal/performance/performance_spec.rb
|
178
|
-
- spec/vorpal/unit/config_builder_spec.rb
|
179
181
|
- spec/vorpal/unit/configs_spec.rb
|
180
182
|
- spec/vorpal/unit/db_loader_spec.rb
|
183
|
+
- spec/vorpal/unit/dsl/config_builder_spec.rb
|
184
|
+
- spec/vorpal/unit/dsl/defaults_generator_spec.rb
|
181
185
|
- spec/vorpal/unit/identity_map_spec.rb
|
182
186
|
- spec/vorpal/unit/loaded_objects_spec.rb
|
183
187
|
- vorpal.gemspec
|
@@ -211,9 +215,11 @@ test_files:
|
|
211
215
|
- spec/integration_spec_helper.rb
|
212
216
|
- spec/unit_spec_helper.rb
|
213
217
|
- spec/vorpal/acceptance/aggregate_mapper_spec.rb
|
218
|
+
- spec/vorpal/integration/db_driver_spec.rb
|
214
219
|
- spec/vorpal/performance/performance_spec.rb
|
215
|
-
- spec/vorpal/unit/config_builder_spec.rb
|
216
220
|
- spec/vorpal/unit/configs_spec.rb
|
217
221
|
- spec/vorpal/unit/db_loader_spec.rb
|
222
|
+
- spec/vorpal/unit/dsl/config_builder_spec.rb
|
223
|
+
- spec/vorpal/unit/dsl/defaults_generator_spec.rb
|
218
224
|
- spec/vorpal/unit/identity_map_spec.rb
|
219
225
|
- spec/vorpal/unit/loaded_objects_spec.rb
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'unit_spec_helper'
|
2
|
-
|
3
|
-
require 'vorpal/config_builder'
|
4
|
-
require 'vorpal/db_driver'
|
5
|
-
|
6
|
-
describe Vorpal::ConfigBuilder do
|
7
|
-
class Tester; end
|
8
|
-
|
9
|
-
let(:builder) { Vorpal::ConfigBuilder.new(Tester, {}, nil) }
|
10
|
-
|
11
|
-
describe 'mapping attributes' do
|
12
|
-
it 'allows the \'attributes\' method to be called multiple times' do
|
13
|
-
builder.attributes :first
|
14
|
-
builder.attributes :second
|
15
|
-
|
16
|
-
expect(builder.attributes_with_id).to eq([:id, :first, :second])
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe 'table name' do
|
21
|
-
it 'is derived from the domain class name' do
|
22
|
-
builder = Vorpal::ConfigBuilder.new(A::B::C::Test, {}, nil)
|
23
|
-
expect(builder.table_name).to eq('a/b/c/tests')
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'can be manually specified' do
|
27
|
-
builder = Vorpal::ConfigBuilder.new(Tester, {table_name: 'testing123'}, nil)
|
28
|
-
expect(builder.table_name).to eq('testing123')
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
module A
|
35
|
-
module B
|
36
|
-
module C
|
37
|
-
class Test
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|