Class: RZShoutout

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.rz_shoutoutObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# 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

Instance Method Details

#childPane(title) ⇒ Object



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

def childPane( title ) 
    Hash["Title" => title, :File => title, "Type" => "PSChildPaneSpecifier" ]
end

#groupItem(title = nil, footer = nil) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# 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