Module: Apache::Rake::Support

Defined in:
lib/apache/rake/support.rb

Instance Method Summary collapse

Instance Method Details

#configObject



7
8
9
# File 'lib/apache/rake/support.rb', line 7

def config
  @config ||= Hash[YAML.load_file('config.yml').collect { |k,v| [ k.to_sym, v ] }]
end

#get_default_environmentObject



19
20
21
# File 'lib/apache/rake/support.rb', line 19

def get_default_environment
  File.read('.environment').strip rescue nil
end

#get_environmentsObject



11
12
13
14
15
16
17
# File 'lib/apache/rake/support.rb', line 11

def get_environments
  config[:source_path] = File.expand_path(config[:source])

  Dir[File.join(config[:source_path], '**', '*.rb')].collect { |file|
    File.readlines(file).find_all { |line| line[%r{(if_environment|build_if)}] }.collect { |line| line.scan(%r{:[a-z_]+}) }
  }.flatten.uniq.sort.collect { |name| name[1..-1] }
end

#need_environmentObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/apache/rake/support.rb', line 23

def need_environment
  puts "You need to specify an environment. Available environments:"
  puts
  puts get_environments.collect { |env| "rake apache:create[#{env}]" } * "\n"
  puts
  puts "Additionally, you can set a default environment for this server:"
  puts
  puts "rake apache:default[#{get_environments.first}]"
  exit 1
end