Created
September 10, 2008 23:12
-
-
Save djwonk/10101 to your computer and use it in GitHub Desktop.
update_merb_and_dm
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
class Updater | |
@base = "/Users/david/dev" | |
@extlib = @base + "/contrib/extlib" | |
@dm = @base + "/contrib/dm" | |
@merb = @base + "/sources/merb" | |
def self.start(force_install = false) | |
@force_install = force_install | |
update "extlib", "#{@extlib}" | |
update "do", "#{@dm}/do" | |
update "dm-core", "#{@dm}/dm-core" | |
update "dm-more", "#{@dm}/dm-more" | |
update "merb-core", "#{@merb}/merb-core" | |
update "merb-more", "#{@merb}/merb-more" | |
update "merb-plugins", "#{@merb}/merb-plugins" | |
puts "\nDone." | |
end | |
private | |
def self.update(name, directory) | |
puts "\n===== Updating #{name} =====" | |
Dir.chdir(directory) | |
result = `git pull` | |
if result =~ /fatal/i | |
raise "Bad. Things. Happening." | |
elsif @force_install | |
puts "Installing even though already up-to-date" | |
install | |
elsif result =~ /up-to-date/i | |
puts "Skipping install: already up-to-date" | |
else | |
ask_and_install | |
end | |
end | |
def self.ask_and_install | |
loop do | |
puts "[i] install | [l] show log and install | [s] skip install" | |
case readline | |
when /^I/i | |
install | |
break | |
when /^L/i | |
git_log | |
install | |
break | |
when /^S/i | |
break | |
else | |
puts "Not recognized, please try again." | |
end | |
end | |
end | |
def self.git_log | |
run "git log" | |
end | |
def self.install | |
run "sudo rake install" | |
end | |
def self.run(command) | |
unless system(command) | |
puts "'#{command}' failed." | |
end | |
end | |
end | |
Updater.start | |
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
# !/bin/bash | |
ruby /usr/local/bin/update.rb | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment