Skip to content

Commit

Permalink
Revert "Merge pull request ddollar#4 from nicholasjhenry/master"
Browse files Browse the repository at this point in the history
This reverts commit 5e5dac6, reversing
changes made to 561d592.
  • Loading branch information
ddollar committed Sep 28, 2012
1 parent 46ef7c1 commit da309b0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ Add the following to `.gitignore`:

# optional --overwrite allows you to have the pull overwrite keys
$ heroku config:pull --overwrite
Config for example written to .env

# optional --keys allows you to specify the keys to pull allowing you to
# include this in an install script. Makes the most sense when used with
# -- overwrite
$ heroku config:pull --keys S3_BUCKET S3_KEY S3_SECRET
Config in example written to .env
Config in .env written to example

# --interactive will prompt for each value to be overwritten
$ heroku config:pull --overwrite --interactive
Expand Down
15 changes: 4 additions & 11 deletions lib/config/heroku/command/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ class Heroku::Command::Config
def pull
interactive = options[:interactive]
overwrite = options[:overwrite]
keys = options[:keys]

config = merge_config(remote_config, local_config, keys, interactive, overwrite)
config = merge_config(remote_config, local_config, interactive, overwrite)
write_local_config config
display "Config for #{app} written to .env"
end
Expand All @@ -33,9 +32,8 @@ def pull
def push
interactive = options[:interactive]
overwrite = options[:overwrite]
keys = options[:keys]

config = merge_config(local_config, remote_config, keys, interactive, overwrite)
config = merge_config(local_config, remote_config, interactive, overwrite)
write_remote_config config
display "Config in .env written to #{app}"
end
Expand Down Expand Up @@ -76,7 +74,7 @@ def write_remote_config(config)
heroku.add_config_vars(app, add_config_vars)
end

def merge_config(source, target, keys, interactive=false, overwrite=false)
def merge_config(source, target, interactive=false, overwrite=false)
if interactive
source.keys.sort.inject(target) do |hash, key|
value = source[key]
Expand All @@ -85,14 +83,9 @@ def merge_config(source, target, keys, interactive=false, overwrite=false)
hash
end
else
filtered_source = filter_source_by_keys(source, keys)
overwrite ? target.merge(filtered_source) : filtered_source.merge(target)
overwrite ? target.merge(source) : source.merge(target)
end
end

def filter_source_by_keys(source, keys)
keys ||= source.keys
source.select { |key,_| keys.include? key }
end
end

0 comments on commit da309b0

Please sign in to comment.