Skip to content

Commit

Permalink
Split up the book tasks.
Browse files Browse the repository at this point in the history
Also extract the BookBuilder::Book creation and output_dir creation into their own tasks.
  • Loading branch information
geoffgarside committed Sep 7, 2008
1 parent 76ca033 commit 87e26b4
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 65 deletions.
20 changes: 18 additions & 2 deletions Rakefile
@@ -1,9 +1,25 @@
# Required to do just about anything with the book.
require 'book_builder/book_builder'

# The book tasks are loaded first, then any
# additional tasks are loaded. This should
# allow you to override the book tasks with
# your own.
Dir["tasks/book/*.rake"].each { |ext| load ext }
Dir["tasks/*.rake"].each { |ext| load ext }

def log(msg = '')
puts msg
end

def deploy
`scp -r book/output/* ninja@4ninjas.org:public_html/merb/`
def announce(msg)
log msg
yield
log 'Done!'
end

def invoke_task(*names)
names.each do |name|
Rake::Task[name].invoke
end
end
63 changes: 0 additions & 63 deletions tasks/book.rake

This file was deleted.

18 changes: 18 additions & 0 deletions tasks/book/misc.rake
@@ -0,0 +1,18 @@
require 'book_builder/book_builder'

namespace :book do
desc "Outstanding TODO's"
task :todo do
FileList["book/source/**/*.markdown"].egrep(/TODO/) do |fn, count, line|
fn.gsub!(/\D+/, '.').gsub!(/^\.|\.$/,'')
log "#{line.chomp} (Section #{fn}, Line #{count})"
end
end

desc "prepare a structure for publishing to"
task :prepare => ['book:setup:book'] do
announce('Preparing a publishing structure...') do
@book.prepare!
end
end
end
11 changes: 11 additions & 0 deletions tasks/book/output.rake
@@ -0,0 +1,11 @@
namespace :book do
namespace :output do
task :html => ['book:setup:output_dir', 'book:setup:book'] do
@book.html!
end

task :plain => ['book:setup:output_dir', 'book:setup:book'] do
@book.plain_text!
end
end
end
28 changes: 28 additions & 0 deletions tasks/book/publish.rake
@@ -0,0 +1,28 @@
namespace :book do
desc "compile files from the current directory and publish to all available formats"
task :publish => ['publish:html', 'publish:text']

desc "deploy the currently built version to the site"
task :deploy => 'publish:deploy'

namespace :publish do
desc "compile files from the current directory into html"
task :html do
announce('Publishing HTML...') do
invoke_task 'book:output:html'
end
end

desc "compile files from the current directory into plain text"
task :text do
announce('Publishing Plain Text...') do
invoke_task 'book:output:plain'
end
end

desc "publish all versions and then deploy"
task :deploy => ['book:output:html', 'book:output:plain'] do
`scp -r book/output/* ninja@4ninjas.org:public_html/merb/`
end
end
end
12 changes: 12 additions & 0 deletions tasks/book/setup.rake
@@ -0,0 +1,12 @@
namespace :book do
namespace :setup do
task :output_dir do
output_folder = './book/output/'
Dir.mkdir(output_folder) unless File.directory?(output_folder)
end

task :book do
@book = BookBuilder::Book.new('merb_book','./book/', :markdown)
end
end
end

0 comments on commit 87e26b4

Please sign in to comment.