class Velcro::Scaffold

Class to build out the filesystem on the host machine

Attributes

dryrun[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/velcro/scaffold.rb, line 8
def initialize(options = {})
  @dryrun = options[:dryrun] || false
end

Public Instance Methods

install(config) click to toggle source
# File lib/velcro/scaffold.rb, line 12
def install(config)
  create_directories config['dirs']
  generate_files config['files']
end

Private Instance Methods

create_directories(dirs) click to toggle source
# File lib/velcro/scaffold.rb, line 19
def create_directories(dirs)
  return if (dirs ||= []).empty?

  puts "\nCreating directories:"
  dirs.each do |dir|
    path = "#{Velcro.home}/#{dir}"
    dryrun ? puts("mkdir -p #{path}") : FileUtils.mkdir_p(path)
  end
end
generate_files(files) click to toggle source
# File lib/velcro/scaffold.rb, line 29
def generate_files(files)
  return if (files ||= []).empty?

  puts "\nTouching Files:"
  files.each do |file|
    path = "#{Velcro.home}/#{file}"
    dryrun ? puts("touch #{path}") : FileUtils.touch(path)
  end
end