Module: Maven::Tools::Coordinate
- Included in:
- Model::Coordinate, Model::Exclusion, Artifact::Helper, GemspecDependencies, Jarfile, Jarfile::DSL
- Defined in:
- lib/maven/tools/coordinate.rb
Instance Method Summary collapse
- #gav(*args) ⇒ Object
- #group_artifact(*args) ⇒ Object
- #to_coordinate(line) ⇒ Object
- #to_split_coordinate(line) ⇒ Object
- #to_version(*args) ⇒ Object
Instance Method Details
#gav(*args) ⇒ Object
96 97 98 99 100 101 102 |
# File 'lib/maven/tools/coordinate.rb', line 96 def gav(*args) if args[0] =~ /:/ [args[0].sub(/:[^:]+$/, ''), args[0].sub(/.*:/, ''), maven_version(*args[1, 2])] else [args[0], args[1], maven_version(*args[2,3])] end end |
#group_artifact(*args) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/maven/tools/coordinate.rb', line 82 def group_artifact(*args) case args.size when 1 name = args[0] if name =~ /:/ [name.sub(/:[^:]+$/, ''), name.sub(/.*:/, '')] else ["rubygems", name] end else [args[0], args[1]] end end |
#to_coordinate(line) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/maven/tools/coordinate.rb', line 74 def to_coordinate( line ) result = to_split_coordinate( line ) if result exclusion = result.last.inspect.gsub( /[" ]/, '' ) ( result[0..-2] + [ exclusion ] ).join( ':' ) end end |
#to_split_coordinate(line) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/maven/tools/coordinate.rb', line 24 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 # split to compartments parts = sanitized_line.split( /[,]/ ).collect{|o| o.gsub( /['"]/, '' ) } # fix no version on one argument if parts.size == 1 parts << '[0,)' end # split first argument parts[ 0 ] = parts[ 0 ].split( /:/ ) parts.flatten! # convert ruby version to maven version versions = parts.select { |i| i.match( /[~><=!]/ ) } if ! versions.empty? version = to_version( *versions ) parts = parts - versions parts << version else # concat maven version ranges versions = parts.select { |i| i.match( /[\[\]()]/ ) } if ! versions.empty? version = versions.join( ',' ) parts = parts - versions parts << version end end # insert packing and exclusion parts.insert( 2, packaging ) parts << exclusions # make sure there are not nils parts.select { |o| !o.nil? } end end |
#to_version(*args) ⇒ Object
104 105 106 |
# File 'lib/maven/tools/coordinate.rb', line 104 def to_version(*args) maven_version(*args) || "[0,)" end |