Sha256: 3aaf13d38d3481f420cb2d7e73c79cd4290f5b621a01915d7ba80816151ea28b

Contents?: true

Size: 745 Bytes

Versions: 2

Compression:

Stored size: 745 Bytes

Contents

module Spade
  module Packager
    class Credentials
      attr_reader :email, :api_key

      def initialize
        parse
      end

      def save(email, api_key)
        @email   = email
        @api_key = api_key
        write
      end

      private

      def write
        FileUtils.mkdir_p(File.dirname(path))
        File.open(path, "w") do |file|
          file.write YAML.dump(:spade_api_key => api_key, :spade_email => email)
        end
      end

      def path
        LibGems.configuration.credentials_path
      end

      def parse
        if File.exist?(path)
          hash     = YAML.load_file(path)
          @email   = hash[:spade_email]
          @api_key = hash[:spade_api_key]
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spade-packager-0.1.0.1 lib/spade/packager/credentials.rb
spade-packager-0.1.0 lib/spade/packager/credentials.rb