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
- #file(path) ⇒ Object (also: #run)
-
#initialize(init = "#!/usr/bin/env bash", &block) ⇒ ScriptKeeper
constructor
A new instance of ScriptKeeper.
- #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) 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
#file(path) ⇒ Object Also known as: run
12 13 14 |
# File 'lib/debstep/script_keeper.rb', line 12 def file(path) @script += File.open(path, 'r').read.strip + "\n" end |
#template(path) ⇒ Object
16 17 18 |
# File 'lib/debstep/script_keeper.rb', line 16 def template(path) @script += ERB.new(File.open(path, 'r').read.strip).result + "\n" end |