Sha256: 611e02df851652269596b7aebcb8b635c0bce5789861c312d4fec6fe0f7d61f4

Contents?: true

Size: 655 Bytes

Versions: 18

Compression:

Stored size: 655 Bytes

Contents

module BPM
  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(:bpm_api_key => api_key, :bpm_email => email)
      end
    end

    def path
      LibGems.configuration.credentials_path
    end

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

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
bpm-1.0.0 lib/bpm/credentials.rb
bpm-1.0.0.rc.4 lib/bpm/credentials.rb
bpm-1.0.0.rc.3 lib/bpm/credentials.rb
bpm-1.0.0.rc.2 lib/bpm/credentials.rb
bpm-1.0.0.rc.1 lib/bpm/credentials.rb
bpm-1.0.0.beta.13 lib/bpm/credentials.rb
bpm-1.0.0.beta.12 lib/bpm/credentials.rb
bpm-1.0.0.beta.11 lib/bpm/credentials.rb
bpm-1.0.0.beta.10 lib/bpm/credentials.rb
bpm-1.0.0.beta.9 lib/bpm/credentials.rb
bpm-1.0.0.beta.8 lib/bpm/credentials.rb
bpm-1.0.0.beta.6 lib/bpm/credentials.rb
bpm-1.0.0.beta.5 lib/bpm/credentials.rb
bpm-1.0.0.beta.4 lib/bpm/credentials.rb
bpm-0.1.4 lib/bpm/credentials.rb
bpm-0.1.3 lib/bpm/credentials.rb
bpm-0.1.2 lib/bpm/credentials.rb
bpm-0.1.0 lib/bpm/credentials.rb