class Pod::Generator::Plist

Public Class Methods

path_from_basepath(path) click to toggle source
# File lib/cocoapods/generator/acknowledgements/plist.rb, line 6
def self.path_from_basepath(path)
  Pathname.new(path.dirname + "#{path.basename}.plist")
end

Public Instance Methods

footnote_hash() click to toggle source
# 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
generate() click to toggle source

@return [String] The contents of the plist

# 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) click to toggle source
# 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_hash() click to toggle source
# 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
licenses() click to toggle source
# 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_hash() click to toggle source
# File lib/cocoapods/generator/acknowledgements/plist.rb, line 23
def plist_hash
  {
    :Title => plist_title,
    :StringsTable => plist_title,
    :PreferenceSpecifiers => licenses,
  }
end
plist_title() click to toggle source
# File lib/cocoapods/generator/acknowledgements/plist.rb, line 31
def plist_title
  'Acknowledgements'
end
save_as(path) click to toggle source
# File lib/cocoapods/generator/acknowledgements/plist.rb, line 10
def save_as(path)
  Xcodeproj::Plist.write_to_path(plist_hash, path)
end

Private Instance Methods

sanitize_encoding(text) click to toggle source

Returns the sanitized text with UTF-8 invalid characters eliminated.

@param [String] text

the text we want to sanitize.

@return [String] The sanitized UTF-8 text.

# File lib/cocoapods/generator/acknowledgements/plist.rb, line 87
def sanitize_encoding(text)
  text.encode('UTF-8', :invalid => :replace, :undef => :replace, :replace => '')
end