Class: Maven::Model::Dependency

Inherits:
Coordinate show all
Defined in:
lib/maven/model/dependencies.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Coordinate

#version?

Methods included from Tools::Coordinate

#gav, #group_artifact, #to_coordinate, #to_version

Methods inherited from Tag

#_name, _tags, #comment, prepend_tags, tags, #to_xml

Constructor Details

#initialize(type, *args) ⇒ Dependency

Returns a new instance of Dependency.



107
108
109
110
111
112
113
114
115
116
# File 'lib/maven/model/dependencies.rb', line 107

def initialize(type, *args)
  super(*args)
  @type = type
  args.flatten!
  if args[0] =~ /:/ && args.size == 3
    @classifier = args[2] unless args[2] =~ /[=~><]/
  elsif args.size == 4
    @classifier = args[3] unless args[3] =~ /[=~><]/
  end
end

Class Method Details

.new_gem(gemname, *args) ⇒ Object



127
128
129
# File 'lib/maven/model/dependencies.rb', line 127

def self.new_gem(gemname, *args)
  new(:gem, "rubygems", gemname, *args)
end

.new_jar(*args) ⇒ Object



135
136
137
# File 'lib/maven/model/dependencies.rb', line 135

def self.new_jar(*args)
  new(:jar, *args)
end

.new_pom(*args) ⇒ Object



131
132
133
# File 'lib/maven/model/dependencies.rb', line 131

def self.new_pom(*args)
  new(:pom, *args)
end

.new_test_jar(*args) ⇒ Object



139
140
141
142
143
# File 'lib/maven/model/dependencies.rb', line 139

def self.new_test_jar(*args)
  result = new(:jar, *args)
  result.scope :test
  result
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



122
123
124
# File 'lib/maven/model/dependencies.rb', line 122

def ==(other)
  super && @type == other.instance_variable_get(:@type) && @classifier == other.instance_variable_get(:@classifier)
end

#exclude(*args) ⇒ Object



153
154
155
# File 'lib/maven/model/dependencies.rb', line 153

def exclude(*args)
  exclusions << args
end

#exclusions(&block) ⇒ Object



145
146
147
148
149
150
151
# File 'lib/maven/model/dependencies.rb', line 145

def exclusions(&block)
  @exclusions ||= ExclusionArray.new
  if block
    block.call(@exclusions)
  end
  @exclusions
end

#hashObject



118
119
120
# File 'lib/maven/model/dependencies.rb', line 118

def hash
  "#{group_id}:#{artifact_id}:#{@type}:#{@classifier}".hash
end