3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/pod_builder/licenses.rb', line 3
def self.write(licenses, all_buildable_items)
puts "Writing licenses".yellow
license_file_path = PodBuilder::project_path(Configuration.license_filename) + ".plist"
current_licenses = []
if File.exist?(license_file_path)
plist = CFPropertyList::List.new(:file => license_file_path)
dict = CFPropertyList.native_types(plist.value)
current_licenses = dict["PreferenceSpecifiers"]
if current_licenses.count > 0
= current_licenses.shift
raise "\n\nUnexpected license found in header\n".red if .has_key?("License")
end
if current_licenses.count > 0
= current_licenses.pop
raise "\n\nUnexpected license found in footer\n".red if .has_key?("License")
end
end
if licenses.count > 0
= licenses.shift
raise "\n\nUnexpected license found in header\n".red if .has_key?("License")
= licenses.pop
raise "\n\nUnexpected license found in footer\n".red if .has_key?("License")
lincenses_titles = licenses.map { |x| x["Title"] }
current_licenses.select! { |x| !lincenses_titles.include?(x["Title"]) }
end
licenses += current_licenses licenses.uniq! { |x| x["Title"] }
licenses.sort_by! { |x| x["Title"] }
licenses.select! { |x| !Configuration.skip_licenses.include?(x["Title"]) }
licenses.select! { |x| all_buildable_items.map(&:root_name).include?(x["Title"]) }
license_dict = {}
license_dict["PreferenceSpecifiers"] = [, licenses, ].compact.flatten
license_dict["StringsTable"] = "Acknowledgements"
license_dict["Title"] = license_dict["StringsTable"]
plist = CFPropertyList::List.new
plist.value = CFPropertyList.guess(license_dict)
plist.save(license_file_path, CFPropertyList::List::FORMAT_BINARY)
if licenses.count > 0
write_markdown(license_file_path)
end
end
|