Class: IOSDevTools::InfoPlist

Inherits:
Object
  • Object
show all
Defined in:
lib/ios_dev_tools/model/info_plist.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(info_plist_file_path) {|_self| ... } ⇒ InfoPlist

Returns a new instance of InfoPlist.

Yields:

  • (_self)

Yield Parameters:



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ios_dev_tools/model/info_plist.rb', line 11

def initialize info_plist_file_path

  @info_plist_file_path=info_plist_file_path

  yield self if block_given?

  @plist_buddy_cmd||="/usr/libexec/PlistBuddy"

  raise "Property list file \"#{info_plist_file_path}\" doesn't exist" if not File.exists? @info_plist_file_path
  raise "Plist editor \"#{info_plist_file_path}\" doesn't exist" if not File.exists? @plist_buddy_cmd

end

Instance Attribute Details

#info_plist_file_pathObject

Returns the value of attribute info_plist_file_path.



8
9
10
# File 'lib/ios_dev_tools/model/info_plist.rb', line 8

def info_plist_file_path
  @info_plist_file_path
end

#plist_buddy_cmdObject

Returns the value of attribute plist_buddy_cmd.



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

def plist_buddy_cmd
  @plist_buddy_cmd
end

Instance Method Details

#bundle_idObject



41
42
43
# File 'lib/ios_dev_tools/model/info_plist.rb', line 41

def bundle_id
  get_property "CFBundleIdentifier"
end

#bundle_id=(new_bundle_id) ⇒ Object



45
46
47
# File 'lib/ios_dev_tools/model/info_plist.rb', line 45

def bundle_id= new_bundle_id
  set_property "CFBundleIdentifier", new_bundle_id
end

#display_nameObject



33
34
35
# File 'lib/ios_dev_tools/model/info_plist.rb', line 33

def display_name
  get_property "CFBundleDisplayName"
end

#display_name=(new_name) ⇒ Object



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

def display_name= new_name
  set_property "CFBundleDisplayName", new_name
end

#get_property(property_id) ⇒ Object



29
30
31
# File 'lib/ios_dev_tools/model/info_plist.rb', line 29

def get_property property_id
  `#{@plist_buddy_cmd} -c "Print :#{property_id}" "#{@info_plist_file_path}"`.strip
end

#set_property(property_id, property_value) ⇒ Object



24
25
26
27
# File 'lib/ios_dev_tools/model/info_plist.rb', line 24

def set_property property_id, property_value
  return if not property_id or not property_value
  `#{@plist_buddy_cmd} -c "Set :#{property_id} #{property_value}" "#{@info_plist_file_path}"`
end