inoculate 0.0.0 → 0.2.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 +11 -2
- data/README.md +153 -18
- data/inoculate.gemspec +2 -8
- data/lib/inoculate/configurer.rb +24 -0
- data/lib/inoculate/errors.rb +33 -0
- data/lib/inoculate/initialization.rb +32 -0
- data/lib/inoculate/manufacturer.rb +82 -0
- data/lib/inoculate/porter.rb +64 -0
- data/lib/inoculate/providers.rb +9 -0
- data/lib/inoculate/version.rb +2 -1
- data/lib/inoculate.rb +6 -5
- data/sig/inoculate.rbs +53 -1
- metadata +9 -13
- data/.idea/.gitignore +0 -8
- data/.idea/inspectionProfiles/Project_Default.xml +0 -8
- data/.idea/misc.xml +0 -6
- data/.idea/modules.xml +0 -8
- data/.idea/vcs.xml +0 -6
- data/.rspec +0 -3
- data/.standard.yml +0 -3
- data/Gemfile +0 -11
- data/Gemfile.lock +0 -67
- data/Rakefile +0 -16
- data/inoculate.iml +0 -75
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e63449f9ee05019e70acf85faafd0f2adf6554704f560de31b66b12c01e54aeb
|
4
|
+
data.tar.gz: e6975710a5802d37bd4b84de1345dbd10a10a5cf8538096cd8ffea8459997af9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95e7e8d09278118af12987096c2919419a66b6ea298d6556a3e7df113403e0fa4edd363a1d19172eef8d4739ffdf10b4e8180b19151cdd19361d3c2ccd861200
|
7
|
+
data.tar.gz: 9dd927feda03995336037f58b86e9c97be8e2bf83f4ac8a101ee67b10e0d40106bdf0f62a138ef046135ef24f759074c289ef61153c8044d02db08b63e4b20be
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
-
## v0.
|
1
|
+
## v0.2.0 \[2022-10-11]
|
2
2
|
|
3
|
-
*
|
3
|
+
* Build modules at initialization time so that usage is always thread-safe.
|
4
|
+
|
5
|
+
## v0.1.0 \[2022-10-10]
|
6
|
+
|
7
|
+
* Add transient dependency registration.
|
8
|
+
* Add initialization process for gem.
|
9
|
+
|
10
|
+
## v0.0.0 \[2022-10-05]
|
11
|
+
|
12
|
+
* Initial gem setup.
|
data/README.md
CHANGED
@@ -3,45 +3,180 @@
|
|
3
3
|
Inoculate is a small, thread-safe dependency injection library configured entirely with Ruby.
|
4
4
|
It provides several life-cycles and provides dependency access through private accessors.
|
5
5
|
|
6
|
-
|
6
|
+
[![Gem Version](https://badge.fury.io/rb/inoculate.svg)](https://badge.fury.io/rb/inoculate)
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
## What's in the box?
|
11
|
+
✅ Simple usage documentation written to get started fast. [Check it out!](#quick-start)
|
12
|
+
|
13
|
+
📚 YARD generated API documentation for the library. [Check it out!](https://tinychameleon.github.io/inoculate/)
|
14
|
+
|
15
|
+
🤖 RBS types for your type checking wants. [Check it out!](./sig/inoculate.rbs)
|
16
|
+
|
17
|
+
💎 Tests against many Ruby versions. [Check it out!](#supported-ruby-versions)
|
18
|
+
|
19
|
+
🔒 MFA protection on all gem owners. [Check it out!](https://rubygems.org/gems/inoculate)
|
20
|
+
|
21
|
+
---
|
22
|
+
|
23
|
+
1. [Quick Start](#quick-start)
|
24
|
+
2. [Usage](#usage)
|
25
|
+
1. [Dependency Life Cycles](#dependency-life-cycles)
|
26
|
+
1. [Transient](#transient)
|
27
|
+
2. [Renaming the Declaration API](#renaming-the-declaration-api)
|
28
|
+
3. [Hide Your Dependency on Inoculate](#hide-your-dependency-on-inoculate)
|
29
|
+
3. [Installation](#installation)
|
30
|
+
1. [Supported Ruby Versions](#supported-ruby-versions)
|
31
|
+
|
32
|
+
## Quick Start
|
33
|
+
Create an initialization file for your dependencies and start registering them.
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
require "inoculate"
|
7
37
|
|
8
|
-
|
38
|
+
Inoculate.initialize do |config|
|
39
|
+
config.transient(:counter) { Counter.new }
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
To take advantage of dependency injection in tests, initialize based on the run-time environment.
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
# config/environments/test.rb
|
47
|
+
require "inoculate"
|
48
|
+
|
49
|
+
Inoculate.initialize do |config|
|
50
|
+
config.transient(:counter) { instance_double(Counter) }
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
54
|
+
Finally, declare your dependencies (which are injected as included modules).
|
9
55
|
|
10
56
|
```ruby
|
11
|
-
|
57
|
+
require "inoculate"
|
58
|
+
|
59
|
+
class HistogramGraph
|
60
|
+
include Inoculate::Porter
|
61
|
+
inoculate_with :counter
|
62
|
+
|
63
|
+
def to_s
|
64
|
+
counter.to_s
|
65
|
+
end
|
66
|
+
end
|
12
67
|
```
|
13
68
|
|
14
|
-
|
69
|
+
## Usage
|
15
70
|
|
16
|
-
|
71
|
+
### Dependency Life Cycles
|
72
|
+
#### Transient
|
73
|
+
Transient dependencies are constructed for each call of the dependency method.
|
17
74
|
|
18
|
-
|
75
|
+
```ruby
|
76
|
+
class Counter
|
77
|
+
attr_reader :count
|
78
|
+
|
79
|
+
def initialize
|
80
|
+
@count = 0
|
81
|
+
end
|
82
|
+
|
83
|
+
def inc
|
84
|
+
@count += 1
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
Inoculate.initialize do |config|
|
89
|
+
config.transient(:counter) { Counter.new }
|
90
|
+
end
|
91
|
+
|
92
|
+
class Example
|
93
|
+
include Inoculate::Porter
|
94
|
+
inoculate_with :counter
|
95
|
+
|
96
|
+
def to_s
|
97
|
+
counter.inc
|
98
|
+
"Count is: #{counter.count}"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
puts Example.new
|
103
|
+
```
|
19
104
|
|
20
|
-
|
105
|
+
This results in:
|
21
106
|
|
22
|
-
|
107
|
+
```
|
108
|
+
Count is: 0
|
109
|
+
=> nil
|
110
|
+
```
|
23
111
|
|
112
|
+
### Renaming the Declaration API
|
113
|
+
The `inoculate_with` API is named to avoid immediate collisions with other modules
|
114
|
+
and code you may have. You can use it as-is, or rename it to something you see fit
|
115
|
+
for your project.
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
require "inoculate"
|
119
|
+
|
120
|
+
class HistogramGraph
|
121
|
+
include Inoculate::Porter[:inject]
|
122
|
+
inject :counter
|
123
|
+
end
|
124
|
+
```
|
125
|
+
|
126
|
+
### Hide Your Dependency on Inoculate
|
127
|
+
Writing `Inocuate::Porter` everywhere in your code is probably going to get old fast,
|
128
|
+
feel free to hide it behind a base class or common included module.
|
129
|
+
|
130
|
+
```ruby
|
131
|
+
# Make it available to all Rails controllers.
|
132
|
+
class ApplicationController < ActionController::Base
|
133
|
+
include Inoculate::Porter[:dependencies]
|
134
|
+
end
|
135
|
+
```
|
136
|
+
|
137
|
+
## Installation
|
138
|
+
Inoculate is a pure ruby library and does not rely on any compiled dependencies.
|
139
|
+
|
140
|
+
Install it by adding it to your gemfile and then running `bundle install`
|
141
|
+
|
142
|
+
```ruby
|
143
|
+
gem "inoculate"
|
144
|
+
```
|
145
|
+
|
146
|
+
Or manually install it with `gem`
|
147
|
+
|
148
|
+
```shell
|
149
|
+
$ gem install inoculate
|
150
|
+
```
|
151
|
+
|
152
|
+
### Supported Ruby Versions
|
24
153
|
Inoculate is tested against the following Ruby versions:
|
25
154
|
|
26
|
-
- 2.7
|
27
|
-
- 3.0
|
28
|
-
- 3.1
|
155
|
+
- 2.7
|
156
|
+
- 3.0
|
157
|
+
- 3.1
|
29
158
|
- 3.2-rc
|
30
159
|
|
31
|
-
##
|
160
|
+
## Development
|
161
|
+
After checking out the repo:
|
32
162
|
|
33
|
-
|
163
|
+
1. run `bin/setup` to install dependencies.
|
164
|
+
2. run `rake spec` to run the tests.
|
165
|
+
3. run `rake spec:all` to run the tests across supported Ruby versions using Docker.
|
166
|
+
4. run `rake standard` to see lint errors.
|
34
167
|
|
35
|
-
|
168
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
36
169
|
|
37
|
-
|
170
|
+
### Local Installation
|
171
|
+
Run `bundle exec rake install` or `bundle exec rake install:local`.
|
38
172
|
|
39
|
-
|
173
|
+
### Releasing
|
174
|
+
1. Update the version number in `lib/inoculate/version.rb`.
|
175
|
+
2. Run `bundle exec rake yard` to generate the latest documentation.
|
176
|
+
3. Run `bundle exec rake release` to create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
40
177
|
|
41
178
|
## Contributing
|
42
|
-
|
43
179
|
Bug reports and pull requests are welcome on GitHub at https://github.com/tinychameleon/inoculate.
|
44
180
|
|
45
181
|
## License
|
46
|
-
|
47
182
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/inoculate.gemspec
CHANGED
@@ -21,15 +21,9 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.metadata["source_code_uri"] = "https://github.com/tinychameleon/inoculate"
|
22
22
|
spec.metadata["bug_tracker_uri"] = "https://github.com/tinychameleon/inoculate/issues"
|
23
23
|
spec.metadata["changelog_uri"] = "https://github.com/tinychameleon/inoculate/blob/main/CHANGELOG.md"
|
24
|
-
|
24
|
+
spec.metadata["documentation_uri"] = "https://tinychameleon.github.io/inoculate"
|
25
25
|
|
26
|
-
|
27
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
|
-
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
29
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
30
|
-
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
31
|
-
end
|
32
|
-
end
|
26
|
+
spec.files = Dir["lib/**/*.rb", "sig/**/*.rbs", "inoculate.gemspec", "CHANGELOG.md", "README.md", "LICENSE.txt"]
|
33
27
|
spec.bindir = "exe"
|
34
28
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
35
29
|
spec.require_paths = ["lib"]
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Inoculate
|
4
|
+
# Configure dependencies through a restricted API during initialization.
|
5
|
+
#
|
6
|
+
# @since 0.1.0
|
7
|
+
class Configurer
|
8
|
+
def initialize(manufacturer)
|
9
|
+
@manufacturer = manufacturer
|
10
|
+
end
|
11
|
+
|
12
|
+
# Register a transient dependency.
|
13
|
+
# @see Manufacturer#transient
|
14
|
+
#
|
15
|
+
# @since 0.1.0
|
16
|
+
def transient(name, builder = nil, &block)
|
17
|
+
manufacturer.transient(name, builder, &block)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
attr_reader :manufacturer
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Inoculate
|
4
|
+
# A namespace for error types.
|
5
|
+
#
|
6
|
+
# @since 0.1.0
|
7
|
+
module Errors
|
8
|
+
# Base type for all Inoculate errors.
|
9
|
+
#
|
10
|
+
# @since 0.1.0
|
11
|
+
class Error < StandardError; end
|
12
|
+
|
13
|
+
# Raised when the user attempts to register a dependency with a name that can't be converted to a symbol.
|
14
|
+
#
|
15
|
+
# @since 0.1.0
|
16
|
+
class InvalidName < Error; end
|
17
|
+
|
18
|
+
# Raised when the user attempts to register a name again.
|
19
|
+
#
|
20
|
+
# @since 0.1.0
|
21
|
+
class AlreadyRegistered < Error; end
|
22
|
+
|
23
|
+
# Raised when the user attempts to depend on an unknown dependency.
|
24
|
+
#
|
25
|
+
# @since 0.1.0
|
26
|
+
class UnknownName < Error; end
|
27
|
+
|
28
|
+
# Raised when the user attempts to register a dependency with a builder that can't be called.
|
29
|
+
#
|
30
|
+
# @since 0.1.0
|
31
|
+
class RequiresCallable < Error; end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Inoculate is a small, thread-safe dependency injection library configured entirely with Ruby.
|
4
|
+
# It provides several life-cycles and provides dependency access through private accessors.
|
5
|
+
#
|
6
|
+
# @since 0.1.0
|
7
|
+
module Inoculate
|
8
|
+
# The main configuration entrypoint for Inoculate. Use this to set up named dependencies.
|
9
|
+
#
|
10
|
+
# @example A simple dependency configuration
|
11
|
+
# Inoculate.initialize do |config|
|
12
|
+
# config.transient(:http) { Faraday }
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# @example An environment-based dynamic dependency configuration
|
16
|
+
# Inoculate.initialize do |config|
|
17
|
+
# http_service = ENV["test"] ? -> { class_double(Faraday) } : -> { Faraday }
|
18
|
+
# config.transient(:http, http_service)
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
# @yieldparam config [Configurer] a configuration object to register dependencies
|
22
|
+
#
|
23
|
+
# @since 0.1.0
|
24
|
+
def self.initialize
|
25
|
+
yield Configurer.new(manufacturer)
|
26
|
+
end
|
27
|
+
|
28
|
+
# @!visibility private
|
29
|
+
def self.manufacturer
|
30
|
+
@manufacturer ||= Manufacturer.new
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "digest"
|
4
|
+
|
5
|
+
module Inoculate
|
6
|
+
# Registers and builds dependency injection modules.
|
7
|
+
# @todo singleton life cycle
|
8
|
+
# @todo instance life cycle
|
9
|
+
# @todo thread singleton life cycle
|
10
|
+
#
|
11
|
+
# @since 0.1.0
|
12
|
+
class Manufacturer
|
13
|
+
# The set of registered blueprints for dependency injection modules.
|
14
|
+
# @return [Hash<Symbol, Hash>]
|
15
|
+
#
|
16
|
+
# @since 0.1.0
|
17
|
+
attr_reader :registered_blueprints
|
18
|
+
|
19
|
+
def initialize
|
20
|
+
@registered_blueprints = {}
|
21
|
+
end
|
22
|
+
|
23
|
+
# Register a transient dependency.
|
24
|
+
#
|
25
|
+
# A transient dependency gets created anew every time it is retrieved through the accessor.
|
26
|
+
#
|
27
|
+
# @example With a block
|
28
|
+
# manufacturer.transient(:sha1_hasher) { Digest::SHA1.new }
|
29
|
+
#
|
30
|
+
# @example With a Proc
|
31
|
+
# manufacturer.transient(:sha1_hasher, -> { Digest::SHA1.new })
|
32
|
+
#
|
33
|
+
# @example With anything Callable
|
34
|
+
# class HashingBuilder
|
35
|
+
# def call = Digest::SHA1.new
|
36
|
+
# end
|
37
|
+
# manufacturer.transient(:sha1_hasher, HashingBuilder.new)
|
38
|
+
#
|
39
|
+
# @param name [Symbol, #to_sym] the dependency name which will be used to access it
|
40
|
+
# @param builder [#call] the callable to build the dependency
|
41
|
+
# @param block [Proc, nil] an alternative builder callable
|
42
|
+
#
|
43
|
+
# @raise [Errors::RequiresCallable] if no builder or block is provided
|
44
|
+
# @raise [Errors::InvalidName] if the name is not a symbol, cannot be converted to a symbol,
|
45
|
+
# or is not a valid attribute name
|
46
|
+
# @raise [Errors::AlreadyRegistered] if the name has been registered previously
|
47
|
+
#
|
48
|
+
# @since 0.1.0
|
49
|
+
def transient(name, builder = nil, &block)
|
50
|
+
validate_builder_name name
|
51
|
+
raise Errors::AlreadyRegistered if @registered_blueprints.has_key? name
|
52
|
+
raise Errors::RequiresCallable unless builder.respond_to?(:call) || block
|
53
|
+
|
54
|
+
blueprint_name = name.to_sym
|
55
|
+
@registered_blueprints[blueprint_name] = {
|
56
|
+
lifecycle: :transient,
|
57
|
+
builder: builder || block,
|
58
|
+
accessor_module: build_module(blueprint_name, :transient, builder || block)
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def build_module(name, lifecycle, builder)
|
65
|
+
module_name = "I#{Digest::SHA1.hexdigest(name.to_s)}"
|
66
|
+
Providers.module_eval do
|
67
|
+
const_set(module_name, Module.new do
|
68
|
+
private define_method(name) { builder.call }
|
69
|
+
end)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def validate_builder_name(name)
|
74
|
+
raise Errors::InvalidName, "name must be a symbol or convert to one" unless name.respond_to? :to_sym
|
75
|
+
begin
|
76
|
+
Module.new { attr_reader name }
|
77
|
+
rescue NameError
|
78
|
+
raise Errors::InvalidName, "name must be a valid attr_reader"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Inoculate
|
4
|
+
# Delivers requested dependencies to user classes.
|
5
|
+
#
|
6
|
+
# The default method +inoculate_with+ is named to avoid collisions with other
|
7
|
+
# libraries. You can alias it to something that makes your codebase legible.
|
8
|
+
#
|
9
|
+
# @example Getting Dependencies
|
10
|
+
# class HealthChecker
|
11
|
+
# include Inoculate::Porter
|
12
|
+
# inoculate_with :http_service
|
13
|
+
#
|
14
|
+
# def healthy?
|
15
|
+
# http_service.get("/health").ok?
|
16
|
+
# end
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# @example With Aliasing Include
|
20
|
+
# class Base
|
21
|
+
# include Inoculate::Porter[:depend_on]
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# class Child < Base
|
25
|
+
# depend_on :http_service
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# @since 0.1.0
|
29
|
+
module Porter
|
30
|
+
# Create a dependency injection module with your chosen method name.
|
31
|
+
#
|
32
|
+
# @param method_name [Symbol] the dependency injection method name
|
33
|
+
# @return [Module] a dependency injection module for inclusion in classes.
|
34
|
+
#
|
35
|
+
# @since 0.1.0
|
36
|
+
def self.[](method_name)
|
37
|
+
m = Module.new do
|
38
|
+
define_method(method_name) do |*names|
|
39
|
+
names.each do |name|
|
40
|
+
mod = Inoculate.manufacturer.registered_blueprints.dig(name, :accessor_module)
|
41
|
+
raise Errors::UnknownName if mod.nil?
|
42
|
+
|
43
|
+
include(mod)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
inclusion = Module.new
|
49
|
+
inclusion.singleton_class.define_method(:included) do |base|
|
50
|
+
base.extend m
|
51
|
+
end
|
52
|
+
inclusion
|
53
|
+
end
|
54
|
+
|
55
|
+
# Including this module makes the default +inoculate_with+ method available.
|
56
|
+
#
|
57
|
+
# @param base [Class] the class this module is included within
|
58
|
+
#
|
59
|
+
# @since 0.1.0
|
60
|
+
def self.included(base)
|
61
|
+
base.include self[:inoculate_with]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/inoculate/version.rb
CHANGED
data/lib/inoculate.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "inoculate/version"
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
require_relative "inoculate/errors"
|
5
|
+
require_relative "inoculate/providers"
|
6
|
+
require_relative "inoculate/manufacturer"
|
7
|
+
require_relative "inoculate/porter"
|
8
|
+
require_relative "inoculate/configurer"
|
9
|
+
require_relative "inoculate/initialization"
|
data/sig/inoculate.rbs
CHANGED
@@ -1,4 +1,56 @@
|
|
1
1
|
module Inoculate
|
2
2
|
VERSION: String
|
3
|
-
|
3
|
+
|
4
|
+
interface _ToSymbol
|
5
|
+
def to_sym: () -> Symbol
|
6
|
+
end
|
7
|
+
|
8
|
+
type callable = ^() -> untyped
|
9
|
+
type lifecycle_name = :transient
|
10
|
+
type builder_name = Symbol
|
11
|
+
type blueprint = { lifecycle: lifecycle_name, builder: callable, accessor_module: Module? }
|
12
|
+
|
13
|
+
module Errors
|
14
|
+
class Error < StandardError
|
15
|
+
end
|
16
|
+
|
17
|
+
class InvalidName < Error
|
18
|
+
end
|
19
|
+
|
20
|
+
class AlreadyRegistered < Error
|
21
|
+
end
|
22
|
+
|
23
|
+
class UnknownName < Error
|
24
|
+
end
|
25
|
+
|
26
|
+
class RequiresCallable < Error
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
module Providers
|
31
|
+
end
|
32
|
+
|
33
|
+
class Manufacturer
|
34
|
+
attr_reader registered_blueprints: Hash[builder_name, blueprint]
|
35
|
+
def transient: (builder_name | _ToSymbol, callable?) ?{ () -> void } -> void
|
36
|
+
end
|
37
|
+
|
38
|
+
class Configurer
|
39
|
+
def initialize: (Manufacturer) -> void
|
40
|
+
|
41
|
+
def transient: (builder_name | _ToSymbol, callable?) -> void
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
attr_reader manufacturer: Manufacturer
|
46
|
+
end
|
47
|
+
|
48
|
+
module Porter
|
49
|
+
def self.[]: (Symbol) -> Module
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.initialize: () { (Configurer) -> void } -> void
|
53
|
+
|
54
|
+
# "Private"
|
55
|
+
def self.manufacturer: () -> Manufacturer
|
4
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inoculate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephan Tarulli
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
Inoculate is a small, thread-safe dependency injection library configured entirely with Ruby.
|
@@ -19,22 +19,17 @@ executables: []
|
|
19
19
|
extensions: []
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
|
-
- ".idea/.gitignore"
|
23
|
-
- ".idea/inspectionProfiles/Project_Default.xml"
|
24
|
-
- ".idea/misc.xml"
|
25
|
-
- ".idea/modules.xml"
|
26
|
-
- ".idea/vcs.xml"
|
27
|
-
- ".rspec"
|
28
|
-
- ".standard.yml"
|
29
22
|
- CHANGELOG.md
|
30
|
-
- Gemfile
|
31
|
-
- Gemfile.lock
|
32
23
|
- LICENSE.txt
|
33
24
|
- README.md
|
34
|
-
- Rakefile
|
35
25
|
- inoculate.gemspec
|
36
|
-
- inoculate.iml
|
37
26
|
- lib/inoculate.rb
|
27
|
+
- lib/inoculate/configurer.rb
|
28
|
+
- lib/inoculate/errors.rb
|
29
|
+
- lib/inoculate/initialization.rb
|
30
|
+
- lib/inoculate/manufacturer.rb
|
31
|
+
- lib/inoculate/porter.rb
|
32
|
+
- lib/inoculate/providers.rb
|
38
33
|
- lib/inoculate/version.rb
|
39
34
|
- sig/inoculate.rbs
|
40
35
|
homepage: https://github.com/tinychameleon/inoculate
|
@@ -45,6 +40,7 @@ metadata:
|
|
45
40
|
source_code_uri: https://github.com/tinychameleon/inoculate
|
46
41
|
bug_tracker_uri: https://github.com/tinychameleon/inoculate/issues
|
47
42
|
changelog_uri: https://github.com/tinychameleon/inoculate/blob/main/CHANGELOG.md
|
43
|
+
documentation_uri: https://tinychameleon.github.io/inoculate
|
48
44
|
post_install_message:
|
49
45
|
rdoc_options: []
|
50
46
|
require_paths:
|
data/.idea/.gitignore
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
<component name="InspectionProjectProfileManager">
|
2
|
-
<profile version="1.0">
|
3
|
-
<option name="myName" value="Project Default" />
|
4
|
-
<inspection_tool class="Rubocop" enabled="true" level="WARNING" enabled_by_default="true">
|
5
|
-
<option name="myUseStandardGemIfPossible" value="true" />
|
6
|
-
</inspection_tool>
|
7
|
-
</profile>
|
8
|
-
</component>
|
data/.idea/misc.xml
DELETED
data/.idea/modules.xml
DELETED
data/.idea/vcs.xml
DELETED
data/.rspec
DELETED
data/.standard.yml
DELETED
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
inoculate (0.0.0)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
ast (2.4.2)
|
10
|
-
diff-lcs (1.5.0)
|
11
|
-
json (2.6.2)
|
12
|
-
parallel (1.22.1)
|
13
|
-
parser (3.1.2.1)
|
14
|
-
ast (~> 2.4.1)
|
15
|
-
rainbow (3.1.1)
|
16
|
-
rake (13.0.6)
|
17
|
-
regexp_parser (2.6.0)
|
18
|
-
rexml (3.2.5)
|
19
|
-
rspec (3.11.0)
|
20
|
-
rspec-core (~> 3.11.0)
|
21
|
-
rspec-expectations (~> 3.11.0)
|
22
|
-
rspec-mocks (~> 3.11.0)
|
23
|
-
rspec-core (3.11.0)
|
24
|
-
rspec-support (~> 3.11.0)
|
25
|
-
rspec-expectations (3.11.1)
|
26
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
-
rspec-support (~> 3.11.0)
|
28
|
-
rspec-mocks (3.11.1)
|
29
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
-
rspec-support (~> 3.11.0)
|
31
|
-
rspec-support (3.11.1)
|
32
|
-
rubocop (1.35.1)
|
33
|
-
json (~> 2.3)
|
34
|
-
parallel (~> 1.10)
|
35
|
-
parser (>= 3.1.2.1)
|
36
|
-
rainbow (>= 2.2.2, < 4.0)
|
37
|
-
regexp_parser (>= 1.8, < 3.0)
|
38
|
-
rexml (>= 3.2.5, < 4.0)
|
39
|
-
rubocop-ast (>= 1.20.1, < 2.0)
|
40
|
-
ruby-progressbar (~> 1.7)
|
41
|
-
unicode-display_width (>= 1.4.0, < 3.0)
|
42
|
-
rubocop-ast (1.21.0)
|
43
|
-
parser (>= 3.1.1.0)
|
44
|
-
rubocop-performance (1.14.3)
|
45
|
-
rubocop (>= 1.7.0, < 2.0)
|
46
|
-
rubocop-ast (>= 0.4.0)
|
47
|
-
ruby-progressbar (1.11.0)
|
48
|
-
standard (1.16.1)
|
49
|
-
rubocop (= 1.35.1)
|
50
|
-
rubocop-performance (= 1.14.3)
|
51
|
-
unicode-display_width (2.3.0)
|
52
|
-
webrick (1.7.0)
|
53
|
-
yard (0.9.28)
|
54
|
-
webrick (~> 1.7.0)
|
55
|
-
|
56
|
-
PLATFORMS
|
57
|
-
x86_64-darwin-19
|
58
|
-
|
59
|
-
DEPENDENCIES
|
60
|
-
inoculate!
|
61
|
-
rake (~> 13.0)
|
62
|
-
rspec (~> 3.11)
|
63
|
-
standard (~> 1.16)
|
64
|
-
yard (~> 0.9)
|
65
|
-
|
66
|
-
BUNDLED WITH
|
67
|
-
2.3.7
|
data/Rakefile
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "bundler/gem_tasks"
|
4
|
-
require "rspec/core/rake_task"
|
5
|
-
require "yard"
|
6
|
-
|
7
|
-
RSpec::Core::RakeTask.new(:spec)
|
8
|
-
|
9
|
-
YARD::Rake::YardocTask.new do |t|
|
10
|
-
t.files = %w[lib/**/*.rb - CHANGELOG.md]
|
11
|
-
t.options = %w[--private -o ./docs]
|
12
|
-
end
|
13
|
-
|
14
|
-
require "standard/rake"
|
15
|
-
|
16
|
-
task default: %i[spec standard]
|
data/inoculate.iml
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<module type="RUBY_MODULE" version="4">
|
3
|
-
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
4
|
-
<exclude-output />
|
5
|
-
<content url="file://$MODULE_DIR$">
|
6
|
-
<sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
|
7
|
-
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
8
|
-
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
9
|
-
</content>
|
10
|
-
<orderEntry type="inheritedJdk" />
|
11
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
12
|
-
<orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, rbenv: 3.1.2) [gem]" level="application" />
|
13
|
-
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.3.7, rbenv: 3.1.2) [gem]" level="application" />
|
14
|
-
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.5.0, rbenv: 3.1.2) [gem]" level="application" />
|
15
|
-
<orderEntry type="library" scope="PROVIDED" name="json (v2.6.2, rbenv: 3.1.2) [gem]" level="application" />
|
16
|
-
<orderEntry type="library" scope="PROVIDED" name="parallel (v1.22.1, rbenv: 3.1.2) [gem]" level="application" />
|
17
|
-
<orderEntry type="library" scope="PROVIDED" name="parser (v3.1.2.1, rbenv: 3.1.2) [gem]" level="application" />
|
18
|
-
<orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, rbenv: 3.1.2) [gem]" level="application" />
|
19
|
-
<orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, rbenv: 3.1.2) [gem]" level="application" />
|
20
|
-
<orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.6.0, rbenv: 3.1.2) [gem]" level="application" />
|
21
|
-
<orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, rbenv: 3.1.2) [gem]" level="application" />
|
22
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec (v3.11.0, rbenv: 3.1.2) [gem]" level="application" />
|
23
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.11.0, rbenv: 3.1.2) [gem]" level="application" />
|
24
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.11.1, rbenv: 3.1.2) [gem]" level="application" />
|
25
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.11.1, rbenv: 3.1.2) [gem]" level="application" />
|
26
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.11.1, rbenv: 3.1.2) [gem]" level="application" />
|
27
|
-
<orderEntry type="library" scope="PROVIDED" name="rubocop (v1.35.1, rbenv: 3.1.2) [gem]" level="application" />
|
28
|
-
<orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.21.0, rbenv: 3.1.2) [gem]" level="application" />
|
29
|
-
<orderEntry type="library" scope="PROVIDED" name="rubocop-performance (v1.14.3, rbenv: 3.1.2) [gem]" level="application" />
|
30
|
-
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.11.0, rbenv: 3.1.2) [gem]" level="application" />
|
31
|
-
<orderEntry type="library" scope="PROVIDED" name="standard (v1.16.1, rbenv: 3.1.2) [gem]" level="application" />
|
32
|
-
<orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.3.0, rbenv: 3.1.2) [gem]" level="application" />
|
33
|
-
<orderEntry type="library" scope="PROVIDED" name="webrick (v1.7.0, rbenv: 3.1.2) [gem]" level="application" />
|
34
|
-
<orderEntry type="library" scope="PROVIDED" name="yard (v0.9.28, rbenv: 3.1.2) [gem]" level="application" />
|
35
|
-
</component>
|
36
|
-
<component name="RakeTasksCache">
|
37
|
-
<option name="myRootTask">
|
38
|
-
<RakeTaskImpl id="rake">
|
39
|
-
<subtasks>
|
40
|
-
<RakeTaskImpl description="Build inoculate-0.0.0.gem into the pkg directory" fullCommand="build" id="build" />
|
41
|
-
<RakeTaskImpl id="build">
|
42
|
-
<subtasks>
|
43
|
-
<RakeTaskImpl description="Generate SHA512 checksum if inoculate-0.0.0.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
|
44
|
-
</subtasks>
|
45
|
-
</RakeTaskImpl>
|
46
|
-
<RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
|
47
|
-
<RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
|
48
|
-
<RakeTaskImpl description="Build and install inoculate-0.0.0.gem into system gems" fullCommand="install" id="install" />
|
49
|
-
<RakeTaskImpl id="install">
|
50
|
-
<subtasks>
|
51
|
-
<RakeTaskImpl description="Build and install inoculate-0.0.0.gem into system gems without network access" fullCommand="install:local" id="local" />
|
52
|
-
</subtasks>
|
53
|
-
</RakeTaskImpl>
|
54
|
-
<RakeTaskImpl description="Create tag v0.0.0 and build and push inoculate-0.0.0.gem to rubygems.org" fullCommand="release[remote]" id="release[remote]" />
|
55
|
-
<RakeTaskImpl description="Run RSpec code examples" fullCommand="spec" id="spec" />
|
56
|
-
<RakeTaskImpl description="Lint with the Standard Ruby style guide" fullCommand="standard" id="standard" />
|
57
|
-
<RakeTaskImpl id="standard">
|
58
|
-
<subtasks>
|
59
|
-
<RakeTaskImpl description="Lint and automatically fix with the Standard Ruby style guide" fullCommand="standard:fix" id="fix" />
|
60
|
-
</subtasks>
|
61
|
-
</RakeTaskImpl>
|
62
|
-
<RakeTaskImpl description="" fullCommand="default" id="default" />
|
63
|
-
<RakeTaskImpl description="" fullCommand="release" id="release" />
|
64
|
-
<RakeTaskImpl id="release">
|
65
|
-
<subtasks>
|
66
|
-
<RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
|
67
|
-
<RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
|
68
|
-
<RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
|
69
|
-
</subtasks>
|
70
|
-
</RakeTaskImpl>
|
71
|
-
</subtasks>
|
72
|
-
</RakeTaskImpl>
|
73
|
-
</option>
|
74
|
-
</component>
|
75
|
-
</module>
|