require 'rubygems' require 'rake' begin require 'jeweler' Jeweler::Tasks.new do |gem| gem.name = "flex-sdk" gem.summary = %Q{Flex SDK Gem for redistribution to vWork servers and developers} gem.description = %Q{Flex SDK Gem for redistribution to vWork servers and developers} gem.email = "jonathan.hoskin@visfleet.com" gem.homepage = "http://github.com/jonathanhoskin/flex-sdk" gem.authors = ["Jonathan Hoskin"] gem.add_development_dependency "thoughtbot-shoulda", ">= 0" # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings end Jeweler::GemcutterTasks.new rescue LoadError puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler" end require 'rake/testtask' Rake::TestTask.new(:test) do |test| test.libs << 'lib' << 'test' test.pattern = 'test/**/test_*.rb' test.verbose = true end begin require 'rcov/rcovtask' Rcov::RcovTask.new do |test| test.libs << 'test' test.pattern = 'test/**/test_*.rb' test.verbose = true end rescue LoadError task :rcov do abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov" end end task :test => :check_dependencies task :default => :test require 'rake/rdoctask' Rake::RDocTask.new do |rdoc| version = File.exist?('VERSION') ? File.read('VERSION') : "" rdoc.rdoc_dir = 'rdoc' rdoc.title = "flex-sdk #{version}" rdoc.rdoc_files.include('README*') rdoc.rdoc_files.include('lib/**/*.rb') end namespace :flex do desc "Download and Unpack the Flex SDK redistributable" task :download do sdk_ver = "3.5.0.12683" sdk_dir = "flex_sdk_" + sdk_ver sdk_file = sdk_dir + ".zip" cdn_path = "http://c2561582.cdn.cloudfiles.rackspacecloud.com/" cdn_file = cdn_path + sdk_file dest_file = File.expand_path(File.join("vendor", sdk_file)) dest_dir = File.expand_path("vendor") mkdir dest_dir unzip_dir = File.join(dest_dir, sdk_dir) puts "\n" unless File.file?(dest_file) puts "Downloading SDK\n\tFrom:\t#{cdn_file}\n\tTo:\t#{dest_file}\n\n" `wget -O #{dest_file} #{cdn_file}` if $?.to_i != 0 raise "Failed to download Flex SDK\n\n" end else puts "Won't download SDK, file #{dest_file} already exists\n\n" end unless File.directory?(unzip_dir) puts "Unzipping SDK\n\tFrom:\t#{dest_file}\n\tTo:\t#{unzip_dir}/\n\n" `unzip #{dest_file} -d #{dest_dir}` if $?.to_i != 0 raise "Failed to unzip Flex SDK" end else puts "Won't unzip, directory #{unzip_dir}/ already exists\n\n" end puts "Done. Flex SDK should now be ready for building\n\n" end desc "Create locales for the flex sdk" task :copylocale do sdk_dir = get_sdk_dir puts = `#{sdk_dir}/bin/copylocale en_US en_NZ` unless $?.to_i != 0 puts "INFO: Process copylocale completed successfully" else raise "ERROR: Process copylocale FAILED" end end end def get_sdk_dir vendor_dir = "vendor" vendor_listing = Dir.entries(vendor_dir) sdk_dir = vendor_listing.find_all{|item| item =~ /^[^.]/ }.first File.join(vendor_dir, sdk_dir) end