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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b1e298c787a7b1af3ec410a5a32d51ec1216746399332cbffc9d9001c83a6b47
4
- data.tar.gz: b6f38a2cd98b8f5a4ee4b9878d24757caa79ce5bef706504123a77b69526af80
3
+ metadata.gz: 20cb1da4c7c47518d39bccbd70943a6de404a97d9987cc7536630dcebad2a2ab
4
+ data.tar.gz: bcd7fa642d1a61bcb4bab8e91253be219ec63ad4bcc1d42fc2c9bad296c6197d
5
5
  SHA512:
6
- metadata.gz: a9d282dd36d6062d4b38704170c0867148e86928f5d11a9c636ce6d703d4f9edc0ece5423a460659affc7e3958cfd2e00064563a9d45a10e51a2915dff4f97de
7
- data.tar.gz: 5dc4a5db810937e870d6749893626593908f58fe0eba64b60edc8a17c436a7ccb736e7a59b310ff5a8a870132a63bccb2544c840941ee0e12caf47d325b4f280
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 the perfect construct for this.
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 circmstances -- be used in production code because it is meant for testing purposes only.
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "containable"
5
- spec.version = "0.2.0"
5
+ spec.version = "0.4.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://alchemists.io/projects/containable"
data/lib/containable.rb CHANGED
@@ -18,4 +18,6 @@ module Containable
18
18
  extend Test
19
19
  stub(**)
20
20
  end
21
+
22
+ def restore = false
21
23
  end
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.2.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-05-31 00:00:00.000000000 Z
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.11
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