require_relative '../code_generator/code_generator' require_relative 'code_model' require 'liquid' module KCommercial module Resources class OCGenerator class << self def templates_root Pathname(__FILE__).parent.join('templates') end end def initialize(file_model, name, keys, resources_status, options) @file_model = file_model @name = name @keys = keys @super_module_name = options.delete(:super) { :KCSemanticResources } @resources_status = resources_status end def header_contents ERB.new(File.read(@file_model.header)).result(code_model.get_binding) end def imp_contents ERB.new(File.read(@file_model.implementation)).result(code_model.get_binding) end def code_model @code_model ||= begin model = CodeModel.new model.keys = @keys model.super_module_name = @super_module_name model.component_name = @name model.resources_status = @resources_status model end end private def render_map { "oc_class_name" => code_model.oc_class_name, "bundle_name" => code_model.bundle_name, "component_name" => code_model.component_name, "keys" => @keys } end end end end