labrat 1.4.1 → 1.5.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 +4 -4
- data/Gemfile +3 -0
- data/Gemfile.lock +55 -40
- data/labrat.gemspec +2 -1
- data/lib/config_files/labeldb.yml +1 -1
- data/lib/labrat/config.rb +4 -208
- data/lib/labrat/label_db.rb +7 -9
- data/lib/labrat/version.rb +1 -1
- metadata +20 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 595b6352e6630e3efbffd4fc438a818b43df1c596de48074fc490562b56f8e8b
|
|
4
|
+
data.tar.gz: 564456cd01a4bb534a41f4046ae34efb7069c0570ce8dd0ae2df2c3c22229553
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e29546a60511b70555b8eb200352ef908ea9c41dacfc86a6d490354ac00e8fe4ff04777cbf2778c58583dc76296da83be21ebdd45fa7ea6fc53b630467bde6bb
|
|
7
|
+
data.tar.gz: 529df6f6936b969f7c23f064954dc2c86d5638a6556dce443177053a2c28961e389ee550eae1a4b1181af7dffd9bad26c3d9709a5a135f5b3030bf6ae5de874d
|
data/Gemfile
CHANGED
|
@@ -5,6 +5,9 @@ source "https://rubygems.org"
|
|
|
5
5
|
# Specify your gem's dependencies in labrat.gemspec
|
|
6
6
|
gemspec
|
|
7
7
|
|
|
8
|
+
# Force the pre-bigdecimal-dep ttfunk so prawn can load even if bigdecimal 4.x is around
|
|
9
|
+
gem "ttfunk", "1.7.0"
|
|
10
|
+
|
|
8
11
|
group :development do
|
|
9
12
|
gem 'debug', '>= 1.0.0'
|
|
10
13
|
gem 'gem_docs', '>=0.3.1'
|
data/Gemfile.lock
CHANGED
|
@@ -12,15 +12,16 @@ GIT
|
|
|
12
12
|
PATH
|
|
13
13
|
remote: .
|
|
14
14
|
specs:
|
|
15
|
-
labrat (1.
|
|
15
|
+
labrat (1.5.0)
|
|
16
16
|
activesupport
|
|
17
17
|
fat_config (>= 0.4.2)
|
|
18
|
-
|
|
18
|
+
matrix
|
|
19
|
+
prawn (<= 2.5)
|
|
19
20
|
|
|
20
21
|
GEM
|
|
21
22
|
remote: https://rubygems.org/
|
|
22
23
|
specs:
|
|
23
|
-
activesupport (8.1.
|
|
24
|
+
activesupport (8.1.2)
|
|
24
25
|
base64
|
|
25
26
|
bigdecimal
|
|
26
27
|
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
@@ -33,6 +34,8 @@ GEM
|
|
|
33
34
|
securerandom (>= 0.3)
|
|
34
35
|
tzinfo (~> 2.0, >= 2.0.5)
|
|
35
36
|
uri (>= 0.13.1)
|
|
37
|
+
addressable (2.8.9)
|
|
38
|
+
public_suffix (>= 2.0.2, < 8.0)
|
|
36
39
|
ast (2.4.3)
|
|
37
40
|
base64 (0.3.0)
|
|
38
41
|
bigdecimal (3.3.1)
|
|
@@ -47,8 +50,8 @@ GEM
|
|
|
47
50
|
diff-lcs (1.6.2)
|
|
48
51
|
docile (1.4.1)
|
|
49
52
|
drb (2.2.3)
|
|
50
|
-
erb (6.0.
|
|
51
|
-
fat_config (0.
|
|
53
|
+
erb (6.0.2)
|
|
54
|
+
fat_config (0.8.0)
|
|
52
55
|
activesupport
|
|
53
56
|
fat_core (>= 5.6.1)
|
|
54
57
|
inifile
|
|
@@ -65,32 +68,38 @@ GEM
|
|
|
65
68
|
concurrent-ruby (~> 1.0)
|
|
66
69
|
inifile (3.0.0)
|
|
67
70
|
io-console (0.8.2)
|
|
68
|
-
irb (1.
|
|
71
|
+
irb (1.17.0)
|
|
69
72
|
pp (>= 0.6.0)
|
|
73
|
+
prism (>= 1.3.0)
|
|
70
74
|
rdoc (>= 4.0.0)
|
|
71
75
|
reline (>= 0.4.2)
|
|
72
|
-
json (2.18.
|
|
76
|
+
json (2.18.1)
|
|
77
|
+
json-schema (6.1.0)
|
|
78
|
+
addressable (~> 2.8)
|
|
79
|
+
bigdecimal (>= 3.1, < 5)
|
|
73
80
|
language_server-protocol (3.17.0.5)
|
|
74
81
|
lint_roller (1.1.0)
|
|
75
82
|
logger (1.7.0)
|
|
76
83
|
matrix (0.4.3)
|
|
84
|
+
mcp (0.8.0)
|
|
85
|
+
json-schema (>= 4.1)
|
|
77
86
|
method_source (1.1.0)
|
|
78
|
-
minitest (6.0.
|
|
87
|
+
minitest (6.0.2)
|
|
88
|
+
drb (~> 2.0)
|
|
79
89
|
prism (~> 1.5)
|
|
80
90
|
ostruct (0.6.3)
|
|
81
91
|
parallel (1.27.0)
|
|
82
|
-
parser (3.3.10.
|
|
92
|
+
parser (3.3.10.2)
|
|
83
93
|
ast (~> 2.4.1)
|
|
84
94
|
racc
|
|
85
|
-
pdf-core (0.
|
|
95
|
+
pdf-core (0.9.0)
|
|
86
96
|
pp (0.6.3)
|
|
87
97
|
prettyprint
|
|
88
|
-
prawn (2.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
ttfunk (~> 1.8)
|
|
98
|
+
prawn (2.4.0)
|
|
99
|
+
pdf-core (~> 0.9.0)
|
|
100
|
+
ttfunk (~> 1.7)
|
|
92
101
|
prettyprint (0.2.0)
|
|
93
|
-
prism (1.
|
|
102
|
+
prism (1.9.0)
|
|
94
103
|
pry (0.16.0)
|
|
95
104
|
coderay (~> 1.1)
|
|
96
105
|
method_source (~> 1.0)
|
|
@@ -98,10 +107,11 @@ GEM
|
|
|
98
107
|
psych (5.3.1)
|
|
99
108
|
date
|
|
100
109
|
stringio
|
|
110
|
+
public_suffix (7.0.5)
|
|
101
111
|
racc (1.8.1)
|
|
102
112
|
rainbow (3.1.1)
|
|
103
113
|
rake (13.3.1)
|
|
104
|
-
rdoc (7.0
|
|
114
|
+
rdoc (7.2.0)
|
|
105
115
|
erb
|
|
106
116
|
psych (>= 4.0.0)
|
|
107
117
|
tsort
|
|
@@ -117,19 +127,20 @@ GEM
|
|
|
117
127
|
rspec-expectations (3.13.5)
|
|
118
128
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
119
129
|
rspec-support (~> 3.13.0)
|
|
120
|
-
rspec-mocks (3.13.
|
|
130
|
+
rspec-mocks (3.13.8)
|
|
121
131
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
122
132
|
rspec-support (~> 3.13.0)
|
|
123
|
-
rspec-support (3.13.
|
|
124
|
-
rubocop (1.
|
|
133
|
+
rspec-support (3.13.7)
|
|
134
|
+
rubocop (1.85.1)
|
|
125
135
|
json (~> 2.3)
|
|
126
136
|
language_server-protocol (~> 3.17.0.2)
|
|
127
137
|
lint_roller (~> 1.1.0)
|
|
138
|
+
mcp (~> 0.6)
|
|
128
139
|
parallel (~> 1.10)
|
|
129
140
|
parser (>= 3.3.0.2)
|
|
130
141
|
rainbow (>= 2.2.2, < 4.0)
|
|
131
142
|
regexp_parser (>= 2.9.3, < 3.0)
|
|
132
|
-
rubocop-ast (>= 1.
|
|
143
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
133
144
|
ruby-progressbar (~> 1.7)
|
|
134
145
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
135
146
|
rubocop-ast (1.49.0)
|
|
@@ -142,7 +153,7 @@ GEM
|
|
|
142
153
|
rubocop-rake (0.7.1)
|
|
143
154
|
lint_roller (~> 1.1)
|
|
144
155
|
rubocop (>= 1.72.1)
|
|
145
|
-
rubocop-rspec (3.
|
|
156
|
+
rubocop-rspec (3.9.0)
|
|
146
157
|
lint_roller (~> 1.1)
|
|
147
158
|
rubocop (~> 1.81)
|
|
148
159
|
rubocop-shopify (2.18.0)
|
|
@@ -159,8 +170,7 @@ GEM
|
|
|
159
170
|
tomlib (0.7.3)
|
|
160
171
|
bigdecimal
|
|
161
172
|
tsort (0.2.0)
|
|
162
|
-
ttfunk (1.
|
|
163
|
-
bigdecimal (~> 3.1)
|
|
173
|
+
ttfunk (1.7.0)
|
|
164
174
|
tzinfo (2.0.6)
|
|
165
175
|
concurrent-ruby (~> 1.0)
|
|
166
176
|
unicode-display_width (3.2.0)
|
|
@@ -183,9 +193,11 @@ DEPENDENCIES
|
|
|
183
193
|
rubocop
|
|
184
194
|
rubocop-ddoherty!
|
|
185
195
|
simplecov
|
|
196
|
+
ttfunk (= 1.7.0)
|
|
186
197
|
|
|
187
198
|
CHECKSUMS
|
|
188
|
-
activesupport (8.1.
|
|
199
|
+
activesupport (8.1.2) sha256=88842578ccd0d40f658289b0e8c842acfe9af751afee2e0744a7873f50b6fdae
|
|
200
|
+
addressable (2.8.9) sha256=cc154fcbe689711808a43601dee7b980238ce54368d23e127421753e46895485
|
|
189
201
|
ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
|
|
190
202
|
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
|
|
191
203
|
bigdecimal (3.3.1) sha256=eaa01e228be54c4f9f53bf3cc34fe3d5e845c31963e7fcc5bedb05a4e7d52218
|
|
@@ -198,49 +210,52 @@ CHECKSUMS
|
|
|
198
210
|
diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962
|
|
199
211
|
docile (1.4.1) sha256=96159be799bfa73cdb721b840e9802126e4e03dfc26863db73647204c727f21e
|
|
200
212
|
drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373
|
|
201
|
-
erb (6.0.
|
|
202
|
-
fat_config (0.
|
|
213
|
+
erb (6.0.2) sha256=9fe6264d44f79422c87490a1558479bd0e7dad4dd0e317656e67ea3077b5242b
|
|
214
|
+
fat_config (0.8.0) sha256=5648b33d5eba414276ea064d9dec99fb853dfac4b5e003636b45b47bf2858dde
|
|
203
215
|
fat_core (7.1.3) sha256=54aae0da4edcfb77cd2370c46c8a36f792cb0a890069191a47c776c5fce5d367
|
|
204
216
|
gem_docs (0.3.1) sha256=cdd4ec7f65e15e12947f8b8db0d9dea7cc0603c3415c06526263cdab8e32ea65
|
|
205
217
|
i18n (1.14.8) sha256=285778639134865c5e0f6269e0b818256017e8cde89993fdfcbfb64d088824a5
|
|
206
218
|
inifile (3.0.0) sha256=b103eb3655ec93cc626cf2de00950e91f7e69b8398842968e17e1815cfacbfb0
|
|
207
219
|
io-console (0.8.2) sha256=d6e3ae7a7cc7574f4b8893b4fca2162e57a825b223a177b7afa236c5ef9814cc
|
|
208
|
-
irb (1.
|
|
209
|
-
json (2.18.
|
|
210
|
-
|
|
220
|
+
irb (1.17.0) sha256=168c4ddb93d8a361a045c41d92b2952c7a118fa73f23fe14e55609eb7a863aae
|
|
221
|
+
json (2.18.1) sha256=fe112755501b8d0466b5ada6cf50c8c3f41e897fa128ac5d263ec09eedc9f986
|
|
222
|
+
json-schema (6.1.0) sha256=6bf70a2cfb6dfd5a06da28093fa8190f324c88eabd36a7f47097f227321dc702
|
|
223
|
+
labrat (1.5.0)
|
|
211
224
|
language_server-protocol (3.17.0.5) sha256=fd1e39a51a28bf3eec959379985a72e296e9f9acfce46f6a79d31ca8760803cc
|
|
212
225
|
lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
|
|
213
226
|
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
|
|
214
227
|
matrix (0.4.3) sha256=a0d5ab7ddcc1973ff690ab361b67f359acbb16958d1dc072b8b956a286564c5b
|
|
228
|
+
mcp (0.8.0) sha256=ae8bd146bb8e168852866fd26f805f52744f6326afb3211e073f78a95e0c34fb
|
|
215
229
|
method_source (1.1.0) sha256=181301c9c45b731b4769bc81e8860e72f9161ad7d66dd99103c9ab84f560f5c5
|
|
216
|
-
minitest (6.0.
|
|
230
|
+
minitest (6.0.2) sha256=db6e57956f6ecc6134683b4c87467d6dd792323c7f0eea7b93f66bd284adbc3d
|
|
217
231
|
ostruct (0.6.3) sha256=95a2ed4a4bd1d190784e666b47b2d3f078e4a9efda2fccf18f84ddc6538ed912
|
|
218
232
|
parallel (1.27.0) sha256=4ac151e1806b755fb4e2dc2332cbf0e54f2e24ba821ff2d3dcf86bf6dc4ae130
|
|
219
|
-
parser (3.3.10.
|
|
220
|
-
pdf-core (0.
|
|
233
|
+
parser (3.3.10.2) sha256=6f60c84aa4bdcedb6d1a2434b738fe8a8136807b6adc8f7f53b97da9bc4e9357
|
|
234
|
+
pdf-core (0.9.0) sha256=4f368b2f12b57ec979872d4bf4bd1a67e8648e0c81ab89801431d2fc89f4e0bb
|
|
221
235
|
pp (0.6.3) sha256=2951d514450b93ccfeb1df7d021cae0da16e0a7f95ee1e2273719669d0ab9df6
|
|
222
|
-
prawn (2.
|
|
236
|
+
prawn (2.4.0) sha256=82062744f7126c2d77501da253a154271790254dfa8c309b8e52e79bc5de2abd
|
|
223
237
|
prettyprint (0.2.0) sha256=2bc9e15581a94742064a3cc8b0fb9d45aae3d03a1baa6ef80922627a0766f193
|
|
224
|
-
prism (1.
|
|
238
|
+
prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85
|
|
225
239
|
pry (0.16.0) sha256=d76c69065698ed1f85e717bd33d7942c38a50868f6b0673c636192b3d1b6054e
|
|
226
240
|
psych (5.3.1) sha256=eb7a57cef10c9d70173ff74e739d843ac3b2c019a003de48447b2963d81b1974
|
|
241
|
+
public_suffix (7.0.5) sha256=1a8bb08f1bbea19228d3bed6e5ed908d1cb4f7c2726d18bd9cadf60bc676f623
|
|
227
242
|
racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
|
|
228
243
|
rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
|
|
229
244
|
rake (13.3.1) sha256=8c9e89d09f66a26a01264e7e3480ec0607f0c497a861ef16063604b1b08eb19c
|
|
230
|
-
rdoc (7.0
|
|
245
|
+
rdoc (7.2.0) sha256=8650f76cd4009c3b54955eb5d7e3a075c60a57276766ebf36f9085e8c9f23192
|
|
231
246
|
regexp_parser (2.11.3) sha256=ca13f381a173b7a93450e53459075c9b76a10433caadcb2f1180f2c741fc55a4
|
|
232
247
|
reline (0.6.3) sha256=1198b04973565b36ec0f11542ab3f5cfeeec34823f4e54cebde90968092b1835
|
|
233
248
|
rspec (3.13.2) sha256=206284a08ad798e61f86d7ca3e376718d52c0bc944626b2349266f239f820587
|
|
234
249
|
rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d
|
|
235
250
|
rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836
|
|
236
|
-
rspec-mocks (3.13.
|
|
237
|
-
rspec-support (3.13.
|
|
238
|
-
rubocop (1.
|
|
251
|
+
rspec-mocks (3.13.8) sha256=086ad3d3d17533f4237643de0b5c42f04b66348c28bf6b9c2d3f4a3b01af1d47
|
|
252
|
+
rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c
|
|
253
|
+
rubocop (1.85.1) sha256=3dbcf9e961baa4c376eeeb2a03913dca5e3987033b04d38fa538aa1e7406cc77
|
|
239
254
|
rubocop-ast (1.49.0) sha256=49c3676d3123a0923d333e20c6c2dbaaae2d2287b475273fddee0c61da9f71fd
|
|
240
255
|
rubocop-ddoherty (0.1.2)
|
|
241
256
|
rubocop-performance (1.26.1) sha256=cd19b936ff196df85829d264b522fd4f98b6c89ad271fa52744a8c11b8f71834
|
|
242
257
|
rubocop-rake (0.7.1) sha256=3797f2b6810c3e9df7376c26d5f44f3475eda59eb1adc38e6f62ecf027cbae4d
|
|
243
|
-
rubocop-rspec (3.
|
|
258
|
+
rubocop-rspec (3.9.0) sha256=8fa70a3619408237d789aeecfb9beef40576acc855173e60939d63332fdb55e2
|
|
244
259
|
rubocop-shopify (2.18.0) sha256=dafa25e5617ce4600ff86b1de3d5b78e43ab3d58cc5729df38e492b8e10294eb
|
|
245
260
|
ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
|
|
246
261
|
securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1
|
|
@@ -250,7 +265,7 @@ CHECKSUMS
|
|
|
250
265
|
stringio (3.2.0) sha256=c37cb2e58b4ffbd33fe5cd948c05934af997b36e0b6ca6fdf43afa234cf222e1
|
|
251
266
|
tomlib (0.7.3) sha256=85e562eeaa40b2aca552a13515f41fc6ae9dc522154bc1089c8d3ef94dcebd9b
|
|
252
267
|
tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f
|
|
253
|
-
ttfunk (1.
|
|
268
|
+
ttfunk (1.7.0) sha256=2370ba484b1891c70bdcafd3448cfd82a32dd794802d81d720a64c15d3ef2a96
|
|
254
269
|
tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b
|
|
255
270
|
unicode-display_width (3.2.0) sha256=0cdd96b5681a5949cdbc2c55e7b420facae74c4aaf9a9815eee1087cb1853c42
|
|
256
271
|
unicode-emoji (4.2.0) sha256=519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f
|
data/labrat.gemspec
CHANGED
data/lib/labrat/config.rb
CHANGED
|
@@ -1,215 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# A thin wrapper around FatConfig.
|
|
3
4
|
module Labrat
|
|
4
|
-
|
|
5
|
-
# returning a Hash to reflect the configuration. We use YAML as the
|
|
6
|
-
# configuration format and look for the config file in the standard places.
|
|
7
|
-
class Config
|
|
8
|
-
# Return a Hash of the YAML-ized config files for app_name directories.
|
|
9
|
-
# Config file may be located in either the xdg locations (containing any
|
|
10
|
-
# variant of base: base, base.yml, or base.yaml) or in the classic
|
|
11
|
-
# locations (/etc/app_namerc, /etc/app_name, ~/.app_namerc~, or
|
|
12
|
-
# ~/.app_name/base[.ya?ml]). Return a hash that reflects the merging of
|
|
13
|
-
# those files according to the following priorities, from highest to
|
|
14
|
-
# lowest:
|
|
15
|
-
#
|
|
16
|
-
# 1. A config file pointed to by the environment variable APPNAME_CONFIG
|
|
17
|
-
# 2. User classic config files
|
|
18
|
-
# 3. User xdg config files for app_name,
|
|
19
|
-
# 4. A config file pointed to by the environment variable APPNAME_SYS_CONFIG
|
|
20
|
-
# 5. System classic config files,
|
|
21
|
-
# 6. System xdg config files for for app_name,
|
|
22
|
-
#
|
|
23
|
-
# If an environment variable is found, the search for xdg and classic
|
|
24
|
-
# config files is skipped. Any dir_prefix is pre-pended to search
|
|
25
|
-
# locations environment, xdg and classic config paths so you can run this
|
|
26
|
-
# on a temporary directory set up for testing.
|
|
5
|
+
module Config
|
|
27
6
|
def self.read(app_name, base: 'config', dir_prefix: '', xdg: true, verbose: false)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
usr_configs = paths[:user]
|
|
31
|
-
merge_configs_from((sys_configs + usr_configs).compact, verbose: verbose)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def self.config_paths(app_name, base: 'config', dir_prefix: '', xdg: true)
|
|
35
|
-
sys_configs = []
|
|
36
|
-
sys_env_name = "#{app_name.upcase}_SYS_CONFIG"
|
|
37
|
-
if ENV[sys_env_name]
|
|
38
|
-
sys_fname = File.join(dir_prefix, File.expand_path(ENV[sys_env_name]))
|
|
39
|
-
sys_configs << sys_fname if File.readable?(sys_fname)
|
|
40
|
-
else
|
|
41
|
-
sys_configs +=
|
|
42
|
-
if xdg
|
|
43
|
-
find_xdg_sys_config_files(app_name, base, dir_prefix)
|
|
44
|
-
else
|
|
45
|
-
find_classic_sys_config_files(app_name, base, dir_prefix)
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
usr_configs = []
|
|
50
|
-
usr_env_name = "#{app_name.upcase}_CONFIG"
|
|
51
|
-
if ENV[usr_env_name]
|
|
52
|
-
usr_fname = File.join(dir_prefix, File.expand_path(ENV[usr_env_name]))
|
|
53
|
-
usr_configs << usr_fname if File.readable?(usr_fname)
|
|
54
|
-
else
|
|
55
|
-
usr_configs <<
|
|
56
|
-
if xdg
|
|
57
|
-
find_xdg_user_config_file(app_name, base, dir_prefix)
|
|
58
|
-
else
|
|
59
|
-
find_classic_user_config_file(app_name, dir_prefix)
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
{ system: sys_configs.compact, user: usr_configs.compact }
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
# Merge the settings from the given Array of config files in order from
|
|
66
|
-
# lowest priority to highest priority, starting with an empty hash. Any
|
|
67
|
-
# values of the top-level hash that are themselves Hashes are merged
|
|
68
|
-
# recursively.
|
|
69
|
-
def self.merge_configs_from(files = [], verbose: false)
|
|
70
|
-
hash = {}
|
|
71
|
-
files.each do |f|
|
|
72
|
-
next unless File.readable?(f)
|
|
73
|
-
|
|
74
|
-
yml_hash = YAML.load_file(f)
|
|
75
|
-
next unless yml_hash
|
|
76
|
-
|
|
77
|
-
if yml_hash.is_a?(Hash)
|
|
78
|
-
yml_hash = yml_hash
|
|
79
|
-
else
|
|
80
|
-
raise "Error loading file #{f}:\n#{File.read(f)[0..500]}"
|
|
81
|
-
end
|
|
82
|
-
yml_hash.report("Merging config from file '#{f}") if verbose
|
|
83
|
-
hash.deep_merge!(yml_hash)
|
|
84
|
-
end
|
|
85
|
-
hash
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
########################################################################
|
|
89
|
-
# XDG config files
|
|
90
|
-
########################################################################
|
|
91
|
-
|
|
92
|
-
# From the XDG standard:
|
|
93
|
-
# Your application should store and load data and configuration files to/from
|
|
94
|
-
# the directories pointed by the following environment variables:
|
|
95
|
-
#
|
|
96
|
-
# $XDG_CONFIG_HOME (default: "$HOME/.config"): user-specific configuration files.
|
|
97
|
-
# $XDG_CONFIG_DIRS (default: "/etc/xdg"): precedence-ordered set of system configuration directories.
|
|
98
|
-
|
|
99
|
-
# Return the absolute path names of all XDG system config files for
|
|
100
|
-
# app_name with the basename variants of base. Return the lowest priority
|
|
101
|
-
# files first, highest last. Prefix the search locations with dir_prefix
|
|
102
|
-
# if given.
|
|
103
|
-
def self.find_xdg_sys_config_files(app_name, base, dir_prefix)
|
|
104
|
-
configs = []
|
|
105
|
-
xdg_search_dirs = ENV['XDG_CONFIG_DIRS']&.split(':')&.reverse || ['/etc/xdg']
|
|
106
|
-
xdg_search_dirs.each do |dir|
|
|
107
|
-
dir = File.expand_path(File.join(dir, app_name))
|
|
108
|
-
dir = File.join(dir_prefix, dir) unless dir_prefix.nil? || dir_prefix.strip.empty?
|
|
109
|
-
base = app_name if base.nil? || base.strip.empty?
|
|
110
|
-
base_candidates = [
|
|
111
|
-
base.to_s,
|
|
112
|
-
"#{base}.yml",
|
|
113
|
-
"#{base}.yaml",
|
|
114
|
-
"#{base}.cfg",
|
|
115
|
-
"#{base}.config"
|
|
116
|
-
]
|
|
117
|
-
config_fname = base_candidates.find { |b| File.readable?(File.join(dir, b)) }
|
|
118
|
-
configs << File.join(dir, config_fname) if config_fname
|
|
119
|
-
end
|
|
120
|
-
configs
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
# Return the absolute path name of any XDG user config files for app_name
|
|
124
|
-
# with the basename variants of base. The XDG_CONFIG_HOME environment
|
|
125
|
-
# variable for the user configs is intended to be the name of a single xdg
|
|
126
|
-
# config directory, not a list of colon-separated directories as for the
|
|
127
|
-
# system config. Return the name of a config file for this app in
|
|
128
|
-
# XDG_CONFIG_HOME (or ~/.config by default). Prefix the search location
|
|
129
|
-
# with dir_prefix if given.
|
|
130
|
-
def self.find_xdg_user_config_file(app_name, base, dir_prefix)
|
|
131
|
-
dir_prefix ||= ''
|
|
132
|
-
base ||= base&.strip || app_name
|
|
133
|
-
xdg_search_dir = ENV['XDG_CONFIG_HOME'] || ['~/.config']
|
|
134
|
-
dir = File.expand_path(File.join(xdg_search_dir, app_name))
|
|
135
|
-
dir = File.join(dir_prefix, dir) unless dir_prefix.strip.empty?
|
|
136
|
-
return unless Dir.exist?(dir)
|
|
137
|
-
|
|
138
|
-
base_candidates = [
|
|
139
|
-
base.to_s,
|
|
140
|
-
"#{base}.yml",
|
|
141
|
-
"#{base}.yaml",
|
|
142
|
-
"#{base}.cfg",
|
|
143
|
-
"#{base}.config"
|
|
144
|
-
]
|
|
145
|
-
config_fname = base_candidates.find { |b| File.readable?(File.join(dir, b)) }
|
|
146
|
-
if config_fname
|
|
147
|
-
File.join(dir, config_fname)
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
########################################################################
|
|
152
|
-
# Classic config files
|
|
153
|
-
########################################################################
|
|
154
|
-
|
|
155
|
-
# Return the absolute path names of all "classic" system config files for
|
|
156
|
-
# app_name with the basename variants of base. Return the lowest priority
|
|
157
|
-
# files first, highest last. Prefix the search locations with dir_prefix
|
|
158
|
-
# if given.
|
|
159
|
-
def self.find_classic_sys_config_files(app_name, base, dir_prefix)
|
|
160
|
-
dir_prefix ||= ''
|
|
161
|
-
configs = []
|
|
162
|
-
env_config = ENV["#{app_name.upcase}_SYS_CONFIG"]
|
|
163
|
-
if env_config && File.readable?(config = File.join(dir_prefix, File.expand_path(env_config)))
|
|
164
|
-
configs = [config]
|
|
165
|
-
elsif File.readable?(config = File.join(dir_prefix, "/etc/#{app_name}"))
|
|
166
|
-
configs = [config]
|
|
167
|
-
elsif File.readable?(config = File.join(dir_prefix, "/etc/#{app_name}rc"))
|
|
168
|
-
configs = [config]
|
|
169
|
-
else
|
|
170
|
-
dir = File.join(dir_prefix, "/etc/#{app_name}")
|
|
171
|
-
if Dir.exist?(dir)
|
|
172
|
-
base = app_name if base.nil? || base.strip.empty?
|
|
173
|
-
base_candidates = [
|
|
174
|
-
base.to_s + "#{base}.yml",
|
|
175
|
-
"#{base}.yaml",
|
|
176
|
-
"#{base}.cfg",
|
|
177
|
-
"#{base}.config"
|
|
178
|
-
]
|
|
179
|
-
config = base_candidates.find { |b| File.readable?(File.join(dir, b)) }
|
|
180
|
-
configs = [File.join(dir, config)] if config
|
|
181
|
-
end
|
|
182
|
-
end
|
|
183
|
-
configs
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
# Return the absolute path names of all "classic" system config files for
|
|
187
|
-
# app_name with the basename variants of base. Return the lowest priority
|
|
188
|
-
# files first, highest last. Prefix the search locations with dir_prefix if
|
|
189
|
-
# given.
|
|
190
|
-
def self.find_classic_user_config_file(app_name, dir_prefix)
|
|
191
|
-
dir_prefix ||= ''
|
|
192
|
-
config_fname = nil
|
|
193
|
-
env_config = ENV["#{app_name.upcase}_CONFIG"]
|
|
194
|
-
if env_config && File.readable?(config = File.join(dir_prefix, File.expand_path(env_config)))
|
|
195
|
-
config_fname = config
|
|
196
|
-
elsif Dir.exist?(config_dir = File.join(dir_prefix, File.expand_path("~/.#{app_name}")))
|
|
197
|
-
base_candidates = ["config.yml", "config.yaml", "config"]
|
|
198
|
-
base_fname = base_candidates.find { |b| File.readable?(File.join(config_dir, b)) }
|
|
199
|
-
config_fname = File.join(config_dir, base_fname)
|
|
200
|
-
elsif Dir.exist?(config_dir = File.join(dir_prefix, File.expand_path('~/')))
|
|
201
|
-
base_candidates = [
|
|
202
|
-
".#{app_name}",
|
|
203
|
-
".#{app_name}rc",
|
|
204
|
-
".#{app_name}.yml",
|
|
205
|
-
".#{app_name}.yaml",
|
|
206
|
-
".#{app_name}.cfg",
|
|
207
|
-
".#{app_name}.config"
|
|
208
|
-
]
|
|
209
|
-
base_fname = base_candidates.find { |b| File.readable?(File.join(config_dir, b)) }
|
|
210
|
-
config_fname = File.join(config_dir, base_fname)
|
|
211
|
-
end
|
|
212
|
-
config_fname
|
|
7
|
+
reader = FatConfig::Reader.new(app_name, xdg:, root_prefix: dir_prefix)
|
|
8
|
+
reader.read(verbose:)
|
|
213
9
|
end
|
|
214
10
|
end
|
|
215
11
|
end
|
data/lib/labrat/label_db.rb
CHANGED
|
@@ -4,26 +4,26 @@ module Labrat
|
|
|
4
4
|
module LabelDb
|
|
5
5
|
class << self
|
|
6
6
|
# Module-level variable to hold the merged database.
|
|
7
|
-
attr_accessor :db
|
|
7
|
+
attr_accessor :db, :reader
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
# Read in the Labrat database of label settings, merging system and user
|
|
11
11
|
# databases.
|
|
12
12
|
def self.read(dir_prefix: '')
|
|
13
|
-
reader = FatConfig::Reader.new('labrat', root_prefix: dir_prefix)
|
|
14
|
-
self.db = reader.read('labeldb')
|
|
13
|
+
self.reader = FatConfig::Reader.new('labrat', root_prefix: dir_prefix)
|
|
14
|
+
self.db = reader.read('labeldb').transform_keys(&:downcase)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
# Return a hash of config settings for the label named by labname.
|
|
18
18
|
def self.[](labname)
|
|
19
19
|
read unless db
|
|
20
|
-
db[labname.to_sym] || {}
|
|
20
|
+
db[labname.to_sym] || db[labname.downcase.to_sym] || {}
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
# Set a runtime configuration for a single labelname.
|
|
24
24
|
def self.[]=(labname, config = {})
|
|
25
25
|
read unless db
|
|
26
|
-
db[labname.to_sym] = config
|
|
26
|
+
db[labname.to_sym.downcase] = config
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
# Return an Array of label names.
|
|
@@ -37,13 +37,11 @@ module Labrat
|
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
def self.system_db_paths(dir_prefix = '')
|
|
40
|
-
|
|
41
|
-
paths[:system]
|
|
40
|
+
reader.config_paths[:system]
|
|
42
41
|
end
|
|
43
42
|
|
|
44
43
|
def self.user_db_paths(dir_prefix = '')
|
|
45
|
-
|
|
46
|
-
paths[:user]
|
|
44
|
+
reader.config_paths[:user]
|
|
47
45
|
end
|
|
48
46
|
end
|
|
49
47
|
end
|
data/lib/labrat/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: labrat
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel E. Doherty
|
|
@@ -37,20 +37,34 @@ dependencies:
|
|
|
37
37
|
- - ">="
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
39
|
version: 0.4.2
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: matrix
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
type: :runtime
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
40
54
|
- !ruby/object:Gem::Dependency
|
|
41
55
|
name: prawn
|
|
42
56
|
requirement: !ruby/object:Gem::Requirement
|
|
43
57
|
requirements:
|
|
44
|
-
- - "
|
|
58
|
+
- - "<="
|
|
45
59
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: '2.
|
|
60
|
+
version: '2.5'
|
|
47
61
|
type: :runtime
|
|
48
62
|
prerelease: false
|
|
49
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
50
64
|
requirements:
|
|
51
|
-
- - "
|
|
65
|
+
- - "<="
|
|
52
66
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: '2.
|
|
67
|
+
version: '2.5'
|
|
54
68
|
description: |2+
|
|
55
69
|
|
|
56
70
|
Labrat is a linux command-line program for quickly printing labels. Labrat uses
|
|
@@ -146,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
146
160
|
- !ruby/object:Gem::Version
|
|
147
161
|
version: '0'
|
|
148
162
|
requirements: []
|
|
149
|
-
rubygems_version: 4.0.
|
|
163
|
+
rubygems_version: 4.0.0
|
|
150
164
|
specification_version: 4
|
|
151
165
|
summary: Command-line and Emacs label print software.
|
|
152
166
|
test_files: []
|