Sha256: c33c50d98995f73eb4f7483aa8216dff0bb6187da02a59fdd91b3790f266d5a7

Contents?: true

Size: 868 Bytes

Versions: 1

Compression:

Stored size: 868 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(ERB.new(File.read(config_file)).result)
          @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.7.0 lib/phone_gap/build/credentials.rb