containable 0.2.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.adoc +15 -2
- data/containable.gemspec +1 -1
- data/lib/containable.rb +2 -0
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20cb1da4c7c47518d39bccbd70943a6de404a97d9987cc7536630dcebad2a2ab
|
4
|
+
data.tar.gz: bcd7fa642d1a61bcb4bab8e91253be219ec63ad4bcc1d42fc2c9bad296c6197d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99044bb884dd733e8bb878490e7c4281b2b9cd9bba4d49eab8e2cabf970672f476b4ae9170eb779b6a64019c9916b39a5c2aa4fde2c138e69e585103fd987fdf
|
7
|
+
data.tar.gz: 803562859a58d4215b19cec5b67beaf3b02ef7983702a51e03001aec0af254c44c0c67224aaa328a84ee2fb035a5b252a7a28b57fa37c003acb2fa21cf816edd
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.adoc
CHANGED
@@ -93,7 +93,7 @@ end
|
|
93
93
|
# Only a module can be a container. (TypeError)
|
94
94
|
----
|
95
95
|
|
96
|
-
This is important since containers are only meant to hold your dependencies and nothing else. Modules are
|
96
|
+
This is important since containers are only meant to hold your dependencies and nothing else. Modules are perfect for this.
|
97
97
|
|
98
98
|
=== Registration
|
99
99
|
|
@@ -175,6 +175,19 @@ Container[:three] = 3
|
|
175
175
|
|
176
176
|
With the above, a combination of `.register` and `.[]=` (setter) messages are used. While the latter is handy the former should be preferred for improved readability.
|
177
177
|
|
178
|
+
⚠️ Due to registration being flexible to begin with, avoid nesting closures. Example:
|
179
|
+
|
180
|
+
[source,ruby]
|
181
|
+
----
|
182
|
+
# No
|
183
|
+
register(:sanitizer) { -> content { Sanitize.fragment content, Sanitize::Config::BASIC } }
|
184
|
+
|
185
|
+
# Yes
|
186
|
+
register :sanitizer, -> content { Sanitize.fragment content, Sanitize::Config::BASIC }
|
187
|
+
----
|
188
|
+
|
189
|
+
While the former will work, there is no benefit to nesting like this. The latter is more performant because you don't have to unwrap the nested closure to achieve the same functionality since there is nothing to achieve from the lazy resolution of the sanitize functionality.
|
190
|
+
|
178
191
|
=== Resolution
|
179
192
|
|
180
193
|
Now that you understand how to register dependencies, we can talk about resolving them. There are two ways to resolve a dependency. Example:
|
@@ -504,7 +517,7 @@ You'll notice, in all of the examples, only two methods are used: `.stub!` and `
|
|
504
517
|
|
505
518
|
_Always_ use `.stub!` to set your container up for testing. Once setup, you can add more stubs by using the `.stub` method (without the bang). So, to recap, use `.stub!` as a one-liner for setup and initial stubs then use `.stub` to add more stubs after the fact. Finally, ensure you restore (i.e. `.restore`) your container for proper cleanup after each test.
|
506
519
|
|
507
|
-
‼️ Use of `.stub!`, while convenient for testing, should -- under no
|
520
|
+
‼️ Use of `.stub!`, while convenient for testing, should -- under no circumstances -- be used in production code because it is meant for testing purposes only.
|
508
521
|
|
509
522
|
== Development
|
510
523
|
|
data/containable.gemspec
CHANGED
data/lib/containable.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: containable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
3n5C8/6Zh9DYTkpcwPSuIfAga6wf4nXc9m6JAw8AuMLaiWN/r/2s4zJsUHYERJEu
|
36
36
|
gZGm4JqtuSg8pYjPeIJxS960owq+SfuC+jxqmRA54BisFCv/0VOJi7tiJVY=
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2024-
|
38
|
+
date: 2024-07-21 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: concurrent-ruby
|
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: '0'
|
96
96
|
requirements: []
|
97
|
-
rubygems_version: 3.5.
|
97
|
+
rubygems_version: 3.5.16
|
98
98
|
signing_key:
|
99
99
|
specification_version: 4
|
100
100
|
summary: A thread-safe dependency injection container.
|
metadata.gz.sig
CHANGED
Binary file
|