Class: DartTrails::Tilt::Engine

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/dart_trails/tilt/engine.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

#log, #logger

Constructor Details

#initialize(file, data, options = {}) ⇒ Engine

Returns a new instance of Engine.



9
10
11
12
# File 'lib/dart_trails/tilt/engine.rb', line 9

def initialize(file, data, options = {})
  @options = defaults.merge(options)
  @file    = fetch_file(file, data)
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



7
8
9
# File 'lib/dart_trails/tilt/engine.rb', line 7

def file
  @file
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/dart_trails/tilt/engine.rb', line 7

def options
  @options
end

Instance Method Details

#compileObject

This should return a string, the creation of a file is an unfortunate side effect (the dart2js compiler does not allow you to direct the compiled output to stdout). So I will need to read in the file, and unlink it when I am finished with it.

Also keep in mind that dart2js also creates .deps and .map files which will need to be cleaned up.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/dart_trails/tilt/engine.rb', line 26

def compile
  redirect = { [:out, :err] => '/dev/null' }
  success  = system( command, *cli_options,
                     output_file_option, input_file,
                     redirect )

  if success
    log(:info, "Successfully compiled #{file.path}.")
    read_and_unlink
  else
    log(:error, "Failed to compile #{file.path}.")
    ''
  end
end

#configObject



14
15
16
# File 'lib/dart_trails/tilt/engine.rb', line 14

def config
  DartTrails
end