vorpal 1.0.0 → 1.2.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 +4 -4
- data/README.md +85 -47
- data/lib/vorpal/aggregate_mapper.rb +11 -0
- data/lib/vorpal/config/class_config.rb +71 -0
- data/lib/vorpal/configs.rb +9 -66
- data/lib/vorpal/driver/postgresql.rb +40 -4
- data/lib/vorpal/dsl/config_builder.rb +12 -50
- data/lib/vorpal/dsl/configuration.rb +131 -42
- data/lib/vorpal/dsl/defaults_generator.rb +14 -4
- data/lib/vorpal/engine.rb +16 -3
- data/lib/vorpal/identity_map.rb +15 -14
- data/lib/vorpal/version.rb +1 -1
- data/vorpal.gemspec +11 -10
- metadata +43 -63
- data/.editorconfig +0 -13
- data/.gitignore +0 -16
- data/.rspec +0 -1
- data/.yardopts +0 -1
- data/Gemfile +0 -4
- data/Rakefile +0 -10
- data/spec/helpers/db_helpers.rb +0 -51
- data/spec/helpers/profile_helpers.rb +0 -26
- data/spec/integration_spec_helper.rb +0 -36
- data/spec/unit_spec_helper.rb +0 -0
- data/spec/vorpal/acceptance/aggregate_mapper_spec.rb +0 -911
- data/spec/vorpal/integration/driver/postgresql_spec.rb +0 -42
- data/spec/vorpal/performance/performance_spec.rb +0 -195
- data/spec/vorpal/unit/configs_spec.rb +0 -117
- data/spec/vorpal/unit/db_loader_spec.rb +0 -103
- data/spec/vorpal/unit/dsl/config_builder_spec.rb +0 -18
- data/spec/vorpal/unit/dsl/defaults_generator_spec.rb +0 -75
- data/spec/vorpal/unit/identity_map_spec.rb +0 -62
- data/spec/vorpal/unit/loaded_objects_spec.rb +0 -22
- data/spec/vorpal/unit/util/string_utils_spec.rb +0 -25
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'unit_spec_helper'
|
2
|
-
|
3
|
-
require 'vorpal/dsl/config_builder'
|
4
|
-
|
5
|
-
describe Vorpal::Dsl::ConfigBuilder do
|
6
|
-
class Tester; end
|
7
|
-
|
8
|
-
let(:builder) { Vorpal::Dsl::ConfigBuilder.new(Tester, {}, nil) }
|
9
|
-
|
10
|
-
describe 'mapping attributes' do
|
11
|
-
it 'allows the \'attributes\' method to be called multiple times' do
|
12
|
-
builder.attributes :first
|
13
|
-
builder.attributes :second
|
14
|
-
|
15
|
-
expect(builder.attributes_with_id).to eq([:id, :first, :second])
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'unit_spec_helper'
|
2
|
-
|
3
|
-
require 'vorpal/dsl/defaults_generator'
|
4
|
-
require 'vorpal/driver/postgresql'
|
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::Driver::Postgresql)}
|
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(Tester, "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(Tester, "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
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require 'unit_spec_helper'
|
2
|
-
|
3
|
-
require 'vorpal/identity_map'
|
4
|
-
|
5
|
-
describe Vorpal::IdentityMap do
|
6
|
-
let(:map) { Vorpal::IdentityMap.new }
|
7
|
-
|
8
|
-
it "does not rely on the key object's implementation of hash and eql?" do
|
9
|
-
funny1 = build_funny_entity(1)
|
10
|
-
map.set(funny1, 'funny 1')
|
11
|
-
|
12
|
-
funny2 = build_funny_entity(2)
|
13
|
-
map.set(funny2, 'funny 2')
|
14
|
-
|
15
|
-
expect(map.get(funny1)).to eq('funny 1')
|
16
|
-
end
|
17
|
-
|
18
|
-
it "raises an exception when the key object does not have an id set" do
|
19
|
-
entity = build_entity(nil)
|
20
|
-
|
21
|
-
expect { map.set(entity, 'something') }.to raise_error(/Cannot put entity/)
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'raises an exception when the key object extends a class with no name (such as anonymous classes)' do
|
25
|
-
anonymous_class = Class.new do
|
26
|
-
attr_accessor :id
|
27
|
-
end
|
28
|
-
|
29
|
-
entity = anonymous_class.new
|
30
|
-
entity.id = 1
|
31
|
-
|
32
|
-
expect { map.set(entity, 'something') }.to raise_error(/Cannot put entity/)
|
33
|
-
end
|
34
|
-
|
35
|
-
def build_entity(id)
|
36
|
-
entity = Entity.new
|
37
|
-
entity.id = id
|
38
|
-
entity
|
39
|
-
end
|
40
|
-
|
41
|
-
class Entity
|
42
|
-
attr_accessor :id
|
43
|
-
end
|
44
|
-
|
45
|
-
def build_funny_entity(id)
|
46
|
-
funny1 = Funny.new
|
47
|
-
funny1.id = id
|
48
|
-
funny1
|
49
|
-
end
|
50
|
-
|
51
|
-
class Funny
|
52
|
-
attr_accessor :id
|
53
|
-
|
54
|
-
def hash
|
55
|
-
1
|
56
|
-
end
|
57
|
-
|
58
|
-
def eql?(other)
|
59
|
-
true
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'unit_spec_helper'
|
2
|
-
|
3
|
-
require 'virtus'
|
4
|
-
require 'vorpal/loaded_objects'
|
5
|
-
require 'vorpal/configs'
|
6
|
-
|
7
|
-
describe Vorpal::LoadedObjects do
|
8
|
-
class TestObject
|
9
|
-
include Virtus.model
|
10
|
-
attribute :id, Integer
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'does not accept duplicate objects' do
|
14
|
-
object = TestObject.new(id: 22)
|
15
|
-
config = Vorpal::ClassConfig.new({domain_class: Object})
|
16
|
-
|
17
|
-
subject.add(config, [object, object])
|
18
|
-
subject.add(config, [object])
|
19
|
-
|
20
|
-
expect(subject.objects.values.flatten).to contain_exactly(object)
|
21
|
-
end
|
22
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'unit_spec_helper'
|
2
|
-
require 'vorpal/util/string_utils'
|
3
|
-
|
4
|
-
describe Vorpal::Util::StringUtils do
|
5
|
-
|
6
|
-
describe '.escape_class_name' do
|
7
|
-
it 'does nothing when there are no :: in the class name' do
|
8
|
-
expect(escape_class_name("Foo")).to eq("Foo")
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'converts :: into __' do
|
12
|
-
expect(escape_class_name("Foo::Bar")).to eq("Foo__Bar")
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'converts multiple :: into __' do
|
16
|
-
expect(escape_class_name("Foo::Bar::Baz")).to eq("Foo__Bar__Baz")
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def escape_class_name(class_name)
|
23
|
-
Vorpal::Util::StringUtils.escape_class_name(class_name)
|
24
|
-
end
|
25
|
-
end
|