confrb 1.8 → 1.9
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 +13 -17
- 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: 30725b1e35a0f6d3302899d61b5790b5924aa575856dfa64f1427f3dc7f6dfac
|
4
|
+
data.tar.gz: c1add6c9c9d122dff3682caf0ed16631a968325db93c82ecdf0023cbb56ae220
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d53d3c316ee9dbf06af8d9fdf95d39b62598cef369c3c9a3bceaa917c7ae508afd11bfa335b03651f48cb6801468f9a9dee30a2170aec6a04bc9d5edaca4bd5c
|
7
|
+
data.tar.gz: 9acd96dd3bf750fb8f3b42ffff57d36c66fa030d9c5d4e78ad73366975b44f8cc7a9217345cd633085bed446da5f464d6dc286892c0276856c1119c51d22a9cc
|
data/lib/confrb.rb
CHANGED
@@ -30,20 +30,18 @@ class Confrb
|
|
30
30
|
|
31
31
|
##
|
32
32
|
# Create/overwrite a config file and write data to it. Can
|
33
|
-
# serialize
|
33
|
+
# serialize data as yaml or json, or write a string.
|
34
34
|
# @param [String] cfgname Name of config file to write to
|
35
35
|
# @param [String] content The content to write, defaults to an empty string.
|
36
36
|
# @param [Hash] opts Optional param hash
|
37
37
|
# @option opts [boolean] :json If true, serialize content
|
38
|
-
# as JSON
|
39
|
-
# false
|
38
|
+
# as JSON Default: false
|
40
39
|
# @option opts [boolean] :yaml If true, serialize content
|
41
|
-
# as YAML
|
42
|
-
# false (json: true takes precedence)
|
40
|
+
# as YAML Default: false (json: true takes precedence)
|
43
41
|
# @return path to configuration file created.
|
44
42
|
def mkcfg(cfgname, content='', opts = {})
|
45
|
-
as_json = opts.fetch(:json, false)
|
46
|
-
as_yaml = opts.fetch(:yaml, false)
|
43
|
+
as_json = opts.fetch(:json, false)
|
44
|
+
as_yaml = opts.fetch(:yaml, false)
|
47
45
|
dotdir = "." + @db
|
48
46
|
cfgpath = File.join(dotdir, cfgname)
|
49
47
|
FileUtils.touch(cfgpath)
|
@@ -79,7 +77,7 @@ class Confrb
|
|
79
77
|
# content as YAML. Default false (json: true takes
|
80
78
|
# precedence
|
81
79
|
# @return [String|Hash] Loaded contents, either a String
|
82
|
-
# if not indicated to treat as JSON or YAML, or a
|
80
|
+
# if not indicated to treat as JSON or YAML, or a data structure
|
83
81
|
# deserialized from content string
|
84
82
|
def readcfg(cfgname, opts = {})
|
85
83
|
dotdir = "." + @db
|
@@ -122,21 +120,19 @@ class Confrb
|
|
122
120
|
end
|
123
121
|
|
124
122
|
##
|
125
|
-
# Create/append to a config file. Can
|
126
|
-
# serialize
|
123
|
+
# Create/append to a config file and write data to it. Can
|
124
|
+
# serialize data as yaml or json, or write a string.
|
127
125
|
# @param [String] cfgname Name of config file to write to
|
128
|
-
# @param [String] content The content to write.
|
126
|
+
# @param [String] content The content to write, defaults to an empty string.
|
129
127
|
# @param [Hash] opts Optional param hash
|
130
128
|
# @option opts [boolean] :json If true, serialize content
|
131
|
-
# as JSON
|
132
|
-
# false
|
129
|
+
# as JSON Default: false
|
133
130
|
# @option opts [boolean] :yaml If true, serialize content
|
134
|
-
# as YAML
|
135
|
-
# false (json: true takes precedence)
|
131
|
+
# as YAML Default: false (json: true takes precedence)
|
136
132
|
# @return path to configuration file created.
|
137
133
|
def writecfg(cfgname, content, opts = {})
|
138
|
-
as_json = opts.fetch(:json, false)
|
139
|
-
as_yaml = opts.fetch(:yaml, false)
|
134
|
+
as_json = opts.fetch(:json, false)
|
135
|
+
as_yaml = opts.fetch(:yaml, false)
|
140
136
|
dotdir = "." + @db
|
141
137
|
cfgpath = File.join(dotdir, cfgname)
|
142
138
|
FileUtils.touch(cfgpath)
|