Class: Tay::Builder
- Inherits:
-
Object
- Object
- Tay::Builder
- Defined in:
- lib/tay/builder.rb
Overview
Takes a Tay::Specification and builds it. It compiles the assets, writes the manifest, and copies everything to the output path.
Instance Attribute Summary collapse
-
#debug ⇒ Object
Set to true for debug output.
-
#spec ⇒ Object
readonly
Pointer to the relevant Tay::Specification.
Class Method Summary collapse
-
.try_to_load_mustache_trimmer ⇒ Object
This is sub-optimal but the mustache/js gem does not require its tilt template automatically.
Instance Method Summary collapse
-
#build! ⇒ Object
Do the building.
-
#initialize(specification, base_dir, output_dir = nil) ⇒ Builder
constructor
Create a new builder.
Constructor Details
#initialize(specification, base_dir, output_dir = nil) ⇒ Builder
Create a new builder. You must pass the specification, full path to the source directory and an optional output directory which defaults to base_dir + ‘/build’
21 22 23 24 25 26 |
# File 'lib/tay/builder.rb', line 21 def initialize(specification, base_dir, output_dir = nil) @spec = specification @base_dir = Pathname.new(base_dir) @output_dir = output_dir ? Pathname.new(output_dir) : @base_dir.join('build') create_sprockets_environment end |
Instance Attribute Details
#debug ⇒ Object
Set to true for debug output
15 16 17 |
# File 'lib/tay/builder.rb', line 15 def debug @debug end |
#spec ⇒ Object (readonly)
Pointer to the relevant Tay::Specification
11 12 13 |
# File 'lib/tay/builder.rb', line 11 def spec @spec end |
Class Method Details
.try_to_load_mustache_trimmer ⇒ Object
This is sub-optimal but the mustache/js gem does not require its tilt template automatically.
42 43 44 45 46 47 48 |
# File 'lib/tay/builder.rb', line 42 def self.try_to_load_mustache_trimmer begin require 'tilt/mustache_js_template' Sprockets.register_engine '.mustache', Tilt::MustacheJsTemplate rescue LoadError end end |
Instance Method Details
#build! ⇒ Object
Do the building. This simply delegates to the private methods in this class.
31 32 33 34 35 36 37 |
# File 'lib/tay/builder.rb', line 31 def build! create_output_directory spec.source_directories.each { |d| simple_compile_directory(d) } compile_files(spec.all_javascript_paths) compile_files(spec.all_stylesheet_paths) write_manifest end |