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(type, group_id, artifact_id, classifier, version, exclusions, **options) ⇒ Artifact
constructor
A new instance of Artifact.
- #key ⇒ Object
- #to_coord(classifier: true) ⇒ Object
- #to_gacv ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(type, group_id, artifact_id, classifier, version, exclusions, **options) ⇒ Artifact
Returns a new instance of Artifact.
91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/jars/gemspec_artifacts.rb', line 91 def initialize(type, group_id, artifact_id, classifier, version, exclusions, **) @type = type @group_id = group_id @artifact_id = artifact_id @classifier = classifier @version = version @exclusions = exclusions .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.
87 88 89 |
# File 'lib/jars/gemspec_artifacts.rb', line 87 def artifact_id @artifact_id end |
#classifier ⇒ Object (readonly)
Returns the value of attribute classifier.
87 88 89 |
# File 'lib/jars/gemspec_artifacts.rb', line 87 def classifier @classifier end |
#exclusions ⇒ Object (readonly)
Returns the value of attribute exclusions.
87 88 89 |
# File 'lib/jars/gemspec_artifacts.rb', line 87 def exclusions @exclusions end |
#group_id ⇒ Object (readonly)
Returns the value of attribute group_id.
87 88 89 |
# File 'lib/jars/gemspec_artifacts.rb', line 87 def group_id @group_id end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
87 88 89 |
# File 'lib/jars/gemspec_artifacts.rb', line 87 def scope @scope end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
87 88 89 |
# File 'lib/jars/gemspec_artifacts.rb', line 87 def type @type end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
87 88 89 |
# File 'lib/jars/gemspec_artifacts.rb', line 87 def version @version end |
Class Method Details
.parse(line) ⇒ Object
103 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 |
# File 'lib/jars/gemspec_artifacts.rb', line 103 def self.parse(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 new(type, group_id, artifact_id, classifier, version, exclusions, **) end |
Instance Method Details
#key ⇒ Object
179 180 181 182 183 |
# File 'lib/jars/gemspec_artifacts.rb', line 179 def key args = [@group_id, @artifact_id] args << @classifier if @classifier args.join(':') end |
#to_coord(classifier: true) ⇒ Object
171 172 173 174 175 176 177 |
# File 'lib/jars/gemspec_artifacts.rb', line 171 def to_coord(classifier: true) args = [@group_id, @artifact_id] args << @classifier if classifier && @classifier args << @type args << MavenVersion.resolve(@version) args.join(':') end |
#to_gacv ⇒ Object
164 165 166 167 168 169 |
# File 'lib/jars/gemspec_artifacts.rb', line 164 def to_gacv args = [@group_id, @artifact_id] args << @classifier if @classifier args << @version args.join(':') end |
#to_s ⇒ Object
156 157 158 159 160 161 162 |
# File 'lib/jars/gemspec_artifacts.rb', line 156 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 |