Skip to content

Instantly share code, notes, and snippets.

@vsalbaba
Created August 27, 2009 15:38
Show Gist options
  • Save vsalbaba/176386 to your computer and use it in GitHub Desktop.
Save vsalbaba/176386 to your computer and use it in GitHub Desktop.
def self.pkg(platform, opt)
extension = case platform
when "win32" then
"exe"
when "linux" then
"run"
when "osx" then
"dmg"
else
raise "Unknown platform"
end
case opt
when I_YES then
url = "http://rock.nalinuxu.cz/~darktatka/pkg/#{RELEASE_NAME.downcase}/#{platform}/shoes"
local_file_path = File.join(LIB_DIR, RELEASE_NAME.downcase, platform, "latest_shoes.#{extension}")
when I_NOV then
url = "http://shoes.heroku.com/pkg/#{RELEASE_NAME.downcase}/#{platform}/shoes-novideo"
local_file_path = File.join(LIB_DIR, RELEASE_NAME.downcase, platform, "latest_shoes-novideo.#{extension}")
end
FileUtils.makedirs File.join(LIB_DIR, RELEASE_NAME.downcase, platform)
begin
url = open(url).read.strip
debug url
rescue Exception => e
error e
internet_failed = true
end
unless File.exists? local_file_path
unless internet_failed then
begin
debug "Downloading #{url}..."
downloaded = open(url)
debug "Download of #{url} finished"
rescue Exception => e
error e
internet_failed = true
end
end
unless internet_failed then
begin
File.open(local_file_path, "wb") do |f|
f.write(downloaded.read)
end
rescue Exception => e
error e
end
end
end
if File.exists? local_file_path then
open(local_file_path)
else
alert "Couldnt find file #{filename} remotely or localy."
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment