Sha256: 39ca6688b292fb23104cbb74294c3f280f186b243bb42ed521fcb4bda57c6e39
Contents?: true
Size: 1.59 KB
Versions: 1
Compression:
Stored size: 1.59 KB
Contents
module Templater module Actions class EmptyDirectory < Action # Builds a new Directory # # === Parameters # generator<Object>:: The generator # name<Symbol>:: The name of this directory # destination<String>:: Full path to the destination of this directory # options<Hash{Symbol=>Symbol}:: Options, including callbacks. def initialize(generator, name, destination, options={}) self.generator = generator self.name = name self.destination = destination self.options = options end # Returns the contents of the source file as a String # # === Returns # String:: The source file. def render ::File.read(source) end # Checks if the destination file already exists. # # === Returns # Boolean:: true if the file exists, false otherwise. def exists? ::File.exists?(destination) end # For empty directory this is in fact alias for exists? method. # # === Returns # Boolean:: true if it is identical, false otherwise. def identical? exists? end # Renders the template and copies it to the destination. def invoke! @generator.send(@options[:before], self) if @options[:before] ::FileUtils.mkdir_p(destination) @generator.send(@options[:after], self) if @options[:after] end # removes the destination file def revoke! ::FileUtils.rm_rf(::File.expand_path(destination)) end end # EmptyDirectory end # Actions end # Templater
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
templater-0.2 | lib/templater/actions/empty_directory.rb |