Class: Shanty::Project

Inherits:
Object
  • Object
show all
Includes:
Mixins::ActsAsLinkGraphNode, Mixins::Callbacks
Defined in:
lib/shanty/project.rb

Overview

Public: Represents a project in the current repository.

Direct Known Subclasses

RubygemProject, StaticProject

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mixins::Callbacks

#callbacks, included, #publish, #subscribe

Methods included from Mixins::ActsAsLinkGraphNode

#add_child, #add_parent, #all_children, #all_parents, #children, included, #parents

Constructor Details

#initialize(project_template) ⇒ Project

Public: Initialise the Project instance.

project_template - An instance of ProjectTemplate from which to

instantiate this project.


18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/shanty/project.rb', line 18

def initialize(project_template)
  @name = project_template.name
  @path = project_template.path
  @options = project_template.options
  @parents_by_path = project_template.parents
  @changed = false

  project_template.plugins.each do |plugin|
    plugin.add_to_project(self)
  end

  instance_eval(&project_template.after_create) unless project_template.after_create.nil?
end

Instance Attribute Details

#changedObject Also known as: changed?

Returns the value of attribute changed.



10
11
12
# File 'lib/shanty/project.rb', line 10

def changed
  @changed
end

#nameObject

Returns the value of attribute name.



10
11
12
# File 'lib/shanty/project.rb', line 10

def name
  @name
end

#optionsObject

Returns the value of attribute options.



10
11
12
# File 'lib/shanty/project.rb', line 10

def options
  @options
end

#parents_by_pathObject

Returns the value of attribute parents_by_path.



10
11
12
# File 'lib/shanty/project.rb', line 10

def parents_by_path
  @parents_by_path
end

#pathObject

Returns the value of attribute path.



10
11
12
# File 'lib/shanty/project.rb', line 10

def path
  @path
end

Instance Method Details

#artifact_pathObject

Public: The absolute path to the artifact that would be created by this project when built, if any. This is expected to be overriden in subclasses.

Returns a String representing the absolute path to the artifact.



45
46
47
# File 'lib/shanty/project.rb', line 45

def artifact_path
  nil
end

#externals_by_nameObject

Public: A list of the external dependencies this project has by name and version. This is used in dependency tree generation.

Returns an Array of Strings representing external dependencies by name and version.



37
38
39
# File 'lib/shanty/project.rb', line 37

def externals_by_name
  []
end

#inspectObject

Public: Overriden String conversion method to return a more detailed representation of this instance that doesn’t include the cyclic parent/children attributes as defined by the ActsAsLinkGraphNode mixin.

Returns more detailed String representation of this instance.



63
64
65
66
67
68
69
# File 'lib/shanty/project.rb', line 63

def inspect
  {
    name: name,
    path: path,
    options: options
  }.inspect
end

#to_sObject

Public: Overriden String conversion method to return a simplified representation of this instance that doesn’t include the cyclic parent/children attributes as defined by the ActsAsLinkGraphNode mixin.

Returns a simple String representation of this instance.



54
55
56
# File 'lib/shanty/project.rb', line 54

def to_s
  "Name: #{name}, Type: #{self.class}"
end