Class: Codestrap::Strap::Abstract Abstract
- Inherits:
-
Object
- Object
- Codestrap::Strap::Abstract
- Includes:
- Mixin::Exceptions::Template
- Defined in:
- lib/codestrap/strap/abstract.rb
Overview
Boilerplate renderer class
Methods (aliased to #abstract) that require overriding
#pre
Pre execution
#execute
Render execution
Methods that may be overridden
#post
Direct Known Subclasses
Instance Attribute Summary collapse
-
#dst ⇒ String
Path to destination file.
-
#ignore ⇒ Array
List of files to ignore.
-
#objects ⇒ Codestrap::Object::Factory
Objects utilized in templates.
-
#overwrite ⇒ true|false
Allow overwrite of files.
-
#src ⇒ String
Path to project.
Class Method Summary collapse
-
.abstract_methods ⇒ Array
List methods aliased to Codestrap::Template::Abstract#abstract.
Instance Method Summary collapse
-
#abstract ⇒ Object
(also: #pre, #execute)
abstract
Method(s) aliased to this method are considered abstract.
-
#initialize ⇒ Abstract
constructor
Abstract class.
-
#overwrite? ⇒ true|false
Check overwrite attribute.
-
#post ⇒ Object
Post execution method.
-
#to_disk ⇒ Integer
Moves #working_dir contents to #dst.
-
#working_dir ⇒ Dir
(also: #file)
Creates and returns path to working directory.
Constructor Details
#initialize ⇒ Abstract
Abstract class. Raise error on instantiation
95 96 97 |
# File 'lib/codestrap/strap/abstract.rb', line 95 def initialize raise RendererAbstractOnly, 'Abstract Class Requires implementation' end |
Instance Attribute Details
#dst ⇒ String
Path to destination file
56 57 58 |
# File 'lib/codestrap/strap/abstract.rb', line 56 def dst @dst end |
#ignore ⇒ Array
List of files to ignore
35 36 37 |
# File 'lib/codestrap/strap/abstract.rb', line 35 def ignore @ignore end |
#objects ⇒ Codestrap::Object::Factory
Objects utilized in templates
30 31 32 |
# File 'lib/codestrap/strap/abstract.rb', line 30 def objects @objects end |
#overwrite ⇒ true|false
Allow overwrite of files
61 62 63 |
# File 'lib/codestrap/strap/abstract.rb', line 61 def overwrite @overwrite end |
#src ⇒ String
Path to project
51 52 53 |
# File 'lib/codestrap/strap/abstract.rb', line 51 def src @src end |
Class Method Details
.abstract_methods ⇒ Array
List methods aliased to Codestrap::Template::Abstract#abstract
39 40 41 42 43 44 45 46 |
# 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 |
Instance Method Details
#abstract ⇒ Object Also known as: pre, execute
Method(s) aliased to this method are considered abstract
103 104 105 |
# File 'lib/codestrap/strap/abstract.rb', line 103 def abstract raise RendererRequiredMethod, "Method #{__method__.to_s} not implemented" end |
#overwrite? ⇒ true|false
Check overwrite attribute
65 66 67 |
# File 'lib/codestrap/strap/abstract.rb', line 65 def overwrite? !!@overwrite end |
#post ⇒ Object
Post execution method
114 115 |
# File 'lib/codestrap/strap/abstract.rb', line 114 def post end |
#to_disk ⇒ Integer
Moves #working_dir contents to #dst
128 129 130 |
# File 'lib/codestrap/strap/abstract.rb', line 128 def to_disk FileUtils.mv self.working_dir.path, self.dst end |
#working_dir ⇒ Dir Also known as: file
Creates and returns path to working directory
120 121 122 |
# File 'lib/codestrap/strap/abstract.rb', line 120 def working_dir @working_dir ||= Dir.new(Dir.mktmpdir('strap')) end |