lib/capistrano-custom-maintenance/deploy.rb in capistrano-custom-maintenance-0.0.1 vs lib/capistrano-custom-maintenance/deploy.rb in capistrano-custom-maintenance-0.0.2

- old
+ new

@@ -53,11 +53,24 @@ run("rm -f #{maintenance_system_path}") } reason = maintenance_reason deadline = maintenance_deadline - template = File.read(maintenance_template) - result = ERB.new(template).result(binding) + + begin + ic = fetch(:maintenance_input_encoding, nil) + template = File.read(maintenance_template, :external_encoding => ic) + rescue + template = File.read(maintenance_template) + end + + _result = ERB.new(template).result(binding) + begin + oc = fetch(:maintenance_output_encoding, nil) + result = oc ? _result.encode(oc) : _result + rescue + result = _result + end put(result, maintenance_system_path, :mode => 0644) } task(:enable, :roles => :web, :except => { :no_release => true }) {