Class: Debstep::ScriptKeeper

Inherits:
Object
  • Object
show all
Defined in:
lib/debstep/script_keeper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(init = "#!/usr/bin/env bash", &block) ⇒ ScriptKeeper

Returns a new instance of ScriptKeeper.


7
8
9
10
# File 'lib/debstep/script_keeper.rb', line 7

def initialize(init="#!/usr/bin/env bash", &block)
  @script = init + "\n"
  instance_eval(&block) if block_given?
end

Instance Attribute Details

#scriptObject (readonly)

Returns the value of attribute script


5
6
7
# File 'lib/debstep/script_keeper.rb', line 5

def script
  @script
end

Instance Method Details

#append(value) ⇒ Object


24
25
26
# File 'lib/debstep/script_keeper.rb', line 24

def append(value)
  @script += value + "\n"
end

#file(path) ⇒ Object Also known as: run


12
13
14
# File 'lib/debstep/script_keeper.rb', line 12

def file(path)
  append(File.open(path, 'r').read.strip)
end

#raw(value) ⇒ Object


16
17
18
# File 'lib/debstep/script_keeper.rb', line 16

def raw(value)
  append(value)
end

#template(path) ⇒ Object


20
21
22
# File 'lib/debstep/script_keeper.rb', line 20

def template(path)
  append(ERB.new(File.open(path, 'r').read.strip).result)
end