class Templater::Actions::EmptyDirectory

Public Class Methods

new(generator, name, destination, options={}) click to toggle source

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.

# File lib/templater/actions/empty_directory.rb, line 12
def initialize(generator, name, destination, options={})
  self.generator = generator
  self.name = name
  self.destination = destination
  self.options = options
end

Public Instance Methods

exists?() click to toggle source

Checks if the destination file already exists.

Returns

Boolean

true if the file exists, false otherwise.

# File lib/templater/actions/empty_directory.rb, line 31
def exists?
  ::File.exists?(destination)
end
identical?() click to toggle source

For empty directory this is in fact alias for exists? method.

Returns

Boolean

true if it is identical, false otherwise.

# File lib/templater/actions/empty_directory.rb, line 39
def identical?
  exists?
end
invoke!() click to toggle source

Renders the template and copies it to the destination.

# File lib/templater/actions/empty_directory.rb, line 44
def invoke!
  callback(:before)
  ::FileUtils.mkdir_p(destination)
  callback(:after)
end
render() click to toggle source

Returns an empty String: there's nothing to read from.

Returns

String

The source file.

# File lib/templater/actions/empty_directory.rb, line 23
def render
  ''
end
revoke!() click to toggle source

removes the destination file

# File lib/templater/actions/empty_directory.rb, line 51
def revoke!
  ::FileUtils.rm_rf(::File.expand_path(destination))
end