pennyworth 11.1.3 → 12.0.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/LICENSE.adoc +207 -155
- data/README.adoc +159 -40
- data/{bin → exe}/pennyworth +0 -0
- data/lib/pennyworth/cli/actions/config.rb +1 -1
- data/lib/pennyworth/cli/actions/encodings.rb +1 -1
- data/lib/pennyworth/cli/actions/git_hub.rb +1 -1
- data/lib/pennyworth/cli/actions/http_statuses.rb +1 -1
- data/lib/pennyworth/cli/actions/ruby_gems.rb +1 -1
- data/lib/pennyworth/cli/actions/system/errors.rb +1 -1
- data/lib/pennyworth/cli/actions/system/signals.rb +1 -1
- data/lib/pennyworth/cli/actions/text.rb +1 -1
- data/lib/pennyworth/cli/parser.rb +33 -0
- data/lib/pennyworth/cli/parsers/core.rb +4 -3
- data/lib/pennyworth/cli/parsers/git_hub.rb +3 -2
- data/lib/pennyworth/cli/parsers/ruby_gems.rb +3 -2
- data/lib/pennyworth/cli/shell.rb +3 -3
- data/lib/pennyworth/configuration/content.rb +33 -0
- data/lib/pennyworth/{cli/configuration → configuration}/defaults.yml +0 -0
- data/lib/pennyworth/configuration/loader.rb +35 -0
- data/lib/pennyworth/container.rb +1 -1
- data/lib/pennyworth/identity.rb +1 -1
- data/lib/pennyworth/inflector.rb +1 -1
- data/lib/pennyworth/integrations/git_hub/client.rb +1 -1
- data/lib/pennyworth/loaders/http_statuses.rb +2 -2
- data/lib/pennyworth/loaders/system/signals.rb +1 -1
- data/lib/pennyworth.rb +6 -5
- data.tar.gz.sig +0 -0
- metadata +18 -18
- metadata.gz.sig +0 -0
- data/lib/pennyworth/cli/configuration/content.rb +0 -28
- data/lib/pennyworth/cli/configuration/loader.rb +0 -37
- data/lib/pennyworth/cli/parsers/assembler.rb +0 -32
- data/lib/pennyworth/cli/parsers.rb +0 -11
data/README.adoc
CHANGED
@@ -16,7 +16,7 @@ image::https://circleci.com/gh/bkuhlmann/pennyworth.svg?style=svg[Circle CI Stat
|
|
16
16
|
Pennyworth is a command line interface and the perfect companion to
|
17
17
|
link:https://www.alfredapp.com[Alfred]. With Pennyworth, you can unlock the full potential of the
|
18
18
|
Ruby language by leveraging modern versions of Ruby through Alfred Workflows. Perfect for when you
|
19
|
-
want to advance beyond the
|
19
|
+
want to advance beyond the basic workflows Alfred provides by default.
|
20
20
|
|
21
21
|
toc::[]
|
22
22
|
|
@@ -36,9 +36,18 @@ video::https://www.alchemists.io/videos/projects/pennyworth/demo.mp4[poster=http
|
|
36
36
|
. link:https://www.gnu.org/software/bash[Bash]
|
37
37
|
. link:https://www.alfredapp.com[Alfred]
|
38
38
|
. link:https://www.alfredapp.com/purchase[Alfred Powerpack]
|
39
|
-
. {frum_link}
|
40
39
|
. link:https://www.ruby-lang.org[Ruby]
|
41
40
|
|
41
|
+
While using a Ruby version manager -- like {frum_link} -- is not a hard requirement, it is strongly
|
42
|
+
encouraged since a version manager will give you the freedom to toggle between different Ruby
|
43
|
+
versions since this gem has strict Ruby version requirements (especially in regards to using a
|
44
|
+
modern version of Ruby).
|
45
|
+
|
46
|
+
I would also like to point out that all of the workflows, scripts, examples for this gem use Bash
|
47
|
+
syntax. That said, if you are comfortable with translating Bash syntax to your shell syntax of
|
48
|
+
choice, you can make this gem work in different shells too. That is beyond the scope of this
|
49
|
+
document, though, so leave that exercise up to you.
|
50
|
+
|
42
51
|
== Setup
|
43
52
|
|
44
53
|
To install, run:
|
@@ -189,7 +198,7 @@ Feel free to take this default configuration, modify, and save as your own custo
|
|
189
198
|
|
190
199
|
=== Themes
|
191
200
|
|
192
|
-
image:https://www.alchemists.io/images/projects/pennyworth/screenshots/alchemists-theme.png[Alchemists Theme,width=
|
201
|
+
image:https://www.alchemists.io/images/projects/pennyworth/screenshots/alchemists-theme.png[Alchemists Theme,width=706,height=632,role=focal_point]
|
193
202
|
|
194
203
|
The above is shared as the link:https://www.alfredapp.com/extras/theme/FSz9kjN1wX[Alchemists Alfred
|
195
204
|
Theme] which can be
|
@@ -198,8 +207,8 @@ directly].
|
|
198
207
|
|
199
208
|
=== Workflows
|
200
209
|
|
201
|
-
Not all workflows require Pennyworth to run properly
|
202
|
-
support, the following assumptions are made:
|
210
|
+
Not all workflows require Pennyworth to run properly (see the _Other_ section below for details).
|
211
|
+
For the workflows that _do_ require Pennyworth support, the following assumptions are made:
|
203
212
|
|
204
213
|
1. Your link:https://www.alchemists.io/projects/dotfiles[Dotfiles] are configured to use
|
205
214
|
link:https://www.gnu.org/software/bash[Bash] and load your environment appropriately. Bash is not
|
@@ -207,6 +216,8 @@ support, the following assumptions are made:
|
|
207
216
|
Alfred to load your development environment before running the Alfred Workflow.
|
208
217
|
2. You have the latest version of Alfred, Ruby, and Pennyworth installed.
|
209
218
|
3. You are using a Ruby version manager, like {frum_link}, which ensures Ruby is on your load path.
|
219
|
+
As mentioned in the _Requirements_ section above, this is not a hard requirement so if you have
|
220
|
+
the correct version of Ruby required by this gem on your path, that'll work too.
|
210
221
|
|
211
222
|
With the above requirements in mind, the following sections document how to download and install all
|
212
223
|
Pennyworth workflows that are compatible with Alfred. Should you want to tweak any of these
|
@@ -230,7 +241,7 @@ image:https://www.alchemists.io/images/projects/pennyworth/screenshots/alchemist
|
|
230
241
|
|
231
242
|
The official link:https://www.alchemists.io[Alchemists] workflow for site navigation.
|
232
243
|
|
233
|
-
1. link:https://www.alchemists.io/public/
|
244
|
+
1. link:https://www.alchemists.io/public/alfred/workflows/alchemists.alfredworkflow[Download] and
|
234
245
|
double click to install.
|
235
246
|
2. Type `ax` to activate.
|
236
247
|
|
@@ -243,7 +254,7 @@ image:https://www.alchemists.io/images/projects/pennyworth/screenshots/dry-gems.
|
|
243
254
|
|
244
255
|
A link:https://dry-rb.org[Dry RB] workflow for navigating all of the Dry RB site.
|
245
256
|
|
246
|
-
1. link:https://www.alchemists.io/public/
|
257
|
+
1. link:https://www.alchemists.io/public/alfred/workflows/dry.alfredworkflow[Download] and double
|
247
258
|
click to install.
|
248
259
|
2. Type `dry` to activate general information and `dryx` for project list.
|
249
260
|
|
@@ -257,7 +268,7 @@ image:https://www.alchemists.io/images/projects/pennyworth/screenshots/rubocop-p
|
|
257
268
|
A link:https://docs.rubocop.org/rubocop[Rubocop] workflow for quick access to documentation,
|
258
269
|
learning about project changes, viewing source code, etc.
|
259
270
|
|
260
|
-
1. link:https://www.alchemists.io/public/
|
271
|
+
1. link:https://www.alchemists.io/public/alfred/workflows/rubocop.alfredworkflow[Download] and
|
261
272
|
double click to install.
|
262
273
|
2. Type `cop` to activate.
|
263
274
|
|
@@ -267,7 +278,7 @@ view issues.
|
|
267
278
|
==== Ruby
|
268
279
|
|
269
280
|
This workflow is feature packed and only requires a
|
270
|
-
link:https://www.alchemists.io/public/
|
281
|
+
link:https://www.alchemists.io/public/alfred/workflows/ruby.alfredworkflow[single download]. Once
|
271
282
|
downloaded, double click to install, and then continue reading to learn all of the
|
272
283
|
capabilities this single workflow provides.
|
273
284
|
|
@@ -290,6 +301,14 @@ use in your own code.
|
|
290
301
|
Type `encodings` to activate. Use `ENTER` to copy label or `OPTION` to copy associated aliases to
|
291
302
|
clipboard.
|
292
303
|
|
304
|
+
===== Gems
|
305
|
+
|
306
|
+
image:https://www.alchemists.io/images/projects/pennyworth/screenshots/ruby-gems.png[Gems,width=706,height=362,role=focal_point]
|
307
|
+
|
308
|
+
Provides access to the RubyGems ecosystem.
|
309
|
+
|
310
|
+
Type `gems` to activate. Use the arrow keys to navigate options and `ENTER` to use.
|
311
|
+
|
293
312
|
===== Hex
|
294
313
|
|
295
314
|
image:https://www.alchemists.io/images/projects/pennyworth/screenshots/ruby-hex.png[Hex,width=706,height=200,role=focal_point]
|
@@ -391,35 +410,129 @@ by macOS.
|
|
391
410
|
==== Other
|
392
411
|
|
393
412
|
The following workflows don't require Pennyworth support but are provided for convenience in case
|
394
|
-
they are of interest/aid to your own productivity.
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
413
|
+
they are of interest/aid to your own productivity.
|
414
|
+
|
415
|
+
===== Acronyms
|
416
|
+
|
417
|
+
Expands acronyms so you can think and type in terms of an acronym but appear as if you typed out the
|
418
|
+
full definition each time.
|
419
|
+
|
420
|
+
1. link:https://www.alchemists.io/public/alfred/workflows/acronyms.alfredworkflow[Download] and
|
421
|
+
double click to install.
|
422
|
+
2. Use any of the macros provided by the workflow to expand acronyms for legibility.
|
423
|
+
|
424
|
+
===== Alpine
|
425
|
+
|
426
|
+
image:https://www.alchemists.io/images/projects/pennyworth/screenshots/alpine.png[Alpine Linux workflow screenshot.,width=706,height=632,role=focal_point]
|
427
|
+
|
428
|
+
Provides link:https://www.alpinelinux.org[Alpine Linux] resources.
|
429
|
+
|
430
|
+
1. link:https://www.alchemists.io/public/alfred/workflows/alpine.alfredworkflow[Download] and double
|
431
|
+
click to install.
|
432
|
+
2. Type `al` to activate.
|
433
|
+
|
434
|
+
===== Applications
|
435
|
+
|
436
|
+
image:https://www.alchemists.io/images/projects/pennyworth/screenshots/applications.png[Applications workflow screenshot.,width=706,height=362,role=focal_point]
|
437
|
+
|
438
|
+
Launches development environment but can be tweaked for your preferences. Using Alfred in this
|
439
|
+
manner ensures your machine boots or restarts quickly and gives you more control over what is
|
440
|
+
launched.
|
441
|
+
|
442
|
+
1. link:https://www.alchemists.io/public/alfred/workflows/applications.alfredworkflow[Download] and
|
443
|
+
double click to install.
|
444
|
+
2. Type `work` to activate.
|
445
|
+
|
446
|
+
===== Browsers
|
447
|
+
|
448
|
+
image:https://www.alchemists.io/images/projects/pennyworth/screenshots/browsers.png[Browsers workflow screenshot.,width=706,height=470,role=focal_point]
|
449
|
+
|
450
|
+
Provides browser related utilities.
|
451
|
+
|
452
|
+
1. link:https://www.alchemists.io/public/alfred/workflows/browsers.alfredworkflow[Download] and
|
453
|
+
double click to install.
|
454
|
+
2. Type `open` to activate.
|
455
|
+
|
456
|
+
===== Bundler
|
457
|
+
|
458
|
+
image:https://www.alchemists.io/images/projects/pennyworth/screenshots/bundler.png[Bundler workflow screenshot.,width=706,height=524,role=focal_point]
|
459
|
+
|
460
|
+
Provides quick access to link:https://bundler.io[Bundler] related resources.
|
461
|
+
|
462
|
+
1. link:https://www.alchemists.io/public/alfred/workflows/bundler.alfredworkflow[Download] and
|
463
|
+
double click to install.
|
464
|
+
2. Type `bundler` to activate.
|
465
|
+
|
466
|
+
===== Elm
|
467
|
+
|
468
|
+
image:https://www.alchemists.io/images/projects/pennyworth/screenshots/elm.png[Elm workflow screenshot.,width=706,height=470,role=focal_point]
|
469
|
+
|
470
|
+
A link:https://elm-lang.org[Elm] workflow for quick access to Elm resources.
|
471
|
+
|
472
|
+
1. link:https://www.alchemists.io/public/alfred/workflows/elm.alfredworkflow[Download] and double
|
473
|
+
click to install.
|
474
|
+
2. Type `elm` to view general information, arrow keys to navigate, and `ENTER` to view information.
|
475
|
+
|
476
|
+
===== Hanami
|
477
|
+
|
478
|
+
image:https://www.alchemists.io/images/projects/pennyworth/screenshots/hanami.png[Hanami workflow screenshot.,width=706,height=632,role=focal_point]
|
479
|
+
|
480
|
+
Provides link:https://hanamirb.org[Hanami] resources.
|
481
|
+
|
482
|
+
1. link:https://www.alchemists.io/public/alfred/workflows/hanami.alfredworkflow[Download] and
|
483
|
+
double click to install.
|
484
|
+
2. Type `h` to activate.
|
485
|
+
|
486
|
+
===== chi.li
|
487
|
+
|
488
|
+
image:https://www.alchemists.io/images/projects/pennyworth/screenshots/chili.png[chi.li workflow screenshot.,width=706,height=200,role=focal_point]
|
489
|
+
|
490
|
+
Shortens URLs using link:https://chl.li[chl.li].
|
491
|
+
|
492
|
+
1. link:https://www.alchemists.io/public/alfred/workflows/chlli.alfredworkflow[Download] and
|
493
|
+
double click to install.
|
494
|
+
2. Type `surl` to activate.
|
495
|
+
|
496
|
+
===== Docker
|
497
|
+
|
498
|
+
image:https://www.alchemists.io/images/projects/pennyworth/screenshots/docker.png[Docker workflow screenshot.,width=706,height=524,role=focal_point]
|
499
|
+
|
500
|
+
Provides link:https://www.docker.com[Docker] resources.
|
501
|
+
|
502
|
+
1. link:https://www.alchemists.io/public/alfred/workflows/docker.alfredworkflow[Download] and
|
503
|
+
double click to install.
|
504
|
+
2. Type `dr` to activate.
|
505
|
+
|
506
|
+
===== macOS
|
507
|
+
|
508
|
+
Provides macOS utilities.
|
509
|
+
|
510
|
+
1. link:https://www.alchemists.io/public/alfred/workflows/mac_os.alfredworkflow[Download] and
|
511
|
+
double click to install.
|
512
|
+
2. Open the workflow to see all available keywords.
|
513
|
+
|
514
|
+
===== Terraform
|
515
|
+
|
516
|
+
image:https://www.alchemists.io/images/projects/pennyworth/screenshots/terraform.png[Terraform workflow screenshot.,width=706,height=632,role=focal_point]
|
517
|
+
|
518
|
+
Provides link:https://www.terraform.io[Terraform] resources.
|
519
|
+
|
520
|
+
1. link:https://www.alchemists.io/public/alfred/workflows/terraform.alfredworkflow[Download] and
|
521
|
+
double click to install.
|
522
|
+
2. Type `tf` to activate.
|
523
|
+
|
524
|
+
===== Text
|
525
|
+
|
526
|
+
Provides general text manipulation utilities beyond the Pennyworth powered _text_ keyword (mentioned
|
527
|
+
earlier).
|
528
|
+
|
529
|
+
1. link:https://www.alchemists.io/public/alfred/workflows/text.alfredworkflow[Download] and
|
530
|
+
double click to install.
|
531
|
+
2. Use any of the following global hotkeys to activate:
|
532
|
+
** `CONTROL + OPTION + COMMAND + o` - Open selected URL in default browser.
|
533
|
+
** `CONTROL + OPTION + COMMAND + d` - View selected word in macOS dictionary.
|
534
|
+
** `CONTROL + OPTION + COMMAND + t` - View selected text as Large Type.
|
535
|
+
** `CONTROL + OPTION + COMMAND + h` - Syntax highlight selected code.
|
423
536
|
|
424
537
|
== Architecture
|
425
538
|
|
@@ -483,14 +596,20 @@ participating in this project you agree to abide by its terms.
|
|
483
596
|
|
484
597
|
Read link:CONTRIBUTING.adoc[CONTRIBUTING] for details.
|
485
598
|
|
599
|
+
== Community
|
600
|
+
|
601
|
+
Feel free to link:https://www.alchemists.io/community[join the commmunity] for discussions related
|
602
|
+
to this project and much more.
|
603
|
+
|
486
604
|
== License
|
487
605
|
|
488
606
|
Read link:LICENSE.adoc[LICENSE] for details.
|
489
607
|
|
490
|
-
==
|
608
|
+
== Changes
|
491
609
|
|
492
610
|
Read link:CHANGES.adoc[CHANGES] for details.
|
493
611
|
|
494
612
|
== Credits
|
495
613
|
|
496
|
-
|
614
|
+
* Built with link:https://www.alchemists.io/projects/gemsmith[Gemsmith].
|
615
|
+
* Engineered by link:https://www.alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
|
data/{bin → exe}/pennyworth
RENAMED
File without changes
|
@@ -5,7 +5,7 @@ module Pennyworth
|
|
5
5
|
module Actions
|
6
6
|
# Handles the configuration action.
|
7
7
|
class Config
|
8
|
-
def initialize configuration: Configuration::Loader::
|
8
|
+
def initialize configuration: Configuration::Loader::CLIENT, container: Container
|
9
9
|
@configuration = configuration
|
10
10
|
@container = container
|
11
11
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "optparse"
|
4
|
+
|
5
|
+
module Pennyworth
|
6
|
+
module CLI
|
7
|
+
# Assembles and parses all Command Line Interface (CLI) options.
|
8
|
+
class Parser
|
9
|
+
CLIENT = OptionParser.new nil, 40, " "
|
10
|
+
SECTIONS = [Parsers::Core, Parsers::GitHub, Parsers::RubyGems].freeze # Order is important.
|
11
|
+
|
12
|
+
def initialize configuration = Configuration::Loader.call,
|
13
|
+
sections: SECTIONS,
|
14
|
+
client: CLIENT
|
15
|
+
@configuration = configuration.dup
|
16
|
+
@sections = sections
|
17
|
+
@client = client
|
18
|
+
end
|
19
|
+
|
20
|
+
def call arguments = []
|
21
|
+
sections.each { |parser| parser.call configuration, client: }
|
22
|
+
client.parse arguments
|
23
|
+
configuration.freeze
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_s = client.to_s
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
attr_reader :configuration, :client, :sections
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -12,7 +12,7 @@ module Pennyworth
|
|
12
12
|
class Core
|
13
13
|
def self.call(...) = new(...).call
|
14
14
|
|
15
|
-
def initialize configuration = Configuration::Loader.call, client: CLIENT
|
15
|
+
def initialize configuration = Configuration::Loader.call, client: Parser::CLIENT
|
16
16
|
@configuration = configuration
|
17
17
|
@client = client
|
18
18
|
end
|
@@ -21,7 +21,8 @@ module Pennyworth
|
|
21
21
|
client.banner = "#{Identity::LABEL} - #{Identity::SUMMARY}"
|
22
22
|
client.separator "\nUSAGE:\n"
|
23
23
|
collate
|
24
|
-
|
24
|
+
client.parse arguments
|
25
|
+
configuration
|
25
26
|
end
|
26
27
|
|
27
28
|
private
|
@@ -85,7 +86,7 @@ module Pennyworth
|
|
85
86
|
|
86
87
|
def add_version
|
87
88
|
client.on "-v", "--version", "Show gem version." do
|
88
|
-
configuration.action_version =
|
89
|
+
configuration.action_version = true
|
89
90
|
end
|
90
91
|
end
|
91
92
|
|
@@ -11,7 +11,7 @@ module Pennyworth
|
|
11
11
|
|
12
12
|
def self.call(...) = new(...).call
|
13
13
|
|
14
|
-
def initialize configuration = Configuration::Loader.call, client: CLIENT
|
14
|
+
def initialize configuration = Configuration::Loader.call, client: Parser::CLIENT
|
15
15
|
@configuration = configuration
|
16
16
|
@client = client
|
17
17
|
end
|
@@ -19,7 +19,8 @@ module Pennyworth
|
|
19
19
|
def call arguments = []
|
20
20
|
client.separator "\nGITHUB OPTIONS:\n"
|
21
21
|
private_methods.sort.grep(/add_/).each { |method| __send__ method }
|
22
|
-
|
22
|
+
client.parse arguments
|
23
|
+
configuration
|
23
24
|
end
|
24
25
|
|
25
26
|
private
|
@@ -7,7 +7,7 @@ module Pennyworth
|
|
7
7
|
class RubyGems
|
8
8
|
def self.call(...) = new(...).call
|
9
9
|
|
10
|
-
def initialize configuration = Configuration::Loader.call, client: CLIENT
|
10
|
+
def initialize configuration = Configuration::Loader.call, client: Parser::CLIENT
|
11
11
|
@configuration = configuration
|
12
12
|
@client = client
|
13
13
|
end
|
@@ -15,7 +15,8 @@ module Pennyworth
|
|
15
15
|
def call arguments = []
|
16
16
|
client.separator "\nRUBYGEMS OPTIONS:\n"
|
17
17
|
add_owner
|
18
|
-
|
18
|
+
client.parse arguments
|
19
|
+
configuration
|
19
20
|
end
|
20
21
|
|
21
22
|
private
|
data/lib/pennyworth/cli/shell.rb
CHANGED
@@ -15,7 +15,7 @@ module Pennyworth
|
|
15
15
|
text: Actions::Text.new
|
16
16
|
}.freeze
|
17
17
|
|
18
|
-
def initialize parser:
|
18
|
+
def initialize parser: Parser.new, actions: ACTIONS, container: Container
|
19
19
|
@parser = parser
|
20
20
|
@actions = actions
|
21
21
|
@container = container
|
@@ -24,7 +24,7 @@ module Pennyworth
|
|
24
24
|
def call arguments = []
|
25
25
|
perform parser.call(arguments)
|
26
26
|
rescue OptionParser::ParseError, KeyError => error
|
27
|
-
logger.error error.message
|
27
|
+
logger.error { error.message }
|
28
28
|
end
|
29
29
|
|
30
30
|
private
|
@@ -43,7 +43,7 @@ module Pennyworth
|
|
43
43
|
in action_system_signals: true then system_signals
|
44
44
|
in action_system_errors: true then system_errors
|
45
45
|
in action_text: String => content then text content
|
46
|
-
in action_version:
|
46
|
+
in action_version: true then logger.info { Identity::VERSION_LABEL }
|
47
47
|
else usage
|
48
48
|
end
|
49
49
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pennyworth
|
4
|
+
module Configuration
|
5
|
+
# Defines configuration content as the primary source of truth for use throughout the gem.
|
6
|
+
Content = Struct.new(
|
7
|
+
:action_encodings,
|
8
|
+
:action_git_hub,
|
9
|
+
:action_http_statuses,
|
10
|
+
:action_ruby_gems,
|
11
|
+
:action_system_errors,
|
12
|
+
:action_system_signals,
|
13
|
+
:action_text,
|
14
|
+
:action_config,
|
15
|
+
:action_version,
|
16
|
+
:action_help,
|
17
|
+
:alfred_preferences,
|
18
|
+
:inflections,
|
19
|
+
:git_hub_api_url,
|
20
|
+
:git_hub_organization,
|
21
|
+
:git_hub_user,
|
22
|
+
:http_statuses_url,
|
23
|
+
:ruby_gems_api_url,
|
24
|
+
:ruby_gems_owner,
|
25
|
+
keyword_init: true
|
26
|
+
) do
|
27
|
+
def initialize *arguments
|
28
|
+
super
|
29
|
+
freeze
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
File without changes
|
@@ -0,0 +1,35 @@
|
|
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 Pennyworth
|
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 "#{Identity::NAME}/configuration.yml", defaults: DEFAULTS
|
18
|
+
|
19
|
+
def self.call = new.call
|
20
|
+
|
21
|
+
def self.with_defaults = new(client: DEFAULTS)
|
22
|
+
|
23
|
+
def initialize content: Content.new, client: CLIENT
|
24
|
+
@content = content
|
25
|
+
@client = client
|
26
|
+
end
|
27
|
+
|
28
|
+
def call = content.merge(**client.to_h.flatten_keys)
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
attr_reader :content, :client
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/pennyworth/container.rb
CHANGED
@@ -10,7 +10,7 @@ module Pennyworth
|
|
10
10
|
module Container
|
11
11
|
extend Dry::Container::Mixin
|
12
12
|
|
13
|
-
register(:configuration) {
|
13
|
+
register(:configuration) { Configuration::Loader.call }
|
14
14
|
register(:environment) { ENV }
|
15
15
|
register(:kernel) { Kernel }
|
16
16
|
register(:http) { HTTP }
|
data/lib/pennyworth/identity.rb
CHANGED
data/lib/pennyworth/inflector.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Pennyworth
|
4
4
|
# Overrides any string to desired form if matched, otherwise answers the original string.
|
5
5
|
class Inflector
|
6
|
-
DEFAULTS = Array(
|
6
|
+
DEFAULTS = Array(Configuration::Loader.call.inflections).reduce({}, :merge)
|
7
7
|
|
8
8
|
def initialize overrides = DEFAULTS
|
9
9
|
@overrides = overrides
|
@@ -8,14 +8,14 @@ module Pennyworth
|
|
8
8
|
class HTTPStatuses
|
9
9
|
def initialize codes: Rack::Utils::HTTP_STATUS_CODES,
|
10
10
|
model: Models::HTTPStatus,
|
11
|
-
configuration:
|
11
|
+
configuration: Configuration::Loader.call
|
12
12
|
@codes = codes
|
13
13
|
@model = model
|
14
14
|
@configuration = configuration
|
15
15
|
end
|
16
16
|
|
17
17
|
def call _omit = nil
|
18
|
-
codes.map { |(code, label)| model[code
|
18
|
+
codes.map { |(code, label)| model[code:, label:, url: "#{url}/#{code}"] }
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
data/lib/pennyworth.rb
CHANGED
@@ -2,11 +2,12 @@
|
|
2
2
|
|
3
3
|
require "zeitwerk"
|
4
4
|
|
5
|
-
|
6
|
-
loader.inflector.inflect "cli" => "CLI",
|
7
|
-
|
8
|
-
|
9
|
-
loader.setup
|
5
|
+
Zeitwerk::Loader.for_gem.then do |loader|
|
6
|
+
loader.inflector.inflect "cli" => "CLI",
|
7
|
+
"http_status" => "HTTPStatus",
|
8
|
+
"http_statuses" => "HTTPStatuses"
|
9
|
+
loader.setup
|
10
|
+
end
|
10
11
|
|
11
12
|
# Main namespace.
|
12
13
|
module Pennyworth
|