Class: BinderCore::Compiler

Inherits:
Object
  • Object
show all
Defined in:
lib/binder_core/compiler.rb

Defined Under Namespace

Classes: Iterator

Class Method Summary collapse

Class Method Details

.compile(binder) ⇒ Object

Compile a configured Binder object data by scanning files and folders using parsers



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/binder_core/compiler.rb', line 4

def self.compile(binder)
  binder.init_console Console.new Settings.propegate
  # assemble pre, default and user config procs into single compiler config proc
  pre_config   = lambda do |config|
    config.set_console binder.console
    config.set_path File.join( binder.console.defaults( :content_folder ), binder.name.to_s )
    config.set_route []
    config.set_name binder.name
  end
  default_config    = BinderCore::Default.config
  user_config       = binder.config
  compiler_config   = lambda do |config|
    pre_config.call(config)
    default_config.call(config)
    user_config.call(config)
    config.verify_context
  end
  # use that compiler proc to trigger the parsing process
  compiled = Scanner.scan compiler_config
  binder.raw = { :data => compiled.data, :assets => compiled.assets  }
end

.configure(&block) ⇒ Object

Configure the global compiler settings, all Binder compiler process will inherit from these settings.

note: If you want to apply compiler settings on an individual Binder Definition you can do so in the BinderCore#define method using the config object



36
37
38
39
# File 'lib/binder_core/compiler.rb', line 36

def self.configure(&block)
  Default.settings
  Settings.configure &block
end

Replace asset object values in the supplied data collection with their asset url



27
28
29
# File 'lib/binder_core/compiler.rb', line 27

def self.link_assets(raw_data)
   linker raw_data
end