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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d987b854bd4105f55ead3efbc73a77a1e168b4c5bcfc6caa487e248463df95e
4
- data.tar.gz: 8d65e3589a6402eb4f4fa374a815ffad56902162d4f0e107c0ef6f676ed39252
3
+ metadata.gz: 9402d73a4e16cab2a9088bece9dfa623d406858b5c0ae641df01ee988029e6a1
4
+ data.tar.gz: 042c81ad9c917ea1073db02259718a73792dd7e134f8c9c3aa4b60f7d9b756b4
5
5
  SHA512:
6
- metadata.gz: f19a80712d34593aa39ebf5f5763a48aa5cce085b721b90a6a591417da9ce878c466800938f482aa88b5c6dac4c2ebdfb2250c7d798e8a0a8cbf415867e8b353
7
- data.tar.gz: 0c8575cf4ffc410eba8c6d14e194e802f0e8505f266e0e08e4a63c7905c2cd5c2c184c6114b870bcec8b86dc56758035a4a8c8b2c5d48fbb871e17423224e073
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](#org6ea1400)
2
- - [Installation](#org0bfc9c4)
3
- - [Usage:](#orgb03325f)
4
- - [Following XDG Standards](#orgcc49e5b)
5
- - [Following Classic UNIX Standards](#orgb094a10)
6
- - [Available Config File Styles](#org77efd19)
7
- - [Hash Keys](#org2489659)
8
- - [Hash Values](#org3c327fd)
9
- - [YAML](#org47246cf)
10
- - [TOML](#orgcd934bb)
11
- - [JSON](#orge3c0568)
12
- - [INI](#org479cf72)
13
- - [Creating a Reader](#org195ed64)
14
- - [Calling the `read` method on a `Reader`](#org0c26613)
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](#orgadf9605)
17
- - [Contributing](#org00f8770)
18
- - [License](#orgbb61eac)
16
+ - [Development](#orgda3ea75)
17
+ - [Contributing](#orgfb56ba2)
18
+ - [License](#org0377369)
19
19
 
20
20
  [![img](https://github.com/ddoherty03/fat_config/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/ddoherty03/fat_config/actions/workflows/main.yml)
21
21
 
22
22
 
23
- <a id="org6ea1400"></a>
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="org0bfc9c4"></a>
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="orgb03325f"></a>
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="orgcc49e5b"></a>
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="orgb094a10"></a>
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="org77efd19"></a>
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="org2489659"></a>
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="org3c327fd"></a>
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="org47246cf"></a>
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="orgcd934bb"></a>
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="orge3c0568"></a>
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="org479cf72"></a>
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="org195ed64"></a>
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="org0c26613"></a>
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="orgadf9605"></a>
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="org00f8770"></a>
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="orgbb61eac"></a>
295
+ <a id="org0377369"></a>
296
296
 
297
297
  # License
298
298
 
@@ -15,39 +15,26 @@ module FatConfig
15
15
  end
16
16
 
17
17
  def self.snippet_from_string(str, line:, column:)
18
- snippet = nil
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
- idx = line.to_i - 1
23
- if idx >= 0 && idx < lines.length
24
- src = lines[idx].chomp
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
- snippet = snippet_from_string(text, line: line, column: column)
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#{snippet}"
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#{context}"
58
+ msg << "\n\n==========================="
59
+ msg << context
60
+ msg << "===========================\n\n"
73
61
  end
74
-
75
62
  msg
76
63
  end
77
64
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FatConfig
4
- VERSION = "0.7.0"
4
+ VERSION = "0.7.1"
5
5
  end
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.0
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-05 00:00:00.000000000 Z
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