rubysmith 4.9.0 → 5.0.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 +0 -0
- data/README.adoc +91 -117
- data/lib/rubysmith/builders/core.rb +0 -1
- data/lib/rubysmith/cli/actions/amazing_print.rb +25 -0
- data/lib/rubysmith/cli/actions/caliber.rb +25 -0
- data/lib/rubysmith/cli/actions/circle_ci.rb +25 -0
- data/lib/rubysmith/cli/actions/citation.rb +25 -0
- data/lib/rubysmith/cli/actions/community.rb +25 -0
- data/lib/rubysmith/cli/actions/conduct.rb +25 -0
- data/lib/rubysmith/cli/actions/console.rb +25 -0
- data/lib/rubysmith/cli/actions/contributions.rb +25 -0
- data/lib/rubysmith/cli/actions/debug.rb +25 -0
- data/lib/rubysmith/cli/actions/funding.rb +25 -0
- data/lib/rubysmith/cli/actions/git.rb +25 -0
- data/lib/rubysmith/cli/actions/git_hub.rb +25 -0
- data/lib/rubysmith/cli/actions/git_hub_ci.rb +25 -0
- data/lib/rubysmith/cli/actions/git_lint.rb +25 -0
- data/lib/rubysmith/cli/actions/guard.rb +25 -0
- data/lib/rubysmith/cli/actions/license.rb +25 -0
- data/lib/rubysmith/cli/actions/maximum.rb +25 -0
- data/lib/rubysmith/cli/actions/minimum.rb +25 -0
- data/lib/rubysmith/cli/actions/name.rb +23 -0
- data/lib/rubysmith/cli/actions/publish.rb +16 -4
- data/lib/rubysmith/cli/actions/rake.rb +25 -0
- data/lib/rubysmith/cli/actions/readme.rb +25 -0
- data/lib/rubysmith/cli/actions/reek.rb +25 -0
- data/lib/rubysmith/cli/actions/refinements.rb +25 -0
- data/lib/rubysmith/cli/actions/rspec.rb +25 -0
- data/lib/rubysmith/cli/actions/security.rb +25 -0
- data/lib/rubysmith/cli/actions/setup.rb +25 -0
- data/lib/rubysmith/cli/actions/simple_cov.rb +25 -0
- data/lib/rubysmith/cli/actions/versions.rb +25 -0
- data/lib/rubysmith/cli/actions/yard.rb +25 -0
- data/lib/rubysmith/cli/actions/zeitwerk.rb +25 -0
- data/lib/rubysmith/cli/{actions → commands}/build.rb +45 -7
- data/lib/rubysmith/cli/shell.rb +20 -18
- data/lib/rubysmith/configuration/contract.rb +78 -0
- data/lib/rubysmith/configuration/defaults.yml +52 -73
- data/lib/rubysmith/configuration/{content.rb → model.rb} +8 -22
- data/lib/rubysmith/configuration/transformers/current_time.rb +18 -0
- data/lib/rubysmith/configuration/transformers/git_email.rb +19 -0
- data/lib/rubysmith/configuration/transformers/git_hub_user.rb +19 -0
- data/lib/rubysmith/configuration/transformers/git_user.rb +24 -0
- data/lib/rubysmith/configuration/transformers/target_root.rb +18 -0
- data/lib/rubysmith/configuration/transformers/template_root.rb +22 -0
- data/lib/rubysmith/container.rb +21 -3
- data/lib/rubysmith/extensions/milestoner.rb +1 -1
- data/lib/rubysmith/extensions/pragmater.rb +8 -8
- data/lib/rubysmith/extensions/tocer.rb +8 -8
- data/lib/rubysmith/pathway.rb +1 -0
- data/lib/rubysmith/templates/%project_name%/Gemfile.erb +4 -4
- data/rubysmith.gemspec +16 -13
- data.tar.gz.sig +0 -0
- metadata +112 -46
- metadata.gz.sig +0 -0
- data/lib/rubysmith/cli/actions/config.rb +0 -33
- data/lib/rubysmith/cli/actions/container.rb +0 -20
- data/lib/rubysmith/cli/actions/import.rb +0 -11
- data/lib/rubysmith/cli/parser.rb +0 -35
- data/lib/rubysmith/cli/parsers/build.rb +0 -307
- data/lib/rubysmith/cli/parsers/core.rb +0 -72
- data/lib/rubysmith/configuration/enhancers/container.rb +0 -20
- data/lib/rubysmith/configuration/enhancers/current_time.rb +0 -14
- data/lib/rubysmith/configuration/enhancers/git_email.rb +0 -21
- data/lib/rubysmith/configuration/enhancers/git_hub_user.rb +0 -21
- data/lib/rubysmith/configuration/enhancers/git_user.rb +0 -25
- data/lib/rubysmith/configuration/enhancers/template_root.rb +0 -12
- data/lib/rubysmith/configuration/loader.rb +0 -44
@@ -1,307 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "core"
|
4
|
-
require "refinements/structs"
|
5
|
-
|
6
|
-
module Rubysmith
|
7
|
-
module CLI
|
8
|
-
module Parsers
|
9
|
-
# Handles parsing of Command Line Interface (CLI) build options.
|
10
|
-
class Build
|
11
|
-
include Import[:color]
|
12
|
-
|
13
|
-
using Refinements::Structs
|
14
|
-
|
15
|
-
def self.call(...) = new(...).call
|
16
|
-
|
17
|
-
def initialize(configuration = Container[:configuration], client: Parser::CLIENT, **)
|
18
|
-
super(**)
|
19
|
-
@configuration = configuration
|
20
|
-
@client = client
|
21
|
-
end
|
22
|
-
|
23
|
-
def call arguments = ::Core::EMPTY_ARRAY
|
24
|
-
client.separator "\nBUILD OPTIONS:\n"
|
25
|
-
collate
|
26
|
-
client.parse arguments
|
27
|
-
configuration
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
attr_reader :configuration, :client
|
33
|
-
|
34
|
-
def collate = private_methods.sort.grep(/add_/).each { |method| __send__ method }
|
35
|
-
|
36
|
-
def add_amazing_print
|
37
|
-
client.on(
|
38
|
-
"--[no-]amazing_print",
|
39
|
-
"Add Amazing Print gem. #{default __method__}."
|
40
|
-
) do |value|
|
41
|
-
configuration.merge! build_amazing_print: value
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def add_caliber
|
46
|
-
client.on(
|
47
|
-
"--[no-]caliber",
|
48
|
-
"Add Caliber gem. #{default __method__}."
|
49
|
-
) do |value|
|
50
|
-
configuration.merge! build_caliber: value
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def add_console
|
55
|
-
client.on(
|
56
|
-
"--[no-]console",
|
57
|
-
"Add console script. #{default __method__}."
|
58
|
-
) do |value|
|
59
|
-
configuration.merge! build_console: value
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def add_contributions
|
64
|
-
client.on(
|
65
|
-
"--[no-]contributions",
|
66
|
-
"Add contributions documentation. #{default __method__}."
|
67
|
-
) do |value|
|
68
|
-
configuration.merge! build_contributions: value
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def add_circle_ci
|
73
|
-
client.on(
|
74
|
-
"--[no-]circle_ci",
|
75
|
-
"Add Circle CI configuration and badge. #{default __method__}."
|
76
|
-
) do |value|
|
77
|
-
configuration.merge! build_circle_ci: value
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def add_citation
|
82
|
-
client.on(
|
83
|
-
"--[no-]citation",
|
84
|
-
"Add citation documentation. #{default __method__}."
|
85
|
-
) do |value|
|
86
|
-
configuration.merge! build_citation: value
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def add_community
|
91
|
-
client.on(
|
92
|
-
"--[no-]community",
|
93
|
-
"Add community documentation. #{default __method__}."
|
94
|
-
) do |value|
|
95
|
-
configuration.merge! build_community: value
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def add_conduct
|
100
|
-
client.on(
|
101
|
-
"--[no-]conduct",
|
102
|
-
"Add code of conduct documentation. #{default __method__}."
|
103
|
-
) do |value|
|
104
|
-
configuration.merge! build_conduct: value
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
def add_debug
|
109
|
-
client.on(
|
110
|
-
"--[no-]debug",
|
111
|
-
"Add Debug gem. #{default __method__}."
|
112
|
-
) do |value|
|
113
|
-
configuration.merge! build_debug: value
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def add_funding
|
118
|
-
client.on(
|
119
|
-
"--[no-]funding",
|
120
|
-
"Add GitHub funding configuration. #{default __method__}."
|
121
|
-
) do |value|
|
122
|
-
configuration.merge! build_funding: value
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
def add_git
|
127
|
-
client.on(
|
128
|
-
"--[no-]git",
|
129
|
-
"Add Git. #{default __method__}."
|
130
|
-
) do |value|
|
131
|
-
configuration.merge! build_git: value
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
def add_git_hub
|
136
|
-
client.on(
|
137
|
-
"--[no-]git_hub",
|
138
|
-
"Add GitHub templates. #{default __method__}."
|
139
|
-
) do |value|
|
140
|
-
configuration.merge! build_git_hub: value
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
def add_git_hub_ci
|
145
|
-
client.on(
|
146
|
-
"--[no-]git_hub_ci",
|
147
|
-
"Add GitHub templates. #{default __method__}."
|
148
|
-
) do |value|
|
149
|
-
configuration.merge! build_git_hub_ci: value
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
def add_git_lint
|
154
|
-
client.on(
|
155
|
-
"--[no-]git-lint",
|
156
|
-
"Add Git Lint gem. #{default __method__}."
|
157
|
-
) do |value|
|
158
|
-
configuration.merge! build_git_lint: value
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
def add_guard
|
163
|
-
client.on(
|
164
|
-
"--[no-]guard",
|
165
|
-
"Add Guard gem. #{default __method__}."
|
166
|
-
) do |value|
|
167
|
-
configuration.merge! build_guard: value
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
def add_license
|
172
|
-
client.on(
|
173
|
-
"--[no-]license",
|
174
|
-
"Add license documentation. #{default __method__}."
|
175
|
-
) do |value|
|
176
|
-
configuration.merge! build_license: value
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
def add_maximum
|
181
|
-
client.on(
|
182
|
-
"--max",
|
183
|
-
"Use maximum/enabled options. #{default __method__}."
|
184
|
-
) do
|
185
|
-
configuration.merge!(**configuration.maximize.to_h)
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
def add_minimum
|
190
|
-
client.on(
|
191
|
-
"--min",
|
192
|
-
"Use minimum/disabled options. #{default __method__}."
|
193
|
-
) do
|
194
|
-
configuration.merge!(**configuration.minimize.to_h)
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
def add_rake
|
199
|
-
client.on(
|
200
|
-
"--[no-]rake",
|
201
|
-
"Add Rake gem. #{default __method__}."
|
202
|
-
) do |value|
|
203
|
-
configuration.merge! build_rake: value
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
def add_readme
|
208
|
-
client.on(
|
209
|
-
"--[no-]readme",
|
210
|
-
"Add readme documentation. #{default __method__}."
|
211
|
-
) do |value|
|
212
|
-
configuration.merge! build_readme: value
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
def add_reek
|
217
|
-
client.on(
|
218
|
-
"--[no-]reek",
|
219
|
-
"Add Reek gem. #{default __method__}."
|
220
|
-
) do |value|
|
221
|
-
configuration.merge! build_reek: value
|
222
|
-
end
|
223
|
-
end
|
224
|
-
|
225
|
-
def add_refinements
|
226
|
-
client.on(
|
227
|
-
"--[no-]refinements",
|
228
|
-
"Add Refinements gem. #{default __method__}."
|
229
|
-
) do |value|
|
230
|
-
configuration.merge! build_refinements: value
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
def add_rspec
|
235
|
-
client.on(
|
236
|
-
"--[no-]rspec",
|
237
|
-
"Add RSpec gem. #{default __method__}."
|
238
|
-
) do |value|
|
239
|
-
configuration.merge! build_rspec: value
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
def add_security
|
244
|
-
client.on(
|
245
|
-
"--[no-]security",
|
246
|
-
"Add security. #{default __method__}."
|
247
|
-
) do |value|
|
248
|
-
configuration.merge! build_security: value
|
249
|
-
end
|
250
|
-
end
|
251
|
-
|
252
|
-
def add_setup
|
253
|
-
client.on(
|
254
|
-
"--[no-]setup",
|
255
|
-
"Add setup script. #{default __method__}."
|
256
|
-
) do |value|
|
257
|
-
configuration.merge! build_setup: value
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
def add_simple_cov
|
262
|
-
client.on(
|
263
|
-
"--[no-]simple_cov",
|
264
|
-
"Add SimpleCov gem. #{default __method__}."
|
265
|
-
) do |value|
|
266
|
-
configuration.merge! build_simple_cov: value
|
267
|
-
end
|
268
|
-
end
|
269
|
-
|
270
|
-
def add_versions
|
271
|
-
client.on(
|
272
|
-
"--[no-]versions",
|
273
|
-
"Add version history. #{default __method__}."
|
274
|
-
) do |value|
|
275
|
-
configuration.merge! build_versions: value
|
276
|
-
end
|
277
|
-
end
|
278
|
-
|
279
|
-
def add_yard
|
280
|
-
client.on(
|
281
|
-
"--[no-]yard",
|
282
|
-
"Add Yard gem. #{default __method__}."
|
283
|
-
) do |value|
|
284
|
-
configuration.merge! build_yard: value
|
285
|
-
end
|
286
|
-
end
|
287
|
-
|
288
|
-
def add_zeitwerk
|
289
|
-
client.on(
|
290
|
-
"--[no-]zeitwerk",
|
291
|
-
"Add Zeitwerk gem. #{default __method__}."
|
292
|
-
) do |value|
|
293
|
-
configuration.merge! build_zeitwerk: value
|
294
|
-
end
|
295
|
-
end
|
296
|
-
|
297
|
-
def default option
|
298
|
-
option.to_s
|
299
|
-
.sub("add_", "build_")
|
300
|
-
.then { |attribute| configuration.public_send attribute }
|
301
|
-
.then { |bool| bool ? color[bool, :green] : color[bool, :red] }
|
302
|
-
.then { |colored_boolean| "Default: #{colored_boolean}" }
|
303
|
-
end
|
304
|
-
end
|
305
|
-
end
|
306
|
-
end
|
307
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "core"
|
4
|
-
require "refinements/structs"
|
5
|
-
|
6
|
-
module Rubysmith
|
7
|
-
module CLI
|
8
|
-
module Parsers
|
9
|
-
# Handles parsing of Command Line Interface (CLI) core options.
|
10
|
-
class Core
|
11
|
-
include Import[:specification]
|
12
|
-
|
13
|
-
using Refinements::Structs
|
14
|
-
|
15
|
-
def self.call(...) = new(...).call
|
16
|
-
|
17
|
-
def initialize(configuration = Container[:configuration], client: Parser::CLIENT, **)
|
18
|
-
super(**)
|
19
|
-
@configuration = configuration
|
20
|
-
@client = client
|
21
|
-
end
|
22
|
-
|
23
|
-
def call arguments = ::Core::EMPTY_ARRAY
|
24
|
-
client.banner = specification.labeled_summary
|
25
|
-
client.separator "\nUSAGE:\n"
|
26
|
-
collate
|
27
|
-
client.parse arguments
|
28
|
-
configuration
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
attr_reader :configuration, :client
|
34
|
-
|
35
|
-
def collate = private_methods.sort.grep(/add_/).each { |method| __send__ method }
|
36
|
-
|
37
|
-
def add_config
|
38
|
-
client.on "-c",
|
39
|
-
"--config ACTION",
|
40
|
-
%i[edit view],
|
41
|
-
"Manage gem configuration: edit or view." do |action|
|
42
|
-
configuration.merge! action_config: action
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def add_build
|
47
|
-
client.on "-b", "--build NAME [options]", "Build new project." do |name|
|
48
|
-
configuration.merge! action_build: true, project_name: name
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def add_publish
|
53
|
-
client.on "-p", "--publish VERSION", "Publish project." do |version|
|
54
|
-
configuration.merge! action_publish: true, project_version: version
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def add_version
|
59
|
-
client.on "-v", "--version", "Show gem version." do
|
60
|
-
configuration.merge! action_version: true
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def add_help
|
65
|
-
client.on "-h", "--help", "Show this message." do
|
66
|
-
configuration.merge! action_help: true
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "dry/container"
|
4
|
-
|
5
|
-
module Rubysmith
|
6
|
-
module Configuration
|
7
|
-
module Enhancers
|
8
|
-
# Provides a container of enhancers for injection into other objects.
|
9
|
-
module Container
|
10
|
-
extend Dry::Container::Mixin
|
11
|
-
|
12
|
-
register(:current_time) { Enhancers::CurrentTime }
|
13
|
-
register(:git_hub_user) { Enhancers::GitHubUser }
|
14
|
-
register(:git_email) { Enhancers::GitEmail }
|
15
|
-
register(:git_user) { Enhancers::GitUser }
|
16
|
-
register(:template_root) { Enhancers::TemplateRoot }
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "refinements/structs"
|
4
|
-
|
5
|
-
module Rubysmith
|
6
|
-
module Configuration
|
7
|
-
# Adds current time to content.
|
8
|
-
module Enhancers
|
9
|
-
using Refinements::Structs
|
10
|
-
|
11
|
-
CurrentTime = -> content, at: Time.now { content.merge(now: at) }
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "gitt"
|
4
|
-
require "refinements/strings"
|
5
|
-
require "refinements/structs"
|
6
|
-
|
7
|
-
module Rubysmith
|
8
|
-
module Configuration
|
9
|
-
# Dynamically adds Git email if defined.
|
10
|
-
module Enhancers
|
11
|
-
using Refinements::Strings
|
12
|
-
using Refinements::Structs
|
13
|
-
|
14
|
-
GitEmail = lambda do |content, git: Gitt::Repository.new|
|
15
|
-
return content unless String(content.author_email).blank?
|
16
|
-
|
17
|
-
content.merge author_email: git.get("user.email").value_or("")
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "gitt"
|
4
|
-
require "refinements/strings"
|
5
|
-
require "refinements/structs"
|
6
|
-
|
7
|
-
module Rubysmith
|
8
|
-
module Configuration
|
9
|
-
# Dynamically adds GitHub user if user is defined.
|
10
|
-
module Enhancers
|
11
|
-
using Refinements::Strings
|
12
|
-
using Refinements::Structs
|
13
|
-
|
14
|
-
GitHubUser = lambda do |content, git: Gitt::Repository.new|
|
15
|
-
return content unless String(content.git_hub_user).blank?
|
16
|
-
|
17
|
-
content.merge git_hub_user: git.get("github.user").value_or("default")
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "gitt"
|
4
|
-
require "refinements/strings"
|
5
|
-
require "refinements/structs"
|
6
|
-
|
7
|
-
module Rubysmith
|
8
|
-
module Configuration
|
9
|
-
# Dynamically adds Git user if defined.
|
10
|
-
module Enhancers
|
11
|
-
using Refinements::Strings
|
12
|
-
using Refinements::Structs
|
13
|
-
|
14
|
-
GitUser = lambda do |content, git: Gitt::Repository.new|
|
15
|
-
return content unless String(content.author_name).blank?
|
16
|
-
|
17
|
-
git.get("user.name")
|
18
|
-
.value_or("")
|
19
|
-
.then { |name| String(name).split }
|
20
|
-
.then { |first, last| {author_given_name: first, author_family_name: last} }
|
21
|
-
.then { |user| content.merge(**user) }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Rubysmith
|
4
|
-
module Configuration
|
5
|
-
module Enhancers
|
6
|
-
# Prepends template roots to existing content.
|
7
|
-
TemplateRoot = lambda do |content, overrides: Pathname(__dir__).join("../../templates")|
|
8
|
-
content.add_template_roots(*Array(overrides))
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "pathname"
|
4
|
-
require "refinements/hashes"
|
5
|
-
require "refinements/structs"
|
6
|
-
require "runcom"
|
7
|
-
require "yaml"
|
8
|
-
|
9
|
-
module Rubysmith
|
10
|
-
module Configuration
|
11
|
-
# Represents the fully assembled Command Line Interface (CLI) configuration.
|
12
|
-
class Loader
|
13
|
-
using Refinements::Hashes
|
14
|
-
using Refinements::Structs
|
15
|
-
|
16
|
-
DEFAULTS = YAML.load_file(Pathname(__dir__).join("defaults.yml")).freeze
|
17
|
-
CLIENT = Runcom::Config.new "rubysmith/configuration.yml", defaults: DEFAULTS
|
18
|
-
|
19
|
-
def self.call(...) = new(...).call
|
20
|
-
|
21
|
-
def self.with_defaults = new(client: DEFAULTS, enhancers: {})
|
22
|
-
|
23
|
-
def initialize content: Content.new, client: CLIENT, enhancers: Enhancers::Container
|
24
|
-
@content = content
|
25
|
-
@client = client
|
26
|
-
@enhancers = enhancers
|
27
|
-
end
|
28
|
-
|
29
|
-
def call
|
30
|
-
enhancers.each
|
31
|
-
.reduce(preload_content) { |preload, (_key, enhancer)| enhancer.call preload }
|
32
|
-
.freeze
|
33
|
-
end
|
34
|
-
|
35
|
-
protected
|
36
|
-
|
37
|
-
attr_reader :content, :client, :enhancers
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
def preload_content = content.merge(**client.to_h.flatten_keys)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|