class RSwift::TemplateManager

Attributes

name[R]

Public Class Methods

source_root() click to toggle source
# File lib/rswift/template_manager.rb, line 8
def self.source_root
  File.dirname(__FILE__)
end

Public Instance Methods

create_files_for_template(name, template) click to toggle source
# File lib/rswift/template_manager.rb, line 12
def create_files_for_template(name, template)
  @name = name
  current_directory_path = File.dirname(__FILE__)
  template_directory = File.join(current_directory_path, 'templates/app', template.to_s)
  Dir.glob("#{template_directory}/**/*.erb", File::FNM_DOTMATCH).each do |template_path|
    relative_template_path = template_path.sub(current_directory_path + '/', '')

    relative_erb_file_path = template_path.sub(template_directory, '')
    file_name = File.basename(relative_erb_file_path, '.erb')
    relative_directory_path = File.dirname(relative_erb_file_path)
    relative_file_path = File.join(name, relative_directory_path, file_name)

    template relative_template_path, relative_file_path
  end
end