containable 0.3.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: e0196e80ae25f490ddef02425b0c6b6653a00919ded08f09ca0b296d11198c07
4
- data.tar.gz: c8c754a7040e460342483ac3b5076e98f941f8e4c5a40db74a0a134a6871adb3
3
+ metadata.gz: 20cb1da4c7c47518d39bccbd70943a6de404a97d9987cc7536630dcebad2a2ab
4
+ data.tar.gz: bcd7fa642d1a61bcb4bab8e91253be219ec63ad4bcc1d42fc2c9bad296c6197d
5
5
  SHA512:
6
- metadata.gz: b6097aa38991af6cf7c30da1854043a62902a4ba64d29ad06a1801644b9a9a37d450d180f62afc930c4d26d277f327552e2de910138bec36ab97663f82ed66b4
7
- data.tar.gz: 29d0f74c94018358c72156ef2a02479652cc844cb9abbafb68fa6f46abf855c0c8876c7af2e411674c26680d2377c9b588e66a138d011c6459b124e62f432fe6
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.3.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.3.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-07-08 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.14
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
@@ -1,4 +1,2 @@
1
- v+S5V���W5���q
2
- wRK��P�����o�����K>���8
3
- Wu�M)��͍ʋQh� e�h"؋��������`?�i��_v��q[Ch�wn���<�6�7�A������
4
- *�x�ih(JsV�[����e��lx sێn�e]�q��ێ��
1
+ �q| (�<C7��v�gB�hlK��9?�_H#/�8|�]gs�#c�N
2
+ 5y��-DG�w�@Jx7��) ʱs��mL��[q��8��>|h�{(���`�fbgL���;����OK�y�%R�cn�Jһ��UkI�7f�#k*�Qs�ʒ�2��������y��TJ�E][�i�@��_�L ~�-$ p�|fh9��Pޚ��RT��/�@B0��?�@�g "��aՋ,G˦�� RI�B�{�r����3~��$V�"��}���t��Wa@��'o��d��W �3?��q`�_�X�"�P�����4���� B�����6;>.L՘� ʈ}3�!�&�?`̧b׬����y��