Sha256: 8df4a1055be27cdd1901fc54b3f2892f2b8c5d928480f3fa2fe2940ca2756d12

Contents?: true

Size: 840 Bytes

Versions: 5

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'
          File.open(path, 'w') { |f| f << content }
        else
          File.write(path, content)
        end

        self
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
aruba-0.8.1 lib/aruba/creators/aruba_file_creator.rb
aruba-0.8.0 lib/aruba/creators/aruba_file_creator.rb
aruba-0.8.0.pre3 lib/aruba/creators/aruba_file_creator.rb
aruba-0.8.0.pre2 lib/aruba/creators/aruba_file_creator.rb
aruba-0.8.0.pre lib/aruba/creators/aruba_file_creator.rb