class Pod::Generator::Acknowledgements

Attributes

file_accessors[R]

@return [Array<Sandbox::FileAccessor>] the list of the file accessors

for the specs of the target that needs to generate the
acknowledgements.

Public Class Methods

generators() click to toggle source

@return [Array<Class>] The classes of the acknowledgements generator

subclasses.
# File lib/cocoapods/generator/acknowledgements.rb, line 7
def self.generators
  [Plist, Markdown]
end
new(file_accessors) click to toggle source

@param [Array<Sandbox::FileAccessor>] @see file_accessors.

# File lib/cocoapods/generator/acknowledgements.rb, line 19
def initialize(file_accessors)
  @file_accessors = file_accessors
end

Public Instance Methods

footnote_text() click to toggle source

@return [String] the foot notes.

# File lib/cocoapods/generator/acknowledgements.rb, line 47
def footnote_text
  'Generated by CocoaPods - https://cocoapods.org'
end
footnote_title() click to toggle source

@return [String] The title of the foot notes.

# File lib/cocoapods/generator/acknowledgements.rb, line 41
def footnote_title
  ''
end
header_text() click to toggle source

@return [String] A text to present before listing the acknowledgements.

# File lib/cocoapods/generator/acknowledgements.rb, line 35
def header_text
  'This application makes use of the following third party libraries:'
end
header_title() click to toggle source

@return [String] The title of the acknowledgements file.

# File lib/cocoapods/generator/acknowledgements.rb, line 29
def header_title
  'Acknowledgements'
end

Protected Instance Methods

file_accessor(spec) click to toggle source

Returns the file accessor for the given spec.

@param [Specification] spec

the specification for which the file accessor is needed.

@return [Sandbox::FileAccessor] The file accessor.

# File lib/cocoapods/generator/acknowledgements.rb, line 112
def file_accessor(spec)
  file_accessors.find { |accessor| accessor.spec.root == spec }
end

Private Instance Methods

format_license(text) click to toggle source

Convenience method for users to format licenses

@param [String] text

Unformatted license text

@return [String] Formatted license text

# File lib/cocoapods/generator/acknowledgements.rb, line 99
def format_license(text)
  text
end
license_text(spec) click to toggle source

Returns the text of the license for the given spec.

@param [Specification] spec

the specification for which license is needed.

@return [String] The text of the license. @return [Nil] If no license text could be found.

# File lib/cocoapods/generator/acknowledgements.rb, line 72
def license_text(spec)
  return nil unless spec.license
  text = spec.license[:text]
  unless text
    if license_file = spec.license[:file]
      license_path = file_accessor(spec).root + license_file
      if File.exist?(license_path)
        text = IO.read(license_path)
      else
        UI.warn "Unable to read the license file `#{license_file}` " \
        "for the spec `#{spec}`"
      end
    elsif license_file = file_accessor(spec).license
      text = IO.read(license_file)
    end
    text = format_license(text)
  end
  text
end
specs() click to toggle source

@return [Array<Specification>] The root specifications for which the

acknowledgements should be generated.
# File lib/cocoapods/generator/acknowledgements.rb, line 60
def specs
  file_accessors.map { |accessor| accessor.spec.root }.uniq
end