Sha256: ae35f4669a2b146f0f6b12fd678e07ddb2f1d2b19a87cb439f166f655a088524
Contents?: true
Size: 1.87 KB
Versions: 4
Compression:
Stored size: 1.87 KB
Contents
# External require 'fileutils' require 'rubygems/user_interaction' # Internal require 'gem_newgem/newgem/configuration' module GemNewgem class Newgem class Template # Class methods class << self include Gem::UserInteraction def get_config @config ||= GemNewgem::Newgem::Configuration.instance end def ensure_default create_base_dir unless Dir.exists?(get_config.templates_base_dir) create_default_template unless Dir.exists?(default_template_path) end def create_base_dir FileUtils.mkdir_p @config.templates_base_dir end def default_template_path File.expand_path(File.join(get_config.templates_base_dir, get_config.default_template)) end def create_default_template alert "Default template doesn't seem to exists yet. Will git clone it now..." command = "git clone -v #{get_config.default_template_git_url} #{default_template_path}" say command result = system(command) alert_error "git not installed or not found in path." if result.nil? alert_error "Cloning default template failed." if $?.exitstatus != 0 terminate_interaction(1) if $?.exitstatus != 0 validate_exists(default_template_path) end def validate_exists(path) unless Dir.exists?(path) alert_error "Templates directory #{path} doesn't exist!" terminate_interaction(1) end end end end class Template # Instance methods attr_reader :name def initialize(name) @name = name @config = Template.get_config end def path File.expand_path(File.join(@config.templates_base_dir, name)) end def validate Template.validate_exists(path) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems