runcom 9.0.3 → 10.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.adoc +47 -93
- data/lib/runcom/cache.rb +3 -3
- data/lib/runcom/config.rb +6 -37
- data/lib/runcom/context.rb +2 -2
- data/lib/runcom/data.rb +3 -3
- data/lib/runcom/paths/common.rb +8 -1
- data/lib/runcom/state.rb +3 -3
- data/runcom.gemspec +4 -4
- data.tar.gz.sig +0 -0
- metadata +8 -8
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb75c89d8e38336ecfb2ca85d3d641299f137150978fddb3dfbc51f8c0d3ef09
|
4
|
+
data.tar.gz: 81c3ac00d58e8e963ea60f0f0af89ede2dae3928c0ab16f845e72987e3cb6281
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8b7486ae122faed212ef572045dcd8450979eaeefba8406f8ebad4f8444e7ce57d14498d271363b0b7fff199c79f78e932f57a5e969103a8bf1c17e7a55e7af
|
7
|
+
data.tar.gz: 58a719fe2be256df2f8104da75a987df809b0f1b18786fe789fb3e785cf9651d9c42862d491caae9aac1fbde34e5cff673171b9f26f1b2759d38272dd5033118
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.adoc
CHANGED
@@ -2,20 +2,18 @@
|
|
2
2
|
:toclevels: 5
|
3
3
|
:figure-caption!:
|
4
4
|
|
5
|
+
:xdg_link: link:https://alchemists.io/projects/xdg[XDG]
|
6
|
+
:etcher_link: link:https://alchemists.io/projects/etcher[Etcher]
|
7
|
+
|
5
8
|
= Runcom
|
6
9
|
|
7
|
-
Runcom is a link:https://en.wikipedia.org/wiki/Run_commands[Run Command] portmanteau (i.e. `run +
|
8
|
-
[com]mand = runcom`) which provides common functionality for Command Line Interfaces (CLIs) in which
|
9
|
-
to manage global, local, or multiple caches, configurations, or data in general. It does this by
|
10
|
-
leveraging the https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html[XDG Base
|
11
|
-
Directory Specification] built atop the link:https://alchemists.io/projects/xdg[XDG]
|
12
|
-
implementation. In other words, Runcom is an advanced version of XDG.
|
10
|
+
Runcom is a link:https://en.wikipedia.org/wiki/Run_commands[Run Command] portmanteau (i.e. `run + [com]mand = runcom`) which provides common functionality for Command Line Interfaces (CLIs) in which to manage global/local caches, configurations, data, and/or state. It does this by leveraging the https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html[XDG Base Directory Specification] built atop the {xdg_link} implementation. In other words, Runcom is an enhanced version of {xdg_link}.
|
13
11
|
|
14
12
|
toc::[]
|
15
13
|
|
16
14
|
== Features
|
17
15
|
|
18
|
-
* Wraps the
|
16
|
+
* Wraps the {xdg_link} implementation which provides access to
|
19
17
|
the following environment variables:
|
20
18
|
** `$XDG_CACHE_HOME`
|
21
19
|
** `$XDG_CONFIG_HOME`
|
@@ -23,11 +21,7 @@ toc::[]
|
|
23
21
|
** `$XDG_DATA_HOME`
|
24
22
|
** `$XDG_DATA_DIRS`
|
25
23
|
** `$XDG_STATE_HOME`
|
26
|
-
* Enhances the
|
27
|
-
supported:
|
28
|
-
** Supports loading of CLI-specific http://yaml.org[YAML] configuration file.
|
29
|
-
** Supports loading and merging of nested/complex configurations.
|
30
|
-
** Supports hash representation of configuration.
|
24
|
+
* Enhances the {xdg_link} cache, config, data, and state implementations.
|
31
25
|
|
32
26
|
== Requirements
|
33
27
|
|
@@ -67,46 +61,52 @@ require "runcom"
|
|
67
61
|
|
68
62
|
== Usage
|
69
63
|
|
70
|
-
The following describes the enhancements built atop the
|
71
|
-
link:https://alchemists.io/projects/xdg[XDG] implementation.
|
64
|
+
The following describes the enhancements built atop the {xdg_link} implementation.
|
72
65
|
|
73
66
|
=== Overview
|
74
67
|
|
75
|
-
While there isn’t an environment convenience object as found
|
76
|
-
instantiate each object individually:
|
68
|
+
While there isn’t an environment convenience object as found with the `XDG` gem, you can instantiate each object individually:
|
77
69
|
|
78
70
|
[source,ruby]
|
79
71
|
----
|
80
|
-
cache = Runcom::Cache.new "
|
81
|
-
config = Runcom::Config.new "
|
82
|
-
data = Runcom::Data.new "
|
83
|
-
state = Runcom::State.new "
|
72
|
+
cache = Runcom::Cache.new "demo/data.json"
|
73
|
+
config = Runcom::Config.new "demo/configuration.yml"
|
74
|
+
data = Runcom::Data.new "demo/store.dat"
|
75
|
+
state = Runcom::State.new "demo/history.log"
|
84
76
|
----
|
85
77
|
|
86
|
-
|
78
|
+
💡 By default, each Runcom object expects a relative path but you can use a fully qualified path as well.
|
79
|
+
|
80
|
+
Each of the above objects share the same Object API:
|
87
81
|
|
88
|
-
* `#relative
|
89
|
-
* `#namespace
|
82
|
+
* `#relative`: Answers the relative path from which the object was constructed.
|
83
|
+
* `#namespace`: Answers the relative namespace as a pathname object from which the object was
|
90
84
|
constructed. The namespace must be identical across the cache, config, and data objects as this is
|
91
85
|
what uniquely identifies and organizes all files associated with your program.
|
92
|
-
* `#file_name
|
93
|
-
* `#
|
94
|
-
computed
|
95
|
-
* `#
|
86
|
+
* `#file_name`: Answers the file name from which the object was constructed.
|
87
|
+
* `#active`: Answers first _existing_ file path as computed by `+$XDG_*_HOME+` followed by each
|
88
|
+
computed `+$XDG_*_DIRS+` path in order defined. Otherwise, `nil` is answered back.
|
89
|
+
* `#global`: Answers the first _existing_ or _non-existing_ global file path only.
|
90
|
+
* `#local`: Answers the first _existing_ or _non-existing_ local file path only.
|
91
|
+
* `#all`: Answers all file system paths which is the combined `$XDG_*_HOME` and
|
96
92
|
`$XDG_*_DIRS` values in order defined. These paths _may_ or _may not_ exist on the file system.
|
97
|
-
* `#inspect
|
93
|
+
* `#inspect`: Answers a string representation of default XDG home and directory paths for debugging
|
98
94
|
purposes.
|
99
95
|
|
100
|
-
Using
|
96
|
+
Using a `cache` object, for example, here is what each method answers back:
|
101
97
|
|
102
98
|
[source,ruby]
|
103
99
|
----
|
104
|
-
cache
|
105
|
-
|
106
|
-
cache.
|
107
|
-
cache.
|
108
|
-
cache.
|
109
|
-
cache.
|
100
|
+
cache = Runcom::Cache.new "demo/content.json"
|
101
|
+
|
102
|
+
cache.relative # => #<Pathname:demo/content.json>
|
103
|
+
cache.namespace # #<Pathname:demo>
|
104
|
+
cache.file_name # #<Pathname:content.json>
|
105
|
+
cache.active # nil
|
106
|
+
cache.global # #<Pathname:/Users/demo/.cache/demo/content.json>
|
107
|
+
cache.local # #<Pathname:/Users/demo/Engineering/OSS/runcom/.cache/demo/content.json>
|
108
|
+
cache.all # [#<Pathname:/Users/demo/Engineering/OSS/runcom/.cache/demo/content.json>, #<Pathname:/Users/demo/.cache/demo/content.json>]
|
109
|
+
cache.inspect # "XDG_CACHE_HOME=/Users/demo/Engineering/OSS/runcom/.cache:/Users/demo/.cache"
|
110
110
|
----
|
111
111
|
|
112
112
|
=== Variable Priority
|
@@ -120,76 +120,30 @@ Path precedence is determined in the following order (with the first taking high
|
|
120
120
|
. *Global Configuration* - When a local configuration isn’t found, the global configuration is used
|
121
121
|
as defined by the _XDG Base Directory Specification_.
|
122
122
|
|
123
|
-
===
|
124
|
-
|
125
|
-
The `Runcom::Config` deserves additional highlighting as it provides support for loading custom
|
126
|
-
CLI configurations directly from the command line or from custom locations. It is meant to be used
|
127
|
-
within your program(s).
|
128
|
-
|
129
|
-
An object is initialized as follows:
|
130
|
-
|
131
|
-
[source,ruby]
|
132
|
-
----
|
133
|
-
configuration = Runcom::Config.new "example/configuration.yml"
|
134
|
-
----
|
135
|
-
|
136
|
-
Default settings can be initialized as well:
|
137
|
-
|
138
|
-
[source,ruby]
|
139
|
-
----
|
140
|
-
configuration = Runcom::Config.new "example/configuration.yml", defaults: {name: "Example"}
|
141
|
-
----
|
142
|
-
|
143
|
-
Once a configuration has been initialized, a hash representation can be obtained:
|
144
|
-
|
145
|
-
[source,ruby]
|
146
|
-
----
|
147
|
-
configuration.to_h
|
148
|
-
----
|
149
|
-
|
150
|
-
A configuration can be merged with another hash (handy for runtime overrides):
|
151
|
-
|
152
|
-
[source,ruby]
|
153
|
-
----
|
154
|
-
updated_configuration = configuration.merge {name: "Updated Name"}
|
155
|
-
----
|
156
|
-
|
157
|
-
A configuration can also be merged with another configuration:
|
158
|
-
|
159
|
-
[source,ruby]
|
160
|
-
----
|
161
|
-
updated_configuration = configuration.merge Runcom::Config.new("other", defaults: {a: 1})
|
162
|
-
----
|
163
|
-
|
164
|
-
The current path of the configuration can be asked for as well:
|
165
|
-
|
166
|
-
[source,ruby]
|
167
|
-
----
|
168
|
-
configuration.current # "~/.config/example/configuration.yml"
|
169
|
-
----
|
123
|
+
=== Building Blocks
|
170
124
|
|
171
|
-
|
172
|
-
link:lib/runcom/config.rb[`Runcom::Config`] object.
|
125
|
+
While {xdg_link} and Runcom are powerful in their own right, a great building block you can add on top of this gem is the {etcher_link} gem which loads, transforms, validates, and produces structured data from raw Runcom information. For more sophisticated applications, this synergetic coupling of `XDG -> Runcom -> Etcher` makes for nicely designed architectures.
|
173
126
|
|
174
127
|
=== Examples
|
175
128
|
|
176
129
|
Examples of gems built atop this gem are:
|
177
130
|
|
178
|
-
* link:https://alchemists.io/projects/rubysmith[Rubysmith]
|
131
|
+
* link:https://alchemists.io/projects/rubysmith[Rubysmith]: A command line interface for
|
179
132
|
smithing Ruby projects.
|
180
|
-
* link:https://alchemists.io/projects/gemsmith[Gemsmith]
|
133
|
+
* link:https://alchemists.io/projects/gemsmith[Gemsmith]: A command line interface for smithing
|
181
134
|
new Ruby gems.
|
182
|
-
* link:https://alchemists.io/projects/
|
183
|
-
* link:https://alchemists.io/projects/
|
135
|
+
* link:https://alchemists.io/projects/hanamismith[Hanamismith]: A command line interace for smithing link:https://hanamirb.org[Hanami] projects.
|
136
|
+
* link:https://alchemists.io/projects/git-lint[Git Lint]: Enforces consistent Git commits.
|
137
|
+
* link:https://alchemists.io/projects/milestoner[Milestoner]: A command line interface for
|
184
138
|
releasing Git repository milestones.
|
185
|
-
* link:https://alchemists.io/projects/pennyworth[Pennyworth]
|
139
|
+
* link:https://alchemists.io/projects/pennyworth[Pennyworth]: A command line interface that
|
186
140
|
enhances and extends link:https://www.alfredapp.com[Alfred] with Ruby support.
|
187
|
-
* link:https://alchemists.io/projects/pragmater[Pragmater]
|
141
|
+
* link:https://alchemists.io/projects/pragmater[Pragmater]: A command line interface for
|
188
142
|
managing/formatting source file pragma comments.
|
189
|
-
* link:https://alchemists.io/projects/sublime_text_kit[Sublime Text Kit]
|
143
|
+
* link:https://alchemists.io/projects/sublime_text_kit[Sublime Text Kit]: A command line
|
190
144
|
interface for managing Sublime Text metadata.
|
191
|
-
* link:https://alchemists.io/projects/tocer[Tocer]
|
192
|
-
table of contents
|
145
|
+
* link:https://alchemists.io/projects/tocer[Tocer]: A command line interface for generating
|
146
|
+
Markdown table of contents.
|
193
147
|
|
194
148
|
== Development
|
195
149
|
|
data/lib/runcom/cache.rb
CHANGED
@@ -7,11 +7,11 @@ module Runcom
|
|
7
7
|
class Cache
|
8
8
|
extend Forwardable
|
9
9
|
|
10
|
-
|
10
|
+
CONTEXT = Context.new xdg: XDG::Cache
|
11
11
|
|
12
|
-
delegate %i[relative namespace file_name
|
12
|
+
delegate %i[relative namespace file_name active global local all inspect] => :common
|
13
13
|
|
14
|
-
def initialize path, context:
|
14
|
+
def initialize path, context: CONTEXT
|
15
15
|
@common = Paths::Common.new path, context:
|
16
16
|
end
|
17
17
|
|
data/lib/runcom/config.rb
CHANGED
@@ -1,53 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
4
|
-
require "yaml"
|
3
|
+
require "forwardable"
|
5
4
|
|
6
5
|
module Runcom
|
7
6
|
# A developer friendly wrapper of XDG config.
|
8
7
|
class Config
|
9
8
|
extend Forwardable
|
10
|
-
using Refinements::Hashes
|
11
9
|
|
12
|
-
|
10
|
+
CONTEXT = Context.new xdg: XDG::Config
|
13
11
|
|
14
|
-
delegate %i[relative namespace file_name
|
12
|
+
delegate %i[relative namespace file_name active global local all inspect] => :common
|
15
13
|
|
16
|
-
def initialize path,
|
17
|
-
@common = Paths::Common.new path, context:
|
18
|
-
@settings = defaults.deep_merge process_settings
|
19
|
-
freeze
|
14
|
+
def initialize path, context: CONTEXT
|
15
|
+
@common = Paths::Common.new path, context:
|
20
16
|
end
|
21
17
|
|
22
|
-
def merge other
|
23
|
-
self.class.new common.relative, defaults: settings.deep_merge(other.to_h), context:
|
24
|
-
end
|
25
|
-
|
26
|
-
# :reek:FeatureEnvy
|
27
|
-
def ==(other) = other.is_a?(Config) && (hash == other.hash)
|
28
|
-
|
29
|
-
alias eql? ==
|
30
|
-
|
31
|
-
def hash = [common.relative, to_h, self.class].hash
|
32
|
-
|
33
|
-
def to_h = settings
|
34
|
-
|
35
18
|
private
|
36
19
|
|
37
|
-
attr_reader :common
|
38
|
-
|
39
|
-
def process_settings
|
40
|
-
load_settings
|
41
|
-
rescue Psych::SyntaxError
|
42
|
-
raise Error, "Invalid configuration: #{common.current}."
|
43
|
-
rescue StandardError
|
44
|
-
context.defaults
|
45
|
-
{}
|
46
|
-
end
|
47
|
-
|
48
|
-
def load_settings
|
49
|
-
yaml = YAML.load_file common.current
|
50
|
-
yaml.is_a?(Hash) ? yaml : {}
|
51
|
-
end
|
20
|
+
attr_reader :common
|
52
21
|
end
|
53
22
|
end
|
data/lib/runcom/context.rb
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
module Runcom
|
4
4
|
# A common context for all XDG custom objects.
|
5
|
-
Context = Struct.new :
|
6
|
-
def initialize
|
5
|
+
Context = Struct.new :home, :environment, :xdg do
|
6
|
+
def initialize(**)
|
7
7
|
super
|
8
8
|
|
9
9
|
self[:home] ||= Paths::Home
|
data/lib/runcom/data.rb
CHANGED
@@ -7,11 +7,11 @@ module Runcom
|
|
7
7
|
class Data
|
8
8
|
extend Forwardable
|
9
9
|
|
10
|
-
|
10
|
+
CONTEXT = Context.new xdg: XDG::Data
|
11
11
|
|
12
|
-
delegate %i[relative namespace file_name
|
12
|
+
delegate %i[relative namespace file_name active global local all inspect] => :common
|
13
13
|
|
14
|
-
def initialize path, context:
|
14
|
+
def initialize path, context: CONTEXT
|
15
15
|
@common = Paths::Common.new path, context:
|
16
16
|
end
|
17
17
|
|
data/lib/runcom/paths/common.rb
CHANGED
@@ -24,7 +24,14 @@ module Runcom
|
|
24
24
|
|
25
25
|
def file_name = relative.basename
|
26
26
|
|
27
|
-
def
|
27
|
+
def active = all.select(&:file?).find(&:exist?)
|
28
|
+
|
29
|
+
def global
|
30
|
+
all.tap { |paths| paths.delete local }
|
31
|
+
.first
|
32
|
+
end
|
33
|
+
|
34
|
+
def local = all.first
|
28
35
|
|
29
36
|
def all = xdg.all.map { |root| root.join relative }
|
30
37
|
|
data/lib/runcom/state.rb
CHANGED
@@ -7,11 +7,11 @@ module Runcom
|
|
7
7
|
class State
|
8
8
|
extend Forwardable
|
9
9
|
|
10
|
-
|
10
|
+
CONTEXT = Context.new xdg: XDG::State
|
11
11
|
|
12
|
-
delegate %i[relative namespace file_name
|
12
|
+
delegate %i[relative namespace file_name active global local all inspect] => :common
|
13
13
|
|
14
|
-
def initialize path, context:
|
14
|
+
def initialize path, context: CONTEXT
|
15
15
|
@common = Paths::Common.new path, context:
|
16
16
|
end
|
17
17
|
|
data/runcom.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "runcom"
|
5
|
-
spec.version = "
|
5
|
+
spec.version = "10.0.1"
|
6
6
|
spec.authors = ["Brooke Kuhlmann"]
|
7
7
|
spec.email = ["brooke@alchemists.io"]
|
8
8
|
spec.homepage = "https://alchemists.io/projects/runcom"
|
9
|
-
spec.summary = "
|
9
|
+
spec.summary = "A XDG enhanced run command manager for command line interfaces."
|
10
10
|
spec.license = "Hippocratic-2.1"
|
11
11
|
|
12
12
|
spec.metadata = {
|
@@ -23,8 +23,8 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.cert_chain = [Gem.default_cert_path]
|
24
24
|
|
25
25
|
spec.required_ruby_version = "~> 3.2"
|
26
|
-
spec.add_dependency "refinements", "~>
|
27
|
-
spec.add_dependency "xdg", "~> 7.
|
26
|
+
spec.add_dependency "refinements", "~> 11.0"
|
27
|
+
spec.add_dependency "xdg", "~> 7.1"
|
28
28
|
spec.add_dependency "zeitwerk", "~> 2.6"
|
29
29
|
|
30
30
|
spec.files = Dir["*.gemspec", "lib/**/*"]
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: runcom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 10.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
3n5C8/6Zh9DYTkpcwPSuIfAga6wf4nXc9m6JAw8AuMLaiWN/r/2s4zJsUHYERJEu
|
36
36
|
gZGm4JqtuSg8pYjPeIJxS960owq+SfuC+jxqmRA54BisFCv/0VOJi7tiJVY=
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2023-
|
38
|
+
date: 2023-06-19 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: refinements
|
@@ -43,28 +43,28 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
46
|
+
version: '11.0'
|
47
47
|
type: :runtime
|
48
48
|
prerelease: false
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '11.0'
|
54
54
|
- !ruby/object:Gem::Dependency
|
55
55
|
name: xdg
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '7.
|
60
|
+
version: '7.1'
|
61
61
|
type: :runtime
|
62
62
|
prerelease: false
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: '7.
|
67
|
+
version: '7.1'
|
68
68
|
- !ruby/object:Gem::Dependency
|
69
69
|
name: zeitwerk
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
@@ -126,8 +126,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
126
|
- !ruby/object:Gem::Version
|
127
127
|
version: '0'
|
128
128
|
requirements: []
|
129
|
-
rubygems_version: 3.4.
|
129
|
+
rubygems_version: 3.4.14
|
130
130
|
signing_key:
|
131
131
|
specification_version: 4
|
132
|
-
summary:
|
132
|
+
summary: A XDG enhanced run command manager for command line interfaces.
|
133
133
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|