Class: Jars::GemspecArtifacts::Artifact
- Inherits:
-
Object
- Object
- Jars::GemspecArtifacts::Artifact
- Defined in:
- lib/jars/gemspec_artifacts.rb
Constant Summary collapse
- ALLOWED_TYPES =
['jar', 'pom']
Instance Attribute Summary collapse
-
#artifact_id ⇒ Object
readonly
Returns the value of attribute artifact_id.
-
#classifier ⇒ Object
readonly
Returns the value of attribute classifier.
-
#exclusions ⇒ Object
readonly
Returns the value of attribute exclusions.
-
#group_id ⇒ Object
readonly
Returns the value of attribute group_id.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options, *args) ⇒ Artifact
constructor
A new instance of Artifact.
- #key ⇒ Object
- #to_coord ⇒ Object
- #to_coord_no_classifier ⇒ Object
- #to_gacv ⇒ Object
- #to_s ⇒ Object
Constructor Details
permalink #initialize(options, *args) ⇒ Artifact
Returns a new instance of Artifact.
97 98 99 100 101 102 |
# File 'lib/jars/gemspec_artifacts.rb', line 97 def initialize( , *args ) @type, @group_id, @artifact_id, @classifier, @version, @exclusions = *args .each do |k,v| instance_variable_set( "@#{k}", v ) end end |
Instance Attribute Details
permalink #artifact_id ⇒ Object (readonly)
Returns the value of attribute artifact_id.
93 94 95 |
# File 'lib/jars/gemspec_artifacts.rb', line 93 def artifact_id @artifact_id end |
permalink #classifier ⇒ Object (readonly)
Returns the value of attribute classifier.
93 94 95 |
# File 'lib/jars/gemspec_artifacts.rb', line 93 def classifier @classifier end |
permalink #exclusions ⇒ Object (readonly)
Returns the value of attribute exclusions.
93 94 95 |
# File 'lib/jars/gemspec_artifacts.rb', line 93 def exclusions @exclusions end |
permalink #group_id ⇒ Object (readonly)
Returns the value of attribute group_id.
93 94 95 |
# File 'lib/jars/gemspec_artifacts.rb', line 93 def group_id @group_id end |
permalink #scope ⇒ Object (readonly)
Returns the value of attribute scope.
93 94 95 |
# File 'lib/jars/gemspec_artifacts.rb', line 93 def scope @scope end |
permalink #type ⇒ Object (readonly)
Returns the value of attribute type.
93 94 95 |
# File 'lib/jars/gemspec_artifacts.rb', line 93 def type @type end |
permalink #version ⇒ Object (readonly)
Returns the value of attribute version.
93 94 95 |
# File 'lib/jars/gemspec_artifacts.rb', line 93 def version @version end |
Class Method Details
permalink .new(line) ⇒ Object
[View source]
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/jars/gemspec_artifacts.rb', line 104 def self.new( line ) line = line.strip index = line.index( /\s/ ) if index.nil? return nil end type = line[0..index].strip unless ALLOWED_TYPES.member?( type ) return nil end line = line[index..-1] line.gsub!(/['"]/, '') line.strip! = {} line.sub!(/,\s*:exclusions\s*(:|=>)\s*(\[[^\]]+\])/) do [ :exclusions ] = Exclusions.new( $2.strip ) '' end line.sub!(/,\s*:([a-z]+)\s*(:|=>)\s*(:?[a-zA-Z0-9_]+)/) do [ $1.to_sym ] = $3.sub(/^:/, '') '' end exclusions = nil line.sub!(/[,:]\s*\[(.+:.+,?\s*)+\]$/) do |a| exclusions = Exclusions.new( a[1..-1].strip ) '' end line.strip! line.gsub!(/,\s*/, ':') if line.match(/[\[\(\)\]]/) index = line.index(/[\[\(].+$/) version = line[index..-1].sub(/:/, ', ') line = line[0..index - 1].strip.sub(/:$/, '') else index = line.index(/[:][^:]+$/) version = line[index + 1..-1] line = line[0..index - 1].strip end case line.count(':') when 2 group_id, artifact_id, classifier = line.split(':') when 1 group_id, artifact_id = line.split(':') classifier = nil else warn line return nil end super( , type, group_id, artifact_id, classifier, version, exclusions ) end |
Instance Method Details
permalink #key ⇒ Object
[View source]
189 190 191 192 193 |
# File 'lib/jars/gemspec_artifacts.rb', line 189 def key args = [@group_id, @artifact_id] args << @classifier if @classifier args.join(':') end |
permalink #to_coord ⇒ Object
[View source]
181 182 183 184 185 186 187 |
# File 'lib/jars/gemspec_artifacts.rb', line 181 def to_coord args = [@group_id, @artifact_id] args << @classifier if @classifier args << @type args << MavenVersion.new( @version ) args.join(':') end |
permalink #to_coord_no_classifier ⇒ Object
[View source]
174 175 176 177 178 179 |
# File 'lib/jars/gemspec_artifacts.rb', line 174 def to_coord_no_classifier args = [@group_id, @artifact_id] args << @type args << MavenVersion.new( @version ) args.join(':') end |
permalink #to_gacv ⇒ Object
[View source]
167 168 169 170 171 172 |
# File 'lib/jars/gemspec_artifacts.rb', line 167 def to_gacv args = [@group_id, @artifact_id] args << @classifier if @classifier args << @version args.join(':') end |
permalink #to_s ⇒ Object
[View source]
159 160 161 162 163 164 165 |
# File 'lib/jars/gemspec_artifacts.rb', line 159 def to_s args = [@group_id, @artifact_id] args << @classifier if @classifier args << @version args << @exclusions.to_s if @exclusions "#{@type} #{group_id}:#{args[1..-1].join(', ')}" end |