Module: Apache::Rake::Support
- Defined in:
- lib/apache/rake/support.rb
Instance Method Summary collapse
- #config ⇒ Object
- #config_paths! ⇒ Object
- #get_default_environment ⇒ Object
- #get_environments ⇒ Object
- #need_environment ⇒ Object
Instance Method Details
#config ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/apache/rake/support.rb', line 8 def config if !@config @config = YAML.load_file('config.yml').to_sym_keys config_paths! class << @config def [](which) if which == :dest_path print "config[:dest_path] is deprecated.".foreground(:red).bright puts " Use config[:destination_path] instead.".foreground(:red) self[:destination_path] else super end end end end @config end |
#config_paths! ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/apache/rake/support.rb', line 30 def config_paths! [ :source, :destination ].each do |which| begin @config[:"#{which}_path"] = File.(@config[which]) rescue StandardError puts "#{which.to_s.bright} is not defined in the configuration file.".foreground(:red) exit 1 end end end |
#get_default_environment ⇒ Object
47 48 49 |
# File 'lib/apache/rake/support.rb', line 47 def get_default_environment File.read('.environment').strip rescue nil end |
#get_environments ⇒ Object
41 42 43 44 45 |
# File 'lib/apache/rake/support.rb', line 41 def get_environments 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_environment ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/apache/rake/support.rb', line 51 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 |