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 +4 -4
- data/README.md +5 -0
- data/bin/envdgen +6 -4
- data/lib/envdgen/version.rb +1 -1
- data/lib/envdgen.rb +6 -4
- 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: 33b754432669377e9c78bef6f713a0281f06d8ff
|
4
|
+
data.tar.gz: 3a74f3924e2f3198a7fc40aad61b55e97303248d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 [
|
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
|
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
|
-
|
17
|
-
|
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!"
|
data/lib/envdgen/version.rb
CHANGED
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.
|
12
|
-
|
13
|
-
|
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
|