Class: AtlassianAppVersions::App

Inherits:
AbstractProduct show all
Defined in:
lib/atlassian_app_versions.rb

Overview

Represents an application on jira.atlassian.com / my.atlassian.com

Constant Summary collapse

VALID_PRODUCTS =
["jira-core", "jira-software", "confluence", "bitbucket", "stash", "fisheye", "crowd"]

Constants inherited from AbstractProduct

AtlassianAppVersions::AbstractProduct::JAC_URL

Instance Attribute Summary

Attributes inherited from AbstractProduct

#key

Instance Method Summary collapse

Methods inherited from AbstractProduct

#allissuesJQL, #allissuesURL, #bugsJQL, #bugsURL, #featuresJQL, #featuresURL, #jacKey, #jacVersions, #keys, #latest, #marketplaceJSON, #method_missing, #projectJQL, #recentbugsJQL, #recentbugsURL, #respond_to_missing?, #templateJQL, #version, #versions, #versionsListJQL

Constructor Details

#initialize(key) ⇒ App

Returns a new instance of App.



229
230
231
232
233
234
235
# File 'lib/atlassian_app_versions.rb', line 229

def initialize(key)
    if !VALID_PRODUCTS.member? key then
	raise "Unknown product: #{key}. Use one of #{VALID_PRODUCTS.join(", ")}"
    end
    if key=="stash" then key="bitbucket"; end
    super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class AtlassianAppVersions::AbstractProduct

Instance Method Details

#allVersionsObject



266
267
268
269
270
271
272
273
274
275
276
# File 'lib/atlassian_app_versions.rb', line 266

def allVersions
    first=true
    versionsJSON.collect { |v|
	if first then
	    first=false
	    LatestAppVersion.new(v["version"], self)
	else
	    ArchivedAppVersion.new(v["version"], self)
	end
    }
end

#archivedReleaseJSONObject



252
253
254
255
256
257
258
259
260
# File 'lib/atlassian_app_versions.rb', line 252

def archivedReleaseJSON
    if !@archivedReleaseJSON then
	macKey = @key == "bitbucket" ? "stash" : @key # MAC still thinks it's 'stash'
	url="https://my.atlassian.com/download/feeds/archived/#{macKey}.json"
	jsonStr = getjson(url)
	@archivedReleaseJSON = JSON.parse( jsonStr )
    end
    @archivedReleaseJSON
end

#getjson(url) ⇒ Object



237
238
239
# File 'lib/atlassian_app_versions.rb', line 237

def getjson(url)
    open(url).read.gsub(/^downloads\(/, '').gsub(/\)$/, '')
end

#latestReleaseJSONObject



241
242
243
244
245
246
247
248
249
250
# File 'lib/atlassian_app_versions.rb', line 241

def latestReleaseJSON
    if !@latestReleaseJSON then

	macKey = @key == "bitbucket" ? "stash" : @key # MAC still thinks it's 'stash'
	url="https://my.atlassian.com/download/feeds/current/#{macKey}.json"
	jsonStr = getjson(url)
	@latestReleaseJSON = JSON.parse(jsonStr)
    end
    @latestReleaseJSON
end

#product_typeObject



278
279
280
# File 'lib/atlassian_app_versions.rb', line 278

def product_type
    "applications"
end

#versionsJSONObject



262
263
264
# File 'lib/atlassian_app_versions.rb', line 262

def versionsJSON
    marketplaceJSON["versions"]
end