Class: Mvnizer::Project

Inherits:
Object
  • Object
show all
Includes:
Erbicole
Defined in:
lib/mvnizer/project.rb

Overview

Class representing a project coordinates. The elements of the coordinates are read-only.

Constant Summary

Constants included from Erbicole

Erbicole::TEMPLATE_PATH

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Erbicole

#get_binding, #render

Constructor Details

#initialize(group_id, artifact_id, version, type, dependencies = [], scope = nil) ⇒ Project

Returns a new instance of Project.



8
9
10
11
12
13
14
15
# File 'lib/mvnizer/project.rb', line 8

def initialize(group_id, artifact_id, version, type, dependencies = [], scope = nil)
  @group_id = group_id
  @artifact_id = artifact_id
  @version = version
  @type = type
  @dependencies = dependencies
  @scope = scope
end

Instance Attribute Details

#artifact_idObject (readonly)

Returns the value of attribute artifact_id.



6
7
8
# File 'lib/mvnizer/project.rb', line 6

def artifact_id
  @artifact_id
end

#dependenciesObject (readonly)

Returns the value of attribute dependencies.



6
7
8
# File 'lib/mvnizer/project.rb', line 6

def dependencies
  @dependencies
end

#group_idObject (readonly)

Returns the value of attribute group_id.



6
7
8
# File 'lib/mvnizer/project.rb', line 6

def group_id
  @group_id
end

#scopeObject (readonly)

Returns the value of attribute scope.



6
7
8
# File 'lib/mvnizer/project.rb', line 6

def scope
  @scope
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/mvnizer/project.rb', line 6

def type
  @type
end

#versionObject (readonly)

Returns the value of attribute version.



6
7
8
# File 'lib/mvnizer/project.rb', line 6

def version
  @version
end

Instance Method Details

#==(project) ⇒ Object

Check whether the project coordinates of this project match the ones of the other project.



23
24
25
26
27
28
# File 'lib/mvnizer/project.rb', line 23

def ==(project)
  (group_id == project.group_id \
   && artifact_id == project.artifact_id \
   && version == project.version \
   && type == project.type)
end

#add_dependency(dependency) ⇒ Object



17
18
19
# File 'lib/mvnizer/project.rb', line 17

def add_dependency(dependency)
  @dependencies << dependency
end

#package_nameObject



30
31
32
33
34
# File 'lib/mvnizer/project.rb', line 30

def package_name
  package = artifact_id
  package = "#{group_id}.#{package}" unless group_id == nil
  package.gsub(/\-/, "")
end

#to_sObject

Converts project into its coordinates representation.



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

def to_s
  "#{group_id}:#{artifact_id}:#{version}:#{type}:#{scope}"
end