Class: OsxApp

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

Overview

this class describes OSX Application

Defined Under Namespace

Classes: CannotFind, Invalid

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name_or_path) ⇒ OsxApp

Returns a new instance of OsxApp.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/osx_app.rb', line 9

def initialize(name_or_path)
  if File.directory?(name_or_path)
    @name = File.basename(name_or_path).gsub('.app', '')
    @path = name_or_path
  else
    @name = name_or_path.gsub('.app', '')
    @path = "/Applications/#{@name}.app"
    fail CannotFind, @path unless File.directory?(@path)
  end
  validate!
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/osx_app.rb', line 6

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/osx_app.rb', line 7

def path
  @path
end

Instance Method Details

#versionObject



21
22
23
# File 'lib/osx_app.rb', line 21

def version
  `defaults read #{info_plist} CFBundleShortVersionString`.strip
end

#version_majorObject



25
26
27
# File 'lib/osx_app.rb', line 25

def version_major
  version.split('.').first
end