fat_config 0.7.0 → 0.7.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
- data/CHANGELOG.md +16 -0
- data/CHANGELOG.org +13 -0
- data/README.md +34 -34
- data/lib/fat_config/errors.rb +14 -27
- data/lib/fat_config/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9402d73a4e16cab2a9088bece9dfa623d406858b5c0ae641df01ee988029e6a1
|
|
4
|
+
data.tar.gz: 042c81ad9c917ea1073db02259718a73792dd7e134f8c9c3aa4b60f7d9b756b4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9026e4d9b87df9db13e341e5e9af201388335db1a750e7e5d72ddea797787034545bdc03b0358acef9a16ae7fb37e31c7e305f23fc6f1023b5e3acf7fb7f2b72
|
|
7
|
+
data.tar.gz: 24b464de194eef9fb81afdcc23afd24dfcf4dcca35b6411d9befed18435dc6c98c3d147c5f6971d586a04e345fdc027be4b34e07fc6f75b6caf47a1ee4da7ccd
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
- [Version 0.7.1 <span class="timestamp-wrapper"><span class="timestamp">[2026-02-06 Fri]</span></span>](#org48cabe8)
|
|
2
|
+
- [Version 0.7.0 <span class="timestamp-wrapper"><span class="timestamp">[2026-02-05 Thu]</span></span>](#orga2f16a3)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
<a id="org48cabe8"></a>
|
|
6
|
+
|
|
7
|
+
# Version 0.7.1 <span class="timestamp-wrapper"><span class="timestamp">[2026-02-06 Fri]</span></span>
|
|
8
|
+
|
|
9
|
+
- Improved error diagnostics on ParseError
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
<a id="orga2f16a3"></a>
|
|
13
|
+
|
|
14
|
+
# Version 0.7.0 <span class="timestamp-wrapper"><span class="timestamp">[2026-02-05 Thu]</span></span>
|
|
15
|
+
|
|
16
|
+
- Parsing error dignostics added
|
data/CHANGELOG.org
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
* COMMENT CHANGELOG tips:
|
|
2
|
+
1. Don't dump your git change logs into this file, write them yourself.
|
|
3
|
+
2. Keep entries short and user-focused,
|
|
4
|
+
3. Use non-technical language, but do speak in the vocabulary of your gem.
|
|
5
|
+
4. Don't document changes only of interest to the programmers, just those the
|
|
6
|
+
user would find useful.
|
|
7
|
+
5. Give each heading a version number and an inactive date (C-c ! is useful here).
|
|
8
|
+
|
|
9
|
+
* Version 0.7.1 [2026-02-06 Fri]
|
|
10
|
+
- Improved error diagnostics on ParseError
|
|
11
|
+
|
|
12
|
+
* Version 0.7.0 [2026-02-05 Thu]
|
|
13
|
+
- Parsing error dignostics added
|
data/README.md
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
- [Introduction](#
|
|
2
|
-
- [Installation](#
|
|
3
|
-
- [Usage:](#
|
|
4
|
-
- [Following XDG Standards](#
|
|
5
|
-
- [Following Classic UNIX Standards](#
|
|
6
|
-
- [Available Config File Styles](#
|
|
7
|
-
- [Hash Keys](#
|
|
8
|
-
- [Hash Values](#
|
|
9
|
-
- [YAML](#
|
|
10
|
-
- [TOML](#
|
|
11
|
-
- [JSON](#
|
|
12
|
-
- [INI](#
|
|
13
|
-
- [Creating a Reader](#
|
|
14
|
-
- [Calling the `read` method on a `Reader`](#
|
|
1
|
+
- [Introduction](#orgc4b482f)
|
|
2
|
+
- [Installation](#orgbce0696)
|
|
3
|
+
- [Usage:](#org7684da4)
|
|
4
|
+
- [Following XDG Standards](#orga8e28a3)
|
|
5
|
+
- [Following Classic UNIX Standards](#orgd716a45)
|
|
6
|
+
- [Available Config File Styles](#org152041e)
|
|
7
|
+
- [Hash Keys](#orgb744014)
|
|
8
|
+
- [Hash Values](#org02d5c86)
|
|
9
|
+
- [YAML](#org73fadf6)
|
|
10
|
+
- [TOML](#orge78f21a)
|
|
11
|
+
- [JSON](#org22479cd)
|
|
12
|
+
- [INI](#org850bdf4)
|
|
13
|
+
- [Creating a Reader](#org570f7c5)
|
|
14
|
+
- [Calling the `read` method on a `Reader`](#org9637e7b)
|
|
15
15
|
- [Parsing Environment and Command Line Strings](#parsing-environment-and-command-line-strings)
|
|
16
|
-
- [Development](#
|
|
17
|
-
- [Contributing](#
|
|
18
|
-
- [License](#
|
|
16
|
+
- [Development](#orgda3ea75)
|
|
17
|
+
- [Contributing](#orgfb56ba2)
|
|
18
|
+
- [License](#org0377369)
|
|
19
19
|
|
|
20
20
|
[](https://github.com/ddoherty03/fat_config/actions/workflows/main.yml)
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
<a id="
|
|
23
|
+
<a id="orgc4b482f"></a>
|
|
24
24
|
|
|
25
25
|
# Introduction
|
|
26
26
|
|
|
@@ -29,7 +29,7 @@ Allowing a user to configure an application to change its behavior at runtime ca
|
|
|
29
29
|
`FatConfig` eliminates the tedium of reading configuration files and the environment to populate a Hash of configuration settings. You need only define a `FatConfig::Reader` and call its `#read` method to look for, read, translate, and merge any config files into a single Hash that encapsulates all the files in the proper priority. It can be set to read `YAML`, `TOML`, `JSON`, or `INI` config files.
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
<a id="
|
|
32
|
+
<a id="orgbce0696"></a>
|
|
33
33
|
|
|
34
34
|
# Installation
|
|
35
35
|
|
|
@@ -46,7 +46,7 @@ gem install fat_config
|
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
<a id="
|
|
49
|
+
<a id="org7684da4"></a>
|
|
50
50
|
|
|
51
51
|
# Usage:
|
|
52
52
|
|
|
@@ -64,7 +64,7 @@ config = reader.read
|
|
|
64
64
|
The `reader.read` method will parse the config files (by default assumed to be YAML files), config environment variable, and optional command-line parameters and return the composite config as a Hash.
|
|
65
65
|
|
|
66
66
|
|
|
67
|
-
<a id="
|
|
67
|
+
<a id="orga8e28a3"></a>
|
|
68
68
|
|
|
69
69
|
## Following XDG Standards
|
|
70
70
|
|
|
@@ -78,7 +78,7 @@ By default, `FatConfig::Reader#read` follows the [XDG Desktop Standards](https:/
|
|
|
78
78
|
6. Finally, it will merge in any options given in the optional `command_line:` named parameter to the `#read` method. That parameter can either be a `Hash` or a `String`. If it is a `String`, it is interpreted the same way as the environment variable `MYAPP_OPTIONS` as explained below in [Parsing Environment and Command Line Strings](#parsing-environment-and-command-line-strings); if it is a `Hash`, it is used directly and merged into the hash returned from the prior methods.
|
|
79
79
|
|
|
80
80
|
|
|
81
|
-
<a id="
|
|
81
|
+
<a id="orgd716a45"></a>
|
|
82
82
|
|
|
83
83
|
## Following Classic UNIX Standards
|
|
84
84
|
|
|
@@ -101,7 +101,7 @@ With the optional `:xdg` keyword parameter to `FatConfig::Reader#read` set to `f
|
|
|
101
101
|
6. Finally, it will merge in any options given in the optional `command_line:` named parameter to the `#read` method. That parameter can either be a `Hash` or a `String`. If it is a `String`, it will interpret the string as explained below in [Parsing Environment and Command Line Strings](#parsing-environment-and-command-line-strings); if it is a `Hash`, it is used directly and merged into the hash returned from the prior methods.
|
|
102
102
|
|
|
103
103
|
|
|
104
|
-
<a id="
|
|
104
|
+
<a id="org152041e"></a>
|
|
105
105
|
|
|
106
106
|
## Available Config File Styles
|
|
107
107
|
|
|
@@ -115,7 +115,7 @@ With the optional `:xdg` keyword parameter to `FatConfig::Reader#read` set to `f
|
|
|
115
115
|
By default, the style is `yaml`. Note that the style only pertains to the syntax of on-disk configuration files. Configuration can also be set by an environment variable, `MYAPP_OPTIONS` and by a command-line string optionally provided to the `#read` method. Those are simple parsers that parse strings of option settings as explained below. See, [Parsing Environment and Command Line Strings](#parsing-environment-and-command-line-strings).
|
|
116
116
|
|
|
117
117
|
|
|
118
|
-
<a id="
|
|
118
|
+
<a id="orgb744014"></a>
|
|
119
119
|
|
|
120
120
|
## Hash Keys
|
|
121
121
|
|
|
@@ -124,14 +124,14 @@ Any keys that are Strings will be converted to a symbol, using the names given i
|
|
|
124
124
|
Keys that are not Strings will be left alone, so that, for example, you might have Integer keys, which may be useful below the top level.
|
|
125
125
|
|
|
126
126
|
|
|
127
|
-
<a id="
|
|
127
|
+
<a id="org02d5c86"></a>
|
|
128
128
|
|
|
129
129
|
## Hash Values
|
|
130
130
|
|
|
131
131
|
Whether the values of the returned Hash will be 'deserialized' into a Ruby object is controlled by the style of the configuration files.
|
|
132
132
|
|
|
133
133
|
|
|
134
|
-
<a id="
|
|
134
|
+
<a id="org73fadf6"></a>
|
|
135
135
|
|
|
136
136
|
### YAML
|
|
137
137
|
|
|
@@ -148,7 +148,7 @@ The `:yaml` style deserializes the following types:
|
|
|
148
148
|
- Date, DateTime, and Time, which FatConfig adds to the foregoing default types deserialized by the default YAML library.
|
|
149
149
|
|
|
150
150
|
|
|
151
|
-
<a id="
|
|
151
|
+
<a id="orge78f21a"></a>
|
|
152
152
|
|
|
153
153
|
### TOML
|
|
154
154
|
|
|
@@ -164,7 +164,7 @@ The `:toml` style deserializes the following types:
|
|
|
164
164
|
- Date and Time, when given in ISO form YYYY-MM-DD or YYYY-MM-DDThh:mm:ss
|
|
165
165
|
|
|
166
166
|
|
|
167
|
-
<a id="
|
|
167
|
+
<a id="org22479cd"></a>
|
|
168
168
|
|
|
169
169
|
### JSON
|
|
170
170
|
|
|
@@ -180,7 +180,7 @@ The `:json` style deserializes the following types:
|
|
|
180
180
|
- Date and Time, NOT deserialized, returns a parse error
|
|
181
181
|
|
|
182
182
|
|
|
183
|
-
<a id="
|
|
183
|
+
<a id="org850bdf4"></a>
|
|
184
184
|
|
|
185
185
|
### INI
|
|
186
186
|
|
|
@@ -196,7 +196,7 @@ The `:ini` style deserializes the following types:
|
|
|
196
196
|
- Date and Time, NOT deserialized, returned as a String
|
|
197
197
|
|
|
198
198
|
|
|
199
|
-
<a id="
|
|
199
|
+
<a id="org570f7c5"></a>
|
|
200
200
|
|
|
201
201
|
## Creating a Reader
|
|
202
202
|
|
|
@@ -213,7 +213,7 @@ reader3 = FatConfig.new('labrat', style: 'ini', xdg: false) # Use classic UNIX
|
|
|
213
213
|
```
|
|
214
214
|
|
|
215
215
|
|
|
216
|
-
<a id="
|
|
216
|
+
<a id="org9637e7b"></a>
|
|
217
217
|
|
|
218
218
|
## Calling the `read` method on a `Reader`
|
|
219
219
|
|
|
@@ -276,7 +276,7 @@ Here are the parsing rules:
|
|
|
276
276
|
4. These rules apply regardless of style being used for config files.
|
|
277
277
|
|
|
278
278
|
|
|
279
|
-
<a id="
|
|
279
|
+
<a id="orgda3ea75"></a>
|
|
280
280
|
|
|
281
281
|
# Development
|
|
282
282
|
|
|
@@ -285,14 +285,14 @@ After checking out the repo, run \`bin/setup\` to install dependencies. Then, ru
|
|
|
285
285
|
To install this gem onto your local machine, run \`bundle exec rake install\`. To release a new version, update the version number in \`version.rb\`, and then run \`bundle exec rake release\`, which will create a git tag for the version, push git commits and the created tag, and push the \`.gem\` file to [rubygems.org](https://rubygems.org).
|
|
286
286
|
|
|
287
287
|
|
|
288
|
-
<a id="
|
|
288
|
+
<a id="orgfb56ba2"></a>
|
|
289
289
|
|
|
290
290
|
# Contributing
|
|
291
291
|
|
|
292
292
|
Bug reports and pull requests are welcome on GitHub at <https://github.com/ddoherty03/fat_config>.
|
|
293
293
|
|
|
294
294
|
|
|
295
|
-
<a id="
|
|
295
|
+
<a id="org0377369"></a>
|
|
296
296
|
|
|
297
297
|
# License
|
|
298
298
|
|
data/lib/fat_config/errors.rb
CHANGED
|
@@ -15,39 +15,26 @@ module FatConfig
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def self.snippet_from_string(str, line:, column:)
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
line = line&.to_i || 1
|
|
19
|
+
column = column&.to_i || 0
|
|
20
20
|
if str && line && line.to_i > 0
|
|
21
|
-
lines = str.lines
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
caret =
|
|
26
|
-
if column
|
|
27
|
-
(" " * column.to_i) + "^"
|
|
28
|
-
end
|
|
29
|
-
snippet = [src, caret].compact.join("\n")
|
|
30
|
-
end
|
|
21
|
+
lines = str.lines.map(&:chomp)
|
|
22
|
+
(lines[0..line - 1] +
|
|
23
|
+
[(' ' * column) + '^'] +
|
|
24
|
+
lines[line..]).join("\n")
|
|
31
25
|
end
|
|
32
|
-
|
|
33
|
-
snippet
|
|
34
26
|
end
|
|
35
27
|
|
|
36
28
|
def self.snippet_from_file(file_name, line:, column:)
|
|
37
29
|
text = nil
|
|
38
|
-
|
|
39
30
|
begin
|
|
40
31
|
text = File.read(file_name, encoding: "UTF-8")
|
|
41
32
|
rescue StandardError
|
|
42
33
|
text = nil
|
|
43
34
|
end
|
|
44
|
-
|
|
45
|
-
snippet = nil
|
|
46
35
|
if text
|
|
47
|
-
|
|
36
|
+
snippet_from_string(text, line: line, column: column)
|
|
48
37
|
end
|
|
49
|
-
|
|
50
|
-
snippet
|
|
51
38
|
end
|
|
52
39
|
|
|
53
40
|
private
|
|
@@ -61,17 +48,17 @@ module FatConfig
|
|
|
61
48
|
else
|
|
62
49
|
""
|
|
63
50
|
end
|
|
64
|
-
|
|
65
|
-
msg = +"#{format.to_s.upcase} parse error in #{file}#{loc}: #{problem}"
|
|
66
|
-
|
|
51
|
+
msg = +"#{format.to_s.upcase} parse error in:\n #{file}\n #{loc}:\n\nERROR:#{problem}"
|
|
67
52
|
if snippet && !snippet.empty?
|
|
68
|
-
msg << "\n\n
|
|
53
|
+
msg << "\n\n===========================\n"
|
|
54
|
+
msg << snippet
|
|
55
|
+
msg << "\n===========================\n\n"
|
|
69
56
|
end
|
|
70
|
-
|
|
71
57
|
if context && !context.empty?
|
|
72
|
-
msg << "\n\n
|
|
58
|
+
msg << "\n\n==========================="
|
|
59
|
+
msg << context
|
|
60
|
+
msg << "===========================\n\n"
|
|
73
61
|
end
|
|
74
|
-
|
|
75
62
|
msg
|
|
76
63
|
end
|
|
77
64
|
end
|
data/lib/fat_config/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fat_config
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.7.
|
|
4
|
+
version: 0.7.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel E. Doherty
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-02-
|
|
10
|
+
date: 2026-02-06 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: activesupport
|
|
@@ -85,6 +85,8 @@ files:
|
|
|
85
85
|
- ".rspec"
|
|
86
86
|
- ".rubocop.yml"
|
|
87
87
|
- ".yardopts"
|
|
88
|
+
- CHANGELOG.md
|
|
89
|
+
- CHANGELOG.org
|
|
88
90
|
- LICENSE.txt
|
|
89
91
|
- README.md
|
|
90
92
|
- README.org
|