Class: Panoramix::Plugin::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/panoramix/plugin/base.rb

Direct Known Subclasses

CloudFormation, DockerImageBase, DockerUp, Environment, Git, S3, Wget

Instance Method Summary collapse

Instance Method Details

#created?Boolean

Has this instance already been created

Returns:

  • (Boolean)


23
24
25
# File 'lib/panoramix/plugin/base.rb', line 23

def created?
	raise "Not implemented"
end

#needed?(timestamps) ⇒ Boolean

When this instance needs to be executed

Returns:

  • (Boolean)


18
19
20
# File 'lib/panoramix/plugin/base.rb', line 18

def needed? timestamps
	raise "Not implemented"
end

#run_defaultObject

Default action for this task



28
29
30
# File 'lib/panoramix/plugin/base.rb', line 28

def run_default
	raise "Not implemented"
end

#shell(cmd, silent = false, env = Hash.new) ⇒ Object

Raises:

  • (@err)


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# 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

#timestampObject

Return current timestamp



13
14
15
# File 'lib/panoramix/plugin/base.rb', line 13

def timestamp
	raise "Not implemented"
end