Class: Pod::Generator::Plist

Inherits:
Acknowledgements show all
Defined in:
lib/cocoapods/generator/acknowledgements/plist.rb

Instance Attribute Summary

Attributes inherited from Acknowledgements

#file_accessors

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Acknowledgements

#footnote_text, #footnote_title, generators, #header_text, #header_title, #initialize

Constructor Details

This class inherits a constructor from Pod::Generator::Acknowledgements

Class Method Details

.path_from_basepath(path) ⇒ Object



6
7
8
# File 'lib/cocoapods/generator/acknowledgements/plist.rb', line 6

def self.path_from_basepath(path)
  Pathname.new(path.dirname + "#{path.basename}.plist")
end

Instance Method Details

#footnote_hashObject



66
67
68
69
70
71
72
# File 'lib/cocoapods/generator/acknowledgements/plist.rb', line 66

def footnote_hash
  {
    :Type => 'PSGroupSpecifier',
    :Title => sanitize_encoding(footnote_title),
    :FooterText => sanitize_encoding(footnote_text),
  }
end

#generateString

Returns The contents of the plist.

Returns:

  • (String)

    The contents of the plist



16
17
18
19
20
21
# File 'lib/cocoapods/generator/acknowledgements/plist.rb', line 16

def generate
  plist = Nanaimo::Plist.new(plist_hash, :xml)
  contents = StringIO.new
  Nanaimo::Writer::XMLWriter.new(plist, :pretty => true, :output => contents, :strict => false).write
  contents.string
end

#hash_for_spec(spec) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/cocoapods/generator/acknowledgements/plist.rb', line 45

def hash_for_spec(spec)
  if (license = license_text(spec))
    hash =  {
      :Type => 'PSGroupSpecifier',
      :Title => sanitize_encoding(spec.name),
      :FooterText => sanitize_encoding(license),
    }
    hash[:License] = sanitize_encoding(spec.license[:type]) if spec.license[:type]

    hash
  end
end

#header_hashObject



58
59
60
61
62
63
64
# File 'lib/cocoapods/generator/acknowledgements/plist.rb', line 58

def header_hash
  {
    :Type => 'PSGroupSpecifier',
    :Title => sanitize_encoding(header_title),
    :FooterText => sanitize_encoding(header_text),
  }
end

#licensesObject



35
36
37
38
39
40
41
42
43
# File 'lib/cocoapods/generator/acknowledgements/plist.rb', line 35

def licenses
  licences_array = [header_hash]
  specs.each do |spec|
    if (hash = hash_for_spec(spec))
      licences_array << hash
    end
  end
  licences_array << footnote_hash
end

#plist_hashObject



23
24
25
26
27
28
29
# File 'lib/cocoapods/generator/acknowledgements/plist.rb', line 23

def plist_hash
  {
    :Title => plist_title,
    :StringsTable => plist_title,
    :PreferenceSpecifiers => licenses,
  }
end

#plist_titleObject



31
32
33
# File 'lib/cocoapods/generator/acknowledgements/plist.rb', line 31

def plist_title
  'Acknowledgements'
end

#save_as(path) ⇒ Object



10
11
12
# File 'lib/cocoapods/generator/acknowledgements/plist.rb', line 10

def save_as(path)
  Xcodeproj::Plist.write_to_path(plist_hash, path)
end