Class: CloudMaker::ShellExecutor
- Inherits:
-
Object
- Object
- CloudMaker::ShellExecutor
- Defined in:
- lib/cloud_maker/shell_executor.rb
Constant Summary collapse
- YAML_DOMAIN =
If we don’t use yaml.org,2002 some YAML implementations don’t pickup our !shell-script nodes properly.
"yaml.org,2002"
- YAML_TYPE =
"shell-script"
Instance Attribute Summary collapse
-
#script ⇒ Object
Returns the value of attribute script.
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(script) ⇒ ShellExecutor
constructor
A new instance of ShellExecutor.
- #to_s ⇒ Object
- #to_yaml(opts = {}) ⇒ Object
- #to_yaml_type ⇒ Object
Constructor Details
#initialize(script) ⇒ ShellExecutor
Returns a new instance of ShellExecutor.
9 10 11 |
# File 'lib/cloud_maker/shell_executor.rb', line 9 def initialize(script) self.script = script end |
Instance Attribute Details
#script ⇒ Object
Returns the value of attribute script.
7 8 9 |
# File 'lib/cloud_maker/shell_executor.rb', line 7 def script @script end |
Class Method Details
.from_string_representation(string_representation) ⇒ Object
31 32 33 |
# File 'lib/cloud_maker/shell_executor.rb', line 31 def self.from_string_representation(string_representation) ShellExecutor.new(string_representation) end |
Instance Method Details
#execute ⇒ Object
23 24 25 |
# File 'lib/cloud_maker/shell_executor.rb', line 23 def execute @result ||= `#{self.script}`.strip end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/cloud_maker/shell_executor.rb', line 27 def to_s execute end |
#to_yaml(opts = {}) ⇒ Object
17 18 19 20 21 |
# File 'lib/cloud_maker/shell_executor.rb', line 17 def to_yaml(opts = {}) YAML.quick_emit( nil, opts ) { |out| out.scalar( "tag:yaml.org,2002:str", execute, :plain ) } end |
#to_yaml_type ⇒ Object
13 14 15 |
# File 'lib/cloud_maker/shell_executor.rb', line 13 def to_yaml_type "#{YAML_DOMAIN}/#{YAML_TYPE}" end |