Skip to content

Commit e8be2f9

Browse files
committed
initial version
0 parents  commit e8be2f9

File tree

8 files changed

+146
-0
lines changed

8 files changed

+146
-0
lines changed

.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
*.bundle
19+
*.so
20+
*.o
21+
*.a
22+
mkmf.log

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source 'https://rubygems.org'
2+
3+
# Specify your gem's dependencies in dotenv-heroku.gemspec
4+
gemspec

LICENSE.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Copyright (c) 2014 Philipp Fehre
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.

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Dotenv::Heroku
2+
3+
TODO: Write a gem description
4+
5+
## Installation
6+
7+
Add this line to your application's Gemfile:
8+
9+
gem 'dotenv-heroku'
10+
11+
And then execute:
12+
13+
$ bundle
14+
15+
Or install it yourself as:
16+
17+
$ gem install dotenv-heroku
18+
19+
## Usage
20+
21+
TODO: Write usage instructions here
22+
23+
## Contributing
24+
25+
1. Fork it ( https://github.com/[my-github-username]/dotenv-heroku/fork )
26+
2. Create your feature branch (`git checkout -b my-new-feature`)
27+
3. Commit your changes (`git commit -am 'Add some feature'`)
28+
4. Push to the branch (`git push origin my-new-feature`)
29+
5. Create a new Pull Request

Rakefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require "bundler/gem_tasks"
2+

dotenv-heroku.gemspec

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# coding: utf-8
2+
lib = File.expand_path('../lib', __FILE__)
3+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4+
require 'dotenv/heroku/version'
5+
6+
Gem::Specification.new do |spec|
7+
spec.name = "dotenv-heroku"
8+
spec.version = Dotenv::Heroku::VERSION
9+
spec.authors = ["Philipp Fehre"]
10+
spec.email = ["philipp.fehre@gmail.com"]
11+
spec.summary = %q{Manage your heroku environment with dotenv}
12+
spec.description = %q{Tasks to manage your heroku environment with dotenv}
13+
spec.homepage = "https://github.com/sideshowcoder/dotenv-heroku"
14+
spec.license = "MIT"
15+
16+
spec.files = `git ls-files -z`.split("\x0")
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.6"
22+
spec.add_dependency "rake"
23+
end

lib/dotenv/heroku.rb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
require "dotenv/heroku/version"
2+
require "mkmf"
3+
4+
namespace :config do
5+
6+
task :executable do
7+
fail "missing heroku executable from the PATH" unless find_executable "heroku"
8+
end
9+
10+
desc "push the .env file to heroku config"
11+
task :push, :env_file, :needs => :executable do |t, args|
12+
args.with_defaults(env_file: ".env")
13+
14+
File.readlines(args[:env_file]).map(&:strip).each do |value|
15+
sh "heroku config:set #{value}"
16+
end
17+
end
18+
19+
desc "pull the config from heroku and write to .env file"
20+
task :pull, :env_file, :needs => :executable do |t, args|
21+
args.with_defaults(env_file: ".env")
22+
23+
remote_config = sh("heroku config").split("/n")
24+
remote_config.shift # remove the header
25+
26+
# reformat the lines from
27+
# XYZ: abc
28+
# to
29+
# XYZ=abc
30+
lines = remote_config.map { |cl|
31+
cl.split(":").map(&:strip).join("=")
32+
}
33+
34+
File.open(args[:env_file], "w") do |f|
35+
f.puts lines
36+
end
37+
end
38+
end
39+

lib/dotenv/heroku/version.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Dotenv
2+
module Heroku
3+
VERSION = "0.0.1"
4+
end
5+
end

0 commit comments

Comments
 (0)