dry-system 0.7.3 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/lib/dry/system.rb +24 -0
- data/lib/dry/system/booter.rb +75 -43
- data/lib/dry/system/booter/component_registry.rb +37 -0
- data/lib/dry/system/component.rb +9 -4
- data/lib/dry/system/components.rb +6 -0
- data/lib/dry/system/components/bootable.rb +307 -0
- data/lib/dry/system/components/config.rb +33 -0
- data/lib/dry/system/constants.rb +2 -0
- data/lib/dry/system/container.rb +69 -22
- data/lib/dry/system/errors.rb +2 -2
- data/lib/dry/system/lifecycle.rb +40 -7
- data/lib/dry/system/provider.rb +46 -0
- data/lib/dry/system/provider_registry.rb +25 -0
- data/lib/dry/system/settings.rb +59 -0
- data/lib/dry/system/settings/file_loader.rb +28 -0
- data/lib/dry/system/settings/file_parser.rb +49 -0
- data/lib/dry/system/system_components/settings.rb +9 -0
- data/lib/dry/system/version.rb +1 -1
- metadata +27 -144
- data/.gitignore +0 -39
- data/.rspec +0 -3
- data/.travis.yml +0 -22
- data/.yardopts +0 -5
- data/CONTRIBUTING.md +0 -29
- data/Gemfile +0 -9
- data/Rakefile +0 -12
- data/dry-system.gemspec +0 -31
- data/examples/custom_configuration_auto_register/Gemfile +0 -5
- data/examples/custom_configuration_auto_register/lib/entities/user.rb +0 -7
- data/examples/custom_configuration_auto_register/lib/user_repo.rb +0 -5
- data/examples/custom_configuration_auto_register/run.rb +0 -8
- data/examples/custom_configuration_auto_register/system/boot/persistence.rb +0 -13
- data/examples/custom_configuration_auto_register/system/container.rb +0 -16
- data/examples/custom_configuration_auto_register/system/import.rb +0 -3
- data/examples/standalone/Gemfile +0 -5
- data/examples/standalone/lib/user_repo.rb +0 -5
- data/examples/standalone/run.rb +0 -8
- data/examples/standalone/system/boot/persistence.rb +0 -13
- data/examples/standalone/system/container.rb +0 -9
- data/examples/standalone/system/import.rb +0 -3
- data/spec/fixtures/components/bar.rb +0 -5
- data/spec/fixtures/components/bar/baz.rb +0 -4
- data/spec/fixtures/components/foo.rb +0 -2
- data/spec/fixtures/components/no_register.rb +0 -4
- data/spec/fixtures/import_test/config/application.yml +0 -2
- data/spec/fixtures/import_test/lib/test/bar.rb +0 -4
- data/spec/fixtures/import_test/lib/test/foo.rb +0 -5
- data/spec/fixtures/import_test/system/boot/bar.rb +0 -11
- data/spec/fixtures/lazytest/config/application.yml +0 -2
- data/spec/fixtures/lazytest/lib/test/dep.rb +0 -4
- data/spec/fixtures/lazytest/lib/test/foo.rb +0 -5
- data/spec/fixtures/lazytest/lib/test/models.rb +0 -4
- data/spec/fixtures/lazytest/lib/test/models/book.rb +0 -6
- data/spec/fixtures/lazytest/lib/test/models/user.rb +0 -6
- data/spec/fixtures/lazytest/system/boot/bar.rb +0 -15
- data/spec/fixtures/magic_comments/comments.rb +0 -17
- data/spec/fixtures/manual_registration/container/foo.rb +0 -6
- data/spec/fixtures/manual_registration/lib/test/foo.rb +0 -9
- data/spec/fixtures/multiple_namespaced_components/multiple/level/baz.rb +0 -7
- data/spec/fixtures/multiple_namespaced_components/multiple/level/foz.rb +0 -6
- data/spec/fixtures/namespaced_components/namespaced/bar.rb +0 -5
- data/spec/fixtures/namespaced_components/namespaced/foo.rb +0 -4
- data/spec/fixtures/other/config/boot/bar.rb +0 -11
- data/spec/fixtures/other/config/boot/hell.rb +0 -3
- data/spec/fixtures/other/lib/test/dep.rb +0 -4
- data/spec/fixtures/other/lib/test/foo.rb +0 -5
- data/spec/fixtures/other/lib/test/models.rb +0 -4
- data/spec/fixtures/other/lib/test/models/book.rb +0 -6
- data/spec/fixtures/other/lib/test/models/user.rb +0 -6
- data/spec/fixtures/stubbing/lib/test/car.rb +0 -7
- data/spec/fixtures/stubbing/system/boot/db.rb +0 -8
- data/spec/fixtures/test/config/application.yml +0 -2
- data/spec/fixtures/test/config/subapp.yml +0 -2
- data/spec/fixtures/test/lib/test/dep.rb +0 -4
- data/spec/fixtures/test/lib/test/foo.rb +0 -5
- data/spec/fixtures/test/lib/test/models.rb +0 -4
- data/spec/fixtures/test/lib/test/models/book.rb +0 -6
- data/spec/fixtures/test/lib/test/models/user.rb +0 -6
- data/spec/fixtures/test/lib/test/singleton_dep.rb +0 -7
- data/spec/fixtures/test/log/.gitkeep +0 -0
- data/spec/fixtures/test/system/boot/bar.rb +0 -11
- data/spec/fixtures/test/system/boot/client.rb +0 -7
- data/spec/fixtures/test/system/boot/db.rb +0 -1
- data/spec/fixtures/test/system/boot/hell.rb +0 -3
- data/spec/fixtures/test/system/boot/logger.rb +0 -5
- data/spec/fixtures/umbrella/system/boot/db.rb +0 -10
- data/spec/integration/boot_spec.rb +0 -18
- data/spec/integration/container/lazy_loading/manual_registration_spec.rb +0 -18
- data/spec/integration/import_spec.rb +0 -81
- data/spec/spec_helper.rb +0 -48
- data/spec/unit/auto_registrar/configuration_spec.rb +0 -26
- data/spec/unit/component_spec.rb +0 -121
- data/spec/unit/container/auto_register_spec.rb +0 -113
- data/spec/unit/container/config_spec.rb +0 -38
- data/spec/unit/container/finalize_spec.rb +0 -97
- data/spec/unit/container/import_spec.rb +0 -53
- data/spec/unit/container/injector_spec.rb +0 -29
- data/spec/unit/container_spec.rb +0 -244
- data/spec/unit/loader_spec.rb +0 -64
- data/spec/unit/magic_comments_parser_spec.rb +0 -41
data/spec/unit/loader_spec.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
require 'dry/system/loader'
|
2
|
-
require 'singleton'
|
3
|
-
|
4
|
-
RSpec.describe Dry::System::Loader, '#call' do
|
5
|
-
shared_examples_for 'object loader' do
|
6
|
-
let(:instance) { loader.call }
|
7
|
-
|
8
|
-
context 'not singleton' do
|
9
|
-
it 'returns a new instance of the constant' do
|
10
|
-
expect(instance).to be_instance_of(constant)
|
11
|
-
expect(instance).not_to be(loader.call)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
context 'singleton' do
|
16
|
-
before { constant.send(:include, Singleton) }
|
17
|
-
|
18
|
-
it 'returns singleton instance' do
|
19
|
-
expect(instance).to be(constant.instance)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'with a singular name' do
|
25
|
-
subject(:loader) { Dry::System::Loader.new('test/bar') }
|
26
|
-
|
27
|
-
let(:constant) { Test::Bar }
|
28
|
-
|
29
|
-
before do
|
30
|
-
module Test;class Bar;end;end
|
31
|
-
end
|
32
|
-
|
33
|
-
it_behaves_like 'object loader'
|
34
|
-
end
|
35
|
-
|
36
|
-
context 'with a plural name' do
|
37
|
-
subject(:loader) { Dry::System::Loader.new('test/bars') }
|
38
|
-
|
39
|
-
let(:constant) { Test::Bars }
|
40
|
-
|
41
|
-
before do
|
42
|
-
module Test;class Bars;end;end
|
43
|
-
end
|
44
|
-
|
45
|
-
it_behaves_like 'object loader'
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'with a constructor accepting args' do
|
49
|
-
subject(:loader) { Dry::System::Loader.new('test/bar') }
|
50
|
-
|
51
|
-
before do
|
52
|
-
module Test
|
53
|
-
Bar = Struct.new(:one, :two)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'passes args to the constructor' do
|
58
|
-
instance = loader.call(1, 2)
|
59
|
-
|
60
|
-
expect(instance.one).to be(1)
|
61
|
-
expect(instance.two).to be(2)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'dry/system/magic_comments_parser'
|
2
|
-
|
3
|
-
RSpec.describe Dry::System::MagicCommentsParser, '.call' do
|
4
|
-
let(:file_name) { SPEC_ROOT.join('fixtures/magic_comments/comments.rb') }
|
5
|
-
let(:comments) { described_class.(file_name) }
|
6
|
-
|
7
|
-
it 'makes comment names available as symbols' do
|
8
|
-
expect(comments.key?(:valid_comment)).to eql true
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'finds magic comments after other commented lines or blank lines' do
|
12
|
-
expect(comments[:valid_comment]).to eq 'hello'
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'does not match comments with invalid names' do
|
16
|
-
expect(comments.values).not_to include 'value for comment using dashes'
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'supports comment names with alpha-numeric characters and underscores (numbers not allowed for first character)' do
|
20
|
-
expect(comments[:comment_123]).to eq 'alpha-numeric and underscores allowed'
|
21
|
-
expect(comments.keys).not_to include(:"123_will_not_match")
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'only matches comments at the start of the line' do
|
25
|
-
expect(comments.key?(:not_at_start_of_line)).to eql false
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'does not match any comments after any lines of code' do
|
29
|
-
expect(comments.key?(:after_code)).to eql false
|
30
|
-
end
|
31
|
-
|
32
|
-
describe 'coercions' do
|
33
|
-
it 'coerces "true" to true' do
|
34
|
-
expect(comments[:true_comment]).to eq true
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'coerces "false" to false' do
|
38
|
-
expect(comments[:false_comment]).to eq false
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|