Class: IronHammer::Projects::Dependency

Inherits:
Object
  • Object
show all
Defined in:
lib/iron_hammer/projects/dependency.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Dependency

Returns a new instance of Dependency.



9
10
11
12
13
14
# File 'lib/iron_hammer/projects/dependency.rb', line 9

def initialize params = {}
  @name = params[:name] || raise(ArgumentError.new('you must specify a name'))
  @version = params[:version]
  @extension = params[:extension] || 'dll'
  @specific = params[:specific] || false
end

Instance Attribute Details

#extensionObject

Returns the value of attribute extension.



6
7
8
# File 'lib/iron_hammer/projects/dependency.rb', line 6

def extension
  @extension
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/iron_hammer/projects/dependency.rb', line 4

def name
  @name
end

#specificObject

Returns the value of attribute specific.



7
8
9
# File 'lib/iron_hammer/projects/dependency.rb', line 7

def specific
  @specific
end

#versionObject

Returns the value of attribute version.



5
6
7
# File 'lib/iron_hammer/projects/dependency.rb', line 5

def version
  @version
end

Class Method Details

.from_project(project) ⇒ Object



36
37
38
39
40
41
# File 'lib/iron_hammer/projects/dependency.rb', line 36

def self.from_project project
  unless project.artifacts.empty?
    Dependency.new :name => project.assembly_name, :version => project.version,
      :extension => project.artifacts.first.split('.').last
  end
end

.from_reference(reference) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/iron_hammer/projects/dependency.rb', line 24

def self.from_reference reference
  includes = reference.attribute(:Include).value
  name = includes.split(', ')[0]
  match = includes.match /Version=(.+?)(,|$)/
  version = match[1] if match
  raise "Cannot parse version on include: #{includes}" unless version
  extension = get_extension reference
  specific_el = reference.elements['SpecificVersion']
  specific = (specific_el && specific_el.text.downcase == 'true') || false
  Dependency.new :name => name, :version => version, :extension => extension, :specific => specific
end

Instance Method Details

#==(other) ⇒ Object



16
17
18
# File 'lib/iron_hammer/projects/dependency.rb', line 16

def == other
  @name == other.name && @version == other.version && @extension == other.extension
end

#to_sObject



20
21
22
# File 'lib/iron_hammer/projects/dependency.rb', line 20

def to_s
  "[Dependency name=#{@name} version=#{@version} extension=#{@extension}]"
end