Class: PomPomPom::Dependency

Inherits:
Object
  • Object
show all
Includes:
UrlBuilder
Defined in:
lib/pompompom/dependency.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from UrlBuilder

#append_slash, #file_url, #group_path, #jar_file_name, #jar_url, #metadata_url, #pom_url

Class Method Details

.parse(artifact_coordinates) ⇒ Object

Raises:

  • (ArgumentError)


8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/pompompom/dependency.rb', line 8

def self.parse(artifact_coordinates)
  raise ArgumentError, %(Malformed artifact coordinate: "#{artifact_coordinates}") if artifact_coordinates.nil? || artifact_coordinates.strip.length == 0
  components = artifact_coordinates.strip.split(':')
  raise ArgumentError, %(Malformed artifact coordinate: "#{artifact_coordinates}") if components.size < 3 || components.size > 5
  case components.size
  when 3
    group_id, artifact_id, version = components
  when 4
    group_id, artifact_id, packaging, version = components
  when 5
    group_id, artifact_id, packaging, classifier, version = components
  end
  Dependency.new(group_id, artifact_id, version, packaging, classifier)
end

Instance Method Details

#clone(overrides = {}) ⇒ Object



47
48
49
# File 'lib/pompompom/dependency.rb', line 47

def clone(overrides={})
  self.class.new(self.to_h.merge(overrides))
end

#eql?(o) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/pompompom/dependency.rb', line 39

def eql?(o)
  o.to_s == to_s
end

#exclusionsObject



23
24
25
# File 'lib/pompompom/dependency.rb', line 23

def exclusions
  self[:exclusions] || []
end

#has_version?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/pompompom/dependency.rb', line 31

def has_version?
  !version.nil?
end

#hashObject



43
44
45
# File 'lib/pompompom/dependency.rb', line 43

def hash
  to_s.hash
end

#optional?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/pompompom/dependency.rb', line 27

def optional?
  optional
end

#same_artifact?(o) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/pompompom/dependency.rb', line 35

def same_artifact?(o)
  o.artifact_id == self.artifact_id && o.group_id == self.group_id
end

#to_sObject



51
52
53
# File 'lib/pompompom/dependency.rb', line 51

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