class Shanty::ProjectTemplate
Public: Allows creation of a project using a discoverer
Attributes
name[W]
options[W]
parents[W]
path[R]
plugins[W]
priority[W]
root[R]
type[W]
Public Class Methods
new(root, path)
click to toggle source
# File lib/shanty/project_template.rb, line 13 def initialize(root, path) fail 'Path to project must be a directory.' unless File.directory?(path) @root = root @path = path @name = File.basename(path) @type = StaticProject @priority = 0 @plugins = [] @parents = [] @options = [] execute_shantyfile end
Public Instance Methods
after_create(&block)
click to toggle source
# File lib/shanty/project_template.rb, line 49 def after_create(&block) if block.nil? @after_create else @after_create = block end end
execute_shantyfile()
click to toggle source
# File lib/shanty/project_template.rb, line 28 def execute_shantyfile shantyfile_path = File.join(@path, 'Shantyfile') return unless File.exist?(shantyfile_path) instance_eval(File.read(shantyfile_path), shantyfile_path) end
option(key, value)
click to toggle source
# File lib/shanty/project_template.rb, line 45 def option(key, value) @options[key] = value end
parent(parent)
click to toggle source
# File lib/shanty/project_template.rb, line 40 def parent(parent) # Will make the parent path relative to the root if (and only if) it is relative. @parents << File.expand_path(parent, @root) end
plugin(plugin)
click to toggle source
# File lib/shanty/project_template.rb, line 36 def plugin(plugin) @plugins << plugin end