Class: VersionLibrary

Inherits:
Download show all
Defined in:
lib/wonko_the_sane/wonko_version.rb

Direct Known Subclasses

Jarmod, VersionLibraryNative

Instance Attribute Summary collapse

Attributes inherited from Download

#internalUrl, #rules, #sha256, #size

Instance Method Summary collapse

Methods inherited from Download

from_json

Instance Attribute Details

#mavenBaseUrlObject

Returns the value of attribute mavenBaseUrl.



67
68
69
# File 'lib/wonko_the_sane/wonko_version.rb', line 67

def mavenBaseUrl
  @mavenBaseUrl
end

#nameObject

Returns the value of attribute name.



66
67
68
# File 'lib/wonko_the_sane/wonko_version.rb', line 66

def name
  @name
end

Instance Method Details

#from_json(json) ⇒ Object



92
93
94
95
96
97
98
99
100
101
# File 'lib/wonko_the_sane/wonko_version.rb', line 92

def from_json(json)
  super
  @name = json[:name]
  @mavenBaseUrl = json[:mavenBaseUrl]

  # if the absolute url is equal to the expected maven url we clear the absolute url
  if @url == url
    @url = nil
  end
end

#mavenObject



76
77
78
# File 'lib/wonko_the_sane/wonko_version.rb', line 76

def maven
  WonkoTheSane::Util::MavenIdentifier.new @name
end

#to_jsonObject



80
81
82
83
84
85
86
87
88
89
90
# File 'lib/wonko_the_sane/wonko_version.rb', line 80

def to_json
  obj = super
  obj[:name] = @name
  obj[:mavenBaseUrl] = @mavenBaseUrl if @mavenBaseUrl

  if not @url
    obj.delete :url
  end

  obj
end

#typeObject



69
70
71
# File 'lib/wonko_the_sane/wonko_version.rb', line 69

def type
  'java.libraries'
end

#urlObject



72
73
74
# File 'lib/wonko_the_sane/wonko_version.rb', line 72

def url
  @url ? @url : (@mavenBaseUrl + WonkoTheSane::Util::MavenIdentifier.new(@name).to_path)
end