envdgen 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a126ec11733144a2590285999ed9de7ec2f05c0c
4
+ data.tar.gz: 1c3f5d9e3293a0fe033a84c2a6c7c5b20be97350
5
+ SHA512:
6
+ metadata.gz: a38ec0e8af2de75bcbc5e1900b88e391481a0d507093012c8d0f81a752f8ea6dced1aeb98e3cf7cc8e839e98afc557df8c7d2b038fc946bdd4d31b9a56f04e8b
7
+ data.tar.gz: 8a24a3ef4f4343dc3d6e629f79587d3c131a304a7abccfe40a9c0b8205708ba2feeeaa74eb6154ed829f0602615e8ab93fb31d435730a0aa2f0805d3f8313112
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ spec/tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in envdgen.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Kris Kovalik
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # envdgen
2
+
3
+ **Environment config directories generator**
4
+
5
+ This simple tool generates `envdir` (daemontools) compatible environment directories from
6
+ sample `.env` files, like those used by Foreman.
7
+
8
+ ## Installation
9
+
10
+ Install via rubygems:
11
+
12
+ $ gem install envdgen
13
+
14
+ ## Usage
15
+
16
+ Generate configuration directory from env file by running:
17
+
18
+ $ envdgen /path/to/.env /path/to/env/dir
19
+
20
+ ## Hacking
21
+
22
+ If you wanna hack on the repo for some reason, first clone it, then run:
23
+
24
+ $ bundle install
25
+
26
+ Now you should be able to run tests:
27
+
28
+ $ rake
29
+
30
+ ## Contributing
31
+
32
+ 1. Work on your changes in a feature branch.
33
+ 2. Make sure that tests are passing.
34
+ 3. Send a pull request.
35
+ 4. Wait for feedback.
36
+
37
+ ## Copyrights
38
+
39
+ Copyright (c) by Kris Kovalik <hi@kkvlk.me>
40
+
41
+ Released under MIT License. Check [LICENSE.txt](LICENSE.txt) for details.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/envdgen ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'envdgen'
5
+
6
+ if ARGV.include?("-h") || ARGV.include?("--help")
7
+ puts "usage: envdgen [-h] [SOURCE_DOTENV_FILE] [TARGET_DIR]"
8
+ exit
9
+ end
10
+
11
+ if ARGV.size != 2
12
+ $stderr.write("ERROR: Invalid parameters. Run with `-h' flag for help.\n")
13
+ exit(1)
14
+ end
15
+
16
+ Envdgen.gen(ARGV[0], ARGV[1]) do |fname|
17
+ puts "Generated #{fname}"
18
+ end
19
+
20
+ puts "Done!"
data/envdgen.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'envdgen/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "envdgen"
8
+ spec.version = Envdgen::VERSION
9
+ spec.authors = ["Kris Kovalik"]
10
+ spec.email = ["hi@kkvlk.me"]
11
+ spec.description = %q{Gem provides a binary to generate envdir compatible env directories from .env foreman files."}
12
+ spec.summary = %q{Env directories generator}
13
+ spec.homepage = "https://github.com/kkvlk/envdgen"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rspec", "~> 2.5"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_dependency "dotenv"
25
+ end
@@ -0,0 +1,3 @@
1
+ module Envdgen
2
+ VERSION = "0.0.1"
3
+ end
data/lib/envdgen.rb ADDED
@@ -0,0 +1,17 @@
1
+ require "envdgen/version"
2
+ require "dotenv"
3
+ require "fileutils"
4
+
5
+ module Envdgen
6
+ def self.gen(src, target)
7
+ env = Dotenv::Environment.new(src)
8
+ FileUtils.mkdir_p(target)
9
+ env.each do |key, value|
10
+ fname = File.join(target, key)
11
+ File.open(fname, 'w+') do |f|
12
+ f.write(value)
13
+ yield fname if block_given?
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ require File.expand_path("../spec_helper.rb", __FILE__)
2
+
3
+ describe "Envdgen" do
4
+ before do
5
+ `rm -rf spec/tmp`
6
+ `mkdir -p spec/tmp`
7
+ `echo "FOO=1" > spec/tmp/.env`
8
+ `echo "BAR=" >> spec/tmp/.env`
9
+ `echo "BAZ=\"foo\"" >> spec/tmp/.env`
10
+ end
11
+
12
+ describe ".gen" do
13
+ it "should generate environment directory from given env file" do
14
+ Envdgen.gen("spec/tmp/.env", "spec/tmp/envdir")
15
+ File.read("spec/tmp/envdir/FOO").should == "1"
16
+ File.read("spec/tmp/envdir/BAR").should == ""
17
+ File.read("spec/tmp/envdir/BAZ").should == "foo"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ require 'rspec'
2
+ require 'envdgen'
3
+
4
+ RSpec.configure do |rspec|
5
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: envdgen
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Kris Kovalik
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '2.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '2.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: dotenv
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Gem provides a binary to generate envdir compatible env directories from
70
+ .env foreman files."
71
+ email:
72
+ - hi@kkvlk.me
73
+ executables:
74
+ - envdgen
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - .gitignore
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/envdgen
84
+ - envdgen.gemspec
85
+ - lib/envdgen.rb
86
+ - lib/envdgen/version.rb
87
+ - spec/envdgen_spec.rb
88
+ - spec/spec_helper.rb
89
+ homepage: https://github.com/kkvlk/envdgen
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.0.6
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Env directories generator
113
+ test_files:
114
+ - spec/envdgen_spec.rb
115
+ - spec/spec_helper.rb