Sha256: 1837ecd7b5359bdd28e9e81a5dccc80b40985d4cc08a6749723ea69b4ed151dd

Contents?: true

Size: 882 Bytes

Versions: 1

Compression:

Stored size: 882 Bytes

Contents

require 'itamae'

module Itamae
  module Resources
    class File < Base
      define_option :action, default: :create
      define_option :path, type: String, default_name: true
      define_option :content, type: String, default: ''
      define_option :content_file, type: String
      define_option :mode, type: String
      define_option :owner, type: String
      define_option :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

1 entries across 1 versions & 1 rubygems

Version Path
itamae-1.0.0.beta1 lib/itamae/resources/file.rb