etcher 0.2.0 → 0.3.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 +42 -7
- data/etcher.gemspec +2 -1
- data/lib/etcher/types.rb +2 -0
- data.tar.gz.sig +0 -0
- metadata +17 -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: bdae8d6e407c3a6d7f9c43c79be0f97040996c4460f726976931a0a395c6f0c5
|
4
|
+
data.tar.gz: 0ff6f4e79245a0e14c4e7dc36672562b5ae7ea370dd9a9ce1dae0cc83ff950bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9cd8e067ab556f27a53804f18f389a41a3987f9e942dcfa471cfbc937fc4a2a353c3f6a0bf260daa91667906bdcd8e162d99133563a6386fa98c9e241f3174c
|
7
|
+
data.tar.gz: 5feeefaa7b6216791071572592d69e93fcbd5de940ff36713c68fec83e368fa53374ab42b780748c26b08c8acc283dbe03ef77c0d2a45cf0ca379a992754db38
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.adoc
CHANGED
@@ -14,8 +14,10 @@
|
|
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]
|
20
|
+
:versionaire_link: link:https://alchemists.io/projects/versionaire[Versionaire]
|
19
21
|
:xdg_link: link:https://alchemists.io/projects/xdg[XDG]
|
20
22
|
:yaml_link: link:https://rubyapi.org/o/yaml[YAML]
|
21
23
|
|
@@ -27,7 +29,7 @@ ____
|
|
27
29
|
[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
30
|
____
|
29
31
|
|
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}
|
32
|
+
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
33
|
|
32
34
|
toc::[]
|
33
35
|
|
@@ -37,7 +39,7 @@ toc::[]
|
|
37
39
|
* 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
40
|
* 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
41
|
* 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 (CLIs) or anything that might require user input at runtime.
|
42
|
+
* 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
43
|
|
42
44
|
== Requirements
|
43
45
|
|
@@ -87,7 +89,9 @@ etcher.call({one: 1, two: 2})
|
|
87
89
|
# Success({:one=>1, :two=>2})
|
88
90
|
----
|
89
91
|
|
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.
|
92
|
+
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.
|
93
|
+
|
94
|
+
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
95
|
|
92
96
|
[source,ruby]
|
93
97
|
----
|
@@ -122,6 +126,18 @@ While this is a more advanced use case, you'll usually only need to register a c
|
|
122
126
|
|
123
127
|
ℹ️ 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.
|
124
128
|
|
129
|
+
=== Steps
|
130
|
+
|
131
|
+
As hinted at above, the complete sequence of steps are performed in the order listed:
|
132
|
+
|
133
|
+
. *Load*: Each loader, if any, is called and merged with the previous loader to build initial content.
|
134
|
+
. *Override*: Any overrides are merged with the result of the last loader to produce updated content.
|
135
|
+
. *Transform*: Each transformer, if any, is called to transform and manipulate the content.
|
136
|
+
. *Validate*: The contract is called to validate the content as previously loaded, overwritten, and transformed.
|
137
|
+
. *Model*: The model consumes the content of the validated contract and creates a new record for you to use as needed.
|
138
|
+
|
139
|
+
You can use the above steps as a reference when using this gem. Each step is explained in greater detail below.
|
140
|
+
|
125
141
|
=== Registry
|
126
142
|
|
127
143
|
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:
|
@@ -195,14 +211,16 @@ Here you can see the power of using a contract to validate your data both as a f
|
|
195
211
|
|
196
212
|
=== Types
|
197
213
|
|
198
|
-
To support contracts further,
|
214
|
+
To support contracts further, there are a couple custom types which might be of interest. Each custom type, as described below, is made possible via {dry_types_link}.
|
215
|
+
|
216
|
+
==== Pathnames
|
199
217
|
|
200
218
|
[source,ruby]
|
201
219
|
----
|
202
220
|
Etcher::Types::Pathname
|
203
221
|
----
|
204
222
|
|
205
|
-
|
223
|
+
The above allows you to use pathname types in your contracts to validate and cast as pathnames:
|
206
224
|
|
207
225
|
[source,ruby]
|
208
226
|
----
|
@@ -214,7 +232,24 @@ contract.call(path: "a/path").to_monad
|
|
214
232
|
# Success(#<Dry::Schema::Result{:path=>#<Pathname:a/path>} errors={} path=[]>)
|
215
233
|
----
|
216
234
|
|
217
|
-
|
235
|
+
==== Versions
|
236
|
+
|
237
|
+
[source,ruby]
|
238
|
+
----
|
239
|
+
Etcher::Types::Version
|
240
|
+
----
|
241
|
+
|
242
|
+
The above allows you to validate and cast versions within your contracts -- via the {versionaire_link} gem -- as follows:
|
243
|
+
|
244
|
+
[source,ruby]
|
245
|
+
----
|
246
|
+
contract = Dry::Schema.Params do
|
247
|
+
required(:version).filled Etcher::Types::Version
|
248
|
+
end
|
249
|
+
|
250
|
+
contract.call(version: "1.2.3").to_monad
|
251
|
+
# Success(#<Dry::Schema::Result{:version=>"1.2.3"} errors={} path=[]>)
|
252
|
+
----
|
218
253
|
|
219
254
|
=== Models
|
220
255
|
|
@@ -258,7 +293,7 @@ There are a few guidelines to using them:
|
|
258
293
|
* They must respond to `#call` with no arguments.
|
259
294
|
* All keys are symbolized which helps streamline merging and overriding values from the same keys across multiple configurations.
|
260
295
|
* 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.
|
261
|
-
* 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
|
296
|
+
* 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.
|
262
297
|
|
263
298
|
The next couple of sections will help you learn about the supported loaders and how to build your own custom loader.
|
264
299
|
|
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.
|
5
|
+
spec.version = "0.3.0"
|
6
6
|
spec.authors = ["Brooke Kuhlmann"]
|
7
7
|
spec.email = ["brooke@alchemists.io"]
|
8
8
|
spec.homepage = "https://alchemists.io/projects/etcher"
|
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_dependency "dry-monads", "~> 1.6"
|
29
29
|
spec.add_dependency "dry-types", "~> 1.7"
|
30
30
|
spec.add_dependency "refinements", "~> 11.0"
|
31
|
+
spec.add_dependency "versionaire", "~> 12.1"
|
31
32
|
spec.add_dependency "zeitwerk", "~> 2.6"
|
32
33
|
|
33
34
|
spec.extra_rdoc_files = Dir["README*", "LICENSE*"]
|
data/lib/etcher/types.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "dry/types"
|
4
4
|
require "pathname"
|
5
|
+
require "versionaire"
|
5
6
|
|
6
7
|
module Etcher
|
7
8
|
# Defines custom types.
|
@@ -9,5 +10,6 @@ module Etcher
|
|
9
10
|
include Dry.Types(default: :strict)
|
10
11
|
|
11
12
|
Pathname = Constructor ::Pathname
|
13
|
+
Version = Constructor Versionaire::Version, Versionaire.method(:Version)
|
12
14
|
end
|
13
15
|
end
|
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.
|
4
|
+
version: 0.3.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: 2023-
|
38
|
+
date: 2023-07-12 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: cogger
|
@@ -107,6 +107,20 @@ dependencies:
|
|
107
107
|
- - "~>"
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '11.0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: versionaire
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '12.1'
|
117
|
+
type: :runtime
|
118
|
+
prerelease: false
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '12.1'
|
110
124
|
- !ruby/object:Gem::Dependency
|
111
125
|
name: zeitwerk
|
112
126
|
requirement: !ruby/object:Gem::Requirement
|
@@ -168,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
182
|
- !ruby/object:Gem::Version
|
169
183
|
version: '0'
|
170
184
|
requirements: []
|
171
|
-
rubygems_version: 3.4.
|
185
|
+
rubygems_version: 3.4.15
|
172
186
|
signing_key:
|
173
187
|
specification_version: 4
|
174
188
|
summary: A monadic configuration loader, transformer, and validator.
|
metadata.gz.sig
CHANGED
Binary file
|