Module: Buildr::ActsAsArtifact
- Included in:
- Artifact
- Defined in:
- lib/core/artifact.rb
Overview
This module gives you a way to access the individual properties of an artifact: id, group, type, classifier and version. It also provides other methods commonly used on an artifact, specifically #to_hash and #to_spec.
Constant Summary collapse
- ARTIFACT_ATTRIBUTES =
[:group, :id, :type, :classifier, :version]
Instance Attribute Summary collapse
-
#classifier ⇒ Object
readonly
Optional artifact classifier.
-
#group ⇒ Object
readonly
The group identifier.
-
#id ⇒ Object
readonly
The artifact identifier.
-
#type ⇒ Object
readonly
The file type.
-
#version ⇒ Object
readonly
The version number.
Class Method Summary collapse
Instance Method Summary collapse
-
#apply_spec(spec) ⇒ Object
Apply specification to this artifact.
-
#pom ⇒ Object
Convenience method that returns a POM artifact.
-
#to_spec ⇒ Object
Returns the artifact specification, in the structure: <group>:<artifact>:<type>:<version> or <group>:<artifact>:<type>:<classifier><:<version>.
-
#to_spec_hash ⇒ Object
(also: #to_hash)
Returns the artifact specification as a hash.
Instance Attribute Details
#classifier ⇒ Object (readonly)
Optional artifact classifier.
25 26 27 |
# File 'lib/core/artifact.rb', line 25 def classifier @classifier end |
#group ⇒ Object (readonly)
The group identifier.
19 20 21 |
# File 'lib/core/artifact.rb', line 19 def group @group end |
#id ⇒ Object (readonly)
The artifact identifier.
17 18 19 |
# File 'lib/core/artifact.rb', line 17 def id @id end |
#type ⇒ Object (readonly)
The file type.
21 22 23 |
# File 'lib/core/artifact.rb', line 21 def type @type end |
#version ⇒ Object (readonly)
The version number.
23 24 25 |
# File 'lib/core/artifact.rb', line 23 def version @version end |
Class Method Details
.included(mod) ⇒ Object
11 12 13 |
# File 'lib/core/artifact.rb', line 11 def included(mod) mod.extend self end |
Instance Method Details
#apply_spec(spec) ⇒ Object
Apply specification to this artifact.
43 44 45 46 47 |
# File 'lib/core/artifact.rb', line 43 def apply_spec(spec) spec = Artifact.to_hash(spec) ARTIFACT_ATTRIBUTES.each { |key| instance_variable_set("@#{key}", spec[key]) } self end |
#pom ⇒ Object
Convenience method that returns a POM artifact.
50 51 52 53 |
# File 'lib/core/artifact.rb', line 50 def pom() return self if type.to_s == "pom" artifact(:group=>group, :id=>id, :version=>version, :type=>"pom", :classifier=>classifier) end |
#to_spec ⇒ Object
Returns the artifact specification, in the structure:
<group>:<artifact>:<type>:<version>
or
<group>:<artifact>:<type>:<classifier><:<version>
38 39 40 |
# File 'lib/core/artifact.rb', line 38 def to_spec() classifier.blank? ? "#{group}:#{id}:#{type}:#{version}" : "#{group}:#{id}:#{type}:#{classifier}:#{version}" end |
#to_spec_hash ⇒ Object Also known as: to_hash
Returns the artifact specification as a hash.
28 29 30 31 |
# File 'lib/core/artifact.rb', line 28 def to_spec_hash() base = { :group=>group, :id=>id, :type=>type, :version=>version } classifier.blank? ? base : base.merge(:classifier=>classifier) end |