Class: Gumdrop::Builder

Inherits:
Object
  • Object
show all
Includes:
Util::SiteAccess
Defined in:
lib/gumdrop/builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util::SiteAccess

#parent, #site

Methods included from Util::Loggable

#log

Methods included from Util::Eventable

#clear_events, #event_block, #fire

Constructor Details

#initialize(opts = {}) ⇒ Builder

Returns a new instance of Builder.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gumdrop/builder.rb', line 11

def initialize(opts={})
  site.active_builder= self
  opts= opts.to_symbolized_hash
  @renderer= opts[:renderer] || Renderer.new
  @copy_files=[]
  @write_files=[]
  @checksums={}
  @options= opts
  @use_checksum= if opts[:force]
      false
    else
      site.config.file_change_test == :checksum
    end
end

Instance Attribute Details

#checksumsObject (readonly)

Returns the value of attribute checksums.



9
10
11
# File 'lib/gumdrop/builder.rb', line 9

def checksums
  @checksums
end

#optionsObject (readonly)

Returns the value of attribute options.



9
10
11
# File 'lib/gumdrop/builder.rb', line 9

def options
  @options
end

#rendererObject (readonly)

Returns the value of attribute renderer.



9
10
11
# File 'lib/gumdrop/builder.rb', line 9

def renderer
  @renderer
end

Instance Method Details

#executeObject



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
# File 'lib/gumdrop/builder.rb', line 26

def execute
  fire :start
  event_block :build do
    log.debug "[Building Site]"
    log.debug "(Rendering)"
    event_block :render do
      if @options[:assets]
        _build_assets @options[:assets], true
      else
        _build_assets site.contents.keys.sort
      end
    end
    # All files rendered without exception, write them to disc
    log.info "(Writing to #{ site.output_path })"
    event_block :write do
      @write_files.each {|files| _write files }
      @copy_files.each  {|files| _copy files }
    end
  end
  fire :end
rescue => ex
  log.error _exception_message ex
  $stderr.puts _exception_message ex, true
  exit 1 unless site.options[:resume]
end