etcher 0.1.0 → 0.2.1
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 +3 -4
- data/README.adoc +37 -9
- data/etcher.gemspec +3 -3
- data/lib/etcher/builder.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +7 -7
- 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: 4c9a9da371f697c41f455434c269b2230dc07ae9f9342d009c4f562e4a047a57
|
4
|
+
data.tar.gz: 2daffd0030266da21a1192a1031358f098f3523852e0857a9195009d18598b5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 968e58e3c5f1fa21ae898d6d71fb3fca3134b368a6bdb85eaa397ca92d19e7de255ec1ae0bb8f31710d53163defeaace018b93eb52b41ac25ed47d6af9e35f1a
|
7
|
+
data.tar.gz: 99eea4d38800458cd1d674e250c09764bde7e32a34cf27eaeb33b640b3650346b9ddcb7687f6800553eca891ac209e29c33f5b71b6331abb56a8ce01b7f49371
|
checksums.yaml.gz.sig
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
��ۤ�����И]�6��Qz�9����8Y<�U��c�W��8u3�_�
|
1
|
+
�W�
|
2
|
+
=t�ɘk�1
|
3
|
+
���TSƳ���\e�?eny#:\�#/�ݥs��@��=� '�=�h�CwC���>���������\R,w��YF�fC����3��P����ܡ����(��gc�_U�v�ߐ�)m~�Zs��hML(|��t,�d�Yqa���mD�)6��%��_�*���<�ԕ����`<��gI�d!��O:R�َ�#!�\��N�FI������S�pU6��Ф���SN`�MP�A�d���=
|
data/README.adoc
CHANGED
@@ -14,6 +14,7 @@
|
|
14
14
|
:hash_link: link:https://rubyapi.org/o/hash[Hash]
|
15
15
|
:json_link: link:https://rubyapi.org/o/json[JSON]
|
16
16
|
:runcom_link: link:https://alchemists.io/projects/runcom[Runcom]
|
17
|
+
:sod_link: link:https://alchemists.io/projects/sod[Sod]
|
17
18
|
:struct_link: link:https://alchemists.io/articles/ruby_structs[Struct]
|
18
19
|
:transactable_link: link:https://alchemists.io/projects/transactable[Transactable]
|
19
20
|
:xdg_link: link:https://alchemists.io/projects/xdg[XDG]
|
@@ -27,17 +28,17 @@ ____
|
|
27
28
|
[Use] strong acid or mordant to cut into the unprotected parts of a metal surface to create a design in intaglio (incised) in the metal.
|
28
29
|
____
|
29
30
|
|
30
|
-
By using Etcher, you have a reliable way to load default configurations (i.e. {environment_link}, {json_link}, {yaml_link}) which can be validated and turned into records (i.e. {hash_link}, {data_link}, {struct_link}) for consumption within your application. In other words, the ability to take primitive hashes and _etch_ them into a _frozen_ record with a nice interface that doesn't violate the {demeter_link}. This comes complete with transformations and validations all via a simple Object API. Finally, this pairs well with the {xdg_link}
|
31
|
+
By using Etcher, you have a reliable way to load default configurations (i.e. {environment_link}, {json_link}, {yaml_link}) which can be validated and turned into records (i.e. {hash_link}, {data_link}, {struct_link}) for consumption within your application. In other words, the ability to take primitive hashes and _etch_ them into a _frozen_ record with a nice interface that doesn't violate the {demeter_link}. This comes complete with transformations and validations all via a simple Object API. Finally, this pairs well with the {xdg_link}, {runcom_link}, and {sod_link} gems.
|
31
32
|
|
32
33
|
toc::[]
|
33
34
|
|
34
35
|
== Features
|
35
36
|
|
36
|
-
* Supports contracts which respond to `#call` to validate a {hash_link} before building the final record. This
|
37
|
-
* Supports models which respond to `.[]` for consuming a splatted {hash_link} to instantiate new records. This
|
37
|
+
* Supports contracts which respond to `#call` to validate a {hash_link} before building the final record. This pairs well with the {dry_schema_link} and {dry_validation_link} gems.
|
38
|
+
* Supports models which respond to `.[]` for consuming a splatted {hash_link} to instantiate new records. This pairs well with primitives such as: {hash_link}, {data_link}, and {struct_link}.
|
38
39
|
* Supports loading of default configurations from the {environment_link}, a {json_link} configuration, a {yaml_link} configuration, or anything that can answer a hash.
|
39
40
|
* Supports multiple transformations which can process loaded configuration hashes and answer a transformed hash.
|
40
|
-
* Supports {hash_link} overrides as a final customization which is handy for Command Line Interfaces (
|
41
|
+
* Supports {hash_link} overrides as a final customization which is handy for Command Line Interfaces (CLIs), as aided by {sod_link}, or anything that might require user input at runtime.
|
41
42
|
|
42
43
|
== Requirements
|
43
44
|
|
@@ -87,7 +88,9 @@ etcher.call({one: 1, two: 2})
|
|
87
88
|
# Success({:one=>1, :two=>2})
|
88
89
|
----
|
89
90
|
|
90
|
-
Notice you get a monad -- either a `Success` or `Failure` -- as provided by the {dry_monads_link} gem. This allows you to create more sophisticated pipelines as found with the {transactable_link} gem or any kind of failsafe workflow you might need.
|
91
|
+
Notice you get a monad -- either a `Success` or `Failure` -- as provided by the {dry_monads_link} gem. This allows you to create more sophisticated pipelines as found with the {transactable_link} gem or any kind of failsafe workflow you might need.
|
92
|
+
|
93
|
+
By default, any attributes you message the instance with will only pass through what you gave it and always answer a `Success`. This is nice for initial experimentation but true power comes with full customization of the instance. Here's an advanced configuration showing all features:
|
91
94
|
|
92
95
|
[source,ruby]
|
93
96
|
----
|
@@ -120,6 +123,8 @@ The above can be broken down into a series of steps:
|
|
120
123
|
|
121
124
|
While this is a more advanced use case, you'll usually only need to register a contract and model. The loaders and transformers provide additional firepower in situations where you need to do more with your data. We'll look at each of these components in greater detail next.
|
122
125
|
|
126
|
+
ℹ️ All keys are converted to symbols before being processed. This is done to ensure consistency and improve debugablity when dealing with raw input that might be a mix of strings and/or symbols.
|
127
|
+
|
123
128
|
=== Registry
|
124
129
|
|
125
130
|
The registry is provided as a way to register any/all complexity for before creating a new Etcher instance. Here's what you get by default:
|
@@ -155,7 +160,7 @@ registry = Etcher::Registry.new
|
|
155
160
|
|
156
161
|
=== Contracts
|
157
162
|
|
158
|
-
Contracts are critical piece of this workflow as they provide a way to validate incoming data,
|
163
|
+
Contracts are critical piece of this workflow as they provide a way to validate incoming data, remove unwanted data, and create a sanitized record for use in your application. Any contract that has the following behavior will work:
|
159
164
|
|
160
165
|
* `#call`: Must be able to consume a {hash_link} and answer an object which can respond to `#to_monad`.
|
161
166
|
|
@@ -240,12 +245,23 @@ Notice we get an failure if all attributes are not provided but if we supply the
|
|
240
245
|
|
241
246
|
=== Loaders
|
242
247
|
|
243
|
-
Loaders are a great way to load _default_ configuration information for your application which can be in multiple formats.
|
248
|
+
Loaders are a great way to load _default_ configuration information for your application which can be in multiple formats. Loaders can either be defined when creating a new registry instance or added after the fact. Here are a few examples:
|
249
|
+
|
250
|
+
[source,ruby]
|
251
|
+
----
|
252
|
+
# Initializer
|
253
|
+
registry = Etcher::Registry[loaders: [MyLoader.new]]
|
254
|
+
|
255
|
+
# Method
|
256
|
+
registry = Etcher::Registry.new.add_loader MyLoader.new
|
257
|
+
----
|
258
|
+
|
259
|
+
There are a few guidelines to using them:
|
244
260
|
|
245
261
|
* They must respond to `#call` with no arguments.
|
246
262
|
* All keys are symbolized which helps streamline merging and overriding values from the same keys across multiple configurations.
|
247
263
|
* All nested keys will be flattened after being loaded. This means a key structure of `{demo: {one: "test"}}` will be flattened to `demo_one: "test"` which adheres to the {demeter_link} when a new recored is _etched_ for you.
|
248
|
-
* The order in which you define your loaders matters. This means the first loader defined will be processed first, then the second, and so forth. Loaders defined last take precedence over
|
264
|
+
* The order in which you define your loaders matters. This means the first loader defined will be processed first, then the second, and so forth. Loaders defined last take precedence over previously defined loaders when overriding the same keys.
|
249
265
|
|
250
266
|
The next couple of sections will help you learn about the supported loaders and how to build your own custom loader.
|
251
267
|
|
@@ -353,10 +369,22 @@ While the above isn't super useful since it only answers whatever you provide as
|
|
353
369
|
|
354
370
|
=== Transformers
|
355
371
|
|
356
|
-
Transformers are great for modifying specific keys and values. They give you finer grained control over your configuration and are the last step before validating and creating an associated record of your configuration.
|
372
|
+
Transformers are great for modifying specific keys and values. They give you finer grained control over your configuration and are the last step before validating and creating an associated record of your configuration. Transformers can either be defined when creating a new registry instance or added after the fact. Here are a few examples:
|
373
|
+
|
374
|
+
[source,ruby]
|
375
|
+
----
|
376
|
+
# Initializer
|
377
|
+
registry = Etcher::Registry[transformers: [MyTransformer]]
|
378
|
+
|
379
|
+
# Method
|
380
|
+
registry = Etcher::Registry.new.add_transformer MyTransformer
|
381
|
+
----
|
382
|
+
|
383
|
+
Here are a few guidelines to using them:
|
357
384
|
|
358
385
|
* They can be initialized with whatever requirements you might need.
|
359
386
|
* They must respond to `#call` which takes a single argument (i.e. `content`) and answers a modified representation of this content as a `Success` with a `Hash` for content.
|
387
|
+
* The `content` passed to your transformer will have symbolized keys.
|
360
388
|
|
361
389
|
Here are a few examples of where you could go with this:
|
362
390
|
|
data/etcher.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "etcher"
|
5
|
-
spec.version = "0.1
|
5
|
+
spec.version = "0.2.1"
|
6
6
|
spec.authors = ["Brooke Kuhlmann"]
|
7
7
|
spec.email = ["brooke@alchemists.io"]
|
8
8
|
spec.homepage = "https://alchemists.io/projects/etcher"
|
@@ -23,11 +23,11 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.cert_chain = [Gem.default_cert_path]
|
24
24
|
|
25
25
|
spec.required_ruby_version = "~> 3.2"
|
26
|
-
spec.add_dependency "cogger", "~> 0.
|
26
|
+
spec.add_dependency "cogger", "~> 0.10"
|
27
27
|
spec.add_dependency "core", "~> 0.1"
|
28
28
|
spec.add_dependency "dry-monads", "~> 1.6"
|
29
29
|
spec.add_dependency "dry-types", "~> 1.7"
|
30
|
-
spec.add_dependency "refinements", "~>
|
30
|
+
spec.add_dependency "refinements", "~> 11.0"
|
31
31
|
spec.add_dependency "zeitwerk", "~> 2.6"
|
32
32
|
|
33
33
|
spec.extra_rdoc_files = Dir["README*", "LICENSE*"]
|
data/lib/etcher/builder.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: etcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
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: 2023-
|
38
|
+
date: 2023-06-19 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: cogger
|
@@ -43,14 +43,14 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '0.
|
46
|
+
version: '0.10'
|
47
47
|
type: :runtime
|
48
48
|
prerelease: false
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0.
|
53
|
+
version: '0.10'
|
54
54
|
- !ruby/object:Gem::Dependency
|
55
55
|
name: core
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,14 +99,14 @@ dependencies:
|
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: '
|
102
|
+
version: '11.0'
|
103
103
|
type: :runtime
|
104
104
|
prerelease: false
|
105
105
|
version_requirements: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
107
|
- - "~>"
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: '
|
109
|
+
version: '11.0'
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
111
|
name: zeitwerk
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
168
|
- !ruby/object:Gem::Version
|
169
169
|
version: '0'
|
170
170
|
requirements: []
|
171
|
-
rubygems_version: 3.4.
|
171
|
+
rubygems_version: 3.4.14
|
172
172
|
signing_key:
|
173
173
|
specification_version: 4
|
174
174
|
summary: A monadic configuration loader, transformer, and validator.
|
metadata.gz.sig
CHANGED
Binary file
|