Sha256: 5ef65d09cb28d78a737af04f90181159dc561988a50afbd86819bac9372b5a53

Contents?: true

Size: 675 Bytes

Versions: 3

Compression:

Stored size: 675 Bytes

Contents

module DeployGate
  class Config
    class << self

      # @return [String]
      def file_path
        File.join(ENV["HOME"], '.dg/credentials')
      end

      # @param [Hash] config
      # @return [void]
      def write(config)
        FileUtils.mkdir_p(File.dirname(file_path))

        data = JSON.generate(config)
        file = File.open(file_path, "w+")
        file.print data
        file.close
      end

      # @return [Hash]
      def read
        file = File.open(file_path)
        data = file.read
        file.close
        JSON.parse(data)
      end

      # @return [Boolean]
      def exist?
        File.exist?(file_path)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
deploygate-0.0.3 lib/deploygate/config.rb
deploygate-0.0.2 lib/deploygate/config.rb
deploygate-0.0.1 lib/deploygate/config.rb