Sha256: 03a0343fad60119dbd82cf3a6ecc8d675eb077b42de5f3303259a6ed78e5247c

Contents?: true

Size: 1021 Bytes

Versions: 4

Compression:

Stored size: 1021 Bytes

Contents

require 'phone_gap/build/version'
require 'phone_gap/build/base'
require 'phone_gap/build/credentials'
require 'phone_gap/build/app_factory'
require 'phone_gap/build/app'
require 'phone_gap/build/api_request'
require 'phone_gap/build/rest_resource'
require 'phone_gap/build/creatable'
require 'phone_gap/build/error'

require 'httparty'

module PhoneGap
  module Build

    def self.credentials(credentials)
      @credentials = Credentials.instance.set(credentials)
    end

    def self.apps
      if credentials?
        http_response = HTTParty.get("https://build.phonegap.com/api/v1/apps?auth_token=#{@credentials.token}")
        parsed_response = JSON.parse(http_response.body)
        AppFactory.create_many(parsed_response)
      else
        Error.new(message: 'Api credentials not found. Set them or add thmem to config/phonegap.yml')
      end
    end

    def self.credentials?
      if @credentials && @credentials.token
        true
      else
        Credentials.instance.load
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
phone_gap-build-0.6.0 lib/phone_gap/build.rb
phone_gap-build-0.5.1 lib/phone_gap/build.rb
phone_gap-build-0.5.0 lib/phone_gap/build.rb
phone_gap-build-0.4.0 lib/phone_gap/build.rb