etcher 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +1 -0
- data/LICENSE.adoc +134 -0
- data/README.adoc +509 -0
- data/etcher.gemspec +34 -0
- data/lib/etcher/builder.rb +59 -0
- data/lib/etcher/contract.rb +11 -0
- data/lib/etcher/loaders/environment.rb +24 -0
- data/lib/etcher/loaders/json.rb +39 -0
- data/lib/etcher/loaders/yaml.rb +47 -0
- data/lib/etcher/registry.rb +20 -0
- data/lib/etcher/resolver.rb +44 -0
- data/lib/etcher.rb +18 -0
- data.tar.gz.sig +0 -0
- metadata +160 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f77fefa60ba596414bd1453ca278ef82a4839286e4c822260bbf7ed391b2fa5a
|
4
|
+
data.tar.gz: 34076cfa28541ac3f6778bde4167a758473bb03874aa3233029df6248af24c78
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f6c2d11ab82fb53535fb7606e5a160381febab7632eb39f8fe91b677b629416536016db42f1838a2a59cf0c51595f6647762758b70356685a7194bda023ac00e
|
7
|
+
data.tar.gz: 260f3e2e1e55d3a82d862aa3140a453f7a357dbc8a5e0702f472e113d180b62b0bd011f641c612846230726b5514231c7b7412fa07cfe3251ad3dc126d204493
|
checksums.yaml.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
v��*�m���JЄ�p��u-Ϸ�u��Kҩ�� �U��QlW�kZ���%F�3�}*�eO��|g˶���q�h4a&�])��d,yY�0q�O?�KdnQ�^v\��K�b�x�\�fj�G�/OE� ��G�ݏ�Rҽ�T�+��/�R&������Y�y�nr�&�z�:܈���?X�F��
|
data/LICENSE.adoc
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
= Hippocratic License
|
2
|
+
|
3
|
+
Version: 2.1.0.
|
4
|
+
|
5
|
+
Purpose. The purpose of this License is for the Licensor named above to
|
6
|
+
permit the Licensee (as defined below) broad permission, if consistent
|
7
|
+
with Human Rights Laws and Human Rights Principles (as each is defined
|
8
|
+
below), to use and work with the Software (as defined below) within the
|
9
|
+
full scope of Licensor’s copyright and patent rights, if any, in the
|
10
|
+
Software, while ensuring attribution and protecting the Licensor from
|
11
|
+
liability.
|
12
|
+
|
13
|
+
Permission and Conditions. The Licensor grants permission by this
|
14
|
+
license ("License"), free of charge, to the extent of Licensor’s
|
15
|
+
rights under applicable copyright and patent law, to any person or
|
16
|
+
entity (the "Licensee") obtaining a copy of this software and
|
17
|
+
associated documentation files (the "Software"), to do everything with
|
18
|
+
the Software that would otherwise infringe (i) the Licensor’s copyright
|
19
|
+
in the Software or (ii) any patent claims to the Software that the
|
20
|
+
Licensor can license or becomes able to license, subject to all of the
|
21
|
+
following terms and conditions:
|
22
|
+
|
23
|
+
* Acceptance. This License is automatically offered to every person and
|
24
|
+
entity subject to its terms and conditions. Licensee accepts this
|
25
|
+
License and agrees to its terms and conditions by taking any action with
|
26
|
+
the Software that, absent this License, would infringe any intellectual
|
27
|
+
property right held by Licensor.
|
28
|
+
* Notice. Licensee must ensure that everyone who gets a copy of any part
|
29
|
+
of this Software from Licensee, with or without changes, also receives
|
30
|
+
the License and the above copyright notice (and if included by the
|
31
|
+
Licensor, patent, trademark and attribution notice). Licensee must cause
|
32
|
+
any modified versions of the Software to carry prominent notices stating
|
33
|
+
that Licensee changed the Software. For clarity, although Licensee is
|
34
|
+
free to create modifications of the Software and distribute only the
|
35
|
+
modified portion created by Licensee with additional or different terms,
|
36
|
+
the portion of the Software not modified must be distributed pursuant to
|
37
|
+
this License. If anyone notifies Licensee in writing that Licensee has
|
38
|
+
not complied with this Notice section, Licensee can keep this License by
|
39
|
+
taking all practical steps to comply within 30 days after the notice. If
|
40
|
+
Licensee does not do so, Licensee’s License (and all rights licensed
|
41
|
+
hereunder) shall end immediately.
|
42
|
+
* Compliance with Human Rights Principles and Human Rights Laws.
|
43
|
+
[arabic]
|
44
|
+
. Human Rights Principles.
|
45
|
+
[loweralpha]
|
46
|
+
.. Licensee is advised to consult the articles of the United Nations
|
47
|
+
Universal Declaration of Human Rights and the United Nations Global
|
48
|
+
Compact that define recognized principles of international human rights
|
49
|
+
(the "Human Rights Principles"). Licensee shall use the Software in a
|
50
|
+
manner consistent with Human Rights Principles.
|
51
|
+
.. Unless the Licensor and Licensee agree otherwise, any dispute,
|
52
|
+
controversy, or claim arising out of or relating to (i) Section 1(a)
|
53
|
+
regarding Human Rights Principles, including the breach of Section 1(a),
|
54
|
+
termination of this License for breach of the Human Rights Principles,
|
55
|
+
or invalidity of Section 1(a) or (ii) a determination of whether any Law
|
56
|
+
is consistent or in conflict with Human Rights Principles pursuant to
|
57
|
+
Section 2, below, shall be settled by arbitration in accordance with the
|
58
|
+
Hague Rules on Business and Human Rights Arbitration (the "Rules");
|
59
|
+
provided, however, that Licensee may elect not to participate in such
|
60
|
+
arbitration, in which event this License (and all rights licensed
|
61
|
+
hereunder) shall end immediately. The number of arbitrators shall be one
|
62
|
+
unless the Rules require otherwise.
|
63
|
+
+
|
64
|
+
Unless both the Licensor and Licensee agree to the contrary: (1) All
|
65
|
+
documents and information concerning the arbitration shall be public and
|
66
|
+
may be disclosed by any party; (2) The repository referred to under
|
67
|
+
Article 43 of the Rules shall make available to the public in a timely
|
68
|
+
manner all documents concerning the arbitration which are communicated
|
69
|
+
to it, including all submissions of the parties, all evidence admitted
|
70
|
+
into the record of the proceedings, all transcripts or other recordings
|
71
|
+
of hearings and all orders, decisions and awards of the arbitral
|
72
|
+
tribunal, subject only to the arbitral tribunal’s powers to take such
|
73
|
+
measures as may be necessary to safeguard the integrity of the arbitral
|
74
|
+
process pursuant to Articles 18, 33, 41 and 42 of the Rules; and (3)
|
75
|
+
Article 26(6) of the Rules shall not apply.
|
76
|
+
. Human Rights Laws. The Software shall not be used by any person or
|
77
|
+
entity for any systems, activities, or other uses that violate any Human
|
78
|
+
Rights Laws. "Human Rights Laws" means any applicable laws,
|
79
|
+
regulations, or rules (collectively, "Laws") that protect human,
|
80
|
+
civil, labor, privacy, political, environmental, security, economic, due
|
81
|
+
process, or similar rights; provided, however, that such Laws are
|
82
|
+
consistent and not in conflict with Human Rights Principles (a dispute
|
83
|
+
over the consistency or a conflict between Laws and Human Rights
|
84
|
+
Principles shall be determined by arbitration as stated above). Where
|
85
|
+
the Human Rights Laws of more than one jurisdiction are applicable or in
|
86
|
+
conflict with respect to the use of the Software, the Human Rights Laws
|
87
|
+
that are most protective of the individuals or groups harmed shall
|
88
|
+
apply.
|
89
|
+
. Indemnity. Licensee shall hold harmless and indemnify Licensor (and
|
90
|
+
any other contributor) against all losses, damages, liabilities,
|
91
|
+
deficiencies, claims, actions, judgments, settlements, interest, awards,
|
92
|
+
penalties, fines, costs, or expenses of whatever kind, including
|
93
|
+
Licensor’s reasonable attorneys’ fees, arising out of or relating to
|
94
|
+
Licensee’s use of the Software in violation of Human Rights Laws or
|
95
|
+
Human Rights Principles.
|
96
|
+
* Failure to Comply. Any failure of Licensee to act according to the
|
97
|
+
terms and conditions of this License is both a breach of the License and
|
98
|
+
an infringement of the intellectual property rights of the Licensor
|
99
|
+
(subject to exceptions under Laws, e.g., fair use). In the event of a
|
100
|
+
breach or infringement, the terms and conditions of this License may be
|
101
|
+
enforced by Licensor under the Laws of any jurisdiction to which
|
102
|
+
Licensee is subject. Licensee also agrees that the Licensor may enforce
|
103
|
+
the terms and conditions of this License against Licensee through
|
104
|
+
specific performance (or similar remedy under Laws) to the extent
|
105
|
+
permitted by Laws. For clarity, except in the event of a breach of this
|
106
|
+
License, infringement, or as otherwise stated in this License, Licensor
|
107
|
+
may not terminate this License with Licensee.
|
108
|
+
* Enforceability and Interpretation. If any term or provision of this
|
109
|
+
License is determined to be invalid, illegal, or unenforceable by a
|
110
|
+
court of competent jurisdiction, then such invalidity, illegality, or
|
111
|
+
unenforceability shall not affect any other term or provision of this
|
112
|
+
License or invalidate or render unenforceable such term or provision in
|
113
|
+
any other jurisdiction; provided, however, subject to a court
|
114
|
+
modification pursuant to the immediately following sentence, if any term
|
115
|
+
or provision of this License pertaining to Human Rights Laws or Human
|
116
|
+
Rights Principles is deemed invalid, illegal, or unenforceable against
|
117
|
+
Licensee by a court of competent jurisdiction, all rights in the
|
118
|
+
Software granted to Licensee shall be deemed null and void as between
|
119
|
+
Licensor and Licensee. Upon a determination that any term or provision
|
120
|
+
is invalid, illegal, or unenforceable, to the extent permitted by Laws,
|
121
|
+
the court may modify this License to affect the original purpose that
|
122
|
+
the Software be used in compliance with Human Rights Principles and
|
123
|
+
Human Rights Laws as closely as possible. The language in this License
|
124
|
+
shall be interpreted as to its fair meaning and not strictly for or
|
125
|
+
against any party.
|
126
|
+
* Disclaimer. TO THE FULL EXTENT ALLOWED BY LAW, THIS SOFTWARE COMES
|
127
|
+
"AS IS," WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED, AND LICENSOR AND
|
128
|
+
ANY OTHER CONTRIBUTOR SHALL NOT BE LIABLE TO ANYONE FOR ANY DAMAGES OR
|
129
|
+
OTHER LIABILITY ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE
|
130
|
+
OR THIS LICENSE, UNDER ANY KIND OF LEGAL CLAIM.
|
131
|
+
|
132
|
+
This Hippocratic License is an link:https://ethicalsource.dev[Ethical Source license] and is offered
|
133
|
+
for use by licensors and licensees at their own risk, on an "AS IS" basis, and with no warranties
|
134
|
+
express or implied, to the maximum extent permitted by Laws.
|
data/README.adoc
ADDED
@@ -0,0 +1,509 @@
|
|
1
|
+
:toc: macro
|
2
|
+
:toclevels: 5
|
3
|
+
:figure-caption!:
|
4
|
+
|
5
|
+
:data_link: link:https://alchemists.io/articles/ruby_data[Data]
|
6
|
+
:demeter_link: link:https://en.wikipedia.org/wiki/Law_of_Demeter[Law of Demeter]
|
7
|
+
:dry_container_link: link:https://dry-rb.org/gems/dry-container[Dry Container]
|
8
|
+
:dry_monads_link: link:https://dry-rb.org/gems/dry-monads[Dry Monads]
|
9
|
+
:dry_schema_link: link:https://dry-rb.org/gems/dry-schema[Dry Schema]
|
10
|
+
:dry_validation_link: link:https://dry-rb.org/gems/dry-validation[Dry Validation]
|
11
|
+
:environment_link: link:https://rubyapi.org/3.2/o/env[Environment]
|
12
|
+
:gitt_link: link:https://alchemists.io/projects/gitt[Gitt]
|
13
|
+
:hash_link: link:https://rubyapi.org/o/hash[Hash]
|
14
|
+
:json_link: link:https://rubyapi.org/o/json[JSON]
|
15
|
+
:runcom_link: link:https://alchemists.io/projects/runcom[Runcom]
|
16
|
+
:struct_link: link:https://alchemists.io/articles/ruby_structs[Struct]
|
17
|
+
:transactable_link: link:https://alchemists.io/projects/transactable[Transactable]
|
18
|
+
:xdg_link: link:https://alchemists.io/projects/xdg[XDG]
|
19
|
+
:yaml_link: link:https://rubyapi.org/o/yaml[YAML]
|
20
|
+
|
21
|
+
= Etcher
|
22
|
+
|
23
|
+
Etcher allows you to take raw settings and/or user input and _etch_ them into a concrete and valid configuration for use within your application. As quoted from link:https://en.wikipedia.org/wiki/Etching[Wikipedia], to _etch_ is to:
|
24
|
+
|
25
|
+
____
|
26
|
+
[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.
|
27
|
+
____
|
28
|
+
|
29
|
+
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} and {runcom_link} gems, Command Line Interfaces (CLIs), Application Programming Interfaces (APIs), or any application that can be configured by the user.
|
30
|
+
|
31
|
+
toc::[]
|
32
|
+
|
33
|
+
== Features
|
34
|
+
|
35
|
+
* Supports contracts which respond to `#call` to validate a {hash_link} before building the final record. This works extremely well with the {dry_schema_link} and {dry_validation_link} gems.
|
36
|
+
* Supports models which respond to `.[]` for consuming a splatted {hash_link} to instantiate new records. This works extremely well with primitives such as: {hash_link}, {data_link}, and {struct_link}.
|
37
|
+
* Supports loading of default configurations from the {environment_link}, a {json_link} configuration, a {yaml_link} configuration, or anything that can answer a hash.
|
38
|
+
* Supports multiple transformations which can process loaded configuration hashes and answer a transformed hash.
|
39
|
+
* Supports {hash_link} overrides as a final customization which is handy for Command Line Interfaces (CLI) or anything that might require user input at runtime.
|
40
|
+
|
41
|
+
== Requirements
|
42
|
+
|
43
|
+
. link:https://www.ruby-lang.org[Ruby].
|
44
|
+
|
45
|
+
== Setup
|
46
|
+
|
47
|
+
To install _with_ security, run:
|
48
|
+
|
49
|
+
[source,bash]
|
50
|
+
----
|
51
|
+
# 💡 Skip this line if you already have the public certificate installed.
|
52
|
+
gem cert --add <(curl --compressed --location https://alchemists.io/gems.pem)
|
53
|
+
gem install etcher --trust-policy HighSecurity
|
54
|
+
----
|
55
|
+
|
56
|
+
To install _without_ security, run:
|
57
|
+
|
58
|
+
[source,bash]
|
59
|
+
----
|
60
|
+
gem install etcher
|
61
|
+
----
|
62
|
+
|
63
|
+
You can also add the gem directly to your project:
|
64
|
+
|
65
|
+
[source,bash]
|
66
|
+
----
|
67
|
+
bundle add etcher
|
68
|
+
----
|
69
|
+
|
70
|
+
Once the gem is installed, you only need to require it:
|
71
|
+
|
72
|
+
[source,ruby]
|
73
|
+
----
|
74
|
+
require "etcher"
|
75
|
+
----
|
76
|
+
|
77
|
+
== Usage
|
78
|
+
|
79
|
+
Basic usage is to new up an instance:
|
80
|
+
|
81
|
+
[source,ruby]
|
82
|
+
----
|
83
|
+
etcher = Etcher.new
|
84
|
+
etcher.call({one: 1, two: 2})
|
85
|
+
|
86
|
+
# Success({:one=>1, :two=>2})
|
87
|
+
----
|
88
|
+
|
89
|
+
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. The only problem is -- 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:
|
90
|
+
|
91
|
+
[source,ruby]
|
92
|
+
----
|
93
|
+
require "dry/monads"
|
94
|
+
require "dry/schema"
|
95
|
+
|
96
|
+
Dry::Schema.load_extensions :monads
|
97
|
+
|
98
|
+
contract = Dry::Schema.Params do
|
99
|
+
required(:user).filled :string
|
100
|
+
required(:home).filled :string
|
101
|
+
end
|
102
|
+
|
103
|
+
model = Data.define :user, :home
|
104
|
+
transformer = -> content { Dry::Monads::Success content.merge! user: content[:user].upcase }
|
105
|
+
|
106
|
+
Etcher::Registry.new(contract:, model:, transformers: [transformer])
|
107
|
+
.add_loader(Etcher::Loaders::Environment.new(%w[USER HOME]))
|
108
|
+
.then { |registry| Etcher.new(registry).call }
|
109
|
+
|
110
|
+
# Success(#<data user="DEMO", home="/Users/demo">)
|
111
|
+
----
|
112
|
+
|
113
|
+
The above can be broken down into a series of steps:
|
114
|
+
|
115
|
+
. A {dry_schema_link} contract -- loaded with {dry_monads_link} extensions -- is created to verify untrusted attributes.
|
116
|
+
. A model is created with attributes: `user` and `home`.
|
117
|
+
. A registry is constructed with a custom contract, model, loader, and transformer.
|
118
|
+
. Finally, we see a _successfully_ built configuration for further use.
|
119
|
+
|
120
|
+
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.
|
121
|
+
|
122
|
+
=== Registry
|
123
|
+
|
124
|
+
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:
|
125
|
+
|
126
|
+
[source,ruby]
|
127
|
+
----
|
128
|
+
Etcher::Registry.new
|
129
|
+
# #<data Etcher::Registry contract=#<Proc:0x000000010e393550 contract.rb:7 (lambda)>, model=Hash, loaders=[], transformers=[]>
|
130
|
+
----
|
131
|
+
|
132
|
+
Since the registry is a {data_link}, you can initialize with everything you need:
|
133
|
+
|
134
|
+
[source,ruby]
|
135
|
+
----
|
136
|
+
Etcher::Registry[
|
137
|
+
contract: MyContract,
|
138
|
+
model: MyModel,
|
139
|
+
loaders: [MyLoader.new],
|
140
|
+
transformers: [MyTransformer]
|
141
|
+
]
|
142
|
+
----
|
143
|
+
|
144
|
+
You can also add additional loaders and/or transformers after the fact:
|
145
|
+
|
146
|
+
[source,ruby]
|
147
|
+
----
|
148
|
+
registry = Etcher::Registry.new
|
149
|
+
.add_loader(MyLoader.new)
|
150
|
+
.add_transformer(MyTransformer)
|
151
|
+
----
|
152
|
+
|
153
|
+
💡 Order matters so ensure you list your loaders and transformers in the order you want them to be processed.
|
154
|
+
|
155
|
+
=== Contracts
|
156
|
+
|
157
|
+
Contracts are critical piece of this workflow as they provide a way to validate incoming data, strip out unwanted data, and create a sanitized record for use in your application. Any contract that has the following behavior will work:
|
158
|
+
|
159
|
+
* `#call`: Must be able to consume a {hash_link} and answer an object which can respond to `#to_monad`.
|
160
|
+
|
161
|
+
The best gems which adhere to this interface are: {dry_schema_link} and {dry_validation_link}. You'll also want to make sure the {dry_monads_link} extensions are loaded as briefly shown earlier so the result will respond to `#to_monad`. Here's how to enable monad support if using both gems:
|
162
|
+
|
163
|
+
[source,ruby]
|
164
|
+
----
|
165
|
+
Dry::Schema.load_extensions :monads
|
166
|
+
Dry::Validation.load_extensions :monads
|
167
|
+
----
|
168
|
+
|
169
|
+
Using {dry_schema_link} syntax, we could create a contract for verifying email addresses and use it to build a new Etcher instance. Example:
|
170
|
+
|
171
|
+
[source,ruby]
|
172
|
+
----
|
173
|
+
require "dry/schema"
|
174
|
+
|
175
|
+
Dry::Schema.load_extensions :monads
|
176
|
+
|
177
|
+
contract = Dry::Schema.Params do
|
178
|
+
required(:from).filled :string
|
179
|
+
required(:to).filled :string
|
180
|
+
end
|
181
|
+
|
182
|
+
etcher = Etcher::Registry[contract:].then { |registry| Etcher.new registry }
|
183
|
+
etcher.call
|
184
|
+
|
185
|
+
# Failure({:step=>:validate, :payload=>{:from=>["is missing"], :to=>["is missing"]}})
|
186
|
+
|
187
|
+
etcher.call from: "Mork", to: "Mindy"
|
188
|
+
# Success({:from=>"Mork", :to=>"Mindy"})
|
189
|
+
----
|
190
|
+
|
191
|
+
Here you can see the power of using a contract to validate your data both as a failure and a success. Unfortunately, with the success, we only get a {hash_link} as a record and it would be nice to structured model which which we'll look at next.
|
192
|
+
|
193
|
+
=== Models
|
194
|
+
|
195
|
+
A model is any object which responds to `.[]` and can accept a splatted hash. Example: `Model[**attributes]`. These primitives are excellent choices: {hash_link}, {data_link}, and {struct_link}.
|
196
|
+
|
197
|
+
ℹ️ Keep in mind that using a `Hash` is the default model and will only result in a pass through situation. You'll want to reach for the more robust `Data` or `Struct` objects instead.
|
198
|
+
|
199
|
+
The model is used in the last step of the _etching_ process to create a _frozen_ record for further use by your application. Here's an example where a {data_link} model is used:
|
200
|
+
|
201
|
+
[source,ruby]
|
202
|
+
----
|
203
|
+
model = Data.define :from, :to
|
204
|
+
etcher = Etcher::Registry[model:].then { |registry| Etcher.new registry }
|
205
|
+
|
206
|
+
etcher.call
|
207
|
+
# Failure({:step=>:record, :payload=>"Missing keywords: :from, :to."})
|
208
|
+
|
209
|
+
etcher.call from: "Mork", to: "Mindy"
|
210
|
+
# Success(#<data Model from="Mork", to="Mindy">)
|
211
|
+
----
|
212
|
+
|
213
|
+
Notice we get an failure if all attributes are not provided but if we supply the required attributes we get a success.
|
214
|
+
|
215
|
+
ℹ️ Keep in mind the default contract is always a pass through so no validation is being done when only using a {hash_link}. Generally you want to supply both a custom contract and model at a minimum.
|
216
|
+
|
217
|
+
=== Loaders
|
218
|
+
|
219
|
+
Loaders are a great way to load _default_ configuration information for your application which can be in multiple formats. There are a few guidelines to using them:
|
220
|
+
|
221
|
+
* They must respond to `#call` with no arguments.
|
222
|
+
* All keys are symbolized which helps streamline merging and overriding values from the same keys across multiple configurations.
|
223
|
+
* 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.
|
224
|
+
* 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 loaders defined first when overriding the same keys.
|
225
|
+
|
226
|
+
The next couple of sections will help you learn about the supported loaders and how to build your own custom loader.
|
227
|
+
|
228
|
+
==== Environment
|
229
|
+
|
230
|
+
Use `Etcher::Loaders::Environment` to load configuration information from your {environment_link}. By default, this object wraps `ENV`, uses an empty array for keys to include, and answers a filtered hash where all keys are downcased. _If you don't specify keys to include, then an empty hash is answered back_. Here's a few examples:
|
231
|
+
|
232
|
+
[source,ruby]
|
233
|
+
----
|
234
|
+
# Default behavior.
|
235
|
+
loader = Etcher::Loaders::Environment.new
|
236
|
+
loader.call
|
237
|
+
# Success({})
|
238
|
+
|
239
|
+
# With specific includes.
|
240
|
+
loader = Etcher::Loaders::Environment.new %w[RACK_ENV DATABASE_URL]
|
241
|
+
loader.call
|
242
|
+
# Success({"rack_env" => "test", "database_url" => "postgres://localhost/demo_test"})
|
243
|
+
|
244
|
+
# With a custom environment and specific include.
|
245
|
+
loader = Etcher::Loaders::Environment.new "USER", source: {"USER" => "Jack"}
|
246
|
+
loader.call
|
247
|
+
# Success({"user"=>"Jack"})
|
248
|
+
----
|
249
|
+
|
250
|
+
This loader is great for pulling from environment variables as a fallback configuration for your application.
|
251
|
+
|
252
|
+
==== JSON
|
253
|
+
|
254
|
+
Use `Etcher::Loaders::JSON` to load configuration information from a {json_link} file. Here's how to use this loader (using a file that doesn't exist):
|
255
|
+
|
256
|
+
[source,ruby]
|
257
|
+
----
|
258
|
+
# Default behavior (a custom path is required).
|
259
|
+
loader = Etcher::Loaders::JSON.new "your/path/to/configuration.json"
|
260
|
+
loader.call # Success({})
|
261
|
+
----
|
262
|
+
|
263
|
+
You can also customize the fallback and logger used. Here are the defaults:
|
264
|
+
|
265
|
+
[source,ruby]
|
266
|
+
----
|
267
|
+
loader = Etcher::Loaders::JSON.new "your/path/to/configuration.json",
|
268
|
+
fallback: {},
|
269
|
+
logger: Logger.new(STDOUT)
|
270
|
+
loader.call # Success({})
|
271
|
+
----
|
272
|
+
|
273
|
+
If the file did exist and had content, you'd get a `Success` with a `Hash` of the contents.
|
274
|
+
|
275
|
+
ℹ️ The logger is only used to log debug information when issues are encountered when reading from the file. This is done to reduce noise in your console when a configuration might have issues and can safely revert to the fallback in order to load the rest of the configuration.
|
276
|
+
|
277
|
+
==== YAML
|
278
|
+
|
279
|
+
Use `Etcher::Loaders::YAML` to load configuration information from a {yaml_link} file. Here's how to use this loader (using a file that doesn't exist):
|
280
|
+
|
281
|
+
[source,ruby]
|
282
|
+
----
|
283
|
+
# Default behavior (a custom path is required).
|
284
|
+
loader = Etcher::Loaders::YAML.new "your/path/to/configuration.yml"
|
285
|
+
loader.call # Success({})
|
286
|
+
----
|
287
|
+
|
288
|
+
You can also customize the fallback and logger used. Here are the defaults:
|
289
|
+
|
290
|
+
[source,ruby]
|
291
|
+
----
|
292
|
+
loader = Etcher::Loaders::YAML.new "your/path/to/configuration.yml",
|
293
|
+
fallback: {},
|
294
|
+
logger: Logger.new(STDOUT)
|
295
|
+
loader.call # Success({})
|
296
|
+
----
|
297
|
+
|
298
|
+
If the file did exist and had content, you'd get a `Success` with a `Hash` of the contents.
|
299
|
+
|
300
|
+
ℹ️ The logger is only used to log debug information when issues are encountered when reading from the file. This is done to reduce noise in your console when a configuration might have issues and can safely revert to the fallback in order to load the rest of the configuration.
|
301
|
+
|
302
|
+
==== Custom
|
303
|
+
|
304
|
+
You can always create your own loader if you don't need or want any of the default loaders provided for you. The only requirement is your loader _must_ respond to `#call` and answer a `Success` with a `Hash` for content which means you can use a class, method, lambda, or proc. Here's an example of creating a custom loader, registering, and using it:
|
305
|
+
|
306
|
+
[source,ruby]
|
307
|
+
----
|
308
|
+
require "dry/monads"
|
309
|
+
|
310
|
+
class Demo
|
311
|
+
include Dry::Monads[:result]
|
312
|
+
|
313
|
+
def initialize fallback: {}
|
314
|
+
@fallback = fallback
|
315
|
+
end
|
316
|
+
|
317
|
+
def call = Success fallback
|
318
|
+
|
319
|
+
private
|
320
|
+
|
321
|
+
attr_reader :fallback
|
322
|
+
end
|
323
|
+
|
324
|
+
etcher = Etcher::Registry[loaders: [Demo.new]].then { |registry| Etcher.new registry }
|
325
|
+
etcher.call # Success({})
|
326
|
+
----
|
327
|
+
|
328
|
+
While the above isn't super useful since it only answers whatever you provide as fallback information, you can see there is little effort required to implement and customize as desired.
|
329
|
+
|
330
|
+
=== Transformers
|
331
|
+
|
332
|
+
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. There are a few guidelines to using them:
|
333
|
+
|
334
|
+
* They can be initialized with whatever requirements you might need.
|
335
|
+
* 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.
|
336
|
+
|
337
|
+
Here are a few examples of where you could go with this:
|
338
|
+
|
339
|
+
The following capitalizes all values (which may or may not be good depending on your data structure).
|
340
|
+
|
341
|
+
[source,ruby]
|
342
|
+
----
|
343
|
+
require "dry/monads"
|
344
|
+
|
345
|
+
Capitalize = -> content { Dry::Monads::Success content.transform_values!(&:capitalize) }
|
346
|
+
Capitalize.call(name: "test")
|
347
|
+
|
348
|
+
# Success({:name=>"Test"})
|
349
|
+
----
|
350
|
+
|
351
|
+
The following updates current time relative to when configuration was transformed.
|
352
|
+
|
353
|
+
[source,ruby]
|
354
|
+
----
|
355
|
+
require "dry/monads"
|
356
|
+
|
357
|
+
CurrentTime = lambda do |content, at: Time.now|
|
358
|
+
content[:at] = at
|
359
|
+
Dry::Monads::Success content
|
360
|
+
end
|
361
|
+
|
362
|
+
CurrentTime.call({})
|
363
|
+
|
364
|
+
# Success({:at=>2023-04-23 15:22:23.746408 -0600})
|
365
|
+
----
|
366
|
+
|
367
|
+
The following obtains the current Git user's email address from the global Git configuration using the {gitt_link} gem.
|
368
|
+
|
369
|
+
[source,ruby]
|
370
|
+
----
|
371
|
+
require "dry/monads"
|
372
|
+
require "gitt"
|
373
|
+
|
374
|
+
class GitEmail
|
375
|
+
def initialize git: Gitt::Repository.new
|
376
|
+
@git = git
|
377
|
+
end
|
378
|
+
|
379
|
+
def call(content) = git.get("user.email").fmap { |email| content[:author_email] = email }
|
380
|
+
|
381
|
+
private
|
382
|
+
|
383
|
+
attr_reader :git
|
384
|
+
end
|
385
|
+
|
386
|
+
GitEmail.new.call({})
|
387
|
+
|
388
|
+
# Success("demo@alchemists.io")
|
389
|
+
----
|
390
|
+
|
391
|
+
To use all of the above, you'd only need to register and use them:
|
392
|
+
|
393
|
+
[source,ruby]
|
394
|
+
----
|
395
|
+
registry = Etcher::Registry[transformers: [Capitalize, CurrentTime, GitEmail.new]]
|
396
|
+
etcher = Etcher.new(registry)
|
397
|
+
etcher.call
|
398
|
+
----
|
399
|
+
|
400
|
+
=== Overrides
|
401
|
+
|
402
|
+
Overrides are what you pass to the Etcher instance when called. Example:
|
403
|
+
|
404
|
+
[source,ruby]
|
405
|
+
----
|
406
|
+
etcher = Etcher.new
|
407
|
+
etcher.call name: "test", label: "Test"
|
408
|
+
|
409
|
+
# Success({:name=>"test", :label=>"Test"})
|
410
|
+
----
|
411
|
+
|
412
|
+
These _overrides_ are applied _after_ all loaders are processed and _before_ any transformations. They are a nice way to deal with user input during runtime or provide any additional configuration not supplied by the loading of your default configuration.
|
413
|
+
|
414
|
+
=== Resolver
|
415
|
+
|
416
|
+
In situations where you'd like Etcher to handle the complete load, transform, validate, and build steps for you, then you can use the resolver. This is provided for use cases where you'd like Etcher to handle everything for you and abort if otherwise. Example:
|
417
|
+
|
418
|
+
[source,ruby]
|
419
|
+
----
|
420
|
+
Etcher.call name: "demo"
|
421
|
+
# {:name=>"demo"}
|
422
|
+
----
|
423
|
+
|
424
|
+
When called _and there are no issues_, you'll get the fully formed record as a result (in this case a Hash which is the default model). You'll never a get a monad when using `Etcher.call` because this is meant to resolve the monadic pipeline for you. If any failure is encountered, then Etcher will _abort_ with a fatal log message. Here's a variation of earlier examples which demonstrates fatal errors:
|
425
|
+
|
426
|
+
[source,ruby]
|
427
|
+
----
|
428
|
+
require "dry/monads"
|
429
|
+
require "dry/schema"
|
430
|
+
|
431
|
+
Dry::Schema.load_extensions :monads
|
432
|
+
|
433
|
+
contract = Dry::Schema.Params do
|
434
|
+
required(:to).filled :string
|
435
|
+
required(:from).filled :string
|
436
|
+
end
|
437
|
+
|
438
|
+
model = Data.define :to, :from
|
439
|
+
registry = Etcher::Registry.new(contract:, model:)
|
440
|
+
|
441
|
+
Etcher.call registry
|
442
|
+
|
443
|
+
# 🔥 Unable to load configuration due to the following issues:
|
444
|
+
# - to is missing
|
445
|
+
# - from is missing
|
446
|
+
|
447
|
+
Etcher.call registry, to: "Mindy"
|
448
|
+
|
449
|
+
# 🔥 Unable to load configuration due to the following issues:
|
450
|
+
# - from is missing
|
451
|
+
|
452
|
+
|
453
|
+
registry = Etcher::Registry.new(model: Data.define(:name, :label))
|
454
|
+
Etcher.call registry, to: "Mindy"
|
455
|
+
|
456
|
+
# 🔥 Build failure: :record. Missing keywords: :name, :label.
|
457
|
+
----
|
458
|
+
|
459
|
+
💡 When using a custom registry, make sure it's the first argument. All arguments afterwards can be any number of key/values overrides which is similar to how `Etcher.new` works.
|
460
|
+
|
461
|
+
== Development
|
462
|
+
|
463
|
+
To contribute, run:
|
464
|
+
|
465
|
+
[source,bash]
|
466
|
+
----
|
467
|
+
git clone https://github.com/bkuhlmann/etcher
|
468
|
+
cd etcher
|
469
|
+
bin/setup
|
470
|
+
----
|
471
|
+
|
472
|
+
You can also use the IRB console for direct access to all objects:
|
473
|
+
|
474
|
+
[source,bash]
|
475
|
+
----
|
476
|
+
bin/console
|
477
|
+
----
|
478
|
+
|
479
|
+
=== Architecture
|
480
|
+
|
481
|
+
The following illustrates the full sequences of events when _etching_ new records:
|
482
|
+
|
483
|
+
image::https://alchemists.io/images/projects/etcher/doc/architecture.svg[Architecture Diagram]
|
484
|
+
|
485
|
+
== Tests
|
486
|
+
|
487
|
+
To test, run:
|
488
|
+
|
489
|
+
[source,bash]
|
490
|
+
----
|
491
|
+
bin/rake
|
492
|
+
----
|
493
|
+
|
494
|
+
== link:https://alchemists.io/policies/license[License]
|
495
|
+
|
496
|
+
== link:https://alchemists.io/policies/security[Security]
|
497
|
+
|
498
|
+
== link:https://alchemists.io/policies/code_of_conduct[Code of Conduct]
|
499
|
+
|
500
|
+
== link:https://alchemists.io/policies/contributions[Contributions]
|
501
|
+
|
502
|
+
== link:https://alchemists.io/projects/etcher/versions[Versions]
|
503
|
+
|
504
|
+
== link:https://alchemists.io/community[Community]
|
505
|
+
|
506
|
+
== Credits
|
507
|
+
|
508
|
+
* Built with link:https://alchemists.io/projects/gemsmith[Gemsmith].
|
509
|
+
* Engineered by link:https://alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
|
data/etcher.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "etcher"
|
5
|
+
spec.version = "0.0.0"
|
6
|
+
spec.authors = ["Brooke Kuhlmann"]
|
7
|
+
spec.email = ["brooke@alchemists.io"]
|
8
|
+
spec.homepage = "https://alchemists.io/projects/etcher"
|
9
|
+
spec.summary = "A configuration loader, transformer, and validator."
|
10
|
+
spec.license = "Hippocratic-2.1"
|
11
|
+
|
12
|
+
spec.metadata = {
|
13
|
+
"bug_tracker_uri" => "https://github.com/bkuhlmann/etcher/issues",
|
14
|
+
"changelog_uri" => "https://alchemists.io/projects/etcher/versions",
|
15
|
+
"documentation_uri" => "https://alchemists.io/projects/etcher",
|
16
|
+
"funding_uri" => "https://github.com/sponsors/bkuhlmann",
|
17
|
+
"label" => "Etcher",
|
18
|
+
"rubygems_mfa_required" => "true",
|
19
|
+
"source_code_uri" => "https://github.com/bkuhlmann/etcher"
|
20
|
+
}
|
21
|
+
|
22
|
+
spec.signing_key = Gem.default_key_path
|
23
|
+
spec.cert_chain = [Gem.default_cert_path]
|
24
|
+
|
25
|
+
spec.required_ruby_version = "~> 3.2"
|
26
|
+
spec.add_dependency "cogger", "~> 0.9"
|
27
|
+
spec.add_dependency "core", "~> 0.1"
|
28
|
+
spec.add_dependency "dry-monads", "~> 1.6"
|
29
|
+
spec.add_dependency "refinements", "~> 10.0"
|
30
|
+
spec.add_dependency "zeitwerk", "~> 2.6"
|
31
|
+
|
32
|
+
spec.extra_rdoc_files = Dir["README*", "LICENSE*"]
|
33
|
+
spec.files = Dir["*.gemspec", "lib/**/*"]
|
34
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "core"
|
4
|
+
require "dry/monads"
|
5
|
+
require "refinements/hashes"
|
6
|
+
|
7
|
+
module Etcher
|
8
|
+
# Builds a configuration.
|
9
|
+
class Builder
|
10
|
+
include Dry::Monads[:result]
|
11
|
+
|
12
|
+
using Refinements::Hashes
|
13
|
+
|
14
|
+
def initialize registry = Registry.new
|
15
|
+
@registry = registry
|
16
|
+
end
|
17
|
+
|
18
|
+
def call(**overrides)
|
19
|
+
load(overrides).then { |content| transform content }
|
20
|
+
.bind { |content| validate content }
|
21
|
+
.bind { |content| record content }
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
attr_reader :registry
|
27
|
+
|
28
|
+
# :reek:NestedIterators
|
29
|
+
# :reek:TooManyStatements
|
30
|
+
def load overrides
|
31
|
+
registry.loaders
|
32
|
+
.map { |loader| loader.call.fmap { |content| content.flatten_keys.symbolize_keys! } }
|
33
|
+
.each
|
34
|
+
.with_object({}) { |content, all| content.bind { |body| all.merge! body } }
|
35
|
+
.merge!(overrides.flatten_keys)
|
36
|
+
.then { |content| Success content }
|
37
|
+
end
|
38
|
+
|
39
|
+
# :reek:NestedIterators
|
40
|
+
def transform content
|
41
|
+
registry.transformers.reduce content do |all, transformer|
|
42
|
+
all.bind { |body| transformer.call body }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def validate content
|
47
|
+
registry.contract
|
48
|
+
.call(content)
|
49
|
+
.to_monad
|
50
|
+
.or { |result| Failure(step: __method__, payload: result.errors.to_h) }
|
51
|
+
end
|
52
|
+
|
53
|
+
def record content
|
54
|
+
Success registry.model[**content.to_h].freeze
|
55
|
+
rescue ArgumentError => error
|
56
|
+
Failure step: __method__, payload: "#{error.message.capitalize}."
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "core"
|
4
|
+
require "dry/monads"
|
5
|
+
|
6
|
+
module Etcher
|
7
|
+
module Loaders
|
8
|
+
# Loads environment configuration with optional includes.
|
9
|
+
class Environment
|
10
|
+
include Dry::Monads[:result]
|
11
|
+
|
12
|
+
def initialize includes = Core::EMPTY_ARRAY, source: ENV
|
13
|
+
@includes = Array includes
|
14
|
+
@source = source
|
15
|
+
end
|
16
|
+
|
17
|
+
def call = Success source.slice(*includes).transform_keys(&:downcase)
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
attr_reader :includes, :source
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "core"
|
4
|
+
require "dry/monads"
|
5
|
+
require "json"
|
6
|
+
|
7
|
+
module Etcher
|
8
|
+
module Loaders
|
9
|
+
# Loads a JSON configuration.
|
10
|
+
class JSON
|
11
|
+
include Dry::Monads[:result]
|
12
|
+
|
13
|
+
def initialize path, fallback: Core::EMPTY_HASH, logger: LOGGER
|
14
|
+
@path = path
|
15
|
+
@fallback = fallback
|
16
|
+
@logger = logger
|
17
|
+
end
|
18
|
+
|
19
|
+
def call
|
20
|
+
Success ::JSON.load_file(path)
|
21
|
+
rescue TypeError, Errno::ENOENT
|
22
|
+
debug_and_fallback "Invalid path: #{path_info}. Using fallback."
|
23
|
+
rescue ::JSON::ParserError => error
|
24
|
+
debug_and_fallback "#{error.message}. Path: #{path_info}. Using fallback."
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
attr_reader :path, :fallback, :logger
|
30
|
+
|
31
|
+
def path_info = path.to_s.inspect
|
32
|
+
|
33
|
+
def debug_and_fallback message
|
34
|
+
logger.debug { message }
|
35
|
+
Success fallback
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "core"
|
4
|
+
require "dry/monads"
|
5
|
+
require "yaml"
|
6
|
+
|
7
|
+
module Etcher
|
8
|
+
module Loaders
|
9
|
+
# Loads a YAML configuration.
|
10
|
+
class YAML
|
11
|
+
include Dry::Monads[:result]
|
12
|
+
|
13
|
+
def initialize path, fallback: Core::EMPTY_HASH, logger: LOGGER
|
14
|
+
@path = path
|
15
|
+
@fallback = fallback
|
16
|
+
@logger = logger
|
17
|
+
end
|
18
|
+
|
19
|
+
def call
|
20
|
+
load
|
21
|
+
rescue TypeError, Errno::ENOENT
|
22
|
+
debug_and_fallback "Invalid path: #{path_info}. Using fallback."
|
23
|
+
rescue Psych::Exception => error
|
24
|
+
debug_and_fallback "#{error.message}. Path: #{path_info}. Using fallback."
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
attr_reader :path, :fallback, :logger
|
30
|
+
|
31
|
+
def load
|
32
|
+
content = ::YAML.safe_load_file path
|
33
|
+
|
34
|
+
return Success content if content.is_a? Hash
|
35
|
+
|
36
|
+
debug_and_fallback "Invalid content: #{content.inspect}. Using fallback."
|
37
|
+
end
|
38
|
+
|
39
|
+
def path_info = path.to_s.inspect
|
40
|
+
|
41
|
+
def debug_and_fallback message
|
42
|
+
logger.debug { message }
|
43
|
+
Success fallback
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Etcher
|
4
|
+
# Provides a registry of customization for loading and resolving a configuration.
|
5
|
+
Registry = Data.define :contract, :model, :loaders, :transformers do
|
6
|
+
def initialize contract: Contract, model: Hash, loaders: [], transformers: []
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
def add_loader loader
|
11
|
+
loaders.append loader
|
12
|
+
self
|
13
|
+
end
|
14
|
+
|
15
|
+
def add_transformer transformer
|
16
|
+
transformers.append transformer
|
17
|
+
self
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "dry/monads"
|
4
|
+
require "refinements/arrays"
|
5
|
+
|
6
|
+
module Etcher
|
7
|
+
# Builds and fully resolves a configuration.
|
8
|
+
class Resolver
|
9
|
+
include Dry::Monads[:result]
|
10
|
+
|
11
|
+
using Refinements::Arrays
|
12
|
+
|
13
|
+
def initialize registry = Registry.new, kernel: Kernel, logger: LOGGER
|
14
|
+
@builder = Builder.new registry
|
15
|
+
@kernel = kernel
|
16
|
+
@logger = logger
|
17
|
+
end
|
18
|
+
|
19
|
+
def call(**overrides)
|
20
|
+
case builder.call(**overrides)
|
21
|
+
in Success(content) then content
|
22
|
+
in Failure(step:, payload: String => payload)
|
23
|
+
logger.fatal { "Build failure: #{step.inspect}. #{payload}" }
|
24
|
+
kernel.abort
|
25
|
+
in Failure(step:, payload: Hash => payload) then log_and_abort payload
|
26
|
+
else fail StandardError, "Unable to parse configuration."
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
attr_reader :builder, :kernel, :logger
|
33
|
+
|
34
|
+
def log_and_abort errors
|
35
|
+
logger.fatal do
|
36
|
+
details = errors.map { |key, message| " - #{key} #{message.to_sentence}\n" }
|
37
|
+
.join
|
38
|
+
"Unable to load configuration due to the following issues:\n#{details}"
|
39
|
+
end
|
40
|
+
|
41
|
+
kernel.abort
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/etcher.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "cogger"
|
4
|
+
require "zeitwerk"
|
5
|
+
|
6
|
+
Zeitwerk::Loader.for_gem.then do |loader|
|
7
|
+
loader.inflector.inflect "json" => "JSON", "yaml" => "YAML"
|
8
|
+
loader.setup
|
9
|
+
end
|
10
|
+
|
11
|
+
# Main namespace.
|
12
|
+
module Etcher
|
13
|
+
LOGGER = Cogger.new id: :etcher, formatter: :emoji
|
14
|
+
|
15
|
+
def self.new(...) = Builder.new(...)
|
16
|
+
|
17
|
+
def self.call(registry = Registry.new, **) = Resolver.new(registry).call(**)
|
18
|
+
end
|
data.tar.gz.sig
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: etcher
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brooke Kuhlmann
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIEeDCCAuCgAwIBAgIBATANBgkqhkiG9w0BAQsFADBBMQ8wDQYDVQQDDAZicm9v
|
14
|
+
a2UxGjAYBgoJkiaJk/IsZAEZFgphbGNoZW1pc3RzMRIwEAYKCZImiZPyLGQBGRYC
|
15
|
+
aW8wHhcNMjMwMzIyMTYxNDQxWhcNMjUwMzIxMTYxNDQxWjBBMQ8wDQYDVQQDDAZi
|
16
|
+
cm9va2UxGjAYBgoJkiaJk/IsZAEZFgphbGNoZW1pc3RzMRIwEAYKCZImiZPyLGQB
|
17
|
+
GRYCaW8wggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQCro8tj5/E1Hg88
|
18
|
+
f4qfiwPVd2zJQHvdYt4GHVvuHRRgx4HGhJuNp+4BId08RBn7V6V1MW6MY3kezRBs
|
19
|
+
M+7QOQ4b1xNLTvY7FYQB1wGK5a4x7TTokDrPYQxDB2jmsdDYCzVbIMrAvUfcecRi
|
20
|
+
khyGZCdByiiCl4fKv77P12tTT+NfsvXkLt/AYCGwjOUyGKTQ01Z6eC09T27GayPH
|
21
|
+
QQvIkakyFgcJtzSyGzs8bzK5q9u7wQ12MNTjJoXzW69lqp0oNvDylu81EiSUb5S6
|
22
|
+
QzzPxZBiRB1sgtbt1gUbVI262ZDq1gR+HxPFmp+Cgt7ZLIJZAtesQvtcMzseXpfn
|
23
|
+
hpmm0Sw22KGhRAy/mqHBRhDl5HqS1SJp2Ko3lcnpXeFResp0HNlt8NSu13vhC08j
|
24
|
+
GUHU9MyIXbFOsnp3K3ADrAVjPWop8EZkmUR3MV/CUm00w2cZHCSGiXl1KMpiVKvk
|
25
|
+
Ywr1gd2ZME4QLSo+EXUtLxDUa/W3xnBS8dBOuMMz02FPWYr3PN8CAwEAAaN7MHkw
|
26
|
+
CQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFAFgmv0tYMZnItuPycSM
|
27
|
+
F5wykJEVMB8GA1UdEQQYMBaBFGJyb29rZUBhbGNoZW1pc3RzLmlvMB8GA1UdEgQY
|
28
|
+
MBaBFGJyb29rZUBhbGNoZW1pc3RzLmlvMA0GCSqGSIb3DQEBCwUAA4IBgQAX+EGY
|
29
|
+
9RLYGxF1VLZz+G1ACQc4uyrCB6kXwI06kzUa5dF9tPXqTX9ffnz3/W8ck2IQhKzu
|
30
|
+
MKO2FVijzbDWTsZeZGglS4E+4Jxpau1lU9HhOIcKolv6LeC6UdALTFudY+GLb8Xw
|
31
|
+
REXgaJkjzzhkUSILmEnRwEbY08dVSl7ZAaxVI679vfI2yapLlIwpbBgmQTiTvPr3
|
32
|
+
qyyLUno9flYEOv9fmGHunSrM+gE0/0niGTXa5GgXBXYGS2he4LQGgSBfGp/cTwMU
|
33
|
+
rDKJRcusZ12lNBeDfgqACz/BBJF8FLodgk6rGMRZz7+ZmjjHEmpG5bQpR6Q2BuWL
|
34
|
+
XMtYk/QzaWuhiR7pWjiF8jbdd7RO6or0ohq7iFkokz/5xrtQ/vPzU2RQ3Qc6YaKw
|
35
|
+
3n5C8/6Zh9DYTkpcwPSuIfAga6wf4nXc9m6JAw8AuMLaiWN/r/2s4zJsUHYERJEu
|
36
|
+
gZGm4JqtuSg8pYjPeIJxS960owq+SfuC+jxqmRA54BisFCv/0VOJi7tiJVY=
|
37
|
+
-----END CERTIFICATE-----
|
38
|
+
date: 2023-04-23 00:00:00.000000000 Z
|
39
|
+
dependencies:
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: cogger
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0.9'
|
47
|
+
type: :runtime
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0.9'
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: core
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0.1'
|
61
|
+
type: :runtime
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0.1'
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: dry-monads
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '1.6'
|
75
|
+
type: :runtime
|
76
|
+
prerelease: false
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '1.6'
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: refinements
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '10.0'
|
89
|
+
type: :runtime
|
90
|
+
prerelease: false
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '10.0'
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
name: zeitwerk
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '2.6'
|
103
|
+
type: :runtime
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '2.6'
|
110
|
+
description:
|
111
|
+
email:
|
112
|
+
- brooke@alchemists.io
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files:
|
116
|
+
- README.adoc
|
117
|
+
- LICENSE.adoc
|
118
|
+
files:
|
119
|
+
- LICENSE.adoc
|
120
|
+
- README.adoc
|
121
|
+
- etcher.gemspec
|
122
|
+
- lib/etcher.rb
|
123
|
+
- lib/etcher/builder.rb
|
124
|
+
- lib/etcher/contract.rb
|
125
|
+
- lib/etcher/loaders/environment.rb
|
126
|
+
- lib/etcher/loaders/json.rb
|
127
|
+
- lib/etcher/loaders/yaml.rb
|
128
|
+
- lib/etcher/registry.rb
|
129
|
+
- lib/etcher/resolver.rb
|
130
|
+
homepage: https://alchemists.io/projects/etcher
|
131
|
+
licenses:
|
132
|
+
- Hippocratic-2.1
|
133
|
+
metadata:
|
134
|
+
bug_tracker_uri: https://github.com/bkuhlmann/etcher/issues
|
135
|
+
changelog_uri: https://alchemists.io/projects/etcher/versions
|
136
|
+
documentation_uri: https://alchemists.io/projects/etcher
|
137
|
+
funding_uri: https://github.com/sponsors/bkuhlmann
|
138
|
+
label: Etcher
|
139
|
+
rubygems_mfa_required: 'true'
|
140
|
+
source_code_uri: https://github.com/bkuhlmann/etcher
|
141
|
+
post_install_message:
|
142
|
+
rdoc_options: []
|
143
|
+
require_paths:
|
144
|
+
- lib
|
145
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - "~>"
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '3.2'
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
requirements: []
|
156
|
+
rubygems_version: 3.4.12
|
157
|
+
signing_key:
|
158
|
+
specification_version: 4
|
159
|
+
summary: A configuration loader, transformer, and validator.
|
160
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|