class RZShoutout

Public Class Methods

rz_shoutout() click to toggle source
# File lib/rz_shoutout.rb, line 36
def self.rz_shoutout()

    options = {}
    OptionParser.new do |opts|
      opts.banner = "Usage: $PROGRAM_NAME [options]"

      opts.on("-o path", "target's settings bundle") do |v|
        options[:output_path] = v
      end
  
      opts.on("-i acknowledgements_plist", "acknowledgements_plist") do |v|
        options[:ack_path] = v
      end  
  
    end.parse!

    if (!options[:output_path] && ENV["BUILT_PRODUCTS_DIR"])  then
        p = Pathname(ENV["BUILT_PRODUCTS_DIR"])
        p += ENV["UNLOCALIZED_RESOURCES_FOLDER_PATH"] + "/Settings.bundle"

        print "using default output_path = #{p}\n"

        options[:output_path] = p
    end

    fail "#{options[:ack_path]} doesn't exist" if ! File.exist?(options[:ack_path])
    fail "#{options[:output_path]} doesn't exist" if ! File.exist?(options[:output_path])


    ack = Xcodeproj::PlistHelper.read( options[:ack_path] )
    fail "can't parse #{options[:ack_path]} as a plist" if !ack

    items = ack["PreferenceSpecifiers"]

    new_items = []
    items.delete_at(0)
    items.each { |item| 
        sub_ack = ack.clone
        sub_ack["PreferenceSpecifiers"] = Array[ item ]
        sub_file = options[:output_path] + ( item["Title"] + ".plist" )
        Xcodeproj::PlistHelper.write( sub_ack, sub_file )

        new_items.push( childPane(item["Title"]) )
    }
    new_items.sort_by { |hsh| hsh["Title"] }
    new_items.insert(0, groupItem(nil, "This application makes use of the following third party software:"),     groupItem(nil, nil))

    new_ack = ack.clone
    new_ack["PreferenceSpecifiers"] = new_items
    Xcodeproj::PlistHelper.write( new_ack, options[:output_path] + "Acknowledgements.plist" )
end

Public Instance Methods

childPane( title ) click to toggle source
# File lib/rz_shoutout.rb, line 21
def childPane( title ) 
    Hash["Title" => title, :File => title, "Type" => "PSChildPaneSpecifier" ]
end
groupItem( title = nil, footer=nil ) click to toggle source
# File lib/rz_shoutout.rb, line 25
def groupItem( title = nil, footer=nil )
    result = Hash[ "Type" => "PSGroupSpecifier" ]
    if ( title ) then
        result["Title" => title]
    end    
    if ( footer ) then
        result["FooterText"] = footer
    end
    return result
end