Class: LockJar::Domain::Pom

Inherits:
Artifact show all
Defined in:
lib/lock_jar/domain/artifact.rb

Instance Attribute Summary collapse

Attributes inherited from Artifact

#type

Instance Method Summary collapse

Methods inherited from Artifact

#resolvable?

Constructor Details

#initialize(_path, _scopes = ['compile','runtime']) ⇒ Pom

Returns a new instance of Pom.



81
82
83
84
85
# File 'lib/lock_jar/domain/artifact.rb', line 81

def initialize( _path, _scopes = ['compile','runtime'] )
  @type = 'pom'
  @path = _path
  @scopes = _scopes
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



79
80
81
# File 'lib/lock_jar/domain/artifact.rb', line 79

def path
  @path
end

#scopesObject (readonly)

Returns the value of attribute scopes.



79
80
81
# File 'lib/lock_jar/domain/artifact.rb', line 79

def scopes
  @scopes
end

Instance Method Details

#<=>(another_artifact) ⇒ Object



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/lock_jar/domain/artifact.rb', line 103

def <=>(another_artifact)
  if another_artifact.is_a? Pom
    if to_urn == another_artifact.to_urn
      return 0 if Set.new(scopes) == Set.new(another_artifact.scopes)
      
      # XXX: this is not a reliable way to compare. 
      if scopes.size > another_artifact.scopes.size
        return 1
      else
        return -1
      end
    else
      to_urn <=> another_artifact.to_urn
    end
  else
    super
  end
end

#==(another_artifact) ⇒ Object



99
100
101
# File 'lib/lock_jar/domain/artifact.rb', line 99

def ==(another_artifact)
  self.<=>(another_artifact) == 0
end

#notationsObject



95
96
97
# File 'lib/lock_jar/domain/artifact.rb', line 95

def notations
  LockJar::Maven.dependencies( path, scopes )  
end

#to_depObject



91
92
93
# File 'lib/lock_jar/domain/artifact.rb', line 91

def to_dep
  { path => scopes }
end

#to_urnObject



87
88
89
# File 'lib/lock_jar/domain/artifact.rb', line 87

def to_urn
  "pom:#{path}"
end