Class: Doubleshot::Dependencies::JarDependency
- Inherits:
-
Dependency
- Object
- Dependency
- Doubleshot::Dependencies::JarDependency
- Defined in:
- lib/doubleshot/dependencies/jar_dependency.rb
Constant Summary collapse
- PACKAGE_TYPES =
[ "pom", "jar", "maven-plugin", "ejb", "war", "ear", "rar", "par", "bundle" ]
Instance Attribute Summary collapse
-
#artifact ⇒ Object
readonly
Returns the value of attribute artifact.
-
#classifier ⇒ Object
readonly
Returns the value of attribute classifier.
-
#exclusions ⇒ Object
readonly
Returns the value of attribute exclusions.
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#packaging ⇒ Object
readonly
Returns the value of attribute packaging.
-
#path ⇒ Object
Returns the value of attribute path.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Attributes inherited from Dependency
Instance Method Summary collapse
- #exclude(coordinate) ⇒ Object
-
#initialize(maven_coordinate) ⇒ JarDependency
constructor
A new instance of JarDependency.
- #to_s(long_form = false) ⇒ Object
Methods inherited from Dependency
#==, #eql?, #hash, #lock, #locked?
Constructor Details
#initialize(maven_coordinate) ⇒ JarDependency
Returns a new instance of JarDependency.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/doubleshot/dependencies/jar_dependency.rb', line 11 def initialize(maven_coordinate) # This is Maven's default package type, if unspecified. @packaging = "jar" maven_coordinate_parts = maven_coordinate.split(":") @group = maven_coordinate_parts.shift @artifact = maven_coordinate_parts.shift if version = maven_coordinate_parts.pop if !PACKAGE_TYPES.include?(version) self.version = version else raise ArgumentError.new("Expected last coordinate part to be a Version but was a Package Type: #{maven_coordinate}") end end if packaging = maven_coordinate_parts.shift self.packaging = packaging end if classifier = maven_coordinate_parts.shift @classifier = classifier end @name = "#{@group}:#{@artifact}:#{@packaging}:#{@version}" if [ @group, @artifact, @packaging, @version ].any? &:blank? raise ArgumentError.new("Invalid coordinate: #{@name}") end @exclusions = [] end |
Instance Attribute Details
#artifact ⇒ Object (readonly)
Returns the value of attribute artifact.
9 10 11 |
# File 'lib/doubleshot/dependencies/jar_dependency.rb', line 9 def artifact @artifact end |
#classifier ⇒ Object (readonly)
Returns the value of attribute classifier.
9 10 11 |
# File 'lib/doubleshot/dependencies/jar_dependency.rb', line 9 def classifier @classifier end |
#exclusions ⇒ Object (readonly)
Returns the value of attribute exclusions.
9 10 11 |
# File 'lib/doubleshot/dependencies/jar_dependency.rb', line 9 def exclusions @exclusions end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
9 10 11 |
# File 'lib/doubleshot/dependencies/jar_dependency.rb', line 9 def group @group end |
#packaging ⇒ Object
Returns the value of attribute packaging.
9 10 11 |
# File 'lib/doubleshot/dependencies/jar_dependency.rb', line 9 def packaging @packaging end |
#path ⇒ Object
Returns the value of attribute path.
9 10 11 |
# File 'lib/doubleshot/dependencies/jar_dependency.rb', line 9 def path @path end |
#version ⇒ Object
Returns the value of attribute version.
9 10 11 |
# File 'lib/doubleshot/dependencies/jar_dependency.rb', line 9 def version @version end |
Instance Method Details
#exclude(coordinate) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/doubleshot/dependencies/jar_dependency.rb', line 52 def exclude(coordinate) if coordinate.split(":").size != 2 raise ArgumentError.new("JarDependency#exclude takes a string of format \"groupId:artifactId\", you provided #{coordinate.inspect}") end @exclusions << coordinate self end |
#to_s(long_form = false) ⇒ Object
44 45 46 |
# File 'lib/doubleshot/dependencies/jar_dependency.rb', line 44 def to_s(long_form = false) @classifier.blank? ? @name : "#{@group}:#{@artifact}:#{@packaging}:#{@classifier}:#{@version}" end |