summaryrefslogtreecommitdiff
path: root/new/lib/crys/batch_builder.rb
blob: 61fdcf226cfc72975b917d69dad1dd9fe7ee0d01 (plain)
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
module Crys
  class BatchBuilder
    def db_path
      output_dir = "#{File.dirname(File.dirname(File.dirname(__FILE__)))}/db/pages.yaml"
    end

    def output_dir
      "#{File.dirname(File.dirname(__FILE__))}/output"
    end
    
    def image_dir
      "#{File.dirname(File.dirname(File.expand_path(__FILE__)))}/assets/images"
    end

    def builder_class
      Crys::Builder
    end

    def db
      Crys::PagesDbManager.new
    end
        
    def build
      db.pages.each do |page|
        builder_class.new(
          file_path: page.file_path,
          output_dir: output_dir,
          image_dir: image_dir,
        ).build
        puts "processed: " + page.filename
      end
    end
  end
end