Class: Jars::Installer::Dependency

Inherits:
Object
  • Object
show all
Defined in:
lib/jars/installer.rb

Constant Summary collapse

REG =
/:jar:|:pom:|:test:|:compile:|:runtime:|:provided:|:system:/.freeze
EMPTY =
''

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line) ⇒ Dependency

Returns a new instance of Dependency.



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
# File 'lib/jars/installer.rb', line 39

def initialize(line)
  # remove ANSI escape sequences and module section (https://issues.apache.org/jira/browse/MDEP-974)
  line = line.gsub(/\e\[\d*m/, '')
  line = line.gsub(/ -- module.*/, '')

  setup_type(line)

  line.strip!

  @coord = line.sub(/:[^:]+:([A-Z]:\\)?[^:]+$/, EMPTY)
  first, second = @coord.split(/:#{type}:/)
  group_id, artifact_id = first.split(':')
  parts = group_id.split('.')
  parts << artifact_id
  parts << second.split(':')[-1]
  @file = line.slice(@coord.length, line.length).sub(REG, EMPTY).strip
  last = @file.reverse.index(%r{\\|/})
  parts << line[-last..]
  @path = File.join(parts).strip

  setup_scope(line)

  @system = !line.index(':system:').nil?
  @gav = @coord.sub(REG, ':')
end

Instance Attribute Details

#coordObject (readonly)

Returns the value of attribute coord.



9
10
11
# File 'lib/jars/installer.rb', line 9

def coord
  @coord
end

#fileObject (readonly)

Returns the value of attribute file.



9
10
11
# File 'lib/jars/installer.rb', line 9

def file
  @file
end

#gavObject (readonly)

Returns the value of attribute gav.



9
10
11
# File 'lib/jars/installer.rb', line 9

def gav
  @gav
end

#pathObject (readonly)

Returns the value of attribute path.



9
10
11
# File 'lib/jars/installer.rb', line 9

def path
  @path
end

#scopeObject (readonly)

Returns the value of attribute scope.



9
10
11
# File 'lib/jars/installer.rb', line 9

def scope
  @scope
end

#typeObject (readonly)

Returns the value of attribute type.



9
10
11
# File 'lib/jars/installer.rb', line 9

def type
  @type
end

Class Method Details

.new(line) ⇒ Object



11
12
13
# File 'lib/jars/installer.rb', line 11

def self.new(line)
  super if /:jar:|:pom:/.match?(line)
end

Instance Method Details

#system?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/jars/installer.rb', line 65

def system?
  @system
end