Class: Jars::Installer::Dependency
- Inherits:
-
Object
- Object
- Jars::Installer::Dependency
- Defined in:
- lib/jars/installer.rb
Constant Summary collapse
- EMPTY =
""- TRAILING_FILE =
the trailing ":
" of a dependency line; the file may itself contain a ':' on Windows (C:...), hence the optional drive-letter prefix /:(?<file>(?:[A-Z]:\\)?[^:]+)\z/.freeze
Instance Attribute Summary collapse
-
#coord ⇒ Object
readonly
Returns the value of attribute coord.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#gav ⇒ Object
readonly
Returns the value of attribute gav.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.parse(line) ⇒ Object
A dependency:list line has the form groupId:artifactId:type:version:scope:/path/to/file.
Instance Method Summary collapse
-
#initialize(type, scope, coord, gav, file, path, system) ⇒ Dependency
constructor
A new instance of Dependency.
- #system? ⇒ Boolean
Constructor Details
#initialize(type, scope, coord, gav, file, path, system) ⇒ Dependency
Returns a new instance of Dependency.
60 61 62 63 64 65 66 67 68 |
# File 'lib/jars/installer.rb', line 60 def initialize(type, scope, coord, gav, file, path, system) @type = type @scope = scope @coord = coord @gav = gav @file = file @path = path @system = system end |
Instance Attribute Details
#coord ⇒ Object (readonly)
Returns the value of attribute coord.
58 59 60 |
# File 'lib/jars/installer.rb', line 58 def coord @coord end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
58 59 60 |
# File 'lib/jars/installer.rb', line 58 def file @file end |
#gav ⇒ Object (readonly)
Returns the value of attribute gav.
58 59 60 |
# File 'lib/jars/installer.rb', line 58 def gav @gav end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
58 59 60 |
# File 'lib/jars/installer.rb', line 58 def path @path end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
58 59 60 |
# File 'lib/jars/installer.rb', line 58 def scope @scope end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
58 59 60 |
# File 'lib/jars/installer.rb', line 58 def type @type end |
Class Method Details
.parse(line) ⇒ Object
A dependency:list line has the form groupId:artifactId:type:version:scope:/path/to/file
16 17 18 19 20 21 22 23 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 |
# File 'lib/jars/installer.rb', line 16 def self.parse(line) return unless /:jar:|:pom:/.match?(line) line = line.dup # remove ANSI escape sequences and module section (https://issues.apache.org/jira/browse/MDEP-974) line.gsub!(/\e\[\d*m/, EMPTY) line.gsub!(/ -- module.*/, EMPTY) line.strip! # Peel off the trailing file path first: since it may contain a ':' it # cannot take part in the split below. What is left (pre_match) is # colon-clean, so every field is addressed by position -- never by # matching a keyword, which breaks when an artifact id is itself a scope # or type keyword (e.g. "com.dylibso.chicory:runtime:jar:1.7.5"). tail = line.match(TRAILING_FILE) file = tail[:file] # classifier is the only optional field, so there are exactly 5 or 6 components = tail.pre_match.split(':') if components.size == 6 group_id, artifact_id, type, classifier, version, scope_name = components else group_id, artifact_id, type, version, scope_name = components end coord = [group_id, artifact_id, type, classifier, version].compact.join(':') gav = [group_id, artifact_id, classifier, version].compact.join(':') path = File.join(*group_id.split('.'), artifact_id, version, file[%r{[^\\/]+\z}]) scope = case scope_name when 'provided' :provided when 'test' :test else :runtime end new(type.to_sym, scope, coord, gav, file, path, scope_name == 'system') end |
Instance Method Details
#system? ⇒ Boolean
70 71 72 |
# File 'lib/jars/installer.rb', line 70 def system? @system end |