initable 0.0.0 → 0.1.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: 11652b09ebedba190e0b35394028990c76e9102ab9f0a35f16d48af094cfeb74
4
- data.tar.gz: a92c36ccaa4ee2b6ee7cb8598017fb8a10c92769255196bf301df8594b6ec812
3
+ metadata.gz: d077a6ae86ec556acd9cb1bb729502462f1f854a81038ab425b1785cea02953f
4
+ data.tar.gz: 758d05271874c63d0d050126e83b79faf3e84376642c19842ee2ee58542185f4
5
5
  SHA512:
6
- metadata.gz: fce4f982b787297b4d392fab52a64fd77684b74516007f403badf86abaeea65cae9129c48f02b343ac3d57b0783731b36ff07ddc46762252eac9dea259e142ca
7
- data.tar.gz: 17ab62fe13848134324f536a8d4b0b867623d37c538aec81aa724b5ff7b9c51cb2137270681948895f72baf949ff33a5ef02a5fc342ce7691e70c388fb5d294f
6
+ metadata.gz: f9aaf8054d7ce64c1d0ea29c4f1c8fd068cd5d634adad82da5720483962ce8a248f97528e1f3f54477920b0f12a4c6f7c9ab7c9e0f3183dcdf6e81394b76833f
7
+ data.tar.gz: fc56bac11899b0042df1ebe715683bd680f82aceb849e51561e9c57f23c696aa5a55b7049257bae02458d914e642a8e3bc1ef2157ad7feb0cc2ae28e001226ff
checksums.yaml.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -18,10 +18,11 @@ toc::[]
18
18
  == Features
19
19
 
20
20
  * Provides a Domain Specific Language (DSL) for initializing objects.
21
+ * Built atop the {marameters_link}.
21
22
  * Uses the same data structure as answered by {method_parameters_link}.
22
23
  * Adheres to the {barewords_link} pattern.
23
24
  * Reduces the amount of code necessary to implement an object.
24
- * Built atop the {marameters_link} gem.
25
+ * Pairs well with {infusible_link}.
25
26
 
26
27
  == Requirements
27
28
 
@@ -317,7 +318,7 @@ This is useful when needing to forward a block to the super class.
317
318
 
318
319
  === Defaults
319
320
 
320
- You've already seen that you can provide a third element for defaults with optional positional and keyword parameters. Sometimes, though, you might want to use a more complex object as a default (especially if you want the default to be lazy loaded/initialized). For those situations use a `Proc`. Example:
321
+ You've already seen you can provide a third element for defaults with optional positional and keyword parameters. Sometimes, though, you might want to use a more complex object as a default (especially if you want the default to be lazy loaded/initialized). For those situations use a `Proc`. Example:
321
322
 
322
323
  [source,ruby]
323
324
  ----
@@ -334,12 +335,12 @@ demo.new
334
335
 
335
336
  Notice, for the `one` optional positional parameter, we get a default value of `"One"` once evaluated. For the `two` optional keyword parameter, we get a new instance of `Object` as a default value.
336
337
 
337
- ⚠️ At the moment, there a few caveats to be aware of when using procs as defaults:
338
+ ⚠️ There a few caveats to be aware of when using proc-based defaults:
338
339
 
339
340
  * Use procs because lambdas will throw a `TypeError`.
340
341
  * Use procs _with no arguments_ because only the body of the `Proc` is meant to be parsed. Otherwise, you'll get an `ArgumentError`.
341
- * Ensure each parameter is defined on a distinct line because the body of the `Proc` is extracted at runtime from the source location of the `Proc`. The goal is to improve upon this more in the future.
342
- * Avoid using within an IRB session because each value will evaluate as `nil`.
342
+ * Ensure each parameter -- with a default -- is defined on a distinct line because the body of the `Proc` is extracted at runtime from the source location of the `Proc`. The goal is to improve upon this further once Ruby supports source location with line start, line end, column start, and column end information.
343
+ * Avoid using C-based primitives since source code can't be obtained and you'll get a `StandardError`.
343
344
 
344
345
  === Barewords
345
346
 
@@ -640,6 +641,20 @@ child.new { "demo" }
640
641
 
641
642
  With blocks, you only have to name them in the `parent` and they will be forwarded by the child. Keep in mind that if you only need to pass the block to the parent but want to use a `block_given?` check before messaging the function in your parent class, then you don't need to use this gem for those situations.
642
643
 
644
+ === Infusible
645
+
646
+ This gem pairs well with the {infusible_link} gem and requires no additional effort on your part. In terms of style, stick with including Initiable before Infusible because you'll most likely be using Initable to define basic parameters while Infusible will be used to inject dependencies from your container. This way your parameters will read sequentially left-to-right or top-to-bottom when looking at the implementation which improves readability. Example:
647
+
648
+ [source,ruby]
649
+ ----
650
+ class Demo
651
+ include Initable[%i[req label]]
652
+ include Infusible[:logger]
653
+ end
654
+ ----
655
+
656
+ You can include Initiable and Infusible in any order, though. Lastly, as with all keyword parameters, make sure you don't define the same key for both or you'll have an order of operations issue where one key overrides the other.
657
+
643
658
  === Guidelines
644
659
 
645
660
  The following is worth adhering to:
data/initable.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "initable"
5
- spec.version = "0.0.0"
5
+ spec.version = "0.1.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://alchemists.io/projects/initable"
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.cert_chain = [Gem.default_cert_path]
24
24
 
25
25
  spec.required_ruby_version = "~> 3.4"
26
- spec.add_dependency "marameters", "~> 4.0"
26
+ spec.add_dependency "marameters", "~> 4.1"
27
27
 
28
28
  spec.extra_rdoc_files = Dir["README*", "LICENSE*"]
29
29
  spec.files = Dir["*.gemspec", "lib/**/*"]
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: initable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -34,7 +34,7 @@ cert_chain:
34
34
  3n5C8/6Zh9DYTkpcwPSuIfAga6wf4nXc9m6JAw8AuMLaiWN/r/2s4zJsUHYERJEu
35
35
  gZGm4JqtuSg8pYjPeIJxS960owq+SfuC+jxqmRA54BisFCv/0VOJi7tiJVY=
36
36
  -----END CERTIFICATE-----
37
- date: 2025-01-01 00:00:00.000000000 Z
37
+ date: 2025-01-10 00:00:00.000000000 Z
38
38
  dependencies:
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: marameters
@@ -42,14 +42,14 @@ dependencies:
42
42
  requirements:
43
43
  - - "~>"
44
44
  - !ruby/object:Gem::Version
45
- version: '4.0'
45
+ version: '4.1'
46
46
  type: :runtime
47
47
  prerelease: false
48
48
  version_requirements: !ruby/object:Gem::Requirement
49
49
  requirements:
50
50
  - - "~>"
51
51
  - !ruby/object:Gem::Version
52
- version: '4.0'
52
+ version: '4.1'
53
53
  email:
54
54
  - brooke@alchemists.io
55
55
  executables: []
metadata.gz.sig CHANGED
Binary file