Skip to content

Commit

Permalink
Berksfile: moving to config-file for Berkshelf, away from inline Ruby…
Browse files Browse the repository at this point in the history
… include
  • Loading branch information
temujin9 committed Jan 23, 2013
1 parent fe558e8 commit 3fc75cf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
File renamed without changes.
26 changes: 12 additions & 14 deletions config/Berksfile.inc.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
# Get configuration in both old and new way. This will eventually go away
# in favor of a singular conf file (which will be loaded direct into
# ENV variables).
OLD_CONF = File.join(File.dirname(__FILE__), 'Berksfile.conf.rb')
if File.exists? OLD_CONF
echo "Please move Berksfile.conf.rb to Berksfile.conf"
require OLD_CONF
%w[ USE_LOCAL LOCAL_PATH PANTRY_REPO PANTRY_BRANCH ].each do |var|
( ENV[var] = eval(var) ) rescue nil unless ENV[var]
end
else
require 'parseconfig'
config = ParseConfig.new File.join(File.dirname(__FILE__), 'Berksfile.conf')
config.params.each_pair {|key,value| ENV[key] = value unless ENV[key] }
conf_file = File.join(File.dirname(__FILE__), 'Berksfile.conf')

# Move the old file to the right place
old_conf_file = "#{conf_file}.rb"
if ((File.exists? old_conf_file) && not (File.exists? conf_file))
require 'fileutils'
echo "Moving #{old_conf_file} to #{conf_file}"
FileUtils.mv(old_conf_file, conf_file)
end

require 'parseconfig'
config = ParseConfig.new File.join(File.dirname(__FILE__), 'Berksfile.conf')
config.params.each_pair {|key,value| ENV[key] = value unless ENV[key] }

ENV['USE_LOCAL'] = false unless ENV['USE_LOCAL']
ENV['LOCAL_PATH'] = "vendor" unless ENV['LOCAL_PATH']
ENV['PANTRY_REPO'] = 'infochimps-labs/ironfan-pantry' unless ENV['PANTRY_REPO']
Expand Down

0 comments on commit 3fc75cf

Please sign in to comment.