Skip to content

Commit 97bb4ae

Browse files
committed
added README and add pull task
1 parent 067d948 commit 97bb4ae

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

README.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# Dotenv::Heroku
1+
# Dotenv Heroku
22

3-
TODO: Write a gem description
3+
Support for config push and pull via Rake tasks for
4+
[dotenv](https://github.com/bkeepers/dotenv). The rake tasks rely on the
5+
`heroku` excutable to be present in the PATH.
46

57
## Installation
68

@@ -18,7 +20,30 @@ Or install it yourself as:
1820

1921
## Usage
2022

21-
TODO: Write usage instructions here
23+
Add
24+
25+
require "dotenv-heroku/tasks"
26+
27+
to your Rakefile.
28+
29+
You can now run
30+
31+
$ rake config:pull
32+
33+
to pull the current heroku config to the local .env file, you can also pass the
34+
desired file as an argument
35+
36+
$ rake config:pull\[my_current_config\]
37+
38+
You can also push the config to heroku via
39+
40+
$ rake config:push
41+
42+
to push the config from the .env file, or
43+
44+
$ rake config:push\[my_current_config\]
45+
46+
to push the config from the my_current_config file
2247

2348
## Contributing
2449

lib/dotenv-heroku/tasks.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
require "mkmf"
2+
# Make the MakeMakefile logger write file output to null.
3+
module MakeMakefile::Logging
4+
@logfile = File::NULL
5+
end
26

37
namespace :config do
48
task :executable do
59
fail "missing heroku executable from the PATH" unless find_executable "heroku"
610
end
711

812
desc "push the .env file to heroku config"
9-
task :push, :env_file, :needs => :executable do |t, args|
13+
task :push, [:env_file] => :executable do |t, args|
1014
args.with_defaults(env_file: ".env")
1115

1216
File.readlines(args[:env_file]).map(&:strip).each do |value|
@@ -15,10 +19,12 @@
1519
end
1620

1721
desc "pull the config from heroku and write to .env file"
18-
task :pull, :env_file, :needs => :executable do |t, args|
22+
task :pull, [:env_file] => :executable do |t, args|
1923
args.with_defaults(env_file: ".env")
2024

21-
remote_config = sh("heroku config").split("/n")
25+
remote_config = `heroku config`
26+
remote_config or fail "could not fetch remote config"
27+
remote_config = remote_config.split("\n")
2228
remote_config.shift # remove the header
2329

2430
# reformat the lines from

0 commit comments

Comments
 (0)