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
data/dry-system.gemspec DELETED
@@ -1,31 +0,0 @@
1
- # coding: utf-8
2
- require File.expand_path('../lib/dry/system/version', __FILE__)
3
-
4
- Gem::Specification.new do |spec|
5
- spec.name = 'dry-system'
6
- spec.version = Dry::System::VERSION
7
- spec.authors = ['Piotr Solnica']
8
- spec.email = ['piotr.solnica@gmail.com']
9
- spec.summary = 'Organize your code into reusable components'
10
- spec.homepage = 'http://dry-rb.org/gems/dry-system'
11
- spec.license = 'MIT'
12
-
13
- spec.files = `git ls-files -z`.split("\x0")
14
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
15
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
- spec.require_paths = ['lib']
17
-
18
- spec.required_ruby_version = '>= 2.1.0'
19
-
20
- spec.add_runtime_dependency 'inflecto', '>= 0.0.2'
21
- spec.add_runtime_dependency 'concurrent-ruby', '~> 1.0'
22
- spec.add_runtime_dependency 'dry-core', '>= 0.3.1'
23
- spec.add_runtime_dependency 'dry-equalizer', '~> 0.2'
24
- spec.add_runtime_dependency 'dry-container', '~> 0.6'
25
- spec.add_runtime_dependency 'dry-auto_inject', '>= 0.4.0'
26
- spec.add_runtime_dependency 'dry-configurable', '~> 0.7', '>= 0.7.0'
27
-
28
- spec.add_development_dependency 'bundler'
29
- spec.add_development_dependency 'rake'
30
- spec.add_development_dependency 'rspec'
31
- end
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'dry-system', path: '../..'
4
- gem 'sequel'
5
- gem 'sqlite3'
@@ -1,7 +0,0 @@
1
- require 'import'
2
-
3
- module Entities
4
- class User
5
- include Import['persistence.db']
6
- end
7
- end
@@ -1,5 +0,0 @@
1
- require 'import'
2
-
3
- class UserRepo
4
- include Import['persistence.db']
5
- end
@@ -1,8 +0,0 @@
1
- require 'bundler/setup'
2
- require_relative 'system/container'
3
-
4
- App.finalize!
5
-
6
- user_repo = App['user_repo']
7
- puts "User has not been loaded" unless App.key?('entities.user')
8
- puts user_repo.db.inspect
@@ -1,13 +0,0 @@
1
- App.finalize(:persistence) do |persistence|
2
- init do
3
- require 'sequel'
4
- end
5
-
6
- start do
7
- persistence.register('persistence.db', Sequel.connect('sqlite::memory'))
8
- end
9
-
10
- stop do
11
- db.close_connection
12
- end
13
- end
@@ -1,16 +0,0 @@
1
- require 'dry/system/container'
2
-
3
- class App < Dry::System::Container
4
- load_paths!('lib', 'system')
5
-
6
- auto_register!('lib') do |config|
7
- config.instance do |component|
8
- # some custom initialization logic
9
- component.instance
10
- end
11
-
12
- config.exclude do |component|
13
- component.path =~ /entities/
14
- end
15
- end
16
- end
@@ -1,3 +0,0 @@
1
- require_relative 'container'
2
-
3
- Import = App.injector
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'dry-system', path: '../..'
4
- gem 'sequel'
5
- gem 'sqlite3'
@@ -1,5 +0,0 @@
1
- require 'import'
2
-
3
- class UserRepo
4
- include Import['persistence.db']
5
- end
@@ -1,8 +0,0 @@
1
- require 'bundler/setup'
2
- require_relative 'system/container'
3
-
4
- App.finalize!
5
-
6
- user_repo = App['user_repo']
7
-
8
- puts user_repo.db.inspect
@@ -1,13 +0,0 @@
1
- App.finalize(:persistence) do |persistence|
2
- init do
3
- require 'sequel'
4
- end
5
-
6
- start do
7
- persistence.register('persistence.db', Sequel.connect('sqlite::memory'))
8
- end
9
-
10
- stop do
11
- db.close_connection
12
- end
13
- end
@@ -1,9 +0,0 @@
1
- require 'dry/system/container'
2
-
3
- class App < Dry::System::Container
4
- configure do |config|
5
- config.auto_register = %w(lib)
6
- end
7
-
8
- load_paths!('lib')
9
- end
@@ -1,3 +0,0 @@
1
- require_relative 'container'
2
-
3
- Import = App.injector
@@ -1,5 +0,0 @@
1
- class Bar
2
- def self.call
3
- "Welcome to my Moe's Tavern!"
4
- end
5
- end
@@ -1,4 +0,0 @@
1
- class Bar
2
- class Baz
3
- end
4
- end
@@ -1,2 +0,0 @@
1
- class Foo
2
- end
@@ -1,4 +0,0 @@
1
- # auto_register: false
2
-
3
- class NoRegister
4
- end
@@ -1,2 +0,0 @@
1
- test:
2
- foo: 'bar'
@@ -1,4 +0,0 @@
1
- module Test
2
- class Bar
3
- end
4
- end
@@ -1,5 +0,0 @@
1
- module Test
2
- class Foo
3
- include Import['test.bar']
4
- end
5
- end
@@ -1,11 +0,0 @@
1
- Test::Container.namespace(:test) do |container|
2
- module Test
3
- module Bar
4
- # I shall be booted
5
- end
6
- end
7
-
8
- container.finalize(:bar) do
9
- container.register(:bar, 'I was finalized')
10
- end
11
- end
@@ -1,2 +0,0 @@
1
- test:
2
- foo: 'bar'
@@ -1,4 +0,0 @@
1
- module Test
2
- class Dep
3
- end
4
- end
@@ -1,5 +0,0 @@
1
- module Test
2
- class Foo
3
- include Import['test.dep']
4
- end
5
- end
@@ -1,4 +0,0 @@
1
- module Test
2
- module Models
3
- end
4
- end
@@ -1,6 +0,0 @@
1
- module Test
2
- module Models
3
- class Book
4
- end
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- module Test
2
- module Models
3
- class User
4
- end
5
- end
6
- end
@@ -1,15 +0,0 @@
1
- Test::Container.namespace(:test) do |container|
2
- container.finalize(:bar) do
3
- init do
4
- module Test
5
- module Bar
6
- # I shall be booted
7
- end
8
- end
9
- end
10
-
11
- start do
12
- container.register(:bar, 'I was finalized')
13
- end
14
- end
15
- end
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # This is a file with a mix of valid and invalid magic comments
4
-
5
- # valid_comment: hello
6
- # true_comment: true
7
- # false_comment: false
8
- # comment_123: alpha-numeric and underscores allowed
9
- # 123_will_not_match: will not match
10
- # not-using-underscores: value for comment using dashes
11
-
12
- # not_at_start_of_line: will not match
13
-
14
- module Test
15
- end
16
-
17
- # after_code: will not match
@@ -1,6 +0,0 @@
1
- Test::Container.namespace(:foo) do |container|
2
- container.register('special') do
3
- require 'test/foo'
4
- Test::Foo.new('special')
5
- end
6
- end
@@ -1,9 +0,0 @@
1
- module Test
2
- class Foo
3
- attr_reader :name
4
-
5
- def initialize(name)
6
- @name = name
7
- end
8
- end
9
- end
@@ -1,7 +0,0 @@
1
- module Multiple
2
- module Level
3
- class Baz
4
- include Test::Container.injector["foz"]
5
- end
6
- end
7
- end
@@ -1,6 +0,0 @@
1
- module Multiple
2
- module Level
3
- class Foz
4
- end
5
- end
6
- end
@@ -1,5 +0,0 @@
1
- module Namespaced
2
- class Bar
3
- include Test::Container.injector["foo"]
4
- end
5
- end
@@ -1,4 +0,0 @@
1
- module Namespaced
2
- class Foo
3
- end
4
- end
@@ -1,11 +0,0 @@
1
- Test::Container.namespace(:test) do |container|
2
- module Test
3
- module Bar
4
- # I shall be booted
5
- end
6
- end
7
-
8
- container.finalize(:bar) do
9
- container.register(:bar, 'I was finalized')
10
- end
11
- end
@@ -1,3 +0,0 @@
1
- Test::Container.finalize :heaven do |container|
2
- container.register('heaven', 'string')
3
- end
@@ -1,4 +0,0 @@
1
- module Test
2
- class Dep
3
- end
4
- end
@@ -1,5 +0,0 @@
1
- module Test
2
- class Foo
3
- include Import['test.dep']
4
- end
5
- end
@@ -1,4 +0,0 @@
1
- module Test
2
- module Models
3
- end
4
- end
@@ -1,6 +0,0 @@
1
- module Test
2
- module Models
3
- class Book
4
- end
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- module Test
2
- module Models
3
- class User
4
- end
5
- end
6
- end
@@ -1,7 +0,0 @@
1
- module Test
2
- class Car
3
- def wheels_count
4
- 4
5
- end
6
- end
7
- end
@@ -1,8 +0,0 @@
1
- Test::Container.finalize :db do |container|
2
- module Test
3
- class DB
4
- end
5
- end
6
-
7
- container.register(:db, Test::DB.new)
8
- end
@@ -1,2 +0,0 @@
1
- test:
2
- foo: 'bar'
@@ -1,2 +0,0 @@
1
- test:
2
- bar: 'baz'
@@ -1,4 +0,0 @@
1
- module Test
2
- class Dep
3
- end
4
- end
@@ -1,5 +0,0 @@
1
- module Test
2
- class Foo
3
- include Import['test.dep']
4
- end
5
- end
@@ -1,4 +0,0 @@
1
- module Test
2
- module Models
3
- end
4
- end