lib/maven/tools/coordinate.rb in maven-tools-1.0.2 vs lib/maven/tools/coordinate.rb in maven-tools-1.0.3

- old
+ new

@@ -19,18 +19,28 @@ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # module Maven module Tools module Coordinate + def to_split_coordinate_with_scope( line ) + line = line.sub( /#.*^/, '' ) + scope = :compile + line.sub!( /,\s+:scope\s+=>\s(:provided|:runtime|:compile|:test)/ ) do |part| + scope = part.sub( /.*:/, '' ).to_sym + '' + end + coord = to_split_coordinate( line ) + [ scope ] + coord if coord + end + def to_split_coordinate( line ) if line =~ /^\s*(jar|pom)\s/ packaging = line.strip.sub(/\s+.*/, '') # Remove packaging, comments and whitespaces sanitized_line = line.sub(/\s*[a-z]+\s+/, '').sub(/#.*/,'').gsub(/\s+/,'') - exclusions = nil sanitized_line.gsub!( /[,:](\[.+:.+\]|'\[.+:.+\]'|"\[.+:.+\]")/ ) do |match| exclusions = match.gsub( /['"]/, '' )[2..-2].split( /,\s*/ ) nil end @@ -64,11 +74,11 @@ # insert packing and exclusion parts.insert( 2, packaging ) parts << exclusions - # make sure there are not nils - parts.select { |o| !o.nil? } + # make sure there are no nils + parts.compact end end def to_coordinate( line ) result = to_split_coordinate( line )