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
Path to destination file @!attribute [r] dst @return [String]
List of files to ignore @!attribute [rw] ignore @return [Array]
Objects utilized in templates @!attribute [rw] objects @return [Codestrap::Object::Factory]
Allow overwrite of files @!attribute [rw] overwrite @return [true|false]
Path to project @!attribute [r] src @return [String]
Public Class Methods
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
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 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
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
Check overwrite attribute @return [true|false]
# File lib/codestrap/strap/abstract.rb, line 65 def overwrite? !!@overwrite end
Post execution method
# File lib/codestrap/strap/abstract.rb, line 114 def post end
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
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
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