Module: ATD::Compilation
- Defined in:
- lib/atd/routes.rb
Overview
This module holds everything related to the compilation of routes.
Defined Under Namespace
Modules: Compiler, Precompiler
Class Method Summary collapse
-
.compile(name, contents) ⇒ Object
This method is responsible for live compilation.
-
.precompile(route, *opts) ⇒ Object
This method is responsible for precompilation.
Class Method Details
.compile(name, contents) ⇒ Object
This method is responsible for live compilation. It takes an ATD::Route as input, and returns either the filename if Route.output is a file or the Route.output string if Route.output is a string. It will also take the file and call the corresponding compilation method on it.
28 29 30 31 32 |
# File 'lib/atd/routes.rb', line 28 def self.compile(name, contents) return contents if name.nil? contents = File.read(contents) if contents.is_a? File parse(Compiler, name, contents) end |
.precompile(route, *opts) ⇒ Object
This method is responsible for precompilation. It takes an ATD::Route as input, and returns either the filename if Route.output is a file or the Route.output string if Route.output is a string. It will also take the file and call the corresponding precompilation method on it. route.output is either a full, expanded file path, a file, or a string
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/atd/routes.rb', line 38 def self.precompile(route, *opts) return nil if route.output.nil? if route.output.is_a?(File) name = route.output.is_a?(File) ? File.basename(route.output) : route.output.dup file = route.output.is_a?(File) ? route.output.dup : File.new(route.output) route.output = parse(Precompiler, name, File.read(file)) if opts[0].nil? || opts[0] return name end route.output end |