Class: Pups::FileCommand
Instance Attribute Summary collapse
-
#chmod ⇒ Object
Returns the value of attribute chmod.
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#params ⇒ Object
Returns the value of attribute params.
-
#path ⇒ Object
Returns the value of attribute path.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ FileCommand
constructor
A new instance of FileCommand.
- #run ⇒ Object
Methods inherited from Command
#interpolate_params, interpolate_params, run
Constructor Details
#initialize ⇒ FileCommand
Returns a new instance of FileCommand.
14 15 16 17 |
# File 'lib/pups/file_command.rb', line 14 def initialize @params = {} @type = :bash end |
Instance Attribute Details
#chmod ⇒ Object
Returns the value of attribute chmod.
2 3 4 |
# File 'lib/pups/file_command.rb', line 2 def chmod @chmod end |
#contents ⇒ Object
Returns the value of attribute contents.
2 3 4 |
# File 'lib/pups/file_command.rb', line 2 def contents @contents end |
#params ⇒ Object
Returns the value of attribute params.
2 3 4 |
# File 'lib/pups/file_command.rb', line 2 def params @params end |
#path ⇒ Object
Returns the value of attribute path.
2 3 4 |
# File 'lib/pups/file_command.rb', line 2 def path @path end |
#type ⇒ Object
Returns the value of attribute type.
2 3 4 |
# File 'lib/pups/file_command.rb', line 2 def type @type end |
Class Method Details
.from_hash(hash, params) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/pups/file_command.rb', line 4 def self.from_hash(hash, params) command = new command.path = hash["path"] command.contents = hash["contents"] command.chmod = hash["chmod"] command.params = params command end |
Instance Method Details
#run ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/pups/file_command.rb', line 23 def run path = interpolate_params(@path) `mkdir -p #{File.dirname(path)}` File.open(path, "w") do |f| f.write(interpolate_params(contents)) end if @chmod `chmod #{@chmod} #{path}` end Pups.log.info("File > #{path} chmod: #{@chmod}") end |