Class: AtlassianAppVersions::AbstractVersion

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/atlassian_app_versions.rb

Overview

A plugin or app version

Direct Known Subclasses

AppVersion, PluginVersion

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(versionName, parent) ⇒ AbstractVersion

Returns a new instance of AbstractVersion.



288
289
290
291
# File 'lib/atlassian_app_versions.rb', line 288

def initialize(versionName, parent) 
    @version = versionName
    @parent = parent
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



325
326
327
328
329
330
331
# File 'lib/atlassian_app_versions.rb', line 325

def method_missing(name, *args, &block)
    if versionJSON and versionJSON.keys.member? name.to_s then
	versionJSON[name.to_s]
    else
	super
    end
end

Instance Attribute Details

#versionObject

Returns the value of attribute version.



287
288
289
# File 'lib/atlassian_app_versions.rb', line 287

def version
  @version
end

Instance Method Details

#<=>(other_version) ⇒ Object



309
310
311
312
313
314
315
316
317
318
319
# File 'lib/atlassian_app_versions.rb', line 309

def <=>(other_version)
    # Confluence has a version with underscores (3.0.0_01) which Gem::Version doesn't like, so strip it
    v1 = @version.gsub('_', '.')
    v2 = other_version.to_s.gsub('_', '.')
    begin
	Gem::Version.new(v1) <=> Gem::Version.new(v2)
    rescue ArgumentError => e
	$stderr.puts e.message
    end

end

#inspectObject



301
302
303
# File 'lib/atlassian_app_versions.rb', line 301

def inspect
    "#<#{self.class.name}:#{self.object_id} #{to_s}>"
end

#keysObject



321
322
323
# File 'lib/atlassian_app_versions.rb', line 321

def keys
    versionJSON.keys
end

#releaseDateObject



297
298
299
# File 'lib/atlassian_app_versions.rb', line 297

def releaseDate
    DateTime.strptime(versionJSON["releaseDate"], '%Y-%m-%dT%H:%M:%S.%L%z') if versionJSON
end

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


333
334
335
# File 'lib/atlassian_app_versions.rb', line 333

def respond_to_missing?(name, include_private = false)
    keys.member? name.to_s || super
end

#to_sObject



305
306
307
# File 'lib/atlassian_app_versions.rb', line 305

def to_s
    @version
end

#versionJSONObject



293
294
295
# File 'lib/atlassian_app_versions.rb', line 293

def versionJSON
    @parent.versionsJSON.find { |v| v["version"] == @version }
end