lib/apache/rake/apache/create.rb in apache-config-generator-0.2.6 vs lib/apache/rake/apache/create.rb in apache-config-generator-0.2.7
- old
+ new
@@ -3,10 +3,19 @@
include Apache::Rake::Support
task :default => 'apache:create'
+def capture_stdout
+ buffer = StringIO.new
+ $stdout = buffer
+ yield
+ $stdout = STDOUT
+ buffer.rewind
+ buffer.read
+end
+
namespace :apache do
desc "Create all defined configs for the specified environment"
task :create, :environment do |t, args|
if get_environments.empty?
APACHE_ENV = true
@@ -14,23 +23,31 @@
need_environment if !args[:environment] && !get_default_environment
APACHE_ENV = (args[:environment] || get_default_environment).to_sym
end
- config[:source_path] = File.expand_path(config[:source])
- config[:dest_path] = File.expand_path(config[:destination])
-
Apache::Config.rotate_logs_path = config[:rotate_logs_path]
- FileUtils.mkdir_p config[:dest_path]
- Dir.chdir config[:dest_path]
+ FileUtils.rm_rf config[:destination_path]
+ FileUtils.mkdir_p config[:destination_path]
+ Dir.chdir config[:destination_path]
- # using CONFIG is deprecated
CONFIG = config
+ ENVIRONMENT_CONFIG = (config[:environments][APACHE_ENV] rescue nil)
+
Dir[File.join(config[:source_path], '**', '*.rb')].each do |file|
- puts file.foreground(:green)
- require file
+ Apache::Config.reset!
+ output = capture_stdout { require file }
+
+ if Apache::Config.written?
+ if Apache::Config.disabled?
+ puts file.foreground(:blue)
+ else
+ puts file.foreground(:green)
+ end
+ puts output
+ end
end
end
desc "List all possible environments"
task :environments do