Class: Rucola::InfoPlist

Inherits:
Object show all
Defined in:
lib/rucola/info_plist.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ InfoPlist

Returns a new instance of InfoPlist.



11
12
13
14
# File 'lib/rucola/info_plist.rb', line 11

def initialize(path)
  @path = path
  @data = OSX::NSDictionary.dictionaryWithContentsOfFile(@path)
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



9
10
11
# File 'lib/rucola/info_plist.rb', line 9

def data
  @data
end

Class Method Details

.open(path) ⇒ Object



5
6
7
# File 'lib/rucola/info_plist.rb', line 5

def self.open(path)
  new(path)
end

Instance Method Details

#add_document_type(name, extension, role, icon = '????', os_type = '????') ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/rucola/info_plist.rb', line 21

def add_document_type(name, extension, role, icon = '????', os_type = '????')
  document_types.push({
    'NSDocumentClass' => name,
    'CFBundleTypeExtensions' => [extension],
    'CFBundleTypeRole' => role,
    'CFBundleTypeIconFile' => icon,
    'CFBundleTypeOSTypes' => [os_type],
    'CFBundleTypeName' => 'DocumentType'
  })
end

#app_nameObject

Returns the name of the application (CFBundleExecutable).



37
38
39
# File 'lib/rucola/info_plist.rb', line 37

def app_name
  @data['CFBundleExecutable'].to_s
end

#document_typesObject



16
17
18
19
# File 'lib/rucola/info_plist.rb', line 16

def document_types
  @data['CFBundleDocumentTypes'] ||= []
  @data['CFBundleDocumentTypes']
end

#saveObject



32
33
34
# File 'lib/rucola/info_plist.rb', line 32

def save
  @data.writeToFile_atomically(@path, true)
end