Class: AppArchetype::Template::Source
- Inherits:
-
Object
- Object
- AppArchetype::Template::Source
- Defined in:
- lib/app_archetype/template/source.rb
Overview
Source is an in memory representation of a template source
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#exist? ⇒ Boolean
Evaluates whether template source still exists.
-
#initialize(path) ⇒ Source
constructor
Creates a templatte source from path and initializes file array.
-
#load ⇒ Object
Loads template files into memory.
Constructor Details
#initialize(path) ⇒ Source
Creates a templatte source from path and initializes file array.
12 13 14 15 |
# File 'lib/app_archetype/template/source.rb', line 12 def initialize(path) @path = path @files = [] end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
5 6 7 |
# File 'lib/app_archetype/template/source.rb', line 5 def files @files end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/app_archetype/template/source.rb', line 5 def path @path end |
Instance Method Details
#exist? ⇒ Boolean
Evaluates whether template source still exists.
34 35 36 |
# File 'lib/app_archetype/template/source.rb', line 34 def exist? File.exist?(@path) end |
#load ⇒ Object
Loads template files into memory. Will raise a RuntimeError if by the time we’re loading the source no longer exists.
21 22 23 24 25 26 27 |
# File 'lib/app_archetype/template/source.rb', line 21 def load raise 'template source does not exist' unless exist? Dir.glob(File.join(@path, '**', '*')).each do |file| @files << file end end |