module AppArchetype::Generators

Generators create empty projects for the app_archetype gem

Constants

DEFAULT_VARS

Default variables provided to new projects

TEMPLATE_MANIFEST

Function that creates a named, empty manifest for new templates

TEMPLATE_README

Function that creates a readme for a new blank template

Public Class Methods

render_empty_template(name, path) click to toggle source

Render empty template renders a manifest and template folder at the given path.

The name param will be rendered into the template manifest at runtime

@param [String] name @param [String] path

# File lib/app_archetype/generators.rb, line 62
def render_empty_template(name, path)
  template_path = File.join(path, name)
  manifest_path = File.join(path, 'manifest.json')
  readme_path = File.join(path, 'README.md')

  make_template_dir(template_path)
  render_manifest(manifest_path, name)
  render_readme(readme_path, name)
end

Private Class Methods

make_template_dir(path) click to toggle source
# File lib/app_archetype/generators.rb, line 74
def make_template_dir(path)
  FileUtils.mkdir_p(path)
end
render_manifest(path, name) click to toggle source
# File lib/app_archetype/generators.rb, line 78
def render_manifest(path, name)
  File.open(path, 'w') do |f|
    f.write(
      TEMPLATE_MANIFEST.call(name).to_json
    )
  end
end
render_readme(path, name) click to toggle source
# File lib/app_archetype/generators.rb, line 86
def render_readme(path, name)
  File.open(path, 'w') do |f|
    f.write(
      TEMPLATE_README.call(name)
    )
  end
end