class Gyro::Generator::Liquid

Generates arbitrary output from the input datamodel, using a Liquid template provided by the user

Attributes

output_dir[RW]
params[RW]

Public Class Methods

new(template_dir, output_dir, params) click to toggle source

PUBLIC METHODS #######################################################

# File lib/gyro/generator/liquid/liquid.rb, line 24
def initialize(template_dir, output_dir, params)
  Gyro::Log.title('Generating Model')

  @params = params
  @output_dir = Pathname.new(output_dir)

  # Define Template path for Liquid file system to use Include Tag
  ::Liquid::Template.file_system = ::Liquid::LocalFileSystem.new(template_dir)

  @entity_template = load_template(template_dir + 'entity.liquid', false)
  @entity_filename_template = load_template(template_dir + 'entity_filename.liquid', true)
  @enum_template = load_template(template_dir + 'enum.liquid', false)
  enum_fn_tpl = template_dir + 'enum_filename.liquid'
  enum_fn_tpl = template_dir + 'filename.liquid' unless enum_fn_tpl.exist?
  @enum_filename_template = load_template(enum_fn_tpl, true)
end

Public Instance Methods

generate(xcdatamodel) click to toggle source
# File lib/gyro/generator/liquid/liquid.rb, line 41
def generate(xcdatamodel)
  generate_entities(xcdatamodel)
  Gyro::Log.success('Model objects are generated !')
end