Permalink
Browse files

Rake will make me drop ruby

  • Loading branch information...
1 parent bfed96b commit 74a2ff61da31d337617ca0e03f9ae1655530f81f @txus txus committed Feb 3, 2011
Showing with 30 additions and 27 deletions.
  1. +5 −1 Gemfile.lock
  2. +24 −26 Rakefile
  3. +1 −0 markdownizer.gemspec
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- markdownizer (0.1.1)
+ markdownizer (0.1.2)
activerecord (~> 3.0.3)
coderay
rdiscount
@@ -23,8 +23,10 @@ GEM
builder (2.1.2)
coderay (0.9.7)
diff-lcs (1.1.2)
+ git (1.2.5)
i18n (0.5.0)
mustache (0.12.0)
+ pygments (0.0.1.a)
rdiscount (1.6.8)
rocco (0.5)
mustache
@@ -45,7 +47,9 @@ PLATFORMS
DEPENDENCIES
activerecord (~> 3.0.3)
coderay
+ git
markdownizer!
+ pygments
rdiscount
rocco
rspec (~> 2.4.0)
View
@@ -26,33 +26,31 @@ CLEAN.include 'docs/index.html'
task :doc => :docs
# GITHUB PAGES ===============================================================
-#
-# desc 'Update gh-pages branch'
-# task :pages => ['docs/.git', :docs] do
-# rev = `git rev-parse --short HEAD`.strip
-# Dir.chdir 'docs' do
-# sh "git add *.html"
-# sh "git commit -m 'rebuild pages from #{rev}'" do |ok,res|
-# if ok
-# verbose { puts "gh-pages updated" }
-# sh "git push -q o HEAD:gh-pages"
-# end
-# end
-# end
-# # Update the pages/ directory clone
-# end
-# file 'docs/.git' => ['docs/', '.git/refs/heads/gh-pages'] do |f|
-# sh "cd docs && git init -q && git remote add o ../.git" if !File.exist?(f.name)
-# sh "cd docs && git fetch -q o && git reset -q --hard o/gh-pages && touch ."
-# end
-# CLOBBER.include 'docs/.git'
-desc 'Update gh-pages branch'
-task :pages do
- file '.git/refs/heads/gh-pages' => 'docs/' do |f|
- `cd docs && git branch gh-pages --track origin/gh-pages`
- `git checkout gh-pages && git add . && git commit 'updated gh-pages'`
- end
+site = 'docs'
+source_branch = 'master'
+deploy_branch = 'gh-pages'
+
+desc "generate and deploy website to github user pages"
+multitask :deploy_github do
+ puts ">>> Deploying #{deploy_branch} branch to Github Pages <<<"
+ require 'git'
+ repo = Git.open('.')
+ puts "\n>>> Checking out #{deploy_branch} branch <<<\n"
+ repo.branch("#{deploy_branch}").checkout
+ (Dir["*"] - [site]).each { |f| rm_rf(f) }
+ Dir["#{site}/*"].each {|f| mv(f, ".")}
+ rm_rf(site)
+ puts "\n>>> Moving generated site files <<<\n"
+ Dir["**/*"].each {|f| repo.add(f) }
+ repo.status.deleted.each {|f, s| repo.remove(f)}
+ puts "\n>>> Commiting: Site updated at #{Time.now.utc} <<<\n"
+ message = ENV["MESSAGE"] || "Site updated at #{Time.now.utc}"
+ repo.commit(message)
+ puts "\n>>> Pushing generated site to #{deploy_branch} branch <<<\n"
+ repo.push
+ puts "\n>>> Github Pages deploy complete <<<\n"
+ repo.branch("#{source_branch}").checkout
end
# TESTS =====================================================================
View
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency 'coderay'
s.add_development_dependency 'rocco'
+ s.add_development_dependency 'git'
s.add_development_dependency 'pygments'
s.add_development_dependency 'rspec', '~> 2.4.0'

0 comments on commit 74a2ff6

Please sign in to comment.