Sha256: eb3de00bf1f8f2187105d75d3f9a2fd0ff013776af211dbc361182f14189eb59

Contents?: true

Size: 693 Bytes

Versions: 3

Compression:

Stored size: 693 Bytes

Contents

class Pups::FileCommand < Pups::Command
  attr_accessor :path, :contents, :params, :type, :chmod

  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

  def initialize
    @params = {}
    @type = :bash
  end

  def params=(p)
    @params = p
  end

  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

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pups-1.0.2 lib/pups/file_command.rb
pups-1.0.1 lib/pups/file_command.rb
pups-1.0.0 lib/pups/file_command.rb