merged dave

This commit is contained in:
brianleroux 2010-08-31 16:50:39 -07:00
parent 83070fc4ea
commit f818f9bda9
2 changed files with 14 additions and 21 deletions

View File

@ -19,7 +19,7 @@ Generate.new(ARGV[1]) if ARGV.first == 'gen'
Create.new(ARGV[1]) if ARGV.first == 'create' Create.new(ARGV[1]) if ARGV.first == 'create'
# droidgap run [optional directory] # droidgap run [optional directory]
Run.new(ARGV[1]) if ARGV.first == 'run' Run.new if ARGV.first == 'run'
# droidgap update [params] # droidgap update [params]
Update.new if ARGV.first == 'update' Update.new if ARGV.first == 'update'

View File

@ -4,34 +4,27 @@
# #
# A handy machine that does the following: # A handy machine that does the following:
# #
# - packages www to a valid android project in tmp/android # - runs ant_debug
# - builds tmp/android project into an apk
# - installs apk onto first device found
# - if there is no device attached it will start an emulator with the first avd found # - if there is no device attached it will start an emulator with the first avd found
# - TODO install apk into now running emulator... need to find way to wait for it to have started # - runs ant_install
# - TODO if no avds present it will attempt to create one
# #
class Run class Run
# if no path is supplied uses current directory for project # if no path is supplied uses current directory for project
def initialize(path) def initialize
puts 'packaging www as phonegap/android project in ./tmp/android...' @path = FileUtils.pwd
path = FileUtils.pwd if path.nil? || path == "" build
@pkg = Package.new(path) start_emulator if first_device.nil?
@apk = File.join(@pkg.path, "bin", "#{ @pkg.name.gsub(' ','') }-debug.apk") install
build_apk
first_device.nil? ? start_emulator : install_to_device
end end
def build_apk def build
puts 'building apk...' Dir.chdir(@path)
Dir.chdir(@pkg.path) `ant debug`
`ant debug;`
end end
def install_to_device def install
puts 'installing to device...' Dir.chdir(@path)
Dir.chdir(@pkg.path) `ant install`
`ant install;`
end end
def start_emulator def start_emulator