Class: Coordinates

Inherits:
Object
  • Object
show all
Defined in:
lib/jlauncher/common.rb

Instance Method Summary collapse

Constructor Details

#initialize(coords) ⇒ Coordinates

Returns a new instance of Coordinates.



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/jlauncher/common.rb', line 3

def initialize(coords)
    if coords.is_a? Hash
        @group_id = coords['groupId']
        @artifact_id = coords['artifactId']
        @version = coords['version']
        return
    end
    if coords.is_a? String
       components = coords.split(":")
       @group_id = components[0]
       @artifact_id = components[1]
       @version = components[2]
       return
    end

    raise "Could not parse coordinates " + coords.to_s


end

Instance Method Details

#local_ivy_pathObject



31
32
33
# File 'lib/jlauncher/common.rb', line 31

def local_ivy_path
    File.join(@group_id, @artifact_id, "jars", @artifact_id + "-" + @version + ".jar")
end

#local_maven_pathObject



27
28
29
# File 'lib/jlauncher/common.rb', line 27

def local_maven_path
    File.join(@group_id.split("."), @artifact_id, @version, @artifact_id + "-" + @version + ".jar")
end

#relative_urlObject



35
36
37
38
# File 'lib/jlauncher/common.rb', line 35

def relative_url
    @group_id.split(".").join("/") + "/" + @artifact_id + "/" + @version + "/"  + @artifact_id + "-" + @version + ".jar"

end

#to_sObject



23
24
25
# File 'lib/jlauncher/common.rb', line 23

def to_s
    @group_id + ":" + @artifact_id + ":" + @version
end