Class: Codex::Rake::CodexTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Codex::Rake::CodexTask
- Defined in:
- lib/codex/rake/codextask.rb
Instance Attribute Summary collapse
-
#content_dir ⇒ Object
Directory of the source content.
-
#metadata ⇒ Object
Metadata filename.
-
#name ⇒ Object
Returns the value of attribute name.
-
#output_dir ⇒ Object
Directory to output the built files into.
Instance Method Summary collapse
- #content_path ⇒ Object
- #contents ⇒ Object
- #define ⇒ Object
-
#initialize(name = :codex) {|_self| ... } ⇒ CodexTask
constructor
A new instance of CodexTask.
- #output_path ⇒ Object
Constructor Details
#initialize(name = :codex) {|_self| ... } ⇒ CodexTask
Returns a new instance of CodexTask.
19 20 21 22 23 24 25 26 |
# File 'lib/codex/rake/codextask.rb', line 19 def initialize(name = :codex) @name = name @content_dir = 'content' @output_dir = 'html' @metadata = "config/metadata.yml" yield self if block_given? define end |
Instance Attribute Details
#content_dir ⇒ Object
Directory of the source content. Defaults to ‘content’
11 12 13 |
# File 'lib/codex/rake/codextask.rb', line 11 def content_dir @content_dir end |
#metadata ⇒ Object
Metadata filename. Defaults to config/metadata.yml
17 18 19 |
# File 'lib/codex/rake/codextask.rb', line 17 def @metadata end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/codex/rake/codextask.rb', line 8 def name @name end |
#output_dir ⇒ Object
Directory to output the built files into. Defaults to ‘html’
14 15 16 |
# File 'lib/codex/rake/codextask.rb', line 14 def output_dir @output_dir end |
Instance Method Details
#content_path ⇒ Object
28 29 30 |
# File 'lib/codex/rake/codextask.rb', line 28 def content_path File.join(*[Codex.root, content_dir].compact) end |
#contents ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/codex/rake/codextask.rb', line 36 def contents Dir.chdir(content_path) do filelist = FileList["*"] filelist.resolve filelist end end |
#define ⇒ Object
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 |
# File 'lib/codex/rake/codextask.rb', line 44 def define @output = [] pressie = Codex::Pressie.new() contents.each do |file| input_file = File.join(content_dir, file) output_file = File.join(output_dir, file.ext('.html')) @output << output_file desc "Build #{output_file} from #{input_file}" file output_file => [output_dir, input_file] do pressie.process(input_file, output_file) end end task :default => name desc "Build all the content" task name => @output # FIXME: clean up all this all_html = File.join(output_dir, "all.html") task :remove_tmp do FileUtils.rm_rf("tmp") end desc "Build all based on the contents of content/table_of_contents.textile" task :all => [ 'tmp', output_dir, all_html, :remove_tmp ] desc "Remove all generated output and temporary files" task :clean => "remove_tmp" do FileUtils.rm_rf output_path end task all_html => 'tmp/all.textile' do pressie.process('tmp/all.textile', all_html) end task 'tmp/all.textile' => @output do sh "ruby bin/build_all.rb #{} #{content_dir}/table_of_contents.textile tmp/all.textile" end directory "tmp" directory output_dir end |