envin 0.1.2 → 0.1.3

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
  SHA1:
3
- metadata.gz: e2974c0b3d8035d29b61890d5dd6aeac4330a7cb
4
- data.tar.gz: d1df007083077ca1befe79ade4f4c006fbdc4d36
3
+ metadata.gz: b17f029845b4706e253b801404dd382e9ad1f9cb
4
+ data.tar.gz: 8f4960fabd8dfe06d265561aee877000ced526a8
5
5
  SHA512:
6
- metadata.gz: 897ff0d27509f8c946406dc821e29482ad1b3bfd3cff52a7ebede2c08c4f5b4ff67d45b36ca8b2bdf97bf5e01fce661f697d1b694d226e6f0e953b4c982b102a
7
- data.tar.gz: 51e29b4babaaadc51fbfe04bfa383b9898eaee82716ac6da2bb0b3d94a0bcc387ab154ea8412589cb9e6ae376a088c9be7d0d5342942457be91773808b7d9c64
6
+ metadata.gz: 39d251d521fc2ca9e9dbee13679e6b8a9f543422b98173759db2de874c7f79bb8b310d64996001f9299b1a45bfe901ef37d06876d83f2dc037d65f2d735fb1ea
7
+ data.tar.gz: 7627c47cca3bad5ef83bf2053cbe06f3d0f8ec96a9aefb1b59f66bcc595908653a6c61f06550a50fac8dc84ffde3d45d5a201ee05361f7927f34de7577e1b10a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- envin (0.1.0)
4
+ envin (0.1.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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
@@ -47,9 +47,9 @@ module Envin
47
47
  end
48
48
  end
49
49
 
50
- def overwrite file, prefix, root_element="production"
51
- file_exist = File.exist?(file)
52
- config_content = file_exist ? load_yaml(file, root_element) : {}
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(file) if file_exist
64
- File.write(file, new_file_content)
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
@@ -1,3 +1,3 @@
1
1
  module Envin
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: envin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zidni Mubarock