bin/calabash-ios-setup.rb in calabash-cucumber-0.9.132 vs bin/calabash-ios-setup.rb in calabash-cucumber-0.9.133
- old
+ new
@@ -92,60 +92,22 @@
def download_calabash(project_path)
file = 'calabash.framework'
##Download calabash.framework
if not File.directory?(File.join(project_path, file))
msg("Info") do
- zip_file = "calabash.framework-#{ENV['FRAMEWORK_VERSION']||Calabash::Cucumber::FRAMEWORK_VERSION}.zip"
- puts "Did not find calabash.framework. I'll download it...'"
- puts "http://cloud.github.com/downloads/calabash/calabash-ios/#{zip_file}"
- require 'uri'
+ zip_file = File.join(@framework_dir,"calabash.framework.zip")
- uri = URI.parse "http://cloud.github.com/downloads/calabash/calabash-ios/#{zip_file}"
- success = false
- if has_proxy?
- proxy_url = proxy
- connection = Net::HTTP::Proxy(proxy_url[0], proxy_url[1])
- else
- connection = Net::HTTP
- end
- begin
- connection.start(uri.host, uri.port) do |http|
- request = Net::HTTP::Get.new uri.request_uri
-
- http.request request do |response|
- if response.code == '200'
- open zip_file, 'wb' do |io|
- response.read_body do |chunk|
- print "."
- io.write chunk
- end
- end
- success = true
- else
- puts "Got bad response code #{response.code}."
- puts "Aborting..."
- end
- end
- end
- rescue SocketError => e
- msg("Error") do
- puts "Exception: #{e}"
- puts "Unable to download Calabash. Please check connection."
- end
- exit 1
- end
- if success
- puts "\nDownload done: #{file}. Unzipping..."
+ if File.exist?(zip_file)
if not system("unzip -C -K -o -q -d #{project_path} #{zip_file} -x __MACOSX/* calabash.framework/.DS_Store")
msg("Error") do
puts "Unable to unzip file: #{zip_file}"
puts "You must install manually."
end
exit 1
end
- FileUtils.rm(zip_file)
else
+ puts "Inconsistent gem state: Cannot find framework: #{zip_file}"
exit 0
end
end
else
msg("Info") do
@@ -172,30 +134,27 @@
puts "Directory #{path} doesn't contain #{proj_file}"
end
exit 1
end
- pwd = FileUtils.pwd
- FileUtils.cd project_path
- ##Backup
- if File.exists? "#{proj_file}.bak"
- msg("Error") do
- puts "Backup file already exists. #{proj_file}.bak"
- puts "For safety, I won't overwrite this file."
- puts "You must manually move this file, if you want to"
- puts "Run calabash-ios setup again."
+ FileUtils.cd project_path do
+ ##Backup
+ if File.exists? "#{proj_file}.bak"
+ msg("Error") do
+ puts "Backup file already exists. #{proj_file}.bak"
+ puts "For safety, I won't overwrite this file."
+ puts "You must manually move this file, if you want to"
+ puts "Run calabash-ios setup again."
+ end
+ exit 1
end
- exit 1
end
- file = download_calabash(project_path)
+ download_calabash(project_path)
msg("Info") do
puts "Setting up project file for calabash-ios."
end
-
-
- FileUtils.cd pwd
##Backup
msg("Info") do
puts "Making backup of project file: #{proj_file}"
FileUtils.cp(proj_file, "#{proj_file}.bak")
\ No newline at end of file