Class: Shanty::ProjectTemplate
- Inherits:
-
Object
- Object
- Shanty::ProjectTemplate
- Extended by:
- Mixins::AttrCombinedAccessor
- Defined in:
- lib/shanty/project_template.rb
Overview
Public: Allows creation of a project using a discoverer
Instance Attribute Summary collapse
-
#name ⇒ Object
writeonly
Sets the attribute name.
-
#options ⇒ Object
writeonly
Sets the attribute options.
-
#parents ⇒ Object
writeonly
Sets the attribute parents.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#plugins ⇒ Object
writeonly
Sets the attribute plugins.
-
#priority ⇒ Object
writeonly
Sets the attribute priority.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#type ⇒ Object
writeonly
Sets the attribute type.
Instance Method Summary collapse
- #after_create(&block) ⇒ Object
- #execute_shantyfile ⇒ Object
-
#initialize(root, path) ⇒ ProjectTemplate
constructor
A new instance of ProjectTemplate.
- #option(key, value) ⇒ Object
- #parent(parent) ⇒ Object
- #plugin(plugin) ⇒ Object
Methods included from Mixins::AttrCombinedAccessor
Constructor Details
#initialize(root, path) ⇒ ProjectTemplate
Returns a new instance of ProjectTemplate.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# 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 |
Instance Attribute Details
#name=(value) ⇒ Object (writeonly)
Sets the attribute name
10 11 12 |
# File 'lib/shanty/project_template.rb', line 10 def name=(value) @name = value end |
#options=(value) ⇒ Object (writeonly)
Sets the attribute options
10 11 12 |
# File 'lib/shanty/project_template.rb', line 10 def (value) @options = value end |
#parents=(value) ⇒ Object (writeonly)
Sets the attribute parents
10 11 12 |
# File 'lib/shanty/project_template.rb', line 10 def parents=(value) @parents = value end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
11 12 13 |
# File 'lib/shanty/project_template.rb', line 11 def path @path end |
#plugins=(value) ⇒ Object (writeonly)
Sets the attribute plugins
10 11 12 |
# File 'lib/shanty/project_template.rb', line 10 def plugins=(value) @plugins = value end |
#priority=(value) ⇒ Object (writeonly)
Sets the attribute priority
10 11 12 |
# File 'lib/shanty/project_template.rb', line 10 def priority=(value) @priority = value end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
11 12 13 |
# File 'lib/shanty/project_template.rb', line 11 def root @root end |
#type=(value) ⇒ Object (writeonly)
Sets the attribute type
10 11 12 |
# File 'lib/shanty/project_template.rb', line 10 def type=(value) @type = value end |
Instance Method Details
#after_create(&block) ⇒ Object
49 50 51 52 53 54 55 |
# 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 ⇒ Object
28 29 30 31 32 33 34 |
# 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) ⇒ Object
45 46 47 |
# File 'lib/shanty/project_template.rb', line 45 def option(key, value) @options[key] = value end |
#parent(parent) ⇒ Object
40 41 42 43 |
# 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.(parent, @root) end |
#plugin(plugin) ⇒ Object
36 37 38 |
# File 'lib/shanty/project_template.rb', line 36 def plugin(plugin) @plugins << plugin end |