confrb 2.1 → 2.2
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 -7
- 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: 9165a2a0d73d5f050509c432b20151a6ca29d6f25d271169e61eb74a17dde60b
|
4
|
+
data.tar.gz: '02708d9d9994f7298115067e855a42d6944458e74526713f665739b04d722659'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0de222c4e4fbb0f3f136645e58550387a1ff496861f7a32e51a60528088ed7b3537520de3444787cf19566a71706794c630f04899442a0523617129586f6fe43
|
7
|
+
data.tar.gz: 47b3c588de6c4372120de9c113b074a60c082844a4e3a00ab00c1f7bcda346dbd91b6dcccd700aa643d74b60d9a5b7f78423c3aefaea01e3ac9aa690eec62d1c
|
data/lib/confrb.rb
CHANGED
@@ -43,9 +43,12 @@ class Confrb
|
|
43
43
|
def mkcfg(cfgname, content='', opts = {})
|
44
44
|
as_json = opts.fetch(:json, false)
|
45
45
|
as_yaml = opts.fetch(:yaml, false)
|
46
|
-
|
47
|
-
|
46
|
+
pnewline = opts.fetch(:prepend_newline, false)
|
47
|
+
anewline = opts.fetch(:append_newline, false)
|
48
|
+
if pnewline == true
|
48
49
|
content = "\n" + content
|
50
|
+
elsif anewline == true
|
51
|
+
content = content + "\n"
|
49
52
|
end
|
50
53
|
dotdir = "." + @db
|
51
54
|
cfgpath = File.join(dotdir, cfgname)
|
@@ -139,21 +142,24 @@ class Confrb
|
|
139
142
|
def writecfg(cfgname, content, opts = {})
|
140
143
|
as_json = opts.fetch(:json, false)
|
141
144
|
as_yaml = opts.fetch(:yaml, false)
|
142
|
-
|
145
|
+
pnewline = opts.fetch(:prepend_newline, true)
|
146
|
+
anewline = opts.fetch(:append_newline, false)
|
143
147
|
dotdir = "." + @db
|
144
148
|
cfgpath = File.join(dotdir, cfgname)
|
145
149
|
FileUtils.touch(cfgpath)
|
146
|
-
if
|
150
|
+
if pnewline == true
|
151
|
+
content = "\n" + content
|
152
|
+
elsif anewline == true
|
147
153
|
content = content + "\n"
|
148
154
|
end
|
149
155
|
if as_json == true
|
150
156
|
content = content.to_json
|
151
|
-
|
157
|
+
File.write(cfgpath, content, mode: "a")
|
152
158
|
elsif as_yaml == true
|
153
159
|
content = content.to_yaml
|
154
|
-
|
160
|
+
File.write(cfgpath, content, mode: "a")
|
155
161
|
else
|
156
|
-
|
162
|
+
File.write(cfgpath, content, mode: "a")
|
157
163
|
end
|
158
164
|
end
|
159
165
|
end
|