Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: 0.7.1
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 85 lines (71 sloc) 2.546 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
LIBPATH = File.expand_path(File.dirname(__FILE__)) + File::SEPARATOR
  
#
# builds and tests
#
desc 'writes lib/phonegap.js and lib/phonegap-min.js and runs docs'
task :default do
  build
  doc
end

task :doc do
  doc
end

def doc
  puts 'writing the full interface source for documentation into tmp/phonegap.js'
  final = "#{ LIBPATH }tmp#{ File::SEPARATOR }phonegap.js"
  js = ""
  interfaces_to_build.each do |lib|
    js << import("#{ LIBPATH }javascripts#{ File::SEPARATOR }#{ lib }.js")
  end
  FileUtils.mkdir_p "#{ LIBPATH }tmp"
  open(final,'w'){|f| f.puts( js )}
  sh "java -jar util#{ File::SEPARATOR }jsdoc-toolkit#{ File::SEPARATOR }jsrun.jar util#{ File::SEPARATOR }jsdoc-toolkit#{ File::SEPARATOR }app#{ File::SEPARATOR }run.js -a -t=util#{ File::SEPARATOR }jsdoc-toolkit#{ File::SEPARATOR }templates#{ File::SEPARATOR }jsdoc tmp#{ File::SEPARATOR }phonegap.js"
end

def build
  puts 'writing the full JS file to lib/phonegap.js'
  final = "#{ LIBPATH }lib#{ File::SEPARATOR }phonegap.js"
  js = ""
  
  interfaces_to_build.each do |interface|
    js << import("#{ LIBPATH }javascripts#{ File::SEPARATOR }#{ interface }.js")
  end
  
  platforms_to_build.each do |platform|
    interfaces_to_build.each do |interface|
      begin
        js << import("#{ LIBPATH }javascripts#{ File::SEPARATOR }#{ platform }#{ File::SEPARATOR }#{ interface }.js")
      rescue
      end
    end
  end

  FileUtils.mkdir_p "#{ LIBPATH }lib"
  open(final,'w'){|f| f.puts( js )}
  
  min
end

# the sub libraries used by xui
def interfaces_to_build
  %w(acceleration accelerometer media camera contact file geolocation map notification orientation position sms telephony)
end

# the sub libraries used by xui
def platforms_to_build
  %w(android blackberry iphone)
end

# helper for build_sub_libaries
def import(lib)
  s = ""
  r = ""
  open(lib) { |f| s << "\n#{f.read}\n\n" }
  s.each_line {|l| r << " #{l}"}
  r
end

# creates lib/xui-min.js (tho not obfuscates)
def min
  puts 'minifying js'
  min_file = "#{ LIBPATH }lib#{ File::SEPARATOR }phonegap-min.js"
  doc_file = "#{ LIBPATH }lib#{ File::SEPARATOR }phonegap.js"
  sh "java -jar #{LIBPATH}#{ File::SEPARATOR }util#{ File::SEPARATOR }yuicompressor-2.4.2.jar --charset UTF-8 -o #{min_file} #{doc_file}"
end
 
# opens up the specs
def spec
  puts 'running automated test suite'
  #sh "open -a WebKit file://#{ LIBPATH }/spec/index.html"
  #sh "open -a '/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app' file://#{ LIBPATH }/spec/index.html"
end
Something went wrong with that request. Please try again.