confrb 1.7 → 1.8
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/lib/confrb.rb +6 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56a83b4fa46ce5e7cf508babd19e67bc988d68648083c00d549a744e866514bf
|
4
|
+
data.tar.gz: 13a6ca74daedef594fd197e5c37dce61b8dde613355d75dc755f9ce94853c330
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e5b81841ee2f41d034b1852c31dbf4ce541367c1d744b5c83866d775a3a185dfc21e9ccb310e1bff0eb7d37e8fa6ca94857458547b269c07bb10f3b39fd7d3f
|
7
|
+
data.tar.gz: 3e1105f85c8742450774296f0fe39c0b1b26746fd8e8e30603347b7a35611029c18a896c0807c43bde3d952849072fac589ad901c47413bad1d073ff4f256f11
|
data/lib/confrb.rb
CHANGED
@@ -18,7 +18,7 @@ class Confrb
|
|
18
18
|
end
|
19
19
|
|
20
20
|
##
|
21
|
-
# Access the given database, prepending '.' to given name.
|
21
|
+
# Access the given database, prepending '.' to given name. Raises an exception if nonexistent.
|
22
22
|
# @param [String] db The name of the configuration directory to access
|
23
23
|
def self.access(db)
|
24
24
|
if Dir.exist? '.' + db
|
@@ -30,8 +30,9 @@ class Confrb
|
|
30
30
|
|
31
31
|
##
|
32
32
|
# Create/overwrite a config file and write data to it. Can
|
33
|
-
# serialize a hash as yaml or json, or write a string
|
34
|
-
# @param [String] cfgname Name of config file to write to
|
33
|
+
# serialize a hash as yaml or json, or write a string.
|
34
|
+
# @param [String] cfgname Name of config file to write to
|
35
|
+
# @param [String] content The content to write, defaults to an empty string.
|
35
36
|
# @param [Hash] opts Optional param hash
|
36
37
|
# @option opts [boolean] :json If true, serialize content
|
37
38
|
# as JSON (ignored if content isn't a hash) Default #
|
@@ -40,7 +41,7 @@ class Confrb
|
|
40
41
|
# as YAML (ignored if content isn't a hash) Default #
|
41
42
|
# false (json: true takes precedence)
|
42
43
|
# @return path to configuration file created.
|
43
|
-
def mkcfg(cfgname, content, opts = {})
|
44
|
+
def mkcfg(cfgname, content='', opts = {})
|
44
45
|
as_json = opts.fetch(:json, false) && content.is_a?(Hash)
|
45
46
|
as_yaml = opts.fetch(:yaml, false) && content.is_a?(Hash)
|
46
47
|
dotdir = "." + @db
|
@@ -124,6 +125,7 @@ class Confrb
|
|
124
125
|
# Create/append to a config file. Can
|
125
126
|
# serialize a hash as yaml or json, or write a string
|
126
127
|
# @param [String] cfgname Name of config file to write to
|
128
|
+
# @param [String] content The content to write.
|
127
129
|
# @param [Hash] opts Optional param hash
|
128
130
|
# @option opts [boolean] :json If true, serialize content
|
129
131
|
# as JSON (ignored if content isn't a hash) Default #
|