Class: Charsi::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/charsi/builder.rb

Overview

Builds the application and handles file watching for changes.

Instance Method Summary collapse

Constructor Details

#initializeBuilder

Returns a new instance of Builder.



4
5
6
7
# File 'lib/charsi/builder.rb', line 4

def initialize
  @app    = Charsi::App.new
  @config = Configuration.new
end

Instance Method Details

#buildObject



9
10
11
12
13
14
15
16
17
# File 'lib/charsi/builder.rb', line 9

def build
  start_time = Time.now

  Charsi::FileManagement.reset_output_dir(@config.path(:output_dir))
  Charsi::Asset.new(@config).build
  Charsi::Template.new(@app, @config).build

  puts "[charsi] Build completed in #{Time.now - start_time} seconds."
end

#watchObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/charsi/builder.rb', line 19

def watch
  Filewatcher.new(watch_paths).watch do |changes|
    changes.each do |filename, event|
      puts "[charsi][#{event}] #{filename}"
    end
    
    build
  end
rescue Interrupt
  puts "\n[charsi] Done watching."
end