Class: Pod::Generator::Markdown

Inherits:
Acknowledgements show all
Defined in:
lib/cocoapods/generator/acknowledgements/markdown.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/markdown.rb', line 6

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

Instance Method Details

#licensesObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/cocoapods/generator/acknowledgements/markdown.rb', line 28

def licenses
  licenses_string = "#{title_from_string(header_title, 1)}\n#{header_text}\n"
  specs.each do |spec|
    if (license = string_for_spec(spec))
      license = license.force_encoding("UTF-8") if license.respond_to?(:force_encoding)
      licenses_string += license
    end
  end
  licenses_string += "#{title_from_string(footnote_title, 2)}#{footnote_text}\n"
end

#save_as(path) ⇒ Object



10
11
12
13
14
# File 'lib/cocoapods/generator/acknowledgements/markdown.rb', line 10

def save_as(path)
  file = File.new(path, "w")
  file.write(licenses)
  file.close
end

#string_for_spec(spec) ⇒ Object



22
23
24
25
26
# File 'lib/cocoapods/generator/acknowledgements/markdown.rb', line 22

def string_for_spec(spec)
  if (license_text = license_text(spec))
    "\n" << title_from_string(spec.name, 2) << "\n\n" << license_text << "\n"
  end
end

#title_from_string(string, level) ⇒ Object



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

def title_from_string(string, level)
  if !string.empty?
    "#" * level << " #{string}"
  end
end