Class: PhoneGap::Build::App
- Inherits:
-
RestResource
- Object
- Base
- RestResource
- PhoneGap::Build::App
- Defined in:
- lib/phone_gap/build/app.rb
Constant Summary collapse
- PATH =
'/apps'
Instance Attribute Summary collapse
-
#create_method ⇒ Object
Returns the value of attribute create_method.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#description ⇒ Object
Returns the value of attribute description.
-
#file ⇒ Object
Returns the value of attribute file.
-
#hydrates ⇒ Object
Returns the value of attribute hydrates.
-
#keys ⇒ Object
Returns the value of attribute keys.
-
#package ⇒ Object
Returns the value of attribute package.
-
#phonegap_version ⇒ Object
Returns the value of attribute phonegap_version.
-
#private ⇒ Object
Returns the value of attribute private.
-
#status ⇒ Object
Returns the value of attribute status.
-
#title ⇒ Object
Returns the value of attribute title.
-
#version ⇒ Object
Returns the value of attribute version.
Attributes inherited from RestResource
#errors, #id, #poll_interval, #poll_time_limit
Instance Method Summary collapse
- #build ⇒ Object
- #build_complete?(params = {}) ⇒ Boolean
- #download(params = {}) ⇒ Object
- #post_options ⇒ Object
Methods inherited from RestResource
#as_json, #create, #destroy, #initialize, #save, #update
Methods included from Creatable
#creatable_attributes, included, #updatable_attributes
Methods inherited from Base
Constructor Details
This class inherits a constructor from PhoneGap::Build::RestResource
Instance Attribute Details
#create_method ⇒ Object
Returns the value of attribute create_method.
10 11 12 |
# File 'lib/phone_gap/build/app.rb', line 10 def create_method @create_method end |
#debug ⇒ Object
Returns the value of attribute debug.
10 11 12 |
# File 'lib/phone_gap/build/app.rb', line 10 def debug @debug end |
#description ⇒ Object
Returns the value of attribute description.
10 11 12 |
# File 'lib/phone_gap/build/app.rb', line 10 def description @description end |
#file ⇒ Object
Returns the value of attribute file.
10 11 12 |
# File 'lib/phone_gap/build/app.rb', line 10 def file @file end |
#hydrates ⇒ Object
Returns the value of attribute hydrates.
10 11 12 |
# File 'lib/phone_gap/build/app.rb', line 10 def hydrates @hydrates end |
#keys ⇒ Object
Returns the value of attribute keys.
10 11 12 |
# File 'lib/phone_gap/build/app.rb', line 10 def keys @keys end |
#package ⇒ Object
Returns the value of attribute package.
10 11 12 |
# File 'lib/phone_gap/build/app.rb', line 10 def package @package end |
#phonegap_version ⇒ Object
Returns the value of attribute phonegap_version.
10 11 12 |
# File 'lib/phone_gap/build/app.rb', line 10 def phonegap_version @phonegap_version end |
#private ⇒ Object
Returns the value of attribute private.
10 11 12 |
# File 'lib/phone_gap/build/app.rb', line 10 def private @private end |
#status ⇒ Object
Returns the value of attribute status.
10 11 12 |
# File 'lib/phone_gap/build/app.rb', line 10 def status @status end |
#title ⇒ Object
Returns the value of attribute title.
10 11 12 |
# File 'lib/phone_gap/build/app.rb', line 10 def title @title end |
#version ⇒ Object
Returns the value of attribute version.
10 11 12 |
# File 'lib/phone_gap/build/app.rb', line 10 def version @version end |
Instance Method Details
#build ⇒ Object
27 28 29 |
# File 'lib/phone_gap/build/app.rb', line 27 def build ApiRequest.new.post("#{PATH}/#{id}/build") end |
#build_complete?(params = {}) ⇒ Boolean
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/phone_gap/build/app.rb', line 32 def build_complete?(params = {}) complete = false error = false start_time = Time.now time_limit = start_time + (params[:poll_time_limit] || poll_time_limit) while !complete && (Time.now < time_limit) && !error response = ApiRequest.new.get("#{PATH}/#{id}") if response.success? json_object = JSON.parse(response.body) complete = json_object['status'].all? { |platform, status| %w(complete skip).include?(status) } error = json_object['status'].any? { |platform, status| status == 'error' } end sleep (params[:poll_interval] || poll_interval) unless complete or error end raise BuildError.new('An error occurred building at least one of the apps.') if error raise BuildError.new('Builds did not complete within the allotted time.') if !error && !complete populate_from_json(json_object) complete end |
#download(params = {}) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/phone_gap/build/app.rb', line 52 def download(params = {}) platforms_to_download = params[:platforms] ? params[:platforms] : built_platforms platforms_to_download.each do |platform| PhoneGap::Build::PackageDownloader.new.download(id, platform, params[:save_to]) end end |
#post_options ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/phone_gap/build/app.rb', line 17 def if file data_attributes = creatable_attributes data_attributes.delete('@file') {query: {file: file, data: as_json(only: data_attributes, remove_nils: true)}, detect_mime_type: true} else {query: {data: as_json(only: creatable_attributes, remove_nils: true)}} end end |