bin/calabash-ios-setup.rb in calabash-cucumber-0.9.47 vs bin/calabash-ios-setup.rb in calabash-cucumber-0.9.48

- old
+ new

@@ -43,13 +43,10 @@ puts "\n\n" puts "After validating, you can generate a features folder:" puts "Go to your project (the dir containing the .xcodeproj file)." puts "Then run calabash-ios gen" puts "(if you don't already have a features folder)." - sleep 2 - system(%Q[open "#{xpath}"]) - end else puts "Xcode is running. We'll be changing the project file so we'd better stop it." puts "Shall I stop Xcode? Please answer yes (y) or no (n)" @@ -95,10 +92,19 @@ def calabash_download(args) download_calabash(File.expand_path(".")) end +def has_proxy? + ENV['http_proxy'] ? true : false +end + +def proxy + url_parts = URI.split(ENV['http_proxy']) + [url_parts[2], url_parts[3]] +end + def download_calabash(project_path) file = 'calabash.framework' ##Download calabash.framework if not File.directory?(File.join(project_path, file)) msg("Info") do @@ -107,10 +113,16 @@ puts "http://cloud.github.com/downloads/calabash/calabash-ios/#{zip_file}" require 'uri' uri = URI.parse "http://cloud.github.com/downloads/calabash/calabash-ios/#{zip_file}" success = false - Net::HTTP.start(uri.host, uri.port) do |http| + if has_proxy? + proxy_url = proxy + connection = Net::HTTP::Proxy(proxy_url[0], proxy_url[1]) + else + connection = Net::HTTP + end + 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| \ No newline at end of file