class Embork::Borkfile::DSL

Constants

SUPPORTED_COMPRESSORS
SUPPORTED_FRAMEWORKS

Public Class Methods

new(environment, logger) click to toggle source
# File lib/embork/borkfile.rb, line 38
def initialize(environment, logger)
  Embork.env = @environment = environment.to_sym
  @asset_paths = []
  @helpers = []
  @sprockets_postprocessors = []
  @sprockets_preprocessors = []
  @sprockets_engines = []
  @project_root = nil
  @html = []
  @backend = :static_index
  @es6_namespace = nil
  @frameworks = []
  @logger = logger
  @compressor = nil
  @es6_transform = nil
  @phrender_javascript_paths = []
  @phrender_raw_javascript = []
  @phrender_index_file = nil
end

Public Instance Methods

add_sprockets_helpers(&block) click to toggle source
# File lib/embork/borkfile.rb, line 85
def add_sprockets_helpers(&block)
  helpers.push block
end
append_asset_path(path) click to toggle source
# File lib/embork/borkfile.rb, line 81
def append_asset_path(path)
  @asset_paths.push path
end
compile_html(files) click to toggle source
# File lib/embork/borkfile.rb, line 115
def compile_html(files)
  files = [ files ] unless files.kind_of? Array
  @html.concat files
end
compress_with(compressor) click to toggle source
# File lib/embork/borkfile.rb, line 120
def compress_with(compressor)
  if compressor.class == Symbol && SUPPORTED_COMPRESSORS.include?(compressor.to_s)
    @compressor = compressor
  elsif compressor.class != String
    @compressor = compressor
  else
    @logger.critical 'Compressor "%s" is not currently supported by embork.' % compressor.to_s
    @logger.unknown ''
    exit 1
  end
end
configure(environment, &block) click to toggle source
# File lib/embork/borkfile.rb, line 105
def configure(environment, &block)
  if environment == @environment
    self.instance_exec &block
  end
end
get_binding() click to toggle source
# File lib/embork/borkfile.rb, line 111
def get_binding
  binding
end
phrender_add_javascript(code) click to toggle source
# File lib/embork/borkfile.rb, line 101
def phrender_add_javascript(code)
  @phrender_raw_javascript.push code
end
phrender_add_javascript_file(path) click to toggle source
# File lib/embork/borkfile.rb, line 97
def phrender_add_javascript_file(path)
  @phrender_javascript_paths.push path
end
register_engine(extension, klass) click to toggle source
# File lib/embork/borkfile.rb, line 77
def register_engine(extension, klass)
  @sprockets_engines.push({ :extension => extension, :klass => klass })
end
register_postprocessor(mime_type, klass) click to toggle source
# File lib/embork/borkfile.rb, line 69
def register_postprocessor(mime_type, klass)
  @sprockets_postprocessors.push({ :mime_type => mime_type, :klass => klass })
end
register_preprocessor(mime_type, klass) click to toggle source
# File lib/embork/borkfile.rb, line 73
def register_preprocessor(mime_type, klass)
  @sprockets_preprocessors.push({ :mime_type => mime_type, :klass => klass })
end
set_backend(app) click to toggle source
# File lib/embork/borkfile.rb, line 93
def set_backend(app)
  @backend = app
end
set_project_root(path) click to toggle source
# File lib/embork/borkfile.rb, line 89
def set_project_root(path)
  @project_root = path
end
transform_es6_module_names(transform_proc) click to toggle source
# File lib/embork/borkfile.rb, line 132
def transform_es6_module_names(transform_proc)
  if transform_proc.respond_to?(:call) || transform_proc.nil?
    @es6_transform = transform_proc
  else
    @logger.critical 'ES6 Module transform must respond to #call'
    exit 1
  end
end
use_framework(framework) click to toggle source
# File lib/embork/borkfile.rb, line 58
def use_framework(framework)
  framework = framework.to_s
  if SUPPORTED_FRAMEWORKS.include? framework
    @frameworks.push framework
  else
    @logger.critical 'Framework "%s" is not currently supported by embork.' % framework
    @logger.unknown ''
    exit 1
  end
end