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!
options = {}
line.sub!(/,\s*:exclusions\s*(:|=>)\s*(\[[^\]]+\])/) do
options[ :exclusions ] = Exclusions.new( $2.strip )
''
end
line.sub!(/,\s*:([a-z]+)\s*(:|=>)\s*(:?[a-zA-Z0-9_]+)/) do
options[ $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( options, type, group_id, artifact_id, classifier, version, exclusions )
end
|