class Octopusci::IO
Attributes
job[RW]
Public Class Methods
new(job)
click to toggle source
# File lib/octopusci/io.rb, line 7 def initialize(job) @job = job end
Public Instance Methods
read_all_log()
click to toggle source
# File lib/octopusci/io.rb, line 23 def read_all_log if File.exists?(abs_log_file_path) f = File.open(abs_log_file_path, 'r', :encoding => "BINARY") cont = f.read() f.close return cont else return "" end end
read_all_log_as_html()
click to toggle source
# File lib/octopusci/io.rb, line 40 def read_all_log_as_html out = StringIO.new ::ANSI2HTML::Main.new(read_all_log(), out) return out.string end
read_all_out()
click to toggle source
# File lib/octopusci/io.rb, line 11 def read_all_out if File.exists?(abs_output_file_path) cont = "" f = File.open(abs_output_file_path, 'r', :encoding => "BINARY") cont = f.read() f.close return cont else return "" end end
read_all_out_as_html()
click to toggle source
# File lib/octopusci/io.rb, line 34 def read_all_out_as_html out = StringIO.new ::ANSI2HTML::Main.new(read_all_out(), out) return out.string end
write_log(msg="", &block)
click to toggle source
# File lib/octopusci/io.rb, line 50 def write_log(msg="", &block) write_raw_output(true, msg, &block) end
write_out(msg="", &block)
click to toggle source
# File lib/octopusci/io.rb, line 46 def write_out(msg="", &block) write_raw_output(false, msg, &block) end
write_raw_output(silently=false, msg="") { |out_f| ... }
click to toggle source
# File lib/octopusci/io.rb, line 54 def write_raw_output(silently=false, msg="") # Make sure that the directory structure is in place for the job output. if !File.directory?(abs_output_base_path) FileUtils.mkdir_p(abs_output_base_path) end # Run the command and output the output to the job file out_f = if silently File.open(abs_log_file_path, 'a') else File.open(abs_output_file_path, 'a') end yield(out_f) if block_given? out_f << msg unless msg.nil? || msg.empty? out_f.close end
Private Instance Methods
abs_log_file_path()
click to toggle source
# File lib/octopusci/io.rb, line 79 def abs_log_file_path return "#{abs_output_base_path}/silent_output.txt" end
abs_output_base_path()
click to toggle source
# File lib/octopusci/io.rb, line 83 def abs_output_base_path return "#{Octopusci::Config['general']['workspace_base_path']}/jobs/#{@job['id']}" end
abs_output_file_path()
click to toggle source
# File lib/octopusci/io.rb, line 75 def abs_output_file_path return "#{abs_output_base_path}/output.txt" end