class Viperaptor::CLI::Template

Public Instance Methods

create(template_name) click to toggle source
# File lib/viperaptor/cli/template/template_create_command.rb, line 8
def create(template_name)
  summary = ask('The brief description of your new template:')
  author = ask('Who is the author of this template:')
  license = ask('What license will be used (e.g. MIT):')

  has_dependencies = yes?('Will your template contain any third-party dependencies (available via Cocoapods or Carthage)? (yes/no)')
  if has_dependencies
    dependencies = ask_loop('Enter the name of your dependency (empty string to stop):')
  end

  properties = {
      TEMPLATE_NAME_KEY => template_name,
      TEMPLATE_SUMMARY_KEY => summary,
      TEMPLATE_AUTHOR_KEY => author,
      TEMPLATE_LICENSE_KEY => license
  }

  if dependencies and !dependencies.empty?
    properties[TEMPLATE_DEPENDENCIES_KEY] = dependencies
  end

  PrintTable.print_values(
      values: properties,
      title: "Summary for template create"
  )

  template_creator = Viperaptor::TemplateCreator.new
  template_creator.create_template(properties)
  puts("The template #{template_name} is successfully generated! Now add some file templates into it.".green)
end
install() click to toggle source
# File lib/viperaptor/cli/template/template_install_command.rb, line 5
def install
  does_rambafile_exist = Rambafile.exist

  unless does_rambafile_exist
    puts('Rambafile not found! Run `viperaptor setup` in the working directory instead!'.red)
    return
  end

  catalog_downloader = Viperaptor::CatalogDownloader.new
  installer_factory = Viperaptor::TemplateInstallerFactory.new
  template_processor = Viperaptor::TemplateProcessor.new(catalog_downloader, installer_factory)

  rambafile = Rambafile.rambafile
  template_processor.install_templates(rambafile)
end
list() click to toggle source
# File lib/viperaptor/cli/template/template_list_command.rb, line 9
def list
  templates = TemplateHelper.global_templates
  templates.each do |template_name|
    puts(template_name)
  end
end