Permalink
Browse files

fixed 'pik update'

  • Loading branch information...
1 parent 7f33fa3 commit 5a536703f87717651cd35bf9bd028babd9ee02e6 @vertiginous committed Jan 26, 2011
Showing with 51 additions and 6 deletions.
  1. +45 −4 lib/pik/commands/update_command.rb
  2. +4 −0 lib/pik/scripts/batch_file.rb
  3. +2 −2 tasks/package.rb
@@ -4,13 +4,54 @@ class Update < Command
aka :up
it "updates pik."
+
+ include Installer
include ScriptFileEditor
def execute
- sh "#{Which::Gem.exe} install pik"
- @script.call("pik_install #{Pik.exe.dirname}")
+ puts pik_version
+ if up_to_date?
+ Log.info "This is the most recent version available."
+ else
+ Log.info "Updating to #{latest}"
+ file = download("#{host}pik-#{latest}.zip")
+ clean_update_directory
+ extract(update_directory, file)
+ @script.copy(update_directory + '*.*', Pik.exe.dirname)
+ Log.info "Updating files."
+ end
+ end
+
+ def update_directory
+ @update_directory ||= download_directory + 'pik'
+ end
+
+ def clean_update_directory
+ FileUtils.rm_rf update_directory
+ update_directory.mkpath
+ end
+
+ def up_to_date?
+ latest == Pik::VERSION
end
-
+
+ def latest
+ @latest ||= packages.last
+ end
+
+ def packages
+ @packages ||= index
+ end
+
+ def index
+ uri = URI.parse(host + 'pik.yml')
+ YAML.load(uri.read)
+ end
+
+ def host
+ 'http://s3.amazonaws.com/vertiginous.pik/'
+ end
+
end
-end
+end
@@ -22,6 +22,10 @@ def set(items)
self
end
+ def copy(src, dest)
+ @lines << "copy /y #{src} #{dest}"
+ end
+
def unset(*items)
items.flatten.each{|k| @lines << "SET #{k}=" }
self
View
@@ -1,9 +1,9 @@
require 'uuid'
task :package => [:build, 'installer:package', "pkg/pik-#{Pik::VERSION}.zip" ]
-file "pkg/pik-#{Pik::VERSION}.zip" => "pkg/pik-#{Pik::VERSION}/tools" do
+file "pkg/pik-#{Pik::VERSION}.zip" => "pkg/pik-#{Pik::VERSION}" do
chdir("pkg/pik-#{Pik::VERSION}/tools") do
- sh %{zip pik-#{Pik::VERSION}.zip pik* }
+ sh %{zip pik-#{Pik::VERSION}.zip pik_runner.exe pik.bat pik.ps1 }
mv "pik-#{Pik::VERSION}.zip", '../..'
end
end

0 comments on commit 5a53670

Please sign in to comment.