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
Mon May 12 07:45:16 -0700 2008
commit  6b4b4434ae7b7f823fcf3cbc610a61a3a31e8916
tree    6968becb5af22fb46233702fbc7b4148a7ae5a64
parent  2affb90df234ba811251d85c3ca1ce0f8fdbec75
book_mdar / Rakefile
100644 99 lines (78 sloc) 2.104 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
93
94
95
96
97
98
99
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
    # man this is messy! -bj
    `grep --exclude=\*.svn\* -nr TODO book/source/`.each_line do |line|
      path, line, *note = line.split ':'
      note = note.join(':').strip
      path.gsub!(/[^\d]+/, '.').gsub!(/^\.|\.$/,'')
      
      log "#{note} (Section #{path}, Line #{line})"
    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 pain 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