Sha256: 39c4514cecc3aba5403e95d9a2cfa622d6084a460d7b43052fd191d0f4280e49

Contents?: true

Size: 902 Bytes

Versions: 2

Compression:

Stored size: 902 Bytes

Contents

require 'itamae'

module Itamae
  module Resource
    class File < Base
      define_attribute :action, default: :create
      define_attribute :path, type: String, default_name: true
      define_attribute :content, type: String, default: ''
      define_attribute :content_file, type: String
      define_attribute :mode, type: String
      define_attribute :owner, type: String
      define_attribute :group, type: String

      def create_action
        src = if content_file
                content_file
              else
                Tempfile.open('itamae') do |f|
                  f.write(content)
                  f.path
                end
              end

        copy_file(src, path)

        if mode
          backend.change_file_mode(path, mode)
        end
        if owner || group
          backend.change_file_owner(path, owner, group)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
itamae-1.0.0.beta3 lib/itamae/resource/file.rb
itamae-1.0.0.beta2 lib/itamae/resource/file.rb