Commit b72322f3 authored by Will Pragnell's avatar Will Pragnell

Fist pass at plist acknowledgements class

parent a6a86b85
......@@ -30,6 +30,7 @@ module Pod
autoload :BridgeSupport, 'cocoapods/generator/bridge_support'
autoload :CopyResourcesScript, 'cocoapods/generator/copy_resources_script'
autoload :Documentation, 'cocoapods/generator/documentation'
autoload :Acknowledgements, 'cocoapods/generator/acknowledgements'
end
end
......
module Pod
module Generator
class Acknowledgements
require 'xcodeproj/xcodeproj_ext'
def initialize(target_definition, pods)
@target_definition, @pods = target_definition, pods
end
def save_as(pathname)
Xcodeproj.write_plist(plist, pathname)
end
def plist
{
:Title => 'Acknowledgements',
:StringsTable => 'Acknowledgements',
:PreferenceSpecifiers => licenses
}
end
def licenses
licences_array = [header]
@pods.each { |pod| licences_array << hash_for_pod(pod) }
licences_array << footnote
end
def hash_for_pod(pod)
if (license = pod.license)
license_hash = {
:Type => 'PSGroupSpecifier',
:Title => pod.name,
:FooterText => license[:text]
}
else
puts '[!] No licence for #{pod.name}'
end
end
def header
{
:Type => 'PSGroupSpecifier',
:Title => header_title,
:FooterText => header_text
}
end
def footnote
{
:Type => 'PSGroupSpecifier',
:Title => footnote_title,
:FooterText => footnote_text
}
end
def header_title
'Acknowledgements'
end
def header_text
'This application uses the following third party software:'
end
def footnote_title
''
end
def footnote_text
'Generated by CocoaPods'
end
end
end
end
require File.expand_path('../../../spec_helper', __FILE__)
describe Pod::Generator::Acknowledgements do
before do
@podfile = Pod::Podfile.new do
platform :ios
xcodeproj 'dummy'
end
@target_definition = @podfile.target_definitions[:default]
@sandbox = temporary_sandbox
@pods = [Pod::LocalPod.new(fixture_spec('banana-lib/BananaLib.podspec'), @sandbox, Pod::Platform.ios)]
copy_fixture_to_pod('banana-lib', @pods[0])
@acknowledgements = Pod::Generator::Acknowledgements.new(@target_definition, @pods)
end
it 'returns the corrent number of licenses (including headera and footnote)' do
@acknowledgements.licenses.count.should == 3
end
it 'returns a correctly formed license hash for each pod' do
@acknowledgements.hash_for_pod(@pods[0]).should == {
:Type => 'PSGroupSpecifier',
:Title => 'BananaLib',
:FooterText => 'Permission is hereby granted ...'
}
end
it 'returns a plist containg the licenses' do
@acknowledgements.plist.should == {
:Title => 'Acknowledgements',
:StringsTable => 'Acknowledgements',
:PreferenceSpecifiers => @acknowledgements.licenses
}
end
it 'writes a plist to disk' do
@acknowledgements.save_as(@sandbox.root + 'test.plist').should.be.true
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