envin 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/envin/cli.rb +5 -1
- data/lib/envin/converter.rb +5 -6
- data/lib/envin/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b17f029845b4706e253b801404dd382e9ad1f9cb
|
4
|
+
data.tar.gz: 8f4960fabd8dfe06d265561aee877000ced526a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39d251d521fc2ca9e9dbee13679e6b8a9f543422b98173759db2de874c7f79bb8b310d64996001f9299b1a45bfe901ef37d06876d83f2dc037d65f2d735fb1ea
|
7
|
+
data.tar.gz: 7627c47cca3bad5ef83bf2053cbe06f3d0f8ec96a9aefb1b59f66bcc595908653a6c61f06550a50fac8dc84ffde3d45d5a201ee05361f7927f34de7577e1b10a
|
data/Gemfile.lock
CHANGED
data/lib/envin/cli.rb
CHANGED
@@ -19,6 +19,10 @@ module Envin
|
|
19
19
|
opt_parser.on '-r', '--root-element ELEMENT', 'root element' do |arg|
|
20
20
|
opts[:rootelement] = arg
|
21
21
|
end
|
22
|
+
|
23
|
+
opt_parser.on '-o', '--output FILENAME', 'root element' do |arg|
|
24
|
+
opts[:targetfile] = arg
|
25
|
+
end
|
22
26
|
end
|
23
27
|
|
24
28
|
parser.on_tail "-h", "--help", "Show help" do
|
@@ -35,7 +39,7 @@ module Envin
|
|
35
39
|
puts "File path & prefix is required"
|
36
40
|
exit(1)
|
37
41
|
end
|
38
|
-
Converter.overwrite(option[:filepath], option[:prefix], option[:rootelement])
|
42
|
+
Converter.overwrite(source_file: option[:filepath], prefix: option[:prefix], root_element: option[:rootelement], target_file: option[:targetfile] )
|
39
43
|
end
|
40
44
|
end
|
41
45
|
end
|
data/lib/envin/converter.rb
CHANGED
@@ -47,9 +47,9 @@ module Envin
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
def overwrite
|
51
|
-
|
52
|
-
config_content =
|
50
|
+
def overwrite source_file:, target_file: false , prefix:, root_element: "production"
|
51
|
+
target_file = source_file if !target_file
|
52
|
+
config_content = File.exist?(source_file) ? load_yaml(source_file, root_element) : {}
|
53
53
|
config_env = build_yaml_from_env(prefix)
|
54
54
|
|
55
55
|
root = {}
|
@@ -58,10 +58,9 @@ module Envin
|
|
58
58
|
else
|
59
59
|
root = config_content.merge(config_env)
|
60
60
|
end
|
61
|
-
new_file_content = YAML.dump(root)
|
62
61
|
|
63
|
-
File.delete(
|
64
|
-
File.write(
|
62
|
+
File.delete(target_file) if File.exist?(target_file)
|
63
|
+
File.write(target_file, YAML.dump(root))
|
65
64
|
end
|
66
65
|
end
|
67
66
|
end
|
data/lib/envin/version.rb
CHANGED