class Environment

Attributes

party[R]

Public Class Methods

new(party, config) click to toggle source
# File lib/release_party/environment.rb, line 7
def initialize(party, config)
  @party = party
  @cap_config = config
  @variables = {}
end

Public Instance Methods

defaults() click to toggle source
# File lib/release_party/environment.rb, line 37
def defaults
  {
    :user => `git config user.name`.chomp,
    :branch => 'master',
    :stage => 'staging',
    :domain => 'releaseparty.org',
    :display_name => 'Release Party',
    :from_address => 'Release Party <releaseparty@noreply.org>',
    :smtp_address => 'localhost',
    :smtp_port => 25,
    :subject => Proc.new {"#{display_name} was released to http://#{domain}/"},
    :finished_stories => [],
    :known_bugs => [],
    :send_email => true,
    :template_engine => :haml,
    :deliver_stories => false,
    :template => 'config/release_party/template.text.html.haml',
  }
end
load_release_file() click to toggle source

Process the Releasefile and merge the variables loaded

# File lib/release_party/environment.rb, line 32
def load_release_file
  release_file = ReleaseFile.new
  @variables = @variables.merge release_file.variables
end
method_missing(method_id, *args, &block) click to toggle source
# File lib/release_party/environment.rb, line 13
def method_missing(method_id, *args, &block)
  case method_id.to_s
  when /\A(.*)=\Z/
    @variables[$1.to_sym] = args.first || block

  else
    key = method_id.to_sym
    value = if @variables.key?(key)
              @variables[key]
            else
              @cap_config.fetch(key, defaults[key])
            end
    return value.call if value.is_a?(Proc)
    value

  end
end