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.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +17 -0
  3. data/lib/dry/system.rb +24 -0
  4. data/lib/dry/system/booter.rb +75 -43
  5. data/lib/dry/system/booter/component_registry.rb +37 -0
  6. data/lib/dry/system/component.rb +9 -4
  7. data/lib/dry/system/components.rb +6 -0
  8. data/lib/dry/system/components/bootable.rb +307 -0
  9. data/lib/dry/system/components/config.rb +33 -0
  10. data/lib/dry/system/constants.rb +2 -0
  11. data/lib/dry/system/container.rb +69 -22
  12. data/lib/dry/system/errors.rb +2 -2
  13. data/lib/dry/system/lifecycle.rb +40 -7
  14. data/lib/dry/system/provider.rb +46 -0
  15. data/lib/dry/system/provider_registry.rb +25 -0
  16. data/lib/dry/system/settings.rb +59 -0
  17. data/lib/dry/system/settings/file_loader.rb +28 -0
  18. data/lib/dry/system/settings/file_parser.rb +49 -0
  19. data/lib/dry/system/system_components/settings.rb +9 -0
  20. data/lib/dry/system/version.rb +1 -1
  21. metadata +27 -144
  22. data/.gitignore +0 -39
  23. data/.rspec +0 -3
  24. data/.travis.yml +0 -22
  25. data/.yardopts +0 -5
  26. data/CONTRIBUTING.md +0 -29
  27. data/Gemfile +0 -9
  28. data/Rakefile +0 -12
  29. data/dry-system.gemspec +0 -31
  30. data/examples/custom_configuration_auto_register/Gemfile +0 -5
  31. data/examples/custom_configuration_auto_register/lib/entities/user.rb +0 -7
  32. data/examples/custom_configuration_auto_register/lib/user_repo.rb +0 -5
  33. data/examples/custom_configuration_auto_register/run.rb +0 -8
  34. data/examples/custom_configuration_auto_register/system/boot/persistence.rb +0 -13
  35. data/examples/custom_configuration_auto_register/system/container.rb +0 -16
  36. data/examples/custom_configuration_auto_register/system/import.rb +0 -3
  37. data/examples/standalone/Gemfile +0 -5
  38. data/examples/standalone/lib/user_repo.rb +0 -5
  39. data/examples/standalone/run.rb +0 -8
  40. data/examples/standalone/system/boot/persistence.rb +0 -13
  41. data/examples/standalone/system/container.rb +0 -9
  42. data/examples/standalone/system/import.rb +0 -3
  43. data/spec/fixtures/components/bar.rb +0 -5
  44. data/spec/fixtures/components/bar/baz.rb +0 -4
  45. data/spec/fixtures/components/foo.rb +0 -2
  46. data/spec/fixtures/components/no_register.rb +0 -4
  47. data/spec/fixtures/import_test/config/application.yml +0 -2
  48. data/spec/fixtures/import_test/lib/test/bar.rb +0 -4
  49. data/spec/fixtures/import_test/lib/test/foo.rb +0 -5
  50. data/spec/fixtures/import_test/system/boot/bar.rb +0 -11
  51. data/spec/fixtures/lazytest/config/application.yml +0 -2
  52. data/spec/fixtures/lazytest/lib/test/dep.rb +0 -4
  53. data/spec/fixtures/lazytest/lib/test/foo.rb +0 -5
  54. data/spec/fixtures/lazytest/lib/test/models.rb +0 -4
  55. data/spec/fixtures/lazytest/lib/test/models/book.rb +0 -6
  56. data/spec/fixtures/lazytest/lib/test/models/user.rb +0 -6
  57. data/spec/fixtures/lazytest/system/boot/bar.rb +0 -15
  58. data/spec/fixtures/magic_comments/comments.rb +0 -17
  59. data/spec/fixtures/manual_registration/container/foo.rb +0 -6
  60. data/spec/fixtures/manual_registration/lib/test/foo.rb +0 -9
  61. data/spec/fixtures/multiple_namespaced_components/multiple/level/baz.rb +0 -7
  62. data/spec/fixtures/multiple_namespaced_components/multiple/level/foz.rb +0 -6
  63. data/spec/fixtures/namespaced_components/namespaced/bar.rb +0 -5
  64. data/spec/fixtures/namespaced_components/namespaced/foo.rb +0 -4
  65. data/spec/fixtures/other/config/boot/bar.rb +0 -11
  66. data/spec/fixtures/other/config/boot/hell.rb +0 -3
  67. data/spec/fixtures/other/lib/test/dep.rb +0 -4
  68. data/spec/fixtures/other/lib/test/foo.rb +0 -5
  69. data/spec/fixtures/other/lib/test/models.rb +0 -4
  70. data/spec/fixtures/other/lib/test/models/book.rb +0 -6
  71. data/spec/fixtures/other/lib/test/models/user.rb +0 -6
  72. data/spec/fixtures/stubbing/lib/test/car.rb +0 -7
  73. data/spec/fixtures/stubbing/system/boot/db.rb +0 -8
  74. data/spec/fixtures/test/config/application.yml +0 -2
  75. data/spec/fixtures/test/config/subapp.yml +0 -2
  76. data/spec/fixtures/test/lib/test/dep.rb +0 -4
  77. data/spec/fixtures/test/lib/test/foo.rb +0 -5
  78. data/spec/fixtures/test/lib/test/models.rb +0 -4
  79. data/spec/fixtures/test/lib/test/models/book.rb +0 -6
  80. data/spec/fixtures/test/lib/test/models/user.rb +0 -6
  81. data/spec/fixtures/test/lib/test/singleton_dep.rb +0 -7
  82. data/spec/fixtures/test/log/.gitkeep +0 -0
  83. data/spec/fixtures/test/system/boot/bar.rb +0 -11
  84. data/spec/fixtures/test/system/boot/client.rb +0 -7
  85. data/spec/fixtures/test/system/boot/db.rb +0 -1
  86. data/spec/fixtures/test/system/boot/hell.rb +0 -3
  87. data/spec/fixtures/test/system/boot/logger.rb +0 -5
  88. data/spec/fixtures/umbrella/system/boot/db.rb +0 -10
  89. data/spec/integration/boot_spec.rb +0 -18
  90. data/spec/integration/container/lazy_loading/manual_registration_spec.rb +0 -18
  91. data/spec/integration/import_spec.rb +0 -81
  92. data/spec/spec_helper.rb +0 -48
  93. data/spec/unit/auto_registrar/configuration_spec.rb +0 -26
  94. data/spec/unit/component_spec.rb +0 -121
  95. data/spec/unit/container/auto_register_spec.rb +0 -113
  96. data/spec/unit/container/config_spec.rb +0 -38
  97. data/spec/unit/container/finalize_spec.rb +0 -97
  98. data/spec/unit/container/import_spec.rb +0 -53
  99. data/spec/unit/container/injector_spec.rb +0 -29
  100. data/spec/unit/container_spec.rb +0 -244
  101. data/spec/unit/loader_spec.rb +0 -64
  102. data/spec/unit/magic_comments_parser_spec.rb +0 -41
@@ -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