public
Description: Life On The Edge With Merb, DataMapper & RSpec
Homepage: http://blog.new-bamboo.co.uk
Clone URL: git://github.com/deimos1986/book_mdar.git
Search Repo:
book_mdar / Rakefile
100644 92 lines (75 sloc) 1.999 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
require 'book_builder/book_builder'
 
 
 
namespace :book do
  desc "compile files from the current directory and publish to all available formats"
  task :publish do
    html()
    plain_text()
    log 'Done!'
  end
  
  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
 
  namespace :publish do
    desc "compile files from the current directory into html"
    task :html do
      log 'Publishing HTML...'
      html
      log 'Done!'
    end
  
    desc "compile files from the current directory into plain text"
    task :text do
      log 'Publishing plain text...'
      
      plain_text
      log 'Done!'
    end
    
    desc "publish all versions and then deploy"
    task :deploy => [:html,:text] do
      deploy
    end
  end
  
  desc "prepare a structure for publishing to"
  task :prepare do
    log 'Preparing a publishing structure...'
    book = default_book
    book.prepare!
    log 'Done!'
  end
  
  desc "deploy the currently built version to the site"
  task :deploy do
    deploy
  end
end
 
# create an html output
def html
  create_output_folder
  book = default_book
  log 'Processing HTML format...'
  book.html!
end
 
# create a plain text output
def plain_text
  create_output_folder
  book = default_book
  log 'Processing Plain Text format...'
  book.plain_text!
end
 
# move the output to the server
def deploy
  `scp -r book/output/* ninja@4ninjas.org:public_html/merb/`
end
 
 
# this is here as a helper so we can send messages somewhere other than stdout at a later date if we want to.
def log(msg='')
  puts msg
end
 
def default_book
  BookBuilder::Book.new('merb_book','./book/', :markdown)
end
 
# create the output folder if it doesn't exist yet
def create_output_folder
  output_folder = './book/output/'
  Dir.mkdir(output_folder) unless File.directory?(output_folder)
end