/gist:d711103f30fe6ef42323 Secret
Created
December 5, 2010 20:31
-
-
Save isaac/d711103f30fe6ef42323 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
framework 'Cocoa' | |
url_string = 'http://www.macruby.org/files/nightlies/macruby_nightly-latest.pkg' | |
url = NSURL.URLWithString(url_string) | |
req = NSURLRequest.requestWithURL(url) | |
def downloadDidBegin(dl_process) | |
puts "downloading..." | |
end | |
def download(dl_process, decideDestinationWithSuggestedFilename:filename) | |
home = NSHomeDirectory() | |
path = home.stringByAppendingPathComponent('Desktop').stringByAppendingPathComponent(filename) | |
dl_process.setDestination(path, allowOverwrite:true) | |
end | |
def download(dl_process, didFailWithError:error) | |
error_description = error.localizedDescription | |
more_details = error.userInfo[NSErrorFailingURLStringKey] | |
puts "Download failed. #{error_description} - #{more_details}" | |
end | |
def downloadDidFinish(dl_process) | |
puts "Download finished!" | |
exit | |
end | |
file_download = NSURLDownload.alloc.initWithRequest(req, delegate: self) | |
# keep the run loop running | |
NSRunLoop.currentRunLoop.runUntilDate(NSDate.distantFuture) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment