Class: DiceBag::AvailableTemplates
- Inherits:
-
Object
- Object
- DiceBag::AvailableTemplates
- Defined in:
- lib/dice_bag/available_templates.rb
Direct Known Subclasses
Class Method Summary collapse
- .all ⇒ Object
- .inherited(base) ⇒ Object
- .template_checkers ⇒ Object
- .template_filename_for(filename) ⇒ Object
Instance Method Summary collapse
-
#templates_location ⇒ Object
By default the final location for any template will be the config directory.
Class Method Details
.all ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/dice_bag/available_templates.rb', line 27 def all #all the classes than inherit from us in the ruby runtime available_templates = [] template_checkers.each do |template_checker| checker = template_checker.new location = checker.templates_location checker.templates.each do |template| available_templates.push( DefaultTemplateFile.new(template, location) ) end end available_templates end |
.inherited(base) ⇒ Object
23 24 25 |
# File 'lib/dice_bag/available_templates.rb', line 23 def inherited(base) template_checkers << base end |
.template_checkers ⇒ Object
19 20 21 |
# File 'lib/dice_bag/available_templates.rb', line 19 def template_checkers @template_checkers ||= [] end |
.template_filename_for(filename) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/dice_bag/available_templates.rb', line 41 def template_filename_for(filename) self.all.each do |template| if template.filename.include? filename return template.file end end end |
Instance Method Details
#templates_location ⇒ Object
By default the final location for any template will be the config directory. If any template ‘plugin’ wants to overwrite the directory where its template will be written it needs to overwrite this method and return a string with the new location as relative path inside the project.
13 14 15 |
# File 'lib/dice_bag/available_templates.rb', line 13 def templates_location 'config' end |