Sha256: ba9cc94154aa5bb2f226db18db24ee5965327d01d75980cc53add174eb4f318d

Contents?: true

Size: 840 Bytes

Versions: 1

Compression:

Stored size: 840 Bytes

Contents

module Aruba
  # Create things to make aruba work
  module Creators
    # Normal File Creator
    # This class is not meant to be used directly by users.
    class ArubaFileCreator
      # Write File
      #
      # @param [String] path
      #   The path to write content to
      #
      # @param [Object] content
      #   The content of the file
      #
      # @param [TrueClass, FalseClass] check_presence (false)
      #   Check if file exist
      def write(path, content, check_presence = false)
        fail "Expected #{path} to be present" if check_presence && !Aruba.platform.file?(path)

        Aruba.platform.mkdir(File.dirname(path))

        if RUBY_VERSION < '1.9.3'
          File.open(path, 'w') { |f| f << content }
        else
          File.write(path, content)
        end

        self
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aruba-0.9.0.pre lib/aruba/platforms/aruba_file_creator.rb