pennyworth 14.3.0 → 15.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/README.adoc +32 -84
  4. data/lib/pennyworth/cli/actions/encodings.rb +9 -3
  5. data/lib/pennyworth/cli/actions/git_hub/organization.rb +33 -0
  6. data/lib/pennyworth/cli/actions/git_hub/user.rb +31 -0
  7. data/lib/pennyworth/cli/actions/http_statuses.rb +9 -3
  8. data/lib/pennyworth/cli/actions/ruby_gems.rb +12 -3
  9. data/lib/pennyworth/cli/actions/standard_errors.rb +9 -3
  10. data/lib/pennyworth/cli/actions/system/errors.rb +9 -3
  11. data/lib/pennyworth/cli/actions/system/signals.rb +9 -3
  12. data/lib/pennyworth/cli/actions/text.rb +8 -2
  13. data/lib/pennyworth/cli/shell.rb +33 -41
  14. data/lib/pennyworth/configuration/contract.rb +20 -0
  15. data/lib/pennyworth/configuration/defaults.yml +8 -38
  16. data/lib/pennyworth/configuration/{content.rb → model.rb} +3 -15
  17. data/lib/pennyworth/container.rb +14 -2
  18. data/lib/pennyworth/inflector.rb +1 -1
  19. data/lib/pennyworth/models/http_status.rb +0 -1
  20. data/lib/pennyworth/models/standard_error.rb +0 -1
  21. data/pennyworth.gemspec +10 -9
  22. data.tar.gz.sig +0 -0
  23. metadata +39 -31
  24. metadata.gz.sig +0 -0
  25. data/lib/pennyworth/cli/actions/config.rb +0 -33
  26. data/lib/pennyworth/cli/actions/container.rb +0 -26
  27. data/lib/pennyworth/cli/actions/git_hub.rb +0 -23
  28. data/lib/pennyworth/cli/actions/import.rb +0 -11
  29. data/lib/pennyworth/cli/parser.rb +0 -34
  30. data/lib/pennyworth/cli/parsers/core.rb +0 -110
  31. data/lib/pennyworth/cli/parsers/git_hub.rb +0 -53
  32. data/lib/pennyworth/cli/parsers/ruby_gems.rb +0 -38
  33. data/lib/pennyworth/configuration/loader.rb +0 -35
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7b134daf60efd3fcaab42d2c10f38267b4e6a62b18464df1fa22cb5d63b94bfd
4
- data.tar.gz: 8da4f47900223e63394d840a03a7f825fc76e71cff8c611907d09277835f2a26
3
+ metadata.gz: 414794a27964f620a93d4c91b8bd54895ebb5f904fc222cd9219ae563f33f331
4
+ data.tar.gz: 56a85dc5f9da6c8b1323f273c8f76b5808ebbd5c1f79719b21a8bd5c5a31a6dc
5
5
  SHA512:
6
- metadata.gz: 77de0d855c33857bce881eb70bc136fb4f6767c674fb9dc5fb2a562ad8880bc43d373872a7a7cc1bb3689ce4dcaf0eeca48b01df795e04d45801104b55f6ca63
7
- data.tar.gz: 69096aeae87c4e069524414c39715aa7cdf12f541d0cdde5ab7c93f8d2dd94bcf781672862892d825381a8b62a302bab88d43c36486668dce98b6609f877aaf0
6
+ metadata.gz: c3bfe9b02f3af2145262480e4a4a5b28097358b8cd7c0178ea58169597d724a0843c26f702dda0c30fbfd7e9ac248e3bd6eeab4e7c2ea09c7841e83041364bfa
7
+ data.tar.gz: a8bd9ca69fedf805b0c55673ebecfafaade206b34f8845f5ef587501b03d09f580926061dab4c41a936a567756add7acdfdc2b7f686c37f645217e84c2604e22
checksums.yaml.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -79,51 +79,27 @@ with others.
79
79
  From the command line, type `pennyworth` to view usage:
80
80
 
81
81
  ....
82
- Pennyworth - A command line interface that augments Alfred workflows.
83
-
84
- USAGE:
85
- -c, --config ACTION Manage gem configuration. Actions: edit || view.
86
- --encodings Render Alfred encodings script filter.
87
- --git_hub Render Alfred GitHub repositories script filter.
88
- -h, --help Show this message.
89
- --http_statuses Render Alfred HTTP statuses script filter.
90
- --ruby_gems Render Alfred RubyGems script filter.
91
- --standard_errors Render Alfred standard errors script filter.
92
- --system_errors Render Alfred system errors script filter.
93
- --system_signals Render Alfred system signals script filter.
94
- --text CONTENT Render Alfred text script filter.
95
- -v, --version Show gem version.
96
-
97
- GITHUB OPTIONS:
98
- --organization [HANDLE] Set organization. Default: "".
99
- --user [HANDLE] Set user. Default: "".
100
-
101
- RUBYGEMS OPTIONS:
102
- --owner [HANDLE] Set owner. Default: "".
82
+ USAGE
83
+ sublime_text_kit [OPTIONS]
84
+ sublime_text_kit COMMAND [OPTIONS]
85
+
86
+ OPTIONS
87
+ --encodings Render Alfred encodings script filter.
88
+ --http_statuses Render Alfred HTTP statuses script filter.
89
+ --ruby_gems [HANDLE] Render Alfred RubyGems script filter.
90
+ --standard_errors Render Alfred standard errors script filter.
91
+ --system_errors Render Alfred system errors script filter.
92
+ --system_signals Render Alfred system signals script filter.
93
+ --text CONTENT Render Alfred text script filter.
94
+ -v, --version Show version.
95
+ -h, --help [COMMAND] Show this message.
96
+
97
+ COMMANDS
98
+ config Manage configuration.
99
+ Path is dynamic per current directory.
100
+ git_hub Render Alfred GitHub repositories script filter.
103
101
  ....
104
102
 
105
- The following demonstrates how to use Pennyworth from the CLI or within an Alfred Script Filter:
106
-
107
- [source,bash]
108
- ----
109
- pennyworth --config edit
110
- pennyworth --config view
111
-
112
- pennyworth --encodings
113
-
114
- pennyworth --git_hub --organization alchemists
115
- pennyworth --git_hub --user bkuhlmann
116
-
117
- pennyworth --http_statuses
118
- pennyworth --ruby_gems --owner bkuhlmann
119
- pennyworth --standard_errors
120
- pennyworth --system_errors
121
- pennyworth --system_signals
122
-
123
- pennyworth --text demo
124
- pennyworth --text "An Example"
125
- ----
126
-
127
103
  While the command line options are nice, the real power comes from using Pennyworth in conjunction
128
104
  with link:https://www.alfredapp.com/help/workflows/inputs/script-filter/json[Alfred Script Filters].
129
105
  Without having Alfred wired up to consume the CLI output, you'll only get a JSON in your console. To
@@ -144,14 +120,12 @@ The default configuration is as follows:
144
120
 
145
121
  [source,yaml]
146
122
  ----
147
- :alfred:
148
- :preferences:
149
- :inflections:
123
+ alfred:
124
+ preferences:
125
+ inflections:
150
126
  - "Bkuhlmann": "bkuhlmann"
151
127
  - "Dry Auto Inject": "Dry AutoInject"
152
128
  - "Dry Cli": "Dry CLI"
153
- - "Flacsmith": "FLACsmith"
154
- - "Git Plus": "Git+"
155
129
  - "Http Fake": "HTTP Fake"
156
130
  - "Mac Os Config": "macOS Configuration"
157
131
  - "Mac Os": "MacOS"
@@ -160,40 +134,17 @@ The default configuration is as follows:
160
134
  - "Rubocop Ast": "Rubocop AST"
161
135
  - "Rubocop Md": "Rubocop Markdown"
162
136
  - "Rubocop Rspec": "Rubocop RSpec"
163
- - "Tty Box": "TTY Box"
164
- - "Tty Color": "TTY Color"
165
- - "Tty Command": "TTY Command"
166
- - "Tty Config": "TTY Config"
167
- - "Tty Cursor": "TTY Cursor"
168
- - "Tty Editor": "TTY Editor"
169
- - "Tty File": "TTY File"
170
- - "Tty Font": "TTY Font"
171
- - "Tty Link": "TTY Link"
172
- - "Tty Logger": "TTY Logger"
173
- - "Tty Markdown": "TTY Markdown"
174
- - "Tty Option": "TTY Option"
175
- - "Tty Pager": "TTY Pager"
176
- - "Tty Pie": "TTY Pie"
177
- - "Tty Platform": "TTY Platform"
178
- - "Tty Progressbar": "TTY ProgressBar"
179
- - "Tty Prompt": "TTY Prompt"
180
- - "Tty Reader": "TTY Reader"
181
- - "Tty Screen": "TTY Screen"
182
- - "Tty Spinner": "TTY Spinner"
183
- - "Tty Table": "TTY Table"
184
- - "Tty Tree": "TTY Tree"
185
- - "Tty Which": "TTY Which"
186
137
  - "Xdg": "XDG"
187
- :git_hub:
188
- :api_url: "https://api.github.com"
189
- :organization:
190
- :user:
191
- :http:
192
- :statuses:
193
- :url: "https://developer.mozilla.org/docs/Web/HTTP/Status"
194
- :ruby_gems:
195
- :api_url: "https://rubygems.org/api/v1"
196
- :owner:
138
+ git_hub:
139
+ api_url: "https://api.github.com"
140
+ organization:
141
+ user:
142
+ http:
143
+ statuses:
144
+ url: "https://developer.mozilla.org/docs/Web/HTTP/Status"
145
+ ruby_gems:
146
+ api_url: "https://rubygems.org/api/v1"
147
+ owner:
197
148
  ----
198
149
 
199
150
  Feel free to take this default configuration, modify, and save as your own custom
@@ -588,9 +539,6 @@ Provides general text manipulation utilities beyond the Pennyworth powered _text
588
539
 
589
540
  === Troubleshooting
590
541
 
591
- * link:https://github.com/ruby/psych[Psych] 4.0.0 has a
592
- link:https://github.com/ruby/psych/issues/490[bug] which prevents loading of YAML configurations
593
- that use symbols as keys. If you get caught by this, please upgrade to Psych 4.0.1 for the fix.
594
542
  * When your Alfred Workflow yields no output, you might want to open the
595
543
  link:https://www.alfredapp.com/help/workflows/utilities/debug[Alfred Debugger], rerun your
596
544
  workflow, and check for errors. You can also jump to the CLI and run Pennyworth directly.
@@ -1,18 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "sod"
4
+
3
5
  module Pennyworth
4
6
  module CLI
5
7
  module Actions
6
8
  # Handles the encodings action.
7
- class Encodings
8
- include Pennyworth::Import[:kernel]
9
+ class Encodings < Sod::Action
10
+ include Import[:kernel]
11
+
12
+ description "Render Alfred encodings script filter."
13
+
14
+ on "--encodings"
9
15
 
10
16
  def initialize(processor: Processor.for_encodings, **)
11
17
  super(**)
12
18
  @processor = processor
13
19
  end
14
20
 
15
- def call = kernel.puts processor.call.to_json
21
+ def call(*) = kernel.puts processor.call.to_json
16
22
 
17
23
  private
18
24
 
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "sod"
4
+
5
+ module Pennyworth
6
+ module CLI
7
+ module Actions
8
+ module GitHub
9
+ # Handles the GitHub user action.
10
+ class Organization < Sod::Action
11
+ include Import[:kernel]
12
+
13
+ description "Specify organization."
14
+
15
+ on %w[-o --organization],
16
+ argument: "[HANDLE]",
17
+ default: Container[:configuration].git_hub_organization
18
+
19
+ def initialize(processor: Processor.for_projects, **)
20
+ super(**)
21
+ @processor = processor
22
+ end
23
+
24
+ def call(handle = default) = kernel.puts processor.call("orgs/#{handle}").to_json
25
+
26
+ private
27
+
28
+ attr_reader :processor
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "sod"
4
+
5
+ module Pennyworth
6
+ module CLI
7
+ module Actions
8
+ module GitHub
9
+ # Handles the GitHub user action.
10
+ class User < Sod::Action
11
+ include Import[:kernel]
12
+
13
+ description "Specify user."
14
+
15
+ on %w[-u --user], argument: "[HANDLE]", default: Container[:configuration].git_hub_user
16
+
17
+ def initialize(processor: Processor.for_projects, **)
18
+ super(**)
19
+ @processor = processor
20
+ end
21
+
22
+ def call(handle = default) = kernel.puts processor.call("users/#{handle}").to_json
23
+
24
+ private
25
+
26
+ attr_reader :processor
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,18 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "sod"
4
+
3
5
  module Pennyworth
4
6
  module CLI
5
7
  module Actions
6
8
  # Handles the HTTP statuses action.
7
- class HTTPStatuses
8
- include Pennyworth::Import[:kernel]
9
+ class HTTPStatuses < Sod::Action
10
+ include Import[:kernel]
11
+
12
+ description "Render Alfred HTTP statuses script filter."
13
+
14
+ on "--http_statuses"
9
15
 
10
16
  def initialize(processor: Processor.for_http_statuses, **)
11
17
  super(**)
12
18
  @processor = processor
13
19
  end
14
20
 
15
- def call = kernel.puts processor.call.to_json
21
+ def call(*) = kernel.puts processor.call.to_json
16
22
 
17
23
  private
18
24
 
@@ -1,18 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "sod"
4
+
3
5
  module Pennyworth
4
6
  module CLI
5
7
  module Actions
6
8
  # Handles the RubyGems action.
7
- class RubyGems
8
- include Pennyworth::Import[:kernel]
9
+ class RubyGems < Sod::Action
10
+ include Import[:kernel]
11
+
12
+ description "Render Alfred RubyGems script filter."
13
+
14
+ on "--ruby_gems", argument: "[HANDLE]", default: Container[:configuration].ruby_gems_owner
9
15
 
10
16
  def initialize(processor: Processor.for_gems, **)
11
17
  super(**)
12
18
  @processor = processor
13
19
  end
14
20
 
15
- def call(endpoint) = kernel.puts processor.call(endpoint).to_json
21
+ def call handle = default
22
+ endpoint = "owners/#{handle}/gems.json"
23
+ kernel.puts processor.call(endpoint).to_json
24
+ end
16
25
 
17
26
  private
18
27
 
@@ -1,18 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "sod"
4
+
3
5
  module Pennyworth
4
6
  module CLI
5
7
  module Actions
6
8
  # Handles the system errors action.
7
- class StandardErrors
8
- include Pennyworth::Import[:kernel]
9
+ class StandardErrors < Sod::Action
10
+ include Import[:kernel]
11
+
12
+ description "Render Alfred standard errors script filter."
13
+
14
+ on "--standard_errors"
9
15
 
10
16
  def initialize(processor: Processor.for_standard_errors, **)
11
17
  super(**)
12
18
  @processor = processor
13
19
  end
14
20
 
15
- def call = kernel.puts processor.call.to_json
21
+ def call(*) = kernel.puts processor.call.to_json
16
22
 
17
23
  private
18
24
 
@@ -1,19 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "sod"
4
+
3
5
  module Pennyworth
4
6
  module CLI
5
7
  module Actions
6
8
  module System
7
9
  # Handles the system errors action.
8
- class Errors
9
- include Pennyworth::Import[:kernel]
10
+ class Errors < Sod::Action
11
+ include Import[:kernel]
12
+
13
+ description "Render Alfred system errors script filter."
14
+
15
+ on "--system_errors"
10
16
 
11
17
  def initialize(processor: Processor.for_system_errors, **)
12
18
  super(**)
13
19
  @processor = processor
14
20
  end
15
21
 
16
- def call = kernel.puts processor.call.to_json
22
+ def call(*) = kernel.puts processor.call.to_json
17
23
 
18
24
  private
19
25
 
@@ -1,19 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "sod"
4
+
3
5
  module Pennyworth
4
6
  module CLI
5
7
  module Actions
6
8
  module System
7
9
  # Handles the signal action.
8
- class Signals
9
- include Pennyworth::Import[:kernel]
10
+ class Signals < Sod::Action
11
+ include Import[:kernel]
12
+
13
+ description "Render Alfred system signals script filter."
14
+
15
+ on "--system_signals"
10
16
 
11
17
  def initialize(processor: Processor.for_system_signals, **)
12
18
  super(**)
13
19
  @processor = processor
14
20
  end
15
21
 
16
- def call = kernel.puts processor.call.to_json
22
+ def call(*) = kernel.puts processor.call.to_json
17
23
 
18
24
  private
19
25
 
@@ -1,11 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "sod"
4
+
3
5
  module Pennyworth
4
6
  module CLI
5
7
  module Actions
6
8
  # Handles the text action.
7
- class Text
8
- include Pennyworth::Import[:kernel]
9
+ class Text < Sod::Action
10
+ include Import[:kernel]
11
+
12
+ description "Render Alfred text script filter."
13
+
14
+ on "--text", argument: "CONTENT"
9
15
 
10
16
  def initialize(processor: Processor.for_text, **)
11
17
  super(**)
@@ -1,59 +1,51 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "core"
3
+ require "sod"
4
4
 
5
5
  module Pennyworth
6
6
  module CLI
7
7
  # The main Command Line Interface (CLI) object.
8
8
  class Shell
9
- include Actions::Import[
10
- :config,
11
- :encodings,
12
- :git_hub,
13
- :http_statuses,
14
- :kernel,
15
- :logger,
16
- :ruby_gems,
17
- :specification,
18
- :standard_errors,
19
- :system_errors,
20
- :system_signals,
21
- :text,
22
- ]
23
-
24
- def initialize(parser: Parser.new, **)
9
+ include Import[:defaults_path, :xdg_config, :specification]
10
+
11
+ def initialize(context: Sod::Context, dsl: Sod, **)
25
12
  super(**)
26
- @parser = parser
13
+ @context = context
14
+ @dsl = dsl
27
15
  end
28
16
 
29
- def call arguments = Core::EMPTY_ARRAY
30
- act_on parser.call(arguments)
31
- rescue OptionParser::ParseError, KeyError => error
32
- logger.error { error.message }
33
- end
17
+ def call(...) = cli.call(...)
34
18
 
35
19
  private
36
20
 
37
- attr_reader :parser
38
-
39
- def act_on configuration
40
- case configuration
41
- in action_config: Symbol => action then config.call action
42
- in action_encodings: true then encodings.call
43
- in action_git_hub: :organization
44
- git_hub.call "orgs/#{configuration.git_hub_organization}"
45
- in action_git_hub: :user then git_hub.call "users/#{configuration.git_hub_user}"
46
- in action_http_statuses: true then http_statuses.call
47
- in action_ruby_gems: true
48
- ruby_gems.call "owners/#{configuration.ruby_gems_owner}/gems.json"
49
- in action_standard_errors: true then standard_errors.call
50
- in action_system_errors: true then system_errors.call
51
- in action_system_signals: true then system_signals.call
52
- in action_text: String => content then text.call content
53
- in action_version: true then kernel.puts specification.labeled_version
54
- else kernel.puts parser.to_s
21
+ attr_reader :context, :dsl
22
+
23
+ def cli
24
+ context = build_context
25
+
26
+ dsl.new :sublime_text_kit, banner: specification.banner do
27
+ on(Sod::Prefabs::Commands::Config, context:)
28
+
29
+ on "git_hub", "Render Alfred GitHub repositories script filter." do
30
+ on Actions::GitHub::Organization
31
+ on Actions::GitHub::User
32
+ end
33
+
34
+ on Actions::Encodings
35
+ on Actions::HTTPStatuses
36
+ on Actions::RubyGems
37
+ on Actions::StandardErrors
38
+ on Actions::System::Errors
39
+ on Actions::System::Signals
40
+ on Actions::Text
41
+ on(Sod::Prefabs::Actions::Version, context:)
42
+ on Sod::Prefabs::Actions::Help, self
55
43
  end
56
44
  end
45
+
46
+ def build_context
47
+ context[defaults_path:, xdg_config:, version_label: specification.labeled_version]
48
+ end
57
49
  end
58
50
  end
59
51
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dry/schema"
4
+
5
+ Dry::Schema.load_extensions :monads
6
+
7
+ module Pennyworth
8
+ module Configuration
9
+ Contract = Dry::Schema.Params do
10
+ optional(:alfred_preferences).filled :string
11
+ required(:inflections).array :hash
12
+ required(:git_hub_api_url).filled :string
13
+ optional(:git_hub_organization).filled :string
14
+ optional(:git_hub_user).filled :string
15
+ required(:http_statuses_url).filled :string
16
+ required(:ruby_gems_api_url).filled :string
17
+ optional(:ruby_gems_owner).filled :string
18
+ end
19
+ end
20
+ end
@@ -1,11 +1,7 @@
1
- :alfred:
2
- :preferences:
3
- :inflections:
1
+ inflections:
4
2
  - "Bkuhlmann": "bkuhlmann"
5
3
  - "Dry Auto Inject": "Dry AutoInject"
6
4
  - "Dry Cli": "Dry CLI"
7
- - "Flacsmith": "FLACsmith"
8
- - "Git Plus": "Git+"
9
5
  - "Http Fake": "HTTP Fake"
10
6
  - "Mac Os Config": "macOS Configuration"
11
7
  - "Mac Os": "MacOS"
@@ -14,37 +10,11 @@
14
10
  - "Rubocop Ast": "Rubocop AST"
15
11
  - "Rubocop Md": "Rubocop Markdown"
16
12
  - "Rubocop Rspec": "Rubocop RSpec"
17
- - "Tty Box": "TTY Box"
18
- - "Tty Color": "TTY Color"
19
- - "Tty Command": "TTY Command"
20
- - "Tty Config": "TTY Config"
21
- - "Tty Cursor": "TTY Cursor"
22
- - "Tty Editor": "TTY Editor"
23
- - "Tty File": "TTY File"
24
- - "Tty Font": "TTY Font"
25
- - "Tty Link": "TTY Link"
26
- - "Tty Logger": "TTY Logger"
27
- - "Tty Markdown": "TTY Markdown"
28
- - "Tty Option": "TTY Option"
29
- - "Tty Pager": "TTY Pager"
30
- - "Tty Pie": "TTY Pie"
31
- - "Tty Platform": "TTY Platform"
32
- - "Tty Progressbar": "TTY ProgressBar"
33
- - "Tty Prompt": "TTY Prompt"
34
- - "Tty Reader": "TTY Reader"
35
- - "Tty Screen": "TTY Screen"
36
- - "Tty Spinner": "TTY Spinner"
37
- - "Tty Table": "TTY Table"
38
- - "Tty Tree": "TTY Tree"
39
- - "Tty Which": "TTY Which"
40
13
  - "Xdg": "XDG"
41
- :git_hub:
42
- :api_url: "https://api.github.com"
43
- :organization:
44
- :user:
45
- :http:
46
- :statuses:
47
- :url: "https://developer.mozilla.org/docs/Web/HTTP/Status"
48
- :ruby_gems:
49
- :api_url: "https://rubygems.org/api/v1"
50
- :owner:
14
+ git_hub:
15
+ api_url: "https://api.github.com"
16
+ http:
17
+ statuses:
18
+ url: "https://developer.mozilla.org/docs/Web/HTTP/Status"
19
+ ruby_gems:
20
+ api_url: "https://rubygems.org/api/v1"
@@ -3,18 +3,7 @@
3
3
  module Pennyworth
4
4
  module Configuration
5
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_standard_errors,
12
- :action_system_errors,
13
- :action_system_signals,
14
- :action_text,
15
- :action_config,
16
- :action_version,
17
- :action_help,
6
+ Model = Struct.new(
18
7
  :alfred_preferences,
19
8
  :inflections,
20
9
  :git_hub_api_url,
@@ -22,10 +11,9 @@ module Pennyworth
22
11
  :git_hub_user,
23
12
  :http_statuses_url,
24
13
  :ruby_gems_api_url,
25
- :ruby_gems_owner,
26
- keyword_init: true
14
+ :ruby_gems_owner
27
15
  ) do
28
- def initialize *arguments
16
+ def initialize(**)
29
17
  super
30
18
  freeze
31
19
  end
@@ -2,7 +2,9 @@
2
2
 
3
3
  require "cogger"
4
4
  require "dry/container"
5
+ require "etcher"
5
6
  require "http"
7
+ require "runcom"
6
8
  require "spek"
7
9
 
8
10
  module Pennyworth
@@ -10,9 +12,19 @@ module Pennyworth
10
12
  module Container
11
13
  extend Dry::Container::Mixin
12
14
 
13
- register(:configuration) { Configuration::Loader.call }
15
+ register :configuration do
16
+ self[:defaults].add_loader(Etcher::Loaders::YAML.new(self[:xdg_config].active))
17
+ .then { |registry| Etcher.call registry }
18
+ end
19
+
20
+ register :defaults do
21
+ Etcher::Registry.new(contract: Configuration::Contract, model: Configuration::Model)
22
+ .add_loader(Etcher::Loaders::YAML.new(self[:defaults_path]))
23
+ end
24
+
25
+ register(:defaults_path) { Pathname(__dir__).join("configuration/defaults.yml") }
26
+ register(:xdg_config) { Runcom::Config.new "pennyworth/configuration.yml" }
14
27
  register(:specification) { Spek::Loader.call "#{__dir__}/../../pennyworth.gemspec" }
15
- register(:environment) { ENV }
16
28
  register(:kernel) { Kernel }
17
29
  register(:http) { HTTP }
18
30
  register(:logger) { Cogger.new formatter: :emoji }