Sha256: 8b0b3984448071c16954c8a7889f215450c385da4f303dd205dbcdb548408cf2
Contents?: true
Size: 1002 Bytes
Versions: 17
Compression:
Stored size: 1002 Bytes
Contents
module Sprout::Generator class DirectoryManifest < Manifest attr_reader :children def initialize super @children = [] end def create if !File.directory?(path) FileUtils.mkdir_p path say "Created directory: #{path}" else say "Skipped existing: #{path}" end create_children end def destroy success = destroy_children if success && can_remove? FileUtils.rmdir path say "Removed directory: #{path}" true else say "Skipped remove directory: #{path}" false end end private def can_remove? File.directory?(path) && Dir.empty?(path) end def create_children created = children.select { |child| child.create } return (created.size == children.size) end def destroy_children destroyed = children.reverse.select { |child| child.destroy } return (destroyed.size == children.size) end end end
Version data entries
17 entries across 17 versions & 1 rubygems