class Panoramix::Plugin::Base

Public Instance Methods

created?() click to toggle source

Has this instance already been created

# File lib/panoramix/plugin/base.rb, line 23
def created?
        raise "Not implemented"
end
needed?(timestamps) click to toggle source

When this instance needs to be executed

# File lib/panoramix/plugin/base.rb, line 18
def needed? timestamps
        raise "Not implemented"
end
run_default() click to toggle source

Default action for this task

# File lib/panoramix/plugin/base.rb, line 28
def run_default
        raise "Not implemented"
end
shell(cmd, silent=false, env=Hash.new) click to toggle source
# File lib/panoramix/plugin/base.rb, line 32
            def shell(cmd, silent=false, env=Hash.new)
  puts "Running #{cmd}  ENV=#{env}".magenta if ENV["VERBOSE"]

  @err = ""
  @out = ""
  Open3.popen3(env, cmd) do |stdin, stdout, stderr, wait_thr|
    stdin.close
    stdout.each_line do |line|
      puts line unless silent
      @out << "#{line}"
    end
    stderr.each_line do |line|
      puts line.red unless silent
      @err << "#{line}"
    end
    @exit_status = wait_thr.value
  end

  if ENV["VERBOSE"] && !@out.empty?
    puts "\tout => \n\t\t#{@out.gsub("\n","\n\t\t")}".green
  end
  if ENV["VERBOSE"] && !@err.empty?
    if @exit_status.success?
      puts "\terr => \n\t\t#{@err.gsub("\n","\n\t\t")}".yellow
    else
      puts "\terr => \n\t\t#{@err.gsub("\n","\n\t\t")}".red
    end
  end
  puts "\texit_status => #{@exit_status}\n".blue if ENV["VERBOSE"]

  raise @err unless @exit_status.success?

  return {
    :out => @out,
    :err => @err,
    :exit_status => @exit_status
  }
end
timestamp() click to toggle source

Return current timestamp

# File lib/panoramix/plugin/base.rb, line 13
def timestamp
        raise "Not implemented"
end