Sha256: cfca5a1df3337e3df1566d07c805bbc878787476dd104e15c1d4762644fc10a5
Contents?: true
Size: 1.46 KB
Versions: 9
Compression:
Stored size: 1.46 KB
Contents
# frozen_string_literal: true require "fileutils" require "rainbow" require_relative "version" class Skeleton def create_configuration puts "\nCreating configuration files" src = File.join(File.dirname(__FILE__), "files", Asker::CONFIGFILE) dst = File.join(Asker::CONFIGFILE) copyfile(src, dst) end def create_input(inputpath) puts "\nCreating example input #{Rainbow(inputpath).bright}" if File.extname(inputpath) == ".haml" dirpath = File.dirname(inputpath) filename = File.basename(inputpath) else dirpath = inputpath filename = "example-concept.haml" end create_dir dirpath source = File.join(File.dirname(__FILE__), "files", "example-concept.haml") copyfile(source, File.join(dirpath, filename)) end private def create_dir(dirpath) if Dir.exist? dirpath puts "* Exists dir! => #{Rainbow(dirpath).yellow.bright}" else begin FileUtils.mkdir_p(dirpath) puts "* Create dir => #{Rainbow(dirpath).green}" rescue warn "* Create dir ERROR => #{Rainbow(dirpath).red}" exit 1 end end end def copyfile(target, dest) if File.exist? dest puts "* Exists file! => #{Rainbow(dest).yellow.bright}" return true end begin FileUtils.cp(target, dest) puts "* Create file => #{Rainbow(dest).green}" rescue warn "* Create file ERROR => #{Rainbow(dest).red}" exit 1 end end end
Version data entries
9 entries across 9 versions & 1 rubygems