Sha256: afc48ac868a5753012704fdd3e7acb2ecc40b4a48bb7a83eb449b6e8b44192ee

Contents?: true

Size: 846 Bytes

Versions: 1

Compression:

Stored size: 846 Bytes

Contents

require 'singleton'

module PhoneGap
  module Build
    class Credentials

      include Singleton

      attr_reader :username, :password, :token, :config
      attr_writer :token

      def set(credentials)
        @username = credentials[:username]
        @password = credentials[:password]
        @token = credentials[:token]
        self
      end

      def load
        if config_file && File.exists?(config_file)
          @config = YAML::load_file(config_file)
          @token = @config['token']
        end
        self
      end

      private

      def config_file
        if ENV['BUNDLE_GEMFILE']
          application_root = ENV['BUNDLE_GEMFILE'].gsub('Gemfile', '')
          File.expand_path(File.join(application_root, 'config', 'phonegap.yml'), __FILE__)
        else
          false
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
phone_gap-build-0.6.2 lib/phone_gap/build/credentials.rb