Skip to content

Commit

Permalink
split up Rakefile into separate ./tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Scott committed Mar 26, 2011
1 parent ad8ae7b commit 3093071
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 68 deletions.
70 changes: 2 additions & 68 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,73 +1,7 @@
require 'rake/testtask'
require 'rake/clean'

Rake::TestTask.new do |t|
t.pattern = "test/*_test.rb"
end

# coffee-script tasks
require 'coffee-script'

namespace :js do
desc "compile coffee-scripts from ./src to ./public/js"
task :compile do
source = "#{File.dirname(__FILE__)}/src/"
javascripts = "#{File.dirname(__FILE__)}/public/js/"

Dir.foreach(source) do |cf|
unless cf == '.' || cf == '..'
js = CoffeeScript.compile File.read("#{source}#{cf}")
open "#{javascripts}#{cf.gsub('.coffee', '.js')}", 'w' do |f|
f.puts js
end
end
end
end
end

# Bring in Rocco tasks
require 'rocco/tasks'
Rocco::make 'docs/', ["*.rb", "models/*.rb", "Rakefile"]

desc 'Build rocco docs'
task :docs => :rocco
directory 'docs/'

desc 'Build docs and open in browser for the reading'
task :read => :docs do
sh 'open docs/rstatus.html'
end

# Make index.html a copy of rstatus.html
file 'docs/index.html' => 'docs/rstatus.html' do |f|
cp 'docs/rstatus.html', 'docs/index.html', :preserve => true
end
task :docs => 'docs/index.html'
CLEAN.include 'docs/index.html'

# Alias for docs task
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
end

# Update the pages/ directory clone
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 ."
Dir.glob "tasks/*" do |t|
load t
end
CLOBBER.include 'docs/.git'

19 changes: 19 additions & 0 deletions tasks/coffee.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# coffee-script tasks
require 'coffee-script'

namespace :js do
desc "compile coffee-scripts from ./src to ./public/js"
task :compile do
source = "#{File.dirname(__FILE__)}/src/"
javascripts = "#{File.dirname(__FILE__)}/public/js/"

Dir.foreach(source) do |cf|
unless cf == '.' || cf == '..'
js = CoffeeScript.compile File.read("#{source}#{cf}")
open "#{javascripts}#{cf.gsub('.coffee', '.js')}", 'w' do |f|
f.puts js
end
end
end
end
end
22 changes: 22 additions & 0 deletions tasks/pages.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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
end

# Update the pages/ directory clone
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'
22 changes: 22 additions & 0 deletions tasks/rocco.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Bring in Rocco tasks
require 'rocco/tasks'
Rocco::make 'docs/', ["*.rb", "models/*.rb", "Rakefile"]

desc 'Build rocco docs'
task :docs => :rocco
directory 'docs/'

desc 'Build docs and open in browser for the reading'
task :read => :docs do
sh 'open docs/rstatus.html'
end

# Make index.html a copy of rstatus.html
file 'docs/index.html' => 'docs/rstatus.html' do |f|
cp 'docs/rstatus.html', 'docs/index.html', :preserve => true
end
task :docs => 'docs/index.html'
CLEAN.include 'docs/index.html'

# Alias for docs task
task :doc => :docs
3 changes: 3 additions & 0 deletions tasks/test.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Rake::TestTask.new do |t|
t.pattern = "test/*_test.rb"
end

0 comments on commit 3093071

Please sign in to comment.