Class: PhoneGap

Inherits:
Object
  • Object
show all
Includes:
Android, Blackberry, Iphone
Defined in:
lib/phonegap.rb

Overview

Provides utilities for generating a PhoneGap application and unifies the build process for each of the supported mobile platforms.

Instance Method Summary collapse

Methods included from Blackberry

#blackberry_supported?, #build_blackberry

Methods included from Android

#android_supported?, #build_android

Methods included from Iphone

#build_iphone, #iphone_supported?

Instance Method Details

#build(path) ⇒ Object

builds a phonegap web application to all supported platforms



52
53
54
55
56
# File 'lib/phonegap.rb', line 52

def build(path)
  build_iphone(path)
  build_android(path)
  build_blackberry(path)
end

#generate(path) ⇒ Object

creates an app skeleton



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/phonegap.rb', line 23

def generate(path)
  `cp -rf generate #{path}`   
  e=<<-E
  
  Generated a fresh PhoneGap application! 
  
  #{ path }/
  |
  |- config/
  |  |- bootstrap.js
  |  |- iphone-dev-cert.txt
  |  |- android-dev-cert.txt
  |  '- blackberry-dev-cert.txt
  |
  '- www/
     |- assets/
     |  |- css/
     |  |- js/
     |  '- images/
     |
     '- index.html
     
  For more information, tutorials, documentation and quickstarts go to http://phonegap.com
  
  E
  trim(e)
end

#install_pathObject

helper for getting the install path of phonegap



18
19
20
# File 'lib/phonegap.rb', line 18

def install_path
  File.expand_path('~/.phonegap')
end

#reportObject

outputs a tidy report of which PhoneGap supported SDK’s are installed



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/phonegap.rb', line 59

def report
  report =<<-E
  
  PhoneGap 0.7.0
  -------------------
  
  Supported Platforms
  -------------------
  iPhone ............ #{ iphone_supported? ? 'yes' : 'no!' } .... #{ iphone_supported? ? '3.0' : 'Download and install from http://developer.apple.com' }
  Android  .......... #{ android_supported? ? 'yes' : 'no!' } .... #{ android_supported? ? '???' : 'Download and install from http://code.google.com/p/android' }
  BlackBerry ........ #{ blackberry_supported? ? 'yes' : 'no!' } .... #{ blackberry_supported? ? '???' : 'Download and install from http://developer.rim.com' }
  
  E
  trim(report)
end

#trim(str) ⇒ Object

helper for removing code indentation whitespace



76
77
78
# File 'lib/phonegap.rb', line 76

def trim(str)
  str.gsub('    ','')
end

#versionObject

outputs the current version of PhoneGap FIXME needs to pull from sauce repo found at install path



13
14
15
# File 'lib/phonegap.rb', line 13

def version
  '0.7.0'
end