Class: StackMaster::TemplateCompilers::SparkleFormation
- Inherits:
-
Object
- Object
- StackMaster::TemplateCompilers::SparkleFormation
- Defined in:
- lib/stack_master/template_compilers/sparkle_formation.rb
Constant Summary collapse
- CompileTime =
StackMaster::SparkleFormation::CompileTime
Class Method Summary collapse
- .compile(template_file_path, compile_time_parameters, compiler_options = {}) ⇒ Object
- .compile_sparkle_template(template_file_path, compiler_options) ⇒ Object
- .compile_template_with_sparkle_path(template_path, sparkle_path) ⇒ Object
- .create_state(definitions, compile_time_parameters) ⇒ Object
- .require_dependencies ⇒ Object
- .validate_definitions(definitions) ⇒ Object
- .validate_parameters(definitions, compile_time_parameters) ⇒ Object
Class Method Details
.compile(template_file_path, compile_time_parameters, compiler_options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/stack_master/template_compilers/sparkle_formation.rb', line 15 def self.compile(template_file_path, compile_time_parameters, = {}) sparkle_template = compile_sparkle_template(template_file_path, ) definitions = sparkle_template.parameters validate_definitions(definitions) validate_parameters(definitions, compile_time_parameters) sparkle_template.compile_time_parameter_setter do sparkle_template.compile_state = create_state(definitions, compile_time_parameters) end JSON.pretty_generate(sparkle_template) end |
.compile_sparkle_template(template_file_path, compiler_options) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/stack_master/template_compilers/sparkle_formation.rb', line 30 def self.compile_sparkle_template(template_file_path, ) sparkle_path = ['sparkle_path'] ? File.(['sparkle_path']) : File.dirname(template_file_path) collection = ::SparkleFormation::SparkleCollection.new root_pack = ::SparkleFormation::Sparkle.new( :root => sparkle_path, ) collection.set_root(root_pack) if ['sparkle_packs'] ['sparkle_packs'].each do |pack_name| require pack_name pack = ::SparkleFormation::SparklePack.new(:name => pack_name) collection.add_sparkle(pack) end end sparkle_template = compile_template_with_sparkle_path(template_file_path, sparkle_path) sparkle_template.sparkle.apply(collection) sparkle_template end |
.compile_template_with_sparkle_path(template_path, sparkle_path) ⇒ Object
52 53 54 55 |
# File 'lib/stack_master/template_compilers/sparkle_formation.rb', line 52 def self.compile_template_with_sparkle_path(template_path, sparkle_path) ::SparkleFormation.sparkle_path = sparkle_path ::SparkleFormation.compile(template_path, :sparkle) end |
.create_state(definitions, compile_time_parameters) ⇒ Object
65 66 67 |
# File 'lib/stack_master/template_compilers/sparkle_formation.rb', line 65 def self.create_state(definitions, compile_time_parameters) CompileTime::StateBuilder.new(definitions, compile_time_parameters).build end |
.require_dependencies ⇒ Object
10 11 12 13 |
# File 'lib/stack_master/template_compilers/sparkle_formation.rb', line 10 def self.require_dependencies require 'sparkle_formation' require 'stack_master/sparkle_formation/template_file' end |
.validate_definitions(definitions) ⇒ Object
57 58 59 |
# File 'lib/stack_master/template_compilers/sparkle_formation.rb', line 57 def self.validate_definitions(definitions) CompileTime::DefinitionsValidator.new(definitions).validate end |
.validate_parameters(definitions, compile_time_parameters) ⇒ Object
61 62 63 |
# File 'lib/stack_master/template_compilers/sparkle_formation.rb', line 61 def self.validate_parameters(definitions, compile_time_parameters) CompileTime::ParametersValidator.new(definitions, compile_time_parameters).validate end |