Class: Debstep::ScriptKeeper
- Inherits:
-
Object
- Object
- Debstep::ScriptKeeper
- Defined in:
- lib/debstep/script_keeper.rb
Instance Attribute Summary collapse
-
#script ⇒ Object
readonly
Returns the value of attribute script.
Instance Method Summary collapse
- #append(value) ⇒ Object
- #file(path) ⇒ Object (also: #run)
-
#initialize(init = "#!/usr/bin/env bash", &block) ⇒ ScriptKeeper
constructor
A new instance of ScriptKeeper.
- #raw(value) ⇒ Object
- #template(path) ⇒ Object
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
#script ⇒ Object (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 |