Sha256: 6f0abbf5f7606bcef1204bd98d20c8f174eb9441f6b5dadc4c96a4a55e7a441e

Contents?: true

Size: 1023 Bytes

Versions: 6

Compression:

Stored size: 1023 Bytes

Contents

# -*- encoding : utf-8 -*-
require 'erb'
require 'tilt/erb'
require 'ib/generator/rendering_helper'

class IB::Generator
  def initialize motion_template_type
    # NOTE: motion_template_type equal to Motion::Project::App.template
    #       but, this class use its value for judging build platform.
    @build_platform = motion_template_type
  end

  def absolute_template_path path
    File.expand_path(File.join(File.dirname(__FILE__), path))
  end

  def render_stub_file path, files
    template = Tilt::ERBTemplate.new(absolute_template_path(path), { :trim => '<>' })
    template.render(RenderingHelper.new(@build_platform, files))
  end

  def write files, dest
    files = IB::Parser.new(@build_platform).find_all(files)

    FileUtils.mkpath dest

    File.open("#{dest}/Stubs.h", 'w') do |f|
      f.write render_stub_file('generator/templates/Stubs.h.erb', files)
    end

    File.open("#{dest}/Stubs.m", 'w') do |f|
      f.write render_stub_file('generator/templates/Stubs.m.erb', files)
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ib-1.0.1 lib/ib/generator.rb
ib-1.0 lib/ib/generator.rb
ib-0.8.0 lib/ib/generator.rb
ib-0.7.2 lib/ib/generator.rb
ib-0.7.1 lib/ib/generator.rb
ib-0.7.0 lib/ib/generator.rb