envdgen 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a126ec11733144a2590285999ed9de7ec2f05c0c
4
- data.tar.gz: 1c3f5d9e3293a0fe033a84c2a6c7c5b20be97350
3
+ metadata.gz: 33b754432669377e9c78bef6f713a0281f06d8ff
4
+ data.tar.gz: 3a74f3924e2f3198a7fc40aad61b55e97303248d
5
5
  SHA512:
6
- metadata.gz: a38ec0e8af2de75bcbc5e1900b88e391481a0d507093012c8d0f81a752f8ea6dced1aeb98e3cf7cc8e839e98afc557df8c7d2b038fc946bdd4d31b9a56f04e8b
7
- data.tar.gz: 8a24a3ef4f4343dc3d6e629f79587d3c131a304a7abccfe40a9c0b8205708ba2feeeaa74eb6154ed829f0602615e8ab93fb31d435730a0aa2f0805d3f8313112
6
+ metadata.gz: 0a8ad3d84d3e2f247dc0c783bba77133baacdc4516e096fe831cca865bd9957f4ddbd0e2e687243087958f50c3beb879210dc649b07bd3c89667082256d090c5
7
+ data.tar.gz: 70fce539121606a4cca81a54a89a95a00d58c121ccbd0aca06268469d09dfffe3fb6f8817952da3d65521a57e0cdf81e57982e451897596d45b44ce60a3061b8
data/README.md CHANGED
@@ -17,6 +17,11 @@ Generate configuration directory from env file by running:
17
17
 
18
18
  $ envdgen /path/to/.env /path/to/env/dir
19
19
 
20
+ Running again the same command will not take any effect, as file are not overwritten.
21
+ To force writing files use `-f` flag:
22
+
23
+ $ envdgen /path/to/.env /path/to/env/dir -f
24
+
20
25
  ## Hacking
21
26
 
22
27
  If you wanna hack on the repo for some reason, first clone it, then run:
data/bin/envdgen CHANGED
@@ -4,17 +4,19 @@ require 'rubygems'
4
4
  require 'envdgen'
5
5
 
6
6
  if ARGV.include?("-h") || ARGV.include?("--help")
7
- puts "usage: envdgen [-h] [SOURCE_DOTENV_FILE] [TARGET_DIR]"
7
+ puts "usage: envdgen [SOURCE_DOTENV_FILE] [TARGET_DIR] [-h|--help] [-f|--force]"
8
8
  exit
9
9
  end
10
10
 
11
- if ARGV.size != 2
11
+ if ARGV.size < 2
12
12
  $stderr.write("ERROR: Invalid parameters. Run with `-h' flag for help.\n")
13
13
  exit(1)
14
14
  end
15
15
 
16
- Envdgen.gen(ARGV[0], ARGV[1]) do |fname|
17
- puts "Generated #{fname}"
16
+ force = ARGV.include?("-f") or ARGV.include?("--force")
17
+
18
+ Envdgen.gen(ARGV[0], ARGV[1], force) do |fname|
19
+ puts "Written #{fname}"
18
20
  end
19
21
 
20
22
  puts "Done!"
@@ -1,3 +1,3 @@
1
1
  module Envdgen
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/envdgen.rb CHANGED
@@ -3,14 +3,16 @@ require "dotenv"
3
3
  require "fileutils"
4
4
 
5
5
  module Envdgen
6
- def self.gen(src, target)
6
+ def self.gen(src, target, force=false)
7
7
  env = Dotenv::Environment.new(src)
8
8
  FileUtils.mkdir_p(target)
9
9
  env.each do |key, value|
10
10
  fname = File.join(target, key)
11
- File.open(fname, 'w+') do |f|
12
- f.write(value)
13
- yield fname if block_given?
11
+ if force || !File.exists?(fname)
12
+ File.open(fname, 'w+') do |f|
13
+ f.write(value)
14
+ yield fname if block_given?
15
+ end
14
16
  end
15
17
  end
16
18
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: envdgen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kris Kovalik