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



59
60
61
62
63
# File 'lib/phonegap.rb', line 59

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

#generate(path) ⇒ Object

creates an app skeleton



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/phonegap.rb', line 28

def generate(path)
  generate_path = File.join(Dir.pwd,path)
  template_path = File.join(File.dirname(__FILE__),'generate')
  FileUtils.cp_r(template_path, 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 visit http://phonegap.com
  
  E
  trim(e)
end

#has_phonegap_sauce?Boolean

check for the phonegap sauce

Returns:

  • (Boolean)


23
24
25
# File 'lib/phonegap.rb', line 23

def has_phonegap_sauce?
  File.exists?(install_path)
end

#install_pathObject

grab install path of the phonegap sauce



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



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/phonegap.rb', line 66

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



83
84
85
# File 'lib/phonegap.rb', line 83

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