class Pups::FileCommand
Attributes
chmod[RW]
chown[RW]
contents[RW]
params[RW]
path[RW]
type[RW]
Public Class Methods
from_hash(hash, params)
click to toggle source
# File lib/pups/file_command.rb, line 7 def self.from_hash(hash, params) command = new command.path = hash['path'] command.contents = hash['contents'] command.chmod = hash['chmod'] command.chown = hash['chown'] command.params = params command end
new()
click to toggle source
# File lib/pups/file_command.rb, line 18 def initialize @params = {} @type = :bash end
Public Instance Methods
run()
click to toggle source
# File lib/pups/file_command.rb, line 25 def run path = interpolate_params(@path) `mkdir -p #{File.dirname(path)}` File.open(path, 'w') do |f| f.write(interpolate_params(contents)) end `chmod #{@chmod} #{path}` if @chmod `chown #{@chown} #{path}` if @chown Pups.log.info("File > #{path} chmod: #{@chmod} chown: #{@chown}") end