Created
April 29, 2010 17:42
-
-
Save andrehjr/383941 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
class CiJoe < Thor | |
include Thor::Actions | |
desc "instal_ci_for [project] [git_clone_url]", "install project for cijoe.\nYou must be builder directory (just for now)" | |
def install_ci_for(project, clone_url) | |
if File.exists? "cijoe-repos" | |
empty_directory "cijoe-repos/#{project}/public" | |
clone project, clone_url | |
build_links project | |
say "Configuring project.conf" | |
inject_into_file "projects.conf", "RackBaseURI /#{project}", :after => "DocumentRoot /home/builder/cijoe\n" | |
else | |
say "Ouch.. try to be in the correct path ;)", :red | |
end | |
end | |
private | |
def command(com, capture = false) | |
capture ? %x(#{com}).chomp : system(com) | |
end | |
def git(action, capture = false) | |
command("git #{action}", capture) | |
end | |
def link(source, target) | |
command "ln -sf #{source} #{target}" | |
end | |
def build_links(project) | |
say "Building links" | |
link "cijoe-repos/config.ru", "cijoe-repos/#{project}/config.ru" | |
link "cijoe/#{project}", "cijoe-repos/#{project}/public" | |
end | |
def clone | |
say "Cloning #{project}..." | |
git "clone #{clone_url} cijoe-repos/#{project}/app" | |
end | |
end | |
# If you're using hooks: | |
#ln -sf /var/www/rails-apps/cijoe-repos/build-hook app/.git/config/build-worked | |
#ln -sf /var/www/rails-apps/cijoe-repos/build-hook app/.git/config/build-failed | |
#ln -sf /var/www/rails-apps/cijoe-repos/build-hook app/.git/config/after-reset |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment