Commit f8774598 authored by Will Pragnell's avatar Will Pragnell

Completed basic implementation of Markdown Acknowledgements subclass

parent bcfb3240
...@@ -4,7 +4,7 @@ module Pod ...@@ -4,7 +4,7 @@ module Pod
class Acknowledgements class Acknowledgements
def self.generators def self.generators
[Plist] [Plist, Markdown]
end end
def initialize(target_definition, pods) def initialize(target_definition, pods)
......
...@@ -3,6 +3,12 @@ module Pod ...@@ -3,6 +3,12 @@ module Pod
class Markdown < Acknowledgements class Markdown < Acknowledgements
def save_as(path)
file = File.new(path, "w")
file.write(licenses)
file.close
end
def title_from_string(string) def title_from_string(string)
if string != "" if string != ""
"#{string}\n" + '-' * string.length + "\n" "#{string}\n" + '-' * string.length + "\n"
...@@ -18,10 +24,12 @@ module Pod ...@@ -18,10 +24,12 @@ module Pod
def licenses def licenses
licenses_string = "#{title_from_string(header_title)}#{header_text}\n" licenses_string = "#{title_from_string(header_title)}#{header_text}\n"
@pods.each do |pod| @pods.each do |pod|
licenses_string += string_for_pod(pod) if (license = string_for_pod(pod))
licenses_string += license
end
end end
licenses_string += "#{title_from_string(footnote_title)}#{footnote_text}\n" licenses_string += "#{title_from_string(footnote_title)}#{footnote_text}\n"
end end
end end
end end
end end
...@@ -33,8 +33,6 @@ module Pod ...@@ -33,8 +33,6 @@ module Pod
:Title => pod.name, :Title => pod.name,
:FooterText => license :FooterText => license
} }
else
puts "[!] No license for #{pod.name}"
end end
end end
......
...@@ -25,4 +25,12 @@ describe Pod::Generator::Markdown do ...@@ -25,4 +25,12 @@ describe Pod::Generator::Markdown do
it "returns a correctly formatted markdown string for the target" do it "returns a correctly formatted markdown string for the target" do
@markdown.licenses.should.equal "Acknowledgements\n----------------\nThis application makes use of the following third party libraries:\nBananaLib\n---------\nPermission is hereby granted ...\nGenerated by CocoaPods - http://cocoapods.org\n" @markdown.licenses.should.equal "Acknowledgements\n----------------\nThis application makes use of the following third party libraries:\nBananaLib\n---------\nPermission is hereby granted ...\nGenerated by CocoaPods - http://cocoapods.org\n"
end end
# TODO Test the we call File.new with the corret arguments
it "writes a markdown file to disk" do
path = @sandbox.root + "#{@target_definition.label}-Acknowledgements.markdown"
File.any_instance.expects(:write)
File.any_instance.expects(:close)
@markdown.save_as(path)
end
end end
...@@ -14,8 +14,9 @@ describe Pod::Generator::Acknowledgements do ...@@ -14,8 +14,9 @@ describe Pod::Generator::Acknowledgements do
@acknowledgements = Pod::Generator::Acknowledgements.new(@target_definition, @pods) @acknowledgements = Pod::Generator::Acknowledgements.new(@target_definition, @pods)
end end
it "calls save_as on a Plist generator" do it "calls save_as on both a Plist and a Markdown generator" do
Pod::Generator::Plist.any_instance.expects(:save_as) Pod::Generator::Plist.any_instance.expects(:save_as)
Pod::Generator::Markdown.any_instance.expects(:save_as)
path = @sandbox.root + "#{@target_definition.label}-Acknowledgements.plist" path = @sandbox.root + "#{@target_definition.label}-Acknowledgements.plist"
@acknowledgements.save_as(path) @acknowledgements.save_as(path)
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment