Class: Jars::GemspecArtifacts::Artifact
- Inherits:
-
Object
- Object
- Jars::GemspecArtifacts::Artifact
- Defined in:
- lib/jars/gemspec_artifacts.rb
Constant Summary collapse
- ALLOWED_TYPES =
%w[jar pom].freeze
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
#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
#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 |
#classifier ⇒ Object (readonly)
Returns the value of attribute classifier.
93 94 95 |
# File 'lib/jars/gemspec_artifacts.rb', line 93 def classifier @classifier end |
#exclusions ⇒ Object (readonly)
Returns the value of attribute exclusions.
93 94 95 |
# File 'lib/jars/gemspec_artifacts.rb', line 93 def exclusions @exclusions end |
#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 |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
93 94 95 |
# File 'lib/jars/gemspec_artifacts.rb', line 93 def scope @scope end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
93 94 95 |
# File 'lib/jars/gemspec_artifacts.rb', line 93 def type @type end |
#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
.new(line) ⇒ Object
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 |
# File 'lib/jars/gemspec_artifacts.rb', line 104 def self.new(line) line = line.strip index = line.index(/\s/) return nil if index.nil? type = line[0..index].strip return nil unless ALLOWED_TYPES.member?(type) line = line[index..] line.gsub!(/['"]/, '') line.strip! = {} line.sub!(/,\s*:exclusions\s*(:|=>)\s*(\[[^\]]+\])/) do [:exclusions] = Exclusions.new(Regexp.last_match(2).strip) '' end line.sub!(/,\s*:([a-z]+)\s*(:|=>)\s*(:?[a-zA-Z0-9_]+)/) do [Regexp.last_match(1).to_sym] = Regexp.last_match(3).sub(/^:/, '') '' end exclusions = nil line.sub!(/[,:]\s*\[(.+:.+,?\s*)+\]$/) do |a| exclusions = Exclusions.new(a[1..].strip) '' end line.strip! line.gsub!(/,\s*/, ':') if /[\[()\]]/.match?(line) index = line.index(/[\[(].+$/) version = line[index..].sub(/:/, ', ') line = line[0..index - 1].strip.sub(/:$/, '') else index = line.index(/:[^:]+$/) version = line[index + 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
#key ⇒ Object
187 188 189 190 191 |
# File 'lib/jars/gemspec_artifacts.rb', line 187 def key args = [@group_id, @artifact_id] args << @classifier if @classifier args.join(':') end |
#to_coord ⇒ Object
179 180 181 182 183 184 185 |
# File 'lib/jars/gemspec_artifacts.rb', line 179 def to_coord args = [@group_id, @artifact_id] args << @classifier if @classifier args << @type args << MavenVersion.new(@version) args.join(':') end |
#to_coord_no_classifier ⇒ Object
172 173 174 175 176 177 |
# File 'lib/jars/gemspec_artifacts.rb', line 172 def to_coord_no_classifier args = [@group_id, @artifact_id] args << @type args << MavenVersion.new(@version) args.join(':') end |
#to_gacv ⇒ Object
165 166 167 168 169 170 |
# File 'lib/jars/gemspec_artifacts.rb', line 165 def to_gacv args = [@group_id, @artifact_id] args << @classifier if @classifier args << @version args.join(':') end |
#to_s ⇒ Object
157 158 159 160 161 162 163 |
# File 'lib/jars/gemspec_artifacts.rb', line 157 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..].join(', ')}" end |