runcom 2.0.1 → 3.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5c682ecef6b0fdb331b60763b7db250864459611ad4b8a42d72f35a4c8b90dc
4
- data.tar.gz: e715f8344daeb274ed95fafaf5b4d027434b86ee120a314520b4d3be05f67b87
3
+ metadata.gz: 6a957c88bd4bd09900d6471688d00d365390837bf00fc04ae417554b9ffb575e
4
+ data.tar.gz: fdece804569302d90ac3ca35c5775416d180e6e3c499dce81742e8e6611f7051
5
5
  SHA512:
6
- metadata.gz: 3eb7680b28f427e9d1043343984080822a5951c373825cd42021ccd1680c0cba84c29d5a002d63b383f1d95595267ccf8c007db3e1c6b0d03b7d4b3514fa2a86
7
- data.tar.gz: 4ee14813ef215fb9076eccde7bc648e7ab46d9b0fb327d2deaa081e96099fec21a65b2b015b5529965c42cdc221eac43bcd3725c573e80d756b838b855c30a4b
6
+ metadata.gz: cbc1145bc4818734ad328b36d1cc1a153ab2aea703e9f9cace693a2be03a131f03bbed1fbb198824b6ac38dc3addd74fcdde34e93153458aade0afd85cca984a
7
+ data.tar.gz: 52f0b77a602b49e8f196ef502b2a9e54a03e3a3cf9b0cd9601ec3cdf4a905d3ebc3e0a77f6dd087cc018edc91d595a5e98965776b9a8a2cf3890dff93131b0e6
Binary file
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -3,9 +3,7 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/runcom.svg)](http://badge.fury.io/rb/runcom)
4
4
  [![Code Climate Maintainability](https://api.codeclimate.com/v1/badges/129b7ea524a0f5a6a805/maintainability)](https://codeclimate.com/github/bkuhlmann/runcom/maintainability)
5
5
  [![Code Climate Test Coverage](https://api.codeclimate.com/v1/badges/129b7ea524a0f5a6a805/test_coverage)](https://codeclimate.com/github/bkuhlmann/runcom/test_coverage)
6
- [![Gemnasium Status](https://gemnasium.com/bkuhlmann/runcom.svg)](https://gemnasium.com/bkuhlmann/runcom)
7
6
  [![Circle CI Status](https://circleci.com/gh/bkuhlmann/runcom.svg?style=svg)](https://circleci.com/gh/bkuhlmann/runcom)
8
- [![Patreon](https://img.shields.io/badge/patreon-donate-brightgreen.svg)](https://www.patreon.com/bkuhlmann)
9
7
 
10
8
  Runcom (a.k.a. [Run Command](https://en.wikipedia.org/wiki/Run_commands)) provides common
11
9
  functionality for Command Line Interfaces (CLIs) in which to manage global, local, or multiple
@@ -71,25 +69,29 @@ from custom locations. It is meant to be used within your CLI program(s).
71
69
 
72
70
  An object can be initialized as follows:
73
71
 
74
- configuration = Runcom::Configuration.new project_name: "example"
72
+ configuration = Runcom::Configuration.new "example"
75
73
 
76
74
  The default file name for a configuration is `configuration.yml` but a custom name can be used if
77
75
  desired:
78
76
 
79
- configuration = Runcom::Configuration.new project_name: "example", file_name: "example.yml"
77
+ configuration = Runcom::Configuration.new "example", file_name: "example.yml"
80
78
 
81
79
  Default settings can be initialized as well:
82
80
 
83
- configuration = Runcom::Configuration.new project_name: "example", defaults: {name: "Example"}
81
+ configuration = Runcom::Configuration.new "example", defaults: {name: "Example"}
84
82
 
85
83
  Once a configuration has been initialized, a hash representation can be obtained:
86
84
 
87
85
  configuration.to_h
88
86
 
89
- A configuration can be merged with another hash (handy for runtime overrides)
87
+ A configuration can be merged with another hash (handy for runtime overrides):
90
88
 
91
89
  updated_configuration = configuration.merge {name: "Updated Name"}
92
90
 
91
+ A configuration can also be merged with another configuration:
92
+
93
+ updated_configuration = configuration.merge Runcom::Configuration.new("other", defaults: {a: 1})
94
+
93
95
  The computed path of the configuration can be asked for as well:
94
96
 
95
97
  configuration.path # "~/.config/example/configuration.yml"
@@ -166,7 +168,7 @@ Read [CONTRIBUTING](CONTRIBUTING.md) for details.
166
168
 
167
169
  ## License
168
170
 
169
- Copyright (c) 2016 [Alchemists](https://www.alchemists.io).
171
+ Copyright 2016 [Alchemists](https://www.alchemists.io).
170
172
  Read [LICENSE](LICENSE.md) for details.
171
173
 
172
174
  ## History
@@ -9,36 +9,42 @@ module Runcom
9
9
  class Configuration
10
10
  using Refinements::Hashes
11
11
 
12
- attr_reader :path
12
+ DEFAULT_FILE_NAME = "configuration.yml"
13
13
 
14
- def initialize project_name:, file_name: "configuration.yml", defaults: {}
15
- @path = load_path project_name, file_name
14
+ def initialize name, file_name: DEFAULT_FILE_NAME, defaults: {}
15
+ @name = name
16
+ @file_name = file_name
16
17
  @defaults = defaults
17
18
  @settings = defaults.deep_merge process_settings
18
19
  end
19
20
 
20
- def merge custom_settings
21
- settings.deep_merge custom_settings
21
+ def path
22
+ paths.find(&:exist?)
22
23
  end
23
24
 
24
- def to_h
25
- settings
25
+ def merge other
26
+ self.class.new name, file_name: file_name, defaults: settings.deep_merge(other.to_h)
26
27
  end
27
28
 
28
- private
29
+ # :reek:FeatureEnvy
30
+ def == other
31
+ other.is_a?(Configuration) && hash == other.hash
32
+ end
29
33
 
30
- attr_reader :paths, :defaults, :settings
34
+ alias eql? ==
31
35
 
32
- def load_path project, file
33
- paths = XDG::Configuration.computed_dirs.map { |root| Pathname "#{root}/#{project}/#{file}" }
34
- paths.find(&:exist?)
36
+ def hash
37
+ [name, file_name, to_h, self.class].hash
35
38
  end
36
39
 
37
- def load_settings
38
- yaml = YAML.load_file path
39
- yaml.is_a?(Hash) ? yaml : {}
40
+ def to_h
41
+ settings
40
42
  end
41
43
 
44
+ private
45
+
46
+ attr_reader :name, :file_name, :defaults, :settings
47
+
42
48
  def process_settings
43
49
  load_settings
44
50
  rescue Psych::SyntaxError => error
@@ -46,5 +52,16 @@ module Runcom
46
52
  rescue StandardError
47
53
  defaults
48
54
  end
55
+
56
+ def load_settings
57
+ yaml = YAML.load_file path
58
+ yaml.is_a?(Hash) ? yaml : {}
59
+ end
60
+
61
+ def paths
62
+ XDG::Configuration.computed_dirs.map do |root|
63
+ Pathname "#{root}/#{name}/#{file_name}"
64
+ end
65
+ end
49
66
  end
50
67
  end
@@ -12,7 +12,7 @@ module Runcom
12
12
  end
13
13
 
14
14
  def self.version
15
- "2.0.1"
15
+ "3.0.0"
16
16
  end
17
17
 
18
18
  def self.version_label
@@ -6,7 +6,7 @@ module Runcom
6
6
  module XDG
7
7
  # Represents X Desktop Group (XGD) configuration support. XGD is also known as
8
8
  # [Free Desktop](https://www.freedesktop.org). Here is the exact
9
- # [specification](https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html) being
9
+ # [specification](https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html) used
10
10
  # for this implementation.
11
11
  class Configuration
12
12
  def self.home_dir
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: 2.0.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -10,27 +10,26 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDeDCCAmCgAwIBAgIBATANBgkqhkiG9w0BAQUFADBBMQ8wDQYDVQQDDAZicm9v
14
- a2UxGjAYBgoJkiaJk/IsZAEZFgphbGNoZW1pc3RzMRIwEAYKCZImiZPyLGQBGRYC
15
- aW8wHhcNMTcxMDI5MjExMDE0WhcNMTgxMDI5MjExMDE0WjBBMQ8wDQYDVQQDDAZi
16
- cm9va2UxGjAYBgoJkiaJk/IsZAEZFgphbGNoZW1pc3RzMRIwEAYKCZImiZPyLGQB
17
- GRYCaW8wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCw5ljqJRwCHI+L
18
- DHJM8mLBNg/PMlK/pVlesbOOnw9yOh04cUX4FNDzGG7MUIbZel55a2FCGpnPcR23
19
- rXNYbdJ69G4pCEZVRHd93EV3mTldlr3cqdJM+V4F9kk3Y5G0AdkEjet0U9CgmNg/
20
- J8fp7mek76hsG5AFZ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x8Yc3EupdH7uhNaTXQGyORN6aOY//1QXXMHIZ9tW74nZLhesWMSUMYy0XhB
18
+ brs+KkurHnc9FnEJAbG7ebGvl/ncqZt72nQvaxpDxvuCBHgJAz+8i5wl6FhLw+oT
19
+ 9z0A8KcGhz67SdcoQiD7qiCjL/2NTeWHOzkpPrdGlt088+VerEEGf5I13QCvaftP
20
+ D5vkU0YlAm1r98BymuJlcQ1qdkVEI1d48ph4kcS0S0nv1RiuyVb6TCAR3Nu3VaVq
21
+ 3fPzZKJLZBx67UvXdbdicWPiUR75elI4PXpLIic3xytaF52ZJYyKZCNZJhNwfQID
22
+ AQABo3sweTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU0nzow9vc
23
+ 2CdikiiE3fJhP/gY4ggwHwYDVR0RBBgwFoEUYnJvb2tlQGFsY2hlbWlzdHMuaW8w
24
+ HwYDVR0SBBgwFoEUYnJvb2tlQGFsY2hlbWlzdHMuaW8wDQYJKoZIhvcNAQELBQAD
25
+ ggEBAImQPNpkb90nkDUCJ4ivQNKK1LCebOjqZnOWGC4HxndvBQBqj78MTZifoODl
26
+ uPBY4fSnnpVGph+Y1OTWw/xhk3HE2AH0GDGC9xbM75qrg3/+a4D81pM94B6zuBdA
27
+ 7hxUy4kByawrii833IidV0zkI4lCombTNicc8JWXXSlL2G/sWPLndNvn5rzoyyRT
28
+ pPOLYGdB4hqUam3hBgLOsYIOVp+yXMvj0gvk/Djq8IR2P1RS4NZU7HHD485xkBfL
29
+ 4Zrsxi713z6sndd9JBAm4G7mJiV93MsuCM5N4ZDY7XaxIhvctNSNhX/Yn8LLdtGI
30
+ b4jw5t40FKyNUvLPPXYAvQALBtk=
32
31
  -----END CERTIFICATE-----
33
- date: 2018-01-01 00:00:00.000000000 Z
32
+ date: 2018-04-01 00:00:00.000000000 Z
34
33
  dependencies:
35
34
  - !ruby/object:Gem::Dependency
36
35
  name: refinements
@@ -38,14 +37,14 @@ dependencies:
38
37
  requirements:
39
38
  - - "~>"
40
39
  - !ruby/object:Gem::Version
41
- version: '5.0'
40
+ version: '5.1'
42
41
  type: :runtime
43
42
  prerelease: false
44
43
  version_requirements: !ruby/object:Gem::Requirement
45
44
  requirements:
46
45
  - - "~>"
47
46
  - !ruby/object:Gem::Version
48
- version: '5.0'
47
+ version: '5.1'
49
48
  - !ruby/object:Gem::Dependency
50
49
  name: bundler-audit
51
50
  requirement: !ruby/object:Gem::Requirement
@@ -88,34 +87,6 @@ dependencies:
88
87
  - - "~>"
89
88
  - !ruby/object:Gem::Version
90
89
  version: '1.0'
91
- - !ruby/object:Gem::Dependency
92
- name: gemsmith
93
- requirement: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - "~>"
96
- - !ruby/object:Gem::Version
97
- version: '11.0'
98
- type: :development
99
- prerelease: false
100
- version_requirements: !ruby/object:Gem::Requirement
101
- requirements:
102
- - - "~>"
103
- - !ruby/object:Gem::Version
104
- version: '11.0'
105
- - !ruby/object:Gem::Dependency
106
- name: git-cop
107
- requirement: !ruby/object:Gem::Requirement
108
- requirements:
109
- - - "~>"
110
- - !ruby/object:Gem::Version
111
- version: '2.0'
112
- type: :development
113
- prerelease: false
114
- version_requirements: !ruby/object:Gem::Requirement
115
- requirements:
116
- - - "~>"
117
- - !ruby/object:Gem::Version
118
- version: '2.0'
119
90
  - !ruby/object:Gem::Dependency
120
91
  name: guard-rspec
121
92
  requirement: !ruby/object:Gem::Requirement
@@ -178,14 +149,14 @@ dependencies:
178
149
  requirements:
179
150
  - - "~>"
180
151
  - !ruby/object:Gem::Version
181
- version: '4.7'
152
+ version: '4.8'
182
153
  type: :development
183
154
  prerelease: false
184
155
  version_requirements: !ruby/object:Gem::Requirement
185
156
  requirements:
186
157
  - - "~>"
187
158
  - !ruby/object:Gem::Version
188
- version: '4.7'
159
+ version: '4.8'
189
160
  - !ruby/object:Gem::Dependency
190
161
  name: rspec
191
162
  requirement: !ruby/object:Gem::Requirement
@@ -206,14 +177,14 @@ dependencies:
206
177
  requirements:
207
178
  - - "~>"
208
179
  - !ruby/object:Gem::Version
209
- version: '0.52'
180
+ version: '0.54'
210
181
  type: :development
211
182
  prerelease: false
212
183
  version_requirements: !ruby/object:Gem::Requirement
213
184
  requirements:
214
185
  - - "~>"
215
186
  - !ruby/object:Gem::Version
216
- version: '0.52'
187
+ version: '0.54'
217
188
  description:
218
189
  email:
219
190
  - brooke@alchemists.io
@@ -234,7 +205,10 @@ files:
234
205
  homepage: https://github.com/bkuhlmann/runcom
235
206
  licenses:
236
207
  - Apache-2.0
237
- metadata: {}
208
+ metadata:
209
+ source_code_uri: https://github.com/bkuhlmann/runcom
210
+ changelog_uri: https://github.com/bkuhlmann/runcom/blob/master/CHANGES.md
211
+ bug_tracker_uri: https://github.com/bkuhlmann/runcom/issues
238
212
  post_install_message:
239
213
  rdoc_options: []
240
214
  require_paths:
@@ -251,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
251
225
  version: '0'
252
226
  requirements: []
253
227
  rubyforge_project:
254
- rubygems_version: 2.7.4
228
+ rubygems_version: 2.7.6
255
229
  signing_key:
256
230
  specification_version: 4
257
231
  summary: A run command manager for command line interfaces.
metadata.gz.sig CHANGED
Binary file