class Codestrap::Strap::Abstract

@abstract

Boilerplate renderer class

Methods (aliased to abstract) that require overriding

#pre

Pre execution

#execute

Render execution

Methods that may be overridden

#post

Attributes

dst[R]

Path to destination file @!attribute [r] dst @return [String]

ignore[RW]

List of files to ignore @!attribute [rw] ignore @return [Array]

objects[RW]

Objects utilized in templates @!attribute [rw] objects @return [Codestrap::Object::Factory]

overwrite[RW]

Allow overwrite of files @!attribute [rw] overwrite @return [true|false]

src[R]

Path to project @!attribute [r] src @return [String]

Public Class Methods

abstract_methods() click to toggle source

List methods aliased to Codestrap::Template::Abstract#abstract @return [Array]

# File lib/codestrap/strap/abstract.rb, line 39
def self.abstract_methods
  instance_methods.group_by { |m| instance_method(m) }.map(&:last).keep_if { |sym| sym.length > 1 }.map { |methods|
    if methods.include?('abstract'.to_sym)
      return methods.map { |method| method.to_s }.select { |method| method != 'abstract' }
    end
  }
  []
end
new() click to toggle source

Abstract class. Raise error on instantiation

# File lib/codestrap/strap/abstract.rb, line 95
def initialize
  raise RendererAbstractOnly, 'Abstract Class Requires implementation'
end

Public Instance Methods

abstract() click to toggle source

@abstract Method(s) aliased to this method are considered abstract @raise [RendererRequiredMethod]

Raise an error if a method remains aliased to this method
# File lib/codestrap/strap/abstract.rb, line 103
def abstract
  raise RendererRequiredMethod, "Method #{__method__.to_s} not implemented"
end
Also aliased as: pre, execute
dst=(dst) click to toggle source

Set destination project

@param [String] dst

Path to destination directory
# File lib/codestrap/strap/abstract.rb, line 82
def dst=(dst)
  if !overwrite? and File.exist? dst
    Codestrap::Core.logger.error(:FILEEXISTS, dst)
    exit 255
  end
  unless File.exist?(File.dirname(dst))
    Codestrap::Core.logger.error(:NOPATH, dst)
    exit 255
  end
  @dst = dst
end
execute()

Execution abstract method

Alias for: abstract
file()
Alias for: working_dir
overwrite?() click to toggle source

Check overwrite attribute @return [true|false]

# File lib/codestrap/strap/abstract.rb, line 65
def overwrite?
  !!@overwrite
end
post() click to toggle source

Post execution method

# File lib/codestrap/strap/abstract.rb, line 114
def post
end
pre()

Pre execution abstract method

Alias for: abstract
src=(src) click to toggle source

Set source project

@param [String] src

Path to source directory
# File lib/codestrap/strap/abstract.rb, line 73
def src=(src)
  raise Exception, %q[File doesn't exist] unless File.exist?(src)
  @src = src
end
to_disk() click to toggle source

Moves working_dir contents to dst

@return [Integer]

Returns 0 on success
# File lib/codestrap/strap/abstract.rb, line 128
def to_disk
  FileUtils.mv self.working_dir.path, self.dst
end
working_dir() click to toggle source

Creates and returns path to working directory

@return [Dir]

# File lib/codestrap/strap/abstract.rb, line 120
def working_dir
  @working_dir ||= Dir.new(Dir.mktmpdir('strap'))
end
Also aliased as: file