super-lite-hub 0.0.1
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.
Potentially problematic release.
This version of super-lite-hub might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/dry-container-0.11.0/CHANGELOG.md +150 -0
- data/dry-container-0.11.0/LICENSE +20 -0
- data/dry-container-0.11.0/README.md +30 -0
- data/dry-container-0.11.0/dry-container.gemspec +37 -0
- data/dry-container-0.11.0/lib/dry/container/error.rb +15 -0
- data/dry-container-0.11.0/lib/dry/container/item/callable.rb +22 -0
- data/dry-container-0.11.0/lib/dry/container/item/factory.rb +26 -0
- data/dry-container-0.11.0/lib/dry/container/item/memoizable.rb +49 -0
- data/dry-container-0.11.0/lib/dry/container/item.rb +51 -0
- data/dry-container-0.11.0/lib/dry/container/mixin.rb +353 -0
- data/dry-container-0.11.0/lib/dry/container/namespace.rb +44 -0
- data/dry-container-0.11.0/lib/dry/container/namespace_dsl.rb +61 -0
- data/dry-container-0.11.0/lib/dry/container/registry.rb +50 -0
- data/dry-container-0.11.0/lib/dry/container/resolver.rb +88 -0
- data/dry-container-0.11.0/lib/dry/container/stub.rb +55 -0
- data/dry-container-0.11.0/lib/dry/container/version.rb +8 -0
- data/dry-container-0.11.0/lib/dry/container.rb +35 -0
- data/dry-container-0.11.0/lib/dry-container.rb +151 -0
- data/super-lite-hub.gemspec +11 -0
- metadata +59 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: ae12786043d4e31b662a20e308086ecf84c694eb958fb22d179b98a6eba2ad9d
|
|
4
|
+
data.tar.gz: c71307ba2c327fa72a8806db46df97b2ff1b8c70f7a509d4f36818eda505a72d
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: f0b1a8290b2f8aa14aae5c3a309df81e09bf8c9542b8ebb6b4f66ca19d5c9498d5ed968ecbf8fee51f78c371eac92ebb14db4121b9c8d54aad3ce76bfec00b66
|
|
7
|
+
data.tar.gz: 44854cb74737dcdbfbd4b5eed37d127d5dfe40ac0be761911c36d91058d390b85b94a3d18c1270422b458ba58ce0751830b4637decb374339dd0323b2d45d04f
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
|
|
2
|
+
|
|
3
|
+
## 0.11.0 2022-09-16
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Changed
|
|
7
|
+
|
|
8
|
+
- dry-configurable will be used whenever it is in the $LOAD_PATH (see dry-rb/dry-system#247 for more context) (@solnic)
|
|
9
|
+
|
|
10
|
+
[Compare v0.10.1...v0.11.0](https://github.com/dry-rb/dry-container/compare/v0.10.1...v0.11.0)
|
|
11
|
+
|
|
12
|
+
## 0.10.1 2022-07-29
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- Make `DidYouMean` integration optional (via #86) (@jbourassa)
|
|
18
|
+
|
|
19
|
+
[Compare v0.10.0...v0.10.1](https://github.com/dry-rb/dry-container/compare/v0.10.0...v0.10.1)
|
|
20
|
+
|
|
21
|
+
## 0.10.0 2022-07-10
|
|
22
|
+
|
|
23
|
+
⚠️ Notice that dry-container no longer depends on dry-configurable. If you happen to rely on the advanced configurable functionality, add dry-configurable as a dependency and require it **before** requiring dry-container.
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
|
|
27
|
+
- Accept block given to `#merge` (via #83) (@timriley)
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- [BREAKING] Replace dep on dry-configurable with a simple `Configuration` mod (see #84 for more details) (@solnic)
|
|
32
|
+
- Raise KeyError for missing key, with DidYouMean integration (via #82) (@cllns)
|
|
33
|
+
- Wrap FrozenError, to state that the container itself is frozen (see #74) (@cllns)
|
|
34
|
+
|
|
35
|
+
[Compare v0.9.0...v0.10.0](https://github.com/dry-rb/dry-container/compare/v0.9.0...v0.10.0)
|
|
36
|
+
|
|
37
|
+
## 0.9.0 2021-09-12
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### Changed
|
|
41
|
+
|
|
42
|
+
- [internal] Upgraded to new `setting` API provided in dry-configurable 0.13.0 (@timriley in #77)
|
|
43
|
+
|
|
44
|
+
[Compare v0.8.0...v0.9.0](https://github.com/dry-rb/dry-container/compare/v0.8.0...v0.9.0)
|
|
45
|
+
|
|
46
|
+
## 0.8.0 2021-06-06
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
### Changed
|
|
50
|
+
|
|
51
|
+
- [BREAKING] Support for 2.4 and 2.5 was dropped
|
|
52
|
+
|
|
53
|
+
[Compare v0.7.2...v0.8.0](https://github.com/dry-rb/dry-container/compare/v0.7.2...v0.8.0)
|
|
54
|
+
|
|
55
|
+
## 0.7.2 2019-07-09
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
### Added
|
|
59
|
+
|
|
60
|
+
- `.resolve` accepts an optional fallback block, similar to how `Hash#fetch` works ([flash-gordon](https://github.com/flash-gordon))
|
|
61
|
+
```ruby
|
|
62
|
+
container.resolve('missing_key') { :fallback } # => :fallback
|
|
63
|
+
```
|
|
64
|
+
- `.decorate` can (again) work with static values. Also, it can take a block instead of `with` ([flash-gordon](https://github.com/flash-gordon))
|
|
65
|
+
```ruby
|
|
66
|
+
container.register('key', 'value')
|
|
67
|
+
container.decorate('key') { |v| "<'#{v}'>" }
|
|
68
|
+
container.resolve('key') # => "<'value'>"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
[Compare v0.7.1...v0.7.2](https://github.com/dry-rb/dry-container/compare/v0.7.1...v0.7.2)
|
|
73
|
+
|
|
74
|
+
## 0.7.1 2019-06-07
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
### Fixed
|
|
78
|
+
|
|
79
|
+
- Added `Mixin#dup` and `Mixin#clone`, now copies don't share underlying containers (flash-gordon)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
[Compare v0.7.0...v0.7.1](https://github.com/dry-rb/dry-container/compare/v0.7.0...v0.7.1)
|
|
83
|
+
|
|
84
|
+
## 0.7.0 2019-02-05
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
### Added
|
|
88
|
+
|
|
89
|
+
- Namespace DSL resolves keys relative to the current namespace, see the corresponding [changes](https://github.com/dry-rb/dry-container/pull/47) ([yuszuv](https://github.com/yuszuv))
|
|
90
|
+
- Registered objects can be decorated with the following API ([igor-alexandrov](https://github.com/igor-alexandrov))
|
|
91
|
+
|
|
92
|
+
```ruby
|
|
93
|
+
class CreateUser
|
|
94
|
+
def call(params)
|
|
95
|
+
# ...
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
container.register('create_user') { CreateUser.new }
|
|
99
|
+
container.decorate('create_user', with: ShinyLogger.new)
|
|
100
|
+
|
|
101
|
+
# Now subsequent resolutions will return a wrapped object
|
|
102
|
+
|
|
103
|
+
container.resolve('create_user')
|
|
104
|
+
# => #<ShinyLogger @obj=#<CreateUser:0x...>]>
|
|
105
|
+
```
|
|
106
|
+
- Freezing a container now prevents further registrations ([flash-gordon](https://github.com/flash-gordon))
|
|
107
|
+
- ## Internal
|
|
108
|
+
- Handling container items was generalized in [#34](https://github.com/dry-rb/dry-container/pull/34) ([GabrielMalakias](https://github.com/GabrielMalakias))
|
|
109
|
+
|
|
110
|
+
### Fixed
|
|
111
|
+
|
|
112
|
+
- Symbols are now coerced to strings when resolving stubbed dependencies ([cthulhu666](https://github.com/cthulhu666))
|
|
113
|
+
- Stubbing keys not present in container will raise an error ([flash-gordon](https://github.com/flash-gordon))
|
|
114
|
+
|
|
115
|
+
This means after upgrading you may see errors like this
|
|
116
|
+
```
|
|
117
|
+
ArgumentError (cannot stub "something" - no such key in container)
|
|
118
|
+
```
|
|
119
|
+
Be sure you register dependencies before using them. The new behavior will likely save quite a bit of time when debugging ill-configured container setups.
|
|
120
|
+
|
|
121
|
+
### Changed
|
|
122
|
+
|
|
123
|
+
- [BREAKING] Now only Ruby 2.3 and above is supported ([flash-gordon](https://github.com/flash-gordon))
|
|
124
|
+
|
|
125
|
+
[Compare v0.6.0...v0.7.0](https://github.com/dry-rb/dry-container/compare/v0.6.0...v0.7.0)
|
|
126
|
+
|
|
127
|
+
## 0.6.0 2016-12-09
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
### Added
|
|
131
|
+
|
|
132
|
+
- `Dry::Container::Mixin#each` - provides a means of seeing what all is registered in the container ([jeremyf](https://github.com/jeremyf))
|
|
133
|
+
|
|
134
|
+
### Fixed
|
|
135
|
+
|
|
136
|
+
- Including mixin into a class with a custom initializer ([maltoe](https://github.com/maltoe))
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
[Compare v0.5.0...v0.6.0](https://github.com/dry-rb/dry-container/compare/v0.5.0...v0.6.0)
|
|
140
|
+
|
|
141
|
+
## 0.5.0 2016-08-31
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
### Added
|
|
145
|
+
|
|
146
|
+
- `memoize` option to `#register` - memoizes items on first resolve ([ivoanjo](https://github.com/ivoanjo))
|
|
147
|
+
|
|
148
|
+
### Fixed
|
|
149
|
+
|
|
150
|
+
- `required_ruby_version` set to `>= 2.0.0` ([artofhuman](https://github.com/artofhuman))
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015-2022 dry-rb team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<!--- this file is synced from dry-rb/template-gem project -->
|
|
2
|
+
[gem]: https://rubygems.org/gems/dry-container
|
|
3
|
+
[actions]: https://github.com/dry-rb/dry-container/actions
|
|
4
|
+
[codacy]: https://www.codacy.com/gh/dry-rb/dry-container
|
|
5
|
+
[chat]: https://dry-rb.zulipchat.com
|
|
6
|
+
[inchpages]: http://inch-ci.org/github/dry-rb/dry-container
|
|
7
|
+
|
|
8
|
+
# dry-container [][chat]
|
|
9
|
+
|
|
10
|
+
[][gem]
|
|
11
|
+
[][actions]
|
|
12
|
+
[][codacy]
|
|
13
|
+
[][codacy]
|
|
14
|
+
[][inchpages]
|
|
15
|
+
|
|
16
|
+
## Links
|
|
17
|
+
|
|
18
|
+
* [User documentation](https://dry-rb.org/gems/dry-container)
|
|
19
|
+
* [API documentation](http://rubydoc.info/gems/dry-container)
|
|
20
|
+
|
|
21
|
+
## Supported Ruby versions
|
|
22
|
+
|
|
23
|
+
This library officially supports the following Ruby versions:
|
|
24
|
+
|
|
25
|
+
* MRI `>= 2.7.0`
|
|
26
|
+
* jruby `>= 9.3` (postponed until 2.7 is supported)
|
|
27
|
+
|
|
28
|
+
## License
|
|
29
|
+
|
|
30
|
+
See `LICENSE` file.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# this file is synced from dry-rb/template-gem project
|
|
4
|
+
|
|
5
|
+
lib = File.expand_path("lib", __dir__)
|
|
6
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
7
|
+
require "dry/container/version"
|
|
8
|
+
|
|
9
|
+
Gem::Specification.new do |spec|
|
|
10
|
+
spec.name = "dry-container"
|
|
11
|
+
spec.authors = ["Andy Holland"]
|
|
12
|
+
spec.email = ["andyholland1991@aol.com"]
|
|
13
|
+
spec.license = "MIT"
|
|
14
|
+
spec.version = Dry::Container::VERSION.dup
|
|
15
|
+
|
|
16
|
+
spec.summary = "A simple, configurable object container implemented in Ruby"
|
|
17
|
+
spec.description = spec.summary
|
|
18
|
+
spec.homepage = "https://dry-rb.org/gems/dry-container"
|
|
19
|
+
spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-container.gemspec", "lib/**/*"]
|
|
20
|
+
spec.bindir = "bin"
|
|
21
|
+
spec.executables = []
|
|
22
|
+
spec.require_paths = ["lib"]
|
|
23
|
+
|
|
24
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
|
25
|
+
spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-container/blob/master/CHANGELOG.md"
|
|
26
|
+
spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-container"
|
|
27
|
+
spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-container/issues"
|
|
28
|
+
|
|
29
|
+
spec.required_ruby_version = ">= 2.7.0"
|
|
30
|
+
|
|
31
|
+
# to update dependencies edit project.yml
|
|
32
|
+
spec.add_runtime_dependency "concurrent-ruby", "~> 1.0"
|
|
33
|
+
|
|
34
|
+
spec.add_development_dependency "bundler"
|
|
35
|
+
spec.add_development_dependency "rake"
|
|
36
|
+
spec.add_development_dependency "rspec"
|
|
37
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dry
|
|
4
|
+
class Container
|
|
5
|
+
# @api public
|
|
6
|
+
Error = Class.new(StandardError)
|
|
7
|
+
|
|
8
|
+
KeyError = Class.new(::KeyError)
|
|
9
|
+
if defined?(DidYouMean::KeyErrorChecker)
|
|
10
|
+
DidYouMean.correct_error(KeyError, DidYouMean::KeyErrorChecker)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
deprecate_constant(:Error)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "dry/container/item"
|
|
4
|
+
|
|
5
|
+
module Dry
|
|
6
|
+
class Container
|
|
7
|
+
class Item
|
|
8
|
+
# Callable class to returns a item call
|
|
9
|
+
#
|
|
10
|
+
# @api public
|
|
11
|
+
#
|
|
12
|
+
class Callable < Item
|
|
13
|
+
# Returns the result of item call or item
|
|
14
|
+
#
|
|
15
|
+
# @return [Mixed]
|
|
16
|
+
def call
|
|
17
|
+
callable? ? item.call : item
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "dry/container/item/memoizable"
|
|
4
|
+
require "dry/container/item/callable"
|
|
5
|
+
|
|
6
|
+
module Dry
|
|
7
|
+
class Container
|
|
8
|
+
class Item
|
|
9
|
+
# Factory for create an Item to register inside of container
|
|
10
|
+
#
|
|
11
|
+
# @api public
|
|
12
|
+
class Factory
|
|
13
|
+
# Creates an Item Memoizable or Callable
|
|
14
|
+
# @param [Mixed] item
|
|
15
|
+
# @param [Hash] options
|
|
16
|
+
#
|
|
17
|
+
# @raise [Dry::Container::Error]
|
|
18
|
+
#
|
|
19
|
+
# @return [Dry::Container::Item::Base]
|
|
20
|
+
def call(item, options = {})
|
|
21
|
+
options[:memoize] ? Memoizable.new(item, options) : Callable.new(item, options)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "dry/container/item"
|
|
4
|
+
|
|
5
|
+
module Dry
|
|
6
|
+
class Container
|
|
7
|
+
class Item
|
|
8
|
+
# Memoizable class to store and execute item calls
|
|
9
|
+
#
|
|
10
|
+
# @api public
|
|
11
|
+
#
|
|
12
|
+
class Memoizable < Item
|
|
13
|
+
# @return [Mutex] the stored mutex
|
|
14
|
+
attr_reader :memoize_mutex
|
|
15
|
+
|
|
16
|
+
# Returns a new Memoizable instance
|
|
17
|
+
#
|
|
18
|
+
# @param [Mixed] item
|
|
19
|
+
# @param [Hash] options
|
|
20
|
+
#
|
|
21
|
+
# @raise [Dry::Container::Error]
|
|
22
|
+
#
|
|
23
|
+
# @return [Dry::Container::Item::Base]
|
|
24
|
+
def initialize(item, options = {})
|
|
25
|
+
super
|
|
26
|
+
raise_not_supported_error unless callable?
|
|
27
|
+
|
|
28
|
+
@memoize_mutex = ::Mutex.new
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Returns the result of item call using a syncronized mutex
|
|
32
|
+
#
|
|
33
|
+
# @return [Dry::Container::Item::Base]
|
|
34
|
+
def call
|
|
35
|
+
memoize_mutex.synchronize do
|
|
36
|
+
@memoized_item ||= item.call
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
# @private
|
|
43
|
+
def raise_not_supported_error
|
|
44
|
+
raise ::Dry::Container::Error, "Memoize only supported for a block or a proc"
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Dry
|
|
4
|
+
class Container
|
|
5
|
+
# Base class to abstract Memoizable and Callable implementations
|
|
6
|
+
#
|
|
7
|
+
# @api abstract
|
|
8
|
+
#
|
|
9
|
+
class Item
|
|
10
|
+
# @return [Mixed] the item to be solved later
|
|
11
|
+
attr_reader :item
|
|
12
|
+
|
|
13
|
+
# @return [Hash] the options to memoize, call or no.
|
|
14
|
+
attr_reader :options
|
|
15
|
+
|
|
16
|
+
# @api abstract
|
|
17
|
+
def initialize(item, options = {})
|
|
18
|
+
@item = item
|
|
19
|
+
@options = {
|
|
20
|
+
call: item.is_a?(::Proc) && item.parameters.empty?
|
|
21
|
+
}.merge(options)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# @api abstract
|
|
25
|
+
def call
|
|
26
|
+
raise NotImplementedError
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# @private
|
|
30
|
+
def value?
|
|
31
|
+
!callable?
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# @private
|
|
35
|
+
def callable?
|
|
36
|
+
options[:call]
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Build a new item with transformation applied
|
|
40
|
+
#
|
|
41
|
+
# @private
|
|
42
|
+
def map(func)
|
|
43
|
+
if callable?
|
|
44
|
+
self.class.new(-> { func.(item.call) }, options)
|
|
45
|
+
else
|
|
46
|
+
self.class.new(func.(item), options)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|