class Pushwagner::Environment
Attributes
config[R]
current[RW]
version[RW]
Public Class Methods
new(opts = {})
click to toggle source
# File lib/pushwagner/environment.rb, line 11 def initialize(opts = {}) opts = HashWithIndifferentAccess.new(opts) config_file = look_for_config_file(opts[:config_file]) @version = opts[:version] && opts[:version].to_s @current = opts[:environment] || 'default' @config = HashWithIndifferentAccess.new(YAML::load_file(config_file) || {}) end
Public Instance Methods
environment()
click to toggle source
# File lib/pushwagner/environment.rb, line 50 def environment environments[current] || {} end
environments()
click to toggle source
# File lib/pushwagner/environment.rb, line 42 def environments config['environments'] || {} end
hooks()
click to toggle source
# File lib/pushwagner/environment.rb, line 46 def hooks config['hooks'] || {} end
hosts()
click to toggle source
# File lib/pushwagner/environment.rb, line 54 def hosts environment['hosts'] || [] end
maven()
click to toggle source
# File lib/pushwagner/environment.rb, line 26 def maven @maven = (config['maven'] ? Maven.new(config['maven'], version) : {}) end
maven?()
click to toggle source
# File lib/pushwagner/environment.rb, line 30 def maven? maven.any? end
path_prefix()
click to toggle source
# File lib/pushwagner/environment.rb, line 22 def path_prefix config['path_prefix'] || '/' end
static()
click to toggle source
# File lib/pushwagner/environment.rb, line 34 def static config['static'] || {} end
static?()
click to toggle source
# File lib/pushwagner/environment.rb, line 38 def static? static.any? end
user()
click to toggle source
# File lib/pushwagner/environment.rb, line 58 def user environment['user'] || "nobody" end
Private Instance Methods
look_for_config_file(file)
click to toggle source
# File lib/pushwagner/environment.rb, line 63 def look_for_config_file(file) locations = [file, './deploy.yml', './.pw.yml', './config/deploy.yml'] locations.each do |location| return location if File.exist? location cf = File.join(File.dirname(__FILE__), location) # i.e rake/thor. return cf if File.exist? cf end raise "Couldn't find config file in locations: #{locations.join(', ')}" end