runcom 5.1.1 → 6.2.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.tar.gz.sig +0 -0
- data/{LICENSE.md → LICENSE.adoc} +29 -30
- data/README.adoc +234 -0
- data/lib/runcom.rb +4 -2
- data/lib/runcom/cache.rb +8 -17
- data/lib/runcom/config.rb +11 -25
- data/lib/runcom/context.rb +14 -0
- data/lib/runcom/data.rb +7 -18
- data/lib/runcom/identity.rb +4 -15
- data/lib/runcom/paths/common.rb +46 -0
- data/lib/runcom/paths/{friendly.rb → home.rb} +4 -4
- metadata +55 -52
- metadata.gz.sig +0 -0
- data/README.md +0 -193
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eca23b44fcd5e275a4e353480ee7ec1eceb6b851d3972d340c27689d169bab76
|
4
|
+
data.tar.gz: 49d05354269f59dd6f70ad524a7bbdfe778ec62dfb644af382d6f5ff0ec4e74b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6333b83c1fa0e9be6de2b39ac6df1676c5bbd25b2d42aefcd54cef78b43b6a4905e6a171f280ba0631fc89a398c6aa50dc6cb90f84fb41d471c1f5515c5d8c8
|
7
|
+
data.tar.gz: 12882cdd8ead36e94563b419cd9ea1a36d0ad1f25ccda3746a7ee511bebab5bec472589116db14c6636d451774a0c3a6ed04f52d2626975573b0a4ce884a4ac5
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/{LICENSE.md → LICENSE.adoc}
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
= Apache License
|
2
2
|
|
3
3
|
Version 2.0, January 2004
|
4
4
|
|
@@ -6,7 +6,7 @@ http://www.apache.org/licenses
|
|
6
6
|
|
7
7
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
8
8
|
|
9
|
-
|
9
|
+
== 1. Definitions
|
10
10
|
|
11
11
|
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by
|
12
12
|
Sections 1 through 9 of this document.
|
@@ -54,14 +54,14 @@ Contribution."
|
|
54
54
|
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a
|
55
55
|
Contribution has been received by Licensor and subsequently incorporated within the Work.
|
56
56
|
|
57
|
-
|
57
|
+
== 2. Grant of Copyright License
|
58
58
|
|
59
59
|
Subject to the terms and conditions of this License, each Contributor hereby grants to You a
|
60
60
|
perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to
|
61
61
|
reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and
|
62
62
|
distribute the Work and such Derivative Works in Source or Object form.
|
63
63
|
|
64
|
-
|
64
|
+
== 3. Grant of Patent License
|
65
65
|
|
66
66
|
Subject to the terms and conditions of this License, each Contributor hereby grants to You a
|
67
67
|
perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
|
@@ -74,39 +74,38 @@ a Contribution incorporated within the Work constitutes direct or contributory p
|
|
74
74
|
then any patent licenses granted to You under this License for that Work shall terminate as of the
|
75
75
|
date such litigation is filed.
|
76
76
|
|
77
|
-
|
77
|
+
== 4. Redistribution
|
78
78
|
|
79
79
|
You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with
|
80
80
|
or without modifications, and in Source or Object form, provided that You meet the following
|
81
81
|
conditions:
|
82
82
|
|
83
|
-
|
83
|
+
. You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
84
84
|
|
85
|
-
|
86
|
-
|
85
|
+
. You must cause any modified files to carry prominent notices stating that You changed the files;
|
86
|
+
and
|
87
87
|
|
88
|
-
|
89
|
-
|
90
|
-
|
88
|
+
. You must retain, in the Source form of any Derivative Works that You distribute, all copyright,
|
89
|
+
patent, trademark, and attribution notices from the Source form of the Work, excluding those
|
90
|
+
notices that do not pertain to any part of the Derivative Works; and
|
91
91
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
construed as modifying the License.
|
92
|
+
. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works
|
93
|
+
that You distribute must include a readable copy of the attribution notices contained within such
|
94
|
+
NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in
|
95
|
+
at least one of the following places: within a NOTICE text file distributed as part of the
|
96
|
+
Derivative Works; within the Source form or documentation, if provided along with the Derivative
|
97
|
+
Works; or, within a display generated by the Derivative Works, if and wherever such third-party
|
98
|
+
notices normally appear. The contents of the NOTICE file are for informational purposes only and
|
99
|
+
do not modify the License. You may add Your own attribution notices within Derivative Works that
|
100
|
+
You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such
|
101
|
+
additional attribution notices cannot be construed as modifying the License.
|
103
102
|
|
104
103
|
You may add Your own copyright statement to Your modifications and may provide additional or
|
105
104
|
different license terms and conditions for use, reproduction, or distribution of Your modifications,
|
106
105
|
or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of
|
107
106
|
the Work otherwise complies with the conditions stated in this License.
|
108
107
|
|
109
|
-
|
108
|
+
== 5. Submission of Contributions
|
110
109
|
|
111
110
|
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the
|
112
111
|
Work by You to the Licensor shall be under the terms and conditions of this License, without any
|
@@ -114,13 +113,13 @@ additional terms or conditions. Notwithstanding the above, nothing herein shall
|
|
114
113
|
the terms of any separate license agreement you may have executed with Licensor regarding such
|
115
114
|
Contributions.
|
116
115
|
|
117
|
-
|
116
|
+
== 6. Trademarks
|
118
117
|
|
119
118
|
This License does not grant permission to use the trade names, trademarks, service marks, or product
|
120
119
|
names of the Licensor, except as required for reasonable and customary use in describing the origin
|
121
120
|
of the Work and reproducing the content of the NOTICE file.
|
122
121
|
|
123
|
-
|
122
|
+
== 7. Disclaimer of Warranty
|
124
123
|
|
125
124
|
Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each
|
126
125
|
Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
@@ -129,7 +128,7 @@ TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. Y
|
|
129
128
|
responsible for determining the appropriateness of using or redistributing the Work and assume any
|
130
129
|
risks associated with Your exercise of permissions under this License.
|
131
130
|
|
132
|
-
|
131
|
+
== 8. Limitation of Liability
|
133
132
|
|
134
133
|
In no event and under no legal theory, whether in tort (including negligence), contract, or
|
135
134
|
otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or
|
@@ -139,7 +138,7 @@ License or out of the use or inability to use the Work (including but not limite
|
|
139
138
|
loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial
|
140
139
|
damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
141
140
|
|
142
|
-
|
141
|
+
== 9. Accepting Warranty or Additional Liability
|
143
142
|
|
144
143
|
While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee
|
145
144
|
for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights
|
@@ -151,11 +150,11 @@ additional liability.
|
|
151
150
|
|
152
151
|
END OF TERMS AND CONDITIONS
|
153
152
|
|
154
|
-
Copyright
|
153
|
+
Copyright link:https://www.alchemists.io[Alchemists].
|
155
154
|
|
156
155
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
|
157
|
-
compliance with the License. You may obtain a
|
158
|
-
the License.
|
156
|
+
compliance with the License. You may obtain a link:https://www.apache.org/licenses/LICENSE-2.0[copy]
|
157
|
+
of the License.
|
159
158
|
|
160
159
|
Unless required by applicable law or agreed to in writing, software distributed under the License is
|
161
160
|
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
data/README.adoc
ADDED
@@ -0,0 +1,234 @@
|
|
1
|
+
:toc: macro
|
2
|
+
:toclevels: 5
|
3
|
+
:figure-caption!:
|
4
|
+
|
5
|
+
= Runcom
|
6
|
+
|
7
|
+
[link=http://badge.fury.io/rb/runcom]
|
8
|
+
image::https://badge.fury.io/rb/runcom.svg[Gem Version]
|
9
|
+
[link=https://circleci.com/gh/bkuhlmann/runcom]
|
10
|
+
image::https://circleci.com/gh/bkuhlmann/runcom.svg?style=svg[Circle CI Status]
|
11
|
+
|
12
|
+
Runcom (short for link:https://en.wikipedia.org/wiki/Run_commands[Run Command]) provides common
|
13
|
+
functionality for Command Line Interfaces (CLIs) in which to manage global, local, or multiple
|
14
|
+
caches, configurations, or data in general. It does this by leveraging the
|
15
|
+
https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html[XDG Base Directory
|
16
|
+
Specification] built atop the link:https://www.alchemists.io/projects/xdg[XDG] implementation.
|
17
|
+
|
18
|
+
toc::[]
|
19
|
+
|
20
|
+
== Features
|
21
|
+
|
22
|
+
* Wraps the link:https://www.alchemists.io/projects/xdg[XDG] implementation which provides access to
|
23
|
+
the following environment variables:
|
24
|
+
** `+$XDG_CACHE_HOME+`
|
25
|
+
** `+$XDG_CONFIG_HOME+`
|
26
|
+
** `+$XDG_CONFIG_DIRS+`
|
27
|
+
** `+$XDG_DATA_HOME+`
|
28
|
+
** `+$XDG_DATA_DIRS+`
|
29
|
+
* Enhances the XDG cache, config, and data implementation. For the config, the following is
|
30
|
+
supported:
|
31
|
+
** Supports loading of CLI-specific http://yaml.org[YAML] configuration file.
|
32
|
+
** Supports loading and merging of nested/complex configurations.
|
33
|
+
** Supports hash representation of configuration.
|
34
|
+
|
35
|
+
== Requirements
|
36
|
+
|
37
|
+
. https://www.ruby-lang.org[Ruby]
|
38
|
+
|
39
|
+
== Setup
|
40
|
+
|
41
|
+
=== Production
|
42
|
+
|
43
|
+
To install, run:
|
44
|
+
|
45
|
+
[source,bash]
|
46
|
+
----
|
47
|
+
gem install runcom
|
48
|
+
----
|
49
|
+
|
50
|
+
Add the following to your Gemfile:
|
51
|
+
|
52
|
+
[source,ruby]
|
53
|
+
----
|
54
|
+
gem "runcom"
|
55
|
+
----
|
56
|
+
|
57
|
+
=== Development
|
58
|
+
|
59
|
+
To contribute, run:
|
60
|
+
|
61
|
+
[source,bash]
|
62
|
+
----
|
63
|
+
git clone https://github.com/bkuhlmann/runcom.git
|
64
|
+
cd runcom
|
65
|
+
bin/setup
|
66
|
+
----
|
67
|
+
|
68
|
+
You can also use the IRB console for direct access to all objects:
|
69
|
+
|
70
|
+
[source,bash]
|
71
|
+
----
|
72
|
+
bin/console
|
73
|
+
----
|
74
|
+
|
75
|
+
== Usage
|
76
|
+
|
77
|
+
The following describes the enhancements built atop the
|
78
|
+
link:https://www.alchemists.io/projects/xdg[XDG] implementation.
|
79
|
+
|
80
|
+
=== Overview
|
81
|
+
|
82
|
+
While there isn’t an environment convenience object as found in the `+XDG+` namespace, you can
|
83
|
+
instantiate each object individually:
|
84
|
+
|
85
|
+
[source,ruby]
|
86
|
+
----
|
87
|
+
cache = Runcom::Cache.new "example/data.json"
|
88
|
+
config = Runcom::Config.new "example/configuration.yml"
|
89
|
+
data = Runcom::Data.new "example/store.dat"
|
90
|
+
----
|
91
|
+
|
92
|
+
Each of the above objects share the same API:
|
93
|
+
|
94
|
+
* `#relative` - Answers the relative path from which the object was constructed.
|
95
|
+
* `#namespace` - Answers the relative namespace as a pathname object from which the object was
|
96
|
+
constructed. The namespace must be identical across the cache, config, and data objects as this is
|
97
|
+
what uniquely identifies and organizes all files associated with your program.
|
98
|
+
* `#file_name` - Answers the file name from which the object was constructed.
|
99
|
+
* `#current` - Answers first _existing_ file system path computed by `$XDG_*_HOME` followed by each
|
100
|
+
computed `$XDG_*_DIRS` path in order defined. Otherwise, `nil` is answered back.
|
101
|
+
* `#all` - Answers all file system paths which is the combined `$XDG_*_HOME` and
|
102
|
+
`$XDG_*_DIRS` values in order defined. These paths _may_ or _may not_ exist on the file system.
|
103
|
+
* `#inspect` - Answers a string representation of default XDG home and directory paths for debugging
|
104
|
+
purposes.
|
105
|
+
|
106
|
+
Using the `cache` object (created above) as an example, here is what each method answers back:
|
107
|
+
|
108
|
+
[source,ruby]
|
109
|
+
----
|
110
|
+
cache.relative # => #<Pathname:example/data.json>
|
111
|
+
cache.namespace # #<Pathname:example>
|
112
|
+
cache.file_name # #<Pathname:data.json>
|
113
|
+
cache.current # #<Pathname:/Users/bkuhlmann/.cache/example/data.json>
|
114
|
+
cache.all # [#<Pathname:/Users/bkuhlmann/.cache/example/data.json>]
|
115
|
+
cache.inspect # "XDG_CACHE_HOME=/Users/bkuhlmann/.cache"
|
116
|
+
----
|
117
|
+
|
118
|
+
=== Variable Priority
|
119
|
+
|
120
|
+
Path precedence is determined in the following order (with the first taking highest priority):
|
121
|
+
|
122
|
+
. *Local Configuration* - If a `$XDG_*_HOME` or `$XDG_*_DIRS` path relative to the
|
123
|
+
current working directory is detected, it will take precedence over the global configuration.
|
124
|
+
This is the same behavior as found in Git where the local `.git/config` takes precedence over the
|
125
|
+
global `$HOME/.gitconfig`.
|
126
|
+
. *Global Configuration* - When a local configuration isn’t found, the global configuration is used
|
127
|
+
as defined by the _XDG Base Directory Specification_.
|
128
|
+
|
129
|
+
=== Configuration Specialization
|
130
|
+
|
131
|
+
The `Runcom::Config` deserves additional highlighting as it provides support for loading custom
|
132
|
+
CLI configurations directly from the command line or from custom locations. It is meant to be used
|
133
|
+
within your program(s).
|
134
|
+
|
135
|
+
An object is initialized as follows:
|
136
|
+
|
137
|
+
[source,ruby]
|
138
|
+
----
|
139
|
+
configuration = Runcom::Config.new "example/configuration.yml"
|
140
|
+
----
|
141
|
+
|
142
|
+
Default settings can be initialized as well:
|
143
|
+
|
144
|
+
[source,ruby]
|
145
|
+
----
|
146
|
+
configuration = Runcom::Config.new "example/configuration.yml", defaults: {name: "Example"}
|
147
|
+
----
|
148
|
+
|
149
|
+
Once a configuration has been initialized, a hash representation can be obtained:
|
150
|
+
|
151
|
+
[source,ruby]
|
152
|
+
----
|
153
|
+
configuration.to_h
|
154
|
+
----
|
155
|
+
|
156
|
+
A configuration can be merged with another hash (handy for runtime overrides):
|
157
|
+
|
158
|
+
[source,ruby]
|
159
|
+
----
|
160
|
+
updated_configuration = configuration.merge {name: "Updated Name"}
|
161
|
+
----
|
162
|
+
|
163
|
+
A configuration can also be merged with another configuration:
|
164
|
+
|
165
|
+
[source,ruby]
|
166
|
+
----
|
167
|
+
updated_configuration = configuration.merge Runcom::Config.new("other", defaults: {a: 1})
|
168
|
+
----
|
169
|
+
|
170
|
+
The current path of the configuration can be asked for as well:
|
171
|
+
|
172
|
+
[source,ruby]
|
173
|
+
----
|
174
|
+
configuration.current # "~/.config/example/configuration.yml"
|
175
|
+
----
|
176
|
+
|
177
|
+
For further details, study the public interface as provided by the
|
178
|
+
link:lib/runcom/config.rb[`Runcom::Config`] object.
|
179
|
+
|
180
|
+
=== Examples
|
181
|
+
|
182
|
+
Examples of gems built atop this gem are:
|
183
|
+
|
184
|
+
* link:https://www.alchemists.io/projects/gemsmith[Gemsmith] - A command line interface for smithing
|
185
|
+
new Ruby gems.
|
186
|
+
* link:https://www.alchemists.io/projects/git-cop[Git Cop] - Enforces consistent Git commits.
|
187
|
+
* link:https://www.alchemists.io/projects/milestoner[Milestoner] - A command line interface for
|
188
|
+
releasing Git repository milestones.
|
189
|
+
* link:https://www.alchemists.io/projects/pennyworth[Pennyworth] - A command line interface that
|
190
|
+
enhances and extends link:https://www.alfredapp.com[Alfred] with Ruby support.
|
191
|
+
* link:https://www.alchemists.io/projects/pragmater[Pragmater] - A command line interface for
|
192
|
+
managing/formatting source file pragma comments.
|
193
|
+
* link:https://www.alchemists.io/projects/sublime_text_kit[Sublime Text Kit] - A command line
|
194
|
+
interface for managing Sublime Text metadata.
|
195
|
+
* link:https://www.alchemists.io/projects/tocer[Tocer] - A command line interface for generating
|
196
|
+
table of contents for Markdown files.
|
197
|
+
|
198
|
+
== Tests
|
199
|
+
|
200
|
+
To test, run:
|
201
|
+
|
202
|
+
[source,bash]
|
203
|
+
----
|
204
|
+
bundle exec rake
|
205
|
+
----
|
206
|
+
|
207
|
+
== Versioning
|
208
|
+
|
209
|
+
Read link:https://semver.org[Semantic Versioning] for details. Briefly, it means:
|
210
|
+
|
211
|
+
* Major (X.y.z) - Incremented for any backwards incompatible public API changes.
|
212
|
+
* Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
|
213
|
+
* Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
|
214
|
+
|
215
|
+
== Code of Conduct
|
216
|
+
|
217
|
+
Please note that this project is released with a link:CODE_OF_CONDUCT.adoc[CODE OF CONDUCT]. By
|
218
|
+
participating in this project you agree to abide by its terms.
|
219
|
+
|
220
|
+
== Contributions
|
221
|
+
|
222
|
+
Read link:CONTRIBUTING.adoc[CONTRIBUTING] for details.
|
223
|
+
|
224
|
+
== License
|
225
|
+
|
226
|
+
Read link:LICENSE.adoc[LICENSE] for details.
|
227
|
+
|
228
|
+
== History
|
229
|
+
|
230
|
+
Read link:CHANGES.adoc[CHANGES] for details.
|
231
|
+
|
232
|
+
== Credits
|
233
|
+
|
234
|
+
Engineered by link:https://www.alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
|
data/lib/runcom.rb
CHANGED
@@ -4,7 +4,9 @@ require "xdg"
|
|
4
4
|
require "runcom/identity"
|
5
5
|
require "runcom/errors/base"
|
6
6
|
require "runcom/errors/syntax"
|
7
|
-
require "runcom/paths/
|
8
|
-
require "runcom/
|
7
|
+
require "runcom/paths/home"
|
8
|
+
require "runcom/paths/common"
|
9
|
+
require "runcom/context"
|
9
10
|
require "runcom/cache"
|
11
|
+
require "runcom/config"
|
10
12
|
require "runcom/data"
|
data/lib/runcom/cache.rb
CHANGED
@@ -1,31 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "forwardable"
|
4
|
+
|
3
5
|
module Runcom
|
4
6
|
# A developer friendly wrapper of XDG cache.
|
5
|
-
Cache
|
7
|
+
class Cache
|
6
8
|
extend Forwardable
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
def initialize *arguments
|
11
|
-
super
|
10
|
+
DEFAULT_CONTEXT = Context.new xdg: XDG::Cache
|
12
11
|
|
13
|
-
|
14
|
-
self[:environment] ||= ENV
|
15
|
-
@cache = XDG::Cache.new home: home, environment: environment
|
16
|
-
freeze
|
17
|
-
end
|
18
|
-
|
19
|
-
def path
|
20
|
-
paths.find(&:exist?)
|
21
|
-
end
|
12
|
+
delegate %i[relative namespace file_name current all inspect] => :common
|
22
13
|
|
23
|
-
def
|
24
|
-
|
14
|
+
def initialize path, context: DEFAULT_CONTEXT
|
15
|
+
@common = Paths::Common.new path, context: context
|
25
16
|
end
|
26
17
|
|
27
18
|
private
|
28
19
|
|
29
|
-
attr_reader :
|
20
|
+
attr_reader :common
|
30
21
|
end
|
31
22
|
end
|
data/lib/runcom/config.rb
CHANGED
@@ -1,42 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "pathname"
|
4
3
|
require "yaml"
|
5
4
|
require "refinements/hashes"
|
6
5
|
|
7
|
-
# :reek:TooManyInstanceVariables
|
8
6
|
module Runcom
|
9
7
|
# A developer friendly wrapper of XDG config.
|
10
8
|
class Config
|
11
9
|
extend Forwardable
|
12
10
|
using Refinements::Hashes
|
13
11
|
|
14
|
-
|
12
|
+
DEFAULT_CONTEXT = Context.new xdg: XDG::Config
|
15
13
|
|
16
|
-
delegate %i[inspect] => :
|
14
|
+
delegate %i[relative namespace file_name current all inspect] => :common
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
@
|
21
|
-
@environment = environment
|
22
|
-
@file_name = file_name
|
23
|
-
@defaults = defaults
|
24
|
-
@config = XDG::Config.new home: Runcom::Paths::Friendly, environment: environment
|
16
|
+
def initialize path, defaults: {}, context: DEFAULT_CONTEXT
|
17
|
+
@common = Paths::Common.new path, context: context
|
18
|
+
@context = context
|
25
19
|
@settings = defaults.deep_merge process_settings
|
26
20
|
freeze
|
27
21
|
end
|
28
|
-
# rubocop:enable Metrics/ParameterLists
|
29
|
-
|
30
|
-
def path
|
31
|
-
paths.find(&:exist?)
|
32
|
-
end
|
33
|
-
|
34
|
-
def paths
|
35
|
-
config.all.map { |root| Pathname "#{root}/#{name}/#{file_name}" }
|
36
|
-
end
|
37
22
|
|
38
23
|
def merge other
|
39
|
-
self.class.new
|
24
|
+
self.class.new common.relative, defaults: settings.deep_merge(other.to_h), context: context
|
40
25
|
end
|
41
26
|
|
42
27
|
# :reek:FeatureEnvy
|
@@ -47,7 +32,7 @@ module Runcom
|
|
47
32
|
alias eql? ==
|
48
33
|
|
49
34
|
def hash
|
50
|
-
[
|
35
|
+
[common.relative, to_h, self.class].hash
|
51
36
|
end
|
52
37
|
|
53
38
|
def to_h
|
@@ -56,18 +41,19 @@ module Runcom
|
|
56
41
|
|
57
42
|
private
|
58
43
|
|
59
|
-
attr_reader :
|
44
|
+
attr_reader :common, :context, :settings
|
60
45
|
|
61
46
|
def process_settings
|
62
47
|
load_settings
|
63
48
|
rescue Psych::SyntaxError => error
|
64
49
|
raise Errors::Syntax, error.message
|
65
50
|
rescue StandardError
|
66
|
-
defaults
|
51
|
+
context.defaults
|
52
|
+
{}
|
67
53
|
end
|
68
54
|
|
69
55
|
def load_settings
|
70
|
-
yaml = YAML.load_file
|
56
|
+
yaml = YAML.load_file common.current
|
71
57
|
yaml.is_a?(Hash) ? yaml : {}
|
72
58
|
end
|
73
59
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Runcom
|
4
|
+
# A common context for all XDG custom objects.
|
5
|
+
Context = Struct.new :defaults, :home, :environment, :xdg, keyword_init: true do
|
6
|
+
def initialize *arguments
|
7
|
+
super
|
8
|
+
|
9
|
+
self[:home] ||= Paths::Home
|
10
|
+
self[:environment] ||= ENV
|
11
|
+
self[:xdg] = xdg.new home: home, environment: environment if xdg
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/runcom/data.rb
CHANGED
@@ -1,33 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
3
|
+
require "forwardable"
|
4
4
|
|
5
5
|
module Runcom
|
6
6
|
# A developer friendly wrapper of XDG data.
|
7
|
-
Data
|
7
|
+
class Data
|
8
8
|
extend Forwardable
|
9
9
|
|
10
|
-
|
10
|
+
DEFAULT_CONTEXT = Context.new xdg: XDG::Data
|
11
11
|
|
12
|
-
|
13
|
-
super
|
12
|
+
delegate %i[relative namespace file_name current all inspect] => :common
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
@data = XDG::Data.new home: home, environment: environment
|
18
|
-
freeze
|
19
|
-
end
|
20
|
-
|
21
|
-
def path
|
22
|
-
paths.find(&:exist?)
|
23
|
-
end
|
24
|
-
|
25
|
-
def paths
|
26
|
-
data.all.map { |root| Pathname "#{root}/#{name}" }
|
14
|
+
def initialize path, context: DEFAULT_CONTEXT
|
15
|
+
@common = Paths::Common.new path, context: context
|
27
16
|
end
|
28
17
|
|
29
18
|
private
|
30
19
|
|
31
|
-
attr_reader :
|
20
|
+
attr_reader :common
|
32
21
|
end
|
33
22
|
end
|
data/lib/runcom/identity.rb
CHANGED
@@ -3,20 +3,9 @@
|
|
3
3
|
module Runcom
|
4
4
|
# Gem identity information.
|
5
5
|
module Identity
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
def self.label
|
11
|
-
"Runcom"
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.version
|
15
|
-
"5.1.1"
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.version_label
|
19
|
-
"#{label} #{version}"
|
20
|
-
end
|
6
|
+
NAME = "runcom"
|
7
|
+
LABEL = "Runcom"
|
8
|
+
VERSION = "6.2.0"
|
9
|
+
VERSION_LABEL = "#{LABEL} #{VERSION}"
|
21
10
|
end
|
22
11
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "forwardable"
|
4
|
+
require "pathname"
|
5
|
+
|
6
|
+
module Runcom
|
7
|
+
module Paths
|
8
|
+
# Provides common path/functionality for all XDG enhanced objects.
|
9
|
+
class Common
|
10
|
+
extend Forwardable
|
11
|
+
|
12
|
+
delegate %i[inspect] => :xdg
|
13
|
+
|
14
|
+
attr_reader :relative
|
15
|
+
|
16
|
+
def initialize relative, context: Context.new
|
17
|
+
@relative = Pathname relative
|
18
|
+
@context = context
|
19
|
+
end
|
20
|
+
|
21
|
+
def namespace
|
22
|
+
relative.parent
|
23
|
+
end
|
24
|
+
|
25
|
+
def file_name
|
26
|
+
relative.basename
|
27
|
+
end
|
28
|
+
|
29
|
+
def current
|
30
|
+
all.find(&:exist?)
|
31
|
+
end
|
32
|
+
|
33
|
+
def all
|
34
|
+
xdg.all.map { |root| root.join relative }
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
attr_reader :context
|
40
|
+
|
41
|
+
def xdg
|
42
|
+
context.xdg
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -1,18 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "forwardable"
|
4
|
+
require "pathname"
|
4
5
|
|
5
6
|
module Runcom
|
6
7
|
module Paths
|
7
|
-
# A XDG home path
|
8
|
-
|
9
|
-
class Friendly
|
8
|
+
# A XDG home path that prefers local over global path.
|
9
|
+
class Home
|
10
10
|
extend Forwardable
|
11
11
|
|
12
12
|
delegate %i[key value default] => :standard
|
13
13
|
|
14
14
|
def initialize pair, environment = ENV
|
15
|
-
@standard = XDG::Paths::
|
15
|
+
@standard = XDG::Paths::Home.new pair, environment
|
16
16
|
end
|
17
17
|
|
18
18
|
def dynamic
|
metadata
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: runcom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
MIIC/
|
14
|
-
|
15
|
-
|
13
|
+
MIIC/jCCAeagAwIBAgIBAzANBgkqhkiG9w0BAQsFADAlMSMwIQYDVQQDDBpicm9v
|
14
|
+
a2UvREM9YWxjaGVtaXN0cy9EQz1pbzAeFw0yMDAzMTUxNDQ1MzJaFw0yMTAzMTUx
|
15
|
+
NDQ1MzJaMCUxIzAhBgNVBAMMGmJyb29rZS9EQz1hbGNoZW1pc3RzL0RDPWlvMIIB
|
16
16
|
IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6l1qpXTiomH1RfMRloyw7MiE
|
17
17
|
xyVx/x8Yc3EupdH7uhNaTXQGyORN6aOY//1QXXMHIZ9tW74nZLhesWMSUMYy0XhB
|
18
18
|
brs+KkurHnc9FnEJAbG7ebGvl/ncqZt72nQvaxpDxvuCBHgJAz+8i5wl6FhLw+oT
|
@@ -20,15 +20,15 @@ cert_chain:
|
|
20
20
|
D5vkU0YlAm1r98BymuJlcQ1qdkVEI1d48ph4kcS0S0nv1RiuyVb6TCAR3Nu3VaVq
|
21
21
|
3fPzZKJLZBx67UvXdbdicWPiUR75elI4PXpLIic3xytaF52ZJYyKZCNZJhNwfQID
|
22
22
|
AQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU0nzow9vc
|
23
|
-
2CdikiiE3fJhP/
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
23
|
+
2CdikiiE3fJhP/gY4ggwDQYJKoZIhvcNAQELBQADggEBAIHhAlD3po4sTYqacXaQ
|
24
|
+
XI9jIhrfMy//2PgbHWcETtlJPBeNUbbSNBABcllUHKqYsVDlSvSmss034KSWNR8F
|
25
|
+
bF1GcloicyvcCC4y6IoW4it0COAcdeaaxkxiBSgKdQFpff9REnDlIKK4uQ9lLxIo
|
26
|
+
Y2G5xubiziKZkyfWFuSr67PIjW3Bu673D1JVBArhA1qbgQmYQcy1CkGOjo+iO8Nf
|
27
|
+
7u/QSfBHb+r/bXhKscDgPpnKwbUmvgO2+94zJG9KsrmIydlzYfsD09aXKx0t6Xy4
|
28
|
+
2XV8FRa7/JimI07sPLC13eLY3xd/aYTi85Z782KIA4j0G8XEEWAX0ouBhlXPocZv
|
29
|
+
QWc=
|
30
30
|
-----END CERTIFICATE-----
|
31
|
-
date:
|
31
|
+
date: 2020-07-23 00:00:00.000000000 Z
|
32
32
|
dependencies:
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: refinements
|
@@ -36,28 +36,28 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
39
|
+
version: '7.4'
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
46
|
+
version: '7.4'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: xdg
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '4.0'
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
60
|
+
version: '4.0'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: bundler-audit
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,28 +78,28 @@ dependencies:
|
|
78
78
|
requirements:
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
81
|
+
version: '14.2'
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
88
|
+
version: '14.2'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
|
-
name: git-
|
90
|
+
name: git-lint
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
93
|
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
95
|
+
version: '1.0'
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: '
|
102
|
+
version: '1.0'
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: guard-rspec
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,28 +120,28 @@ dependencies:
|
|
120
120
|
requirements:
|
121
121
|
- - "~>"
|
122
122
|
- !ruby/object:Gem::Version
|
123
|
-
version: '0.
|
123
|
+
version: '0.13'
|
124
124
|
type: :development
|
125
125
|
prerelease: false
|
126
126
|
version_requirements: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
128
|
- - "~>"
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version: '0.
|
130
|
+
version: '0.13'
|
131
131
|
- !ruby/object:Gem::Dependency
|
132
132
|
name: pry-byebug
|
133
133
|
requirement: !ruby/object:Gem::Requirement
|
134
134
|
requirements:
|
135
135
|
- - "~>"
|
136
136
|
- !ruby/object:Gem::Version
|
137
|
-
version: '3.
|
137
|
+
version: '3.9'
|
138
138
|
type: :development
|
139
139
|
prerelease: false
|
140
140
|
version_requirements: !ruby/object:Gem::Requirement
|
141
141
|
requirements:
|
142
142
|
- - "~>"
|
143
143
|
- !ruby/object:Gem::Version
|
144
|
-
version: '3.
|
144
|
+
version: '3.9'
|
145
145
|
- !ruby/object:Gem::Dependency
|
146
146
|
name: rake
|
147
147
|
requirement: !ruby/object:Gem::Requirement
|
@@ -162,14 +162,14 @@ dependencies:
|
|
162
162
|
requirements:
|
163
163
|
- - "~>"
|
164
164
|
- !ruby/object:Gem::Version
|
165
|
-
version: '
|
165
|
+
version: '6.0'
|
166
166
|
type: :development
|
167
167
|
prerelease: false
|
168
168
|
version_requirements: !ruby/object:Gem::Requirement
|
169
169
|
requirements:
|
170
170
|
- - "~>"
|
171
171
|
- !ruby/object:Gem::Version
|
172
|
-
version: '
|
172
|
+
version: '6.0'
|
173
173
|
- !ruby/object:Gem::Dependency
|
174
174
|
name: rspec
|
175
175
|
requirement: !ruby/object:Gem::Requirement
|
@@ -190,97 +190,100 @@ dependencies:
|
|
190
190
|
requirements:
|
191
191
|
- - "~>"
|
192
192
|
- !ruby/object:Gem::Version
|
193
|
-
version: '0.
|
193
|
+
version: '0.83'
|
194
194
|
type: :development
|
195
195
|
prerelease: false
|
196
196
|
version_requirements: !ruby/object:Gem::Requirement
|
197
197
|
requirements:
|
198
198
|
- - "~>"
|
199
199
|
- !ruby/object:Gem::Version
|
200
|
-
version: '0.
|
200
|
+
version: '0.83'
|
201
201
|
- !ruby/object:Gem::Dependency
|
202
202
|
name: rubocop-performance
|
203
203
|
requirement: !ruby/object:Gem::Requirement
|
204
204
|
requirements:
|
205
205
|
- - "~>"
|
206
206
|
- !ruby/object:Gem::Version
|
207
|
-
version: '1.
|
207
|
+
version: '1.5'
|
208
208
|
type: :development
|
209
209
|
prerelease: false
|
210
210
|
version_requirements: !ruby/object:Gem::Requirement
|
211
211
|
requirements:
|
212
212
|
- - "~>"
|
213
213
|
- !ruby/object:Gem::Version
|
214
|
-
version: '1.
|
214
|
+
version: '1.5'
|
215
215
|
- !ruby/object:Gem::Dependency
|
216
216
|
name: rubocop-rake
|
217
217
|
requirement: !ruby/object:Gem::Requirement
|
218
218
|
requirements:
|
219
219
|
- - "~>"
|
220
220
|
- !ruby/object:Gem::Version
|
221
|
-
version: '0.
|
221
|
+
version: '0.5'
|
222
222
|
type: :development
|
223
223
|
prerelease: false
|
224
224
|
version_requirements: !ruby/object:Gem::Requirement
|
225
225
|
requirements:
|
226
226
|
- - "~>"
|
227
227
|
- !ruby/object:Gem::Version
|
228
|
-
version: '0.
|
228
|
+
version: '0.5'
|
229
229
|
- !ruby/object:Gem::Dependency
|
230
230
|
name: rubocop-rspec
|
231
231
|
requirement: !ruby/object:Gem::Requirement
|
232
232
|
requirements:
|
233
233
|
- - "~>"
|
234
234
|
- !ruby/object:Gem::Version
|
235
|
-
version: '1.
|
235
|
+
version: '1.39'
|
236
236
|
type: :development
|
237
237
|
prerelease: false
|
238
238
|
version_requirements: !ruby/object:Gem::Requirement
|
239
239
|
requirements:
|
240
240
|
- - "~>"
|
241
241
|
- !ruby/object:Gem::Version
|
242
|
-
version: '1.
|
242
|
+
version: '1.39'
|
243
243
|
- !ruby/object:Gem::Dependency
|
244
244
|
name: simplecov
|
245
245
|
requirement: !ruby/object:Gem::Requirement
|
246
246
|
requirements:
|
247
247
|
- - "~>"
|
248
248
|
- !ruby/object:Gem::Version
|
249
|
-
version: '0.
|
249
|
+
version: '0.18'
|
250
250
|
type: :development
|
251
251
|
prerelease: false
|
252
252
|
version_requirements: !ruby/object:Gem::Requirement
|
253
253
|
requirements:
|
254
254
|
- - "~>"
|
255
255
|
- !ruby/object:Gem::Version
|
256
|
-
version: '0.
|
257
|
-
description:
|
256
|
+
version: '0.18'
|
257
|
+
description:
|
258
258
|
email:
|
259
259
|
- brooke@alchemists.io
|
260
260
|
executables: []
|
261
261
|
extensions: []
|
262
262
|
extra_rdoc_files:
|
263
|
-
- README.
|
264
|
-
- LICENSE.
|
263
|
+
- README.adoc
|
264
|
+
- LICENSE.adoc
|
265
265
|
files:
|
266
|
-
- LICENSE.
|
267
|
-
- README.
|
266
|
+
- LICENSE.adoc
|
267
|
+
- README.adoc
|
268
268
|
- lib/runcom.rb
|
269
269
|
- lib/runcom/cache.rb
|
270
270
|
- lib/runcom/config.rb
|
271
|
+
- lib/runcom/context.rb
|
271
272
|
- lib/runcom/data.rb
|
272
273
|
- lib/runcom/errors/base.rb
|
273
274
|
- lib/runcom/errors/syntax.rb
|
274
275
|
- lib/runcom/identity.rb
|
275
|
-
- lib/runcom/paths/
|
276
|
-
|
276
|
+
- lib/runcom/paths/common.rb
|
277
|
+
- lib/runcom/paths/home.rb
|
278
|
+
homepage: https://www.alchemists.io/projects/runcom
|
277
279
|
licenses:
|
278
280
|
- Apache-2.0
|
279
281
|
metadata:
|
280
|
-
source_code_uri: https://github.com/bkuhlmann/runcom
|
281
|
-
changelog_uri: https://github.com/bkuhlmann/runcom/blob/master/CHANGES.md
|
282
282
|
bug_tracker_uri: https://github.com/bkuhlmann/runcom/issues
|
283
|
-
|
283
|
+
changelog_uri: https://www.alchemists.io/projects/runcom/changes.html
|
284
|
+
documentation_uri: https://www.alchemists.io/projects/runcom
|
285
|
+
source_code_uri: https://github.com/bkuhlmann/runcom
|
286
|
+
post_install_message:
|
284
287
|
rdoc_options: []
|
285
288
|
require_paths:
|
286
289
|
- lib
|
@@ -288,15 +291,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
288
291
|
requirements:
|
289
292
|
- - "~>"
|
290
293
|
- !ruby/object:Gem::Version
|
291
|
-
version: '2.
|
294
|
+
version: '2.7'
|
292
295
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
293
296
|
requirements:
|
294
297
|
- - ">="
|
295
298
|
- !ruby/object:Gem::Version
|
296
299
|
version: '0'
|
297
300
|
requirements: []
|
298
|
-
rubygems_version: 3.
|
299
|
-
signing_key:
|
301
|
+
rubygems_version: 3.1.4
|
302
|
+
signing_key:
|
300
303
|
specification_version: 4
|
301
|
-
summary: An XDG enhanced run command manager for command line interfaces
|
304
|
+
summary: An XDG enhanced run command manager for command line interfaces.
|
302
305
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|
data/README.md
DELETED
@@ -1,193 +0,0 @@
|
|
1
|
-
<p align="center">
|
2
|
-
<img src="runcom.png" alt="Runcom Icon"/>
|
3
|
-
</p>
|
4
|
-
|
5
|
-
# Runcom
|
6
|
-
|
7
|
-
[![Gem Version](https://badge.fury.io/rb/runcom.svg)](http://badge.fury.io/rb/runcom)
|
8
|
-
[![Code Climate Maintainability](https://api.codeclimate.com/v1/badges/129b7ea524a0f5a6a805/maintainability)](https://codeclimate.com/github/bkuhlmann/runcom/maintainability)
|
9
|
-
[![Code Climate Test Coverage](https://api.codeclimate.com/v1/badges/129b7ea524a0f5a6a805/test_coverage)](https://codeclimate.com/github/bkuhlmann/runcom/test_coverage)
|
10
|
-
[![Circle CI Status](https://circleci.com/gh/bkuhlmann/runcom.svg?style=svg)](https://circleci.com/gh/bkuhlmann/runcom)
|
11
|
-
|
12
|
-
Runcom (short for [Run Command](https://en.wikipedia.org/wiki/Run_commands)) provides common
|
13
|
-
functionality for Command Line Interfaces (CLIs) in which to manage global, local, or multiple
|
14
|
-
caches, configurations, or data in general. It does this by leveraging the [XDG Base Directory
|
15
|
-
Specification](https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html) built atop
|
16
|
-
the [XDG](https://github.com/bkuhlmann/xdg) implementation.
|
17
|
-
|
18
|
-
<!-- Tocer[start]: Auto-generated, don't remove. -->
|
19
|
-
|
20
|
-
## Table of Contents
|
21
|
-
|
22
|
-
- [Features](#features)
|
23
|
-
- [Requirements](#requirements)
|
24
|
-
- [Setup](#setup)
|
25
|
-
- [Usage](#usage)
|
26
|
-
- [Overview](#overview)
|
27
|
-
- [Variable Priority](#variable-priority)
|
28
|
-
- [Configuration Specialization](#configuration-specialization)
|
29
|
-
- [Examples](#examples)
|
30
|
-
- [Tests](#tests)
|
31
|
-
- [Versioning](#versioning)
|
32
|
-
- [Code of Conduct](#code-of-conduct)
|
33
|
-
- [Contributions](#contributions)
|
34
|
-
- [License](#license)
|
35
|
-
- [History](#history)
|
36
|
-
- [Credits](#credits)
|
37
|
-
|
38
|
-
<!-- Tocer[finish]: Auto-generated, don't remove. -->
|
39
|
-
|
40
|
-
## Features
|
41
|
-
|
42
|
-
- Wraps the [XDG](https://github.com/bkuhlmann/xdg) implementation which provides access to the
|
43
|
-
following environment variables:
|
44
|
-
- `$XDG_CACHE_HOME`
|
45
|
-
- `$XDG_CONFIG_HOME`
|
46
|
-
- `$XDG_CONFIG_DIRS`
|
47
|
-
- `$XDG_DATA_HOME`
|
48
|
-
- `$XDG_DATA_DIRS`
|
49
|
-
- Enhances the XDG cache, config, and data implementation. For the config, the following is
|
50
|
-
supported:
|
51
|
-
- Supports loading of CLI-specific [YAML](http://yaml.org) configuration file.
|
52
|
-
- Supports loading and merging of nested/complex configurations.
|
53
|
-
- Supports hash representation of configuration.
|
54
|
-
|
55
|
-
## Requirements
|
56
|
-
|
57
|
-
1. [Ruby 2.6.x](https://www.ruby-lang.org).
|
58
|
-
|
59
|
-
## Setup
|
60
|
-
|
61
|
-
Type the following to install:
|
62
|
-
|
63
|
-
gem install runcom
|
64
|
-
|
65
|
-
Add the following to your Gemfile:
|
66
|
-
|
67
|
-
gem "runcom"
|
68
|
-
|
69
|
-
## Usage
|
70
|
-
|
71
|
-
The following describes the enhancements built atop the [XDG](https://github.com/bkuhlmann/xdg)
|
72
|
-
implementation.
|
73
|
-
|
74
|
-
#### Overview
|
75
|
-
|
76
|
-
While there isn't an environment convenience object as found in the `XDG` namespace, you can
|
77
|
-
instantiate each object individually:
|
78
|
-
|
79
|
-
cache = Runcom::Cache.new
|
80
|
-
config = Runcom::Config.new
|
81
|
-
data = Runcom::Data.new
|
82
|
-
|
83
|
-
Each of the above objects share the same basic API:
|
84
|
-
|
85
|
-
- `#path` - Answers first *existing* file system path computed by `$XDG_*_HOME` followed
|
86
|
-
by each computed `$XDG_*_DIRS` path in order defined.
|
87
|
-
- `#paths` - Answers all file system paths which is the combined `$XDG_*_HOME` and `$XDG_*_DIRS`
|
88
|
-
values in order defined. These paths *may* or *may not* exist on the file system.
|
89
|
-
|
90
|
-
#### Variable Priority
|
91
|
-
|
92
|
-
Path precedence is determined in the following order (with the first taking highest priority):
|
93
|
-
|
94
|
-
1. **Local Configuration** - If a `$XDG_*_HOME` or `$XDG_*_DIRS` path relative to the current
|
95
|
-
working directory is detected, it will take precedence over the global configuration. This is the
|
96
|
-
same behavior as found in Git where the local `.git/config` takes precedence over the global
|
97
|
-
`~/.gitconfig`.
|
98
|
-
1. **Global Configuration** - When a local configuration isn't found, the global configuration is
|
99
|
-
used as defined by the *XDG Base Directory Specification*.
|
100
|
-
|
101
|
-
#### Configuration Specialization
|
102
|
-
|
103
|
-
The `Runcom::Config` deserves additional highlighting as it provides support for loading custom CLI
|
104
|
-
configurations directly from the command line or from custom locations. It is meant to be used
|
105
|
-
within your program(s).
|
106
|
-
|
107
|
-
An object can be initialized as follows:
|
108
|
-
|
109
|
-
configuration = Runcom::Config.new "example"
|
110
|
-
|
111
|
-
The default file name for a configuration is `configuration.yml` but a custom name can be used if
|
112
|
-
desired:
|
113
|
-
|
114
|
-
configuration = Runcom::Config.new "example", file_name: "example.yml"
|
115
|
-
|
116
|
-
Default settings can be initialized as well:
|
117
|
-
|
118
|
-
configuration = Runcom::Config.new "example", defaults: {name: "Example"}
|
119
|
-
|
120
|
-
Once a configuration has been initialized, a hash representation can be obtained:
|
121
|
-
|
122
|
-
configuration.to_h
|
123
|
-
|
124
|
-
A configuration can be merged with another hash (handy for runtime overrides):
|
125
|
-
|
126
|
-
updated_configuration = configuration.merge {name: "Updated Name"}
|
127
|
-
|
128
|
-
A configuration can also be merged with another configuration:
|
129
|
-
|
130
|
-
updated_configuration = configuration.merge Runcom::Config.new("other", defaults: {a: 1})
|
131
|
-
|
132
|
-
The computed path of the configuration can be asked for as well:
|
133
|
-
|
134
|
-
configuration.path # "~/.config/example/configuration.yml"
|
135
|
-
|
136
|
-
For further details, study the public interface as provided by the
|
137
|
-
[`Runcom::Config`](lib/runcom/config.rb) object.
|
138
|
-
|
139
|
-
### Examples
|
140
|
-
|
141
|
-
Examples of gems built atop this gem are:
|
142
|
-
|
143
|
-
- [Gemsmith](https://github.com/bkuhlmann/gemsmith) - A command line interface for smithing new Ruby
|
144
|
-
gems.
|
145
|
-
- [Git Cop](https://github.com/bkuhlmann/git-cop) - Enforces consistent Git commits.
|
146
|
-
- [Milestoner](https://github.com/bkuhlmann/milestoner) - A command line interface for releasing Git
|
147
|
-
repository milestones.
|
148
|
-
- [Pennyworth](https://github.com/bkuhlmann/pennyworth) - A command line interface that enhances and
|
149
|
-
extends [Alfred](https://www.alfredapp.com) with Ruby support.
|
150
|
-
- [Pragmater](https://github.com/bkuhlmann/pragmater) - A command line interface for
|
151
|
-
managing/formatting source file pragma comments.
|
152
|
-
- [Sublime Text Kit](https://github.com/bkuhlmann/sublime_text_kit) - A command line interface for
|
153
|
-
managing Sublime Text metadata.
|
154
|
-
- [Tocer](https://github.com/bkuhlmann/tocer) - A command line interface for generating table of
|
155
|
-
contents for Markdown files.
|
156
|
-
|
157
|
-
## Tests
|
158
|
-
|
159
|
-
To test, run:
|
160
|
-
|
161
|
-
bundle exec rake
|
162
|
-
|
163
|
-
## Versioning
|
164
|
-
|
165
|
-
Read [Semantic Versioning](https://semver.org) for details. Briefly, it means:
|
166
|
-
|
167
|
-
- Major (X.y.z) - Incremented for any backwards incompatible public API changes.
|
168
|
-
- Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
|
169
|
-
- Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
|
170
|
-
|
171
|
-
## Code of Conduct
|
172
|
-
|
173
|
-
Please note that this project is released with a [CODE OF CONDUCT](CODE_OF_CONDUCT.md). By
|
174
|
-
participating in this project you agree to abide by its terms.
|
175
|
-
|
176
|
-
## Contributions
|
177
|
-
|
178
|
-
Read [CONTRIBUTING](CONTRIBUTING.md) for details.
|
179
|
-
|
180
|
-
## License
|
181
|
-
|
182
|
-
Copyright 2016 [Alchemists](https://www.alchemists.io).
|
183
|
-
Read [LICENSE](LICENSE.md) for details.
|
184
|
-
|
185
|
-
## History
|
186
|
-
|
187
|
-
Read [CHANGES](CHANGES.md) for details.
|
188
|
-
Built with [Gemsmith](https://github.com/bkuhlmann/gemsmith).
|
189
|
-
|
190
|
-
## Credits
|
191
|
-
|
192
|
-
Developed by [Brooke Kuhlmann](https://www.alchemists.io) at
|
193
|
-
[Alchemists](https://www.alchemists.io).
|