Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
cdad6fe4
Commit
cdad6fe4
authored
May 02, 2012
by
Will Pragnell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Plist Acknowledgements sub-class
parent
908327e6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
116 additions
and
69 deletions
+116
-69
cocoapods.rb
lib/cocoapods.rb
+1
-0
acknowledgements.rb
lib/cocoapods/generator/acknowledgements.rb
+6
-47
plist.rb
lib/cocoapods/generator/acknowledgements/plist.rb
+58
-0
plist_spec.rb
spec/unit/generator/acknowledgements/plist_spec.rb
+42
-0
acknowledgements_spec.rb
spec/unit/generator/acknowledgements_spec.rb
+9
-22
No files found.
lib/cocoapods.rb
View file @
cdad6fe4
...
...
@@ -31,6 +31,7 @@ module Pod
autoload
:CopyResourcesScript
,
'cocoapods/generator/copy_resources_script'
autoload
:Documentation
,
'cocoapods/generator/documentation'
autoload
:Acknowledgements
,
'cocoapods/generator/acknowledgements'
autoload
:Plist
,
'cocoapods/generator/acknowledgements/plist'
end
end
...
...
lib/cocoapods/generator/acknowledgements.rb
View file @
cdad6fe4
...
...
@@ -2,60 +2,19 @@ module Pod
module
Generator
class
Acknowledgements
require
"xcodeproj/xcodeproj_ext"
def
self
.
generators
[
Plist
]
end
def
initialize
(
target_definition
,
pods
)
@target_definition
,
@pods
=
target_definition
,
pods
end
def
save_as
(
path
)
Xcodeproj
.
write_plist
(
plist
,
path
)
end
def
plist
{
:Title
=>
"Acknowledgements"
,
:StringsTable
=>
"Acknowledgements"
,
:PreferenceSpecifiers
=>
licenses
}
end
def
licenses
licences_array
=
[
header
]
@pods
.
each
do
|
pod
|
if
(
hash
=
hash_for_pod
(
pod
))
licences_array
<<
hash
end
Acknowledgements
.
generators
.
each
do
|
generator
|
generator
.
new
(
@target_definition
,
@pods
).
save_as
(
path
)
end
licences_array
<<
footnote
end
def
hash_for_pod
(
pod
)
if
(
license
=
pod
.
license_text
)
{
:Type
=>
"PSGroupSpecifier"
,
:Title
=>
pod
.
name
,
:FooterText
=>
license
}
else
puts
"[!] No license 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
...
...
lib/cocoapods/generator/acknowledgements/plist.rb
0 → 100644
View file @
cdad6fe4
module
Pod
module
Generator
class
Plist
<
Acknowledgements
require
"xcodeproj/xcodeproj_ext"
def
save_as
(
path
)
Xcodeproj
.
write_plist
(
plist
,
path
)
end
def
plist
{
:Title
=>
"Acknowledgements"
,
:StringsTable
=>
"Acknowledgements"
,
:PreferenceSpecifiers
=>
licenses
}
end
def
licenses
licences_array
=
[
header_hash
]
@pods
.
each
do
|
pod
|
if
(
hash
=
hash_for_pod
(
pod
))
licences_array
<<
hash
end
end
licences_array
<<
footnote_hash
end
def
hash_for_pod
(
pod
)
if
(
license
=
pod
.
license_text
)
{
:Type
=>
"PSGroupSpecifier"
,
:Title
=>
pod
.
name
,
:FooterText
=>
license
}
else
puts
"[!] No license for
#{
pod
.
name
}
"
end
end
def
header_hash
{
:Type
=>
"PSGroupSpecifier"
,
:Title
=>
header_title
,
:FooterText
=>
header_text
}
end
def
footnote_hash
{
:Type
=>
"PSGroupSpecifier"
,
:Title
=>
footnote_title
,
:FooterText
=>
footnote_text
}
end
end
end
end
spec/unit/generator/acknowledgements/plist_spec.rb
0 → 100644
View file @
cdad6fe4
require
File
.
expand_path
(
"../../../../spec_helper"
,
__FILE__
)
describe
Pod
::
Generator
::
Plist
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
])
@plist
=
Pod
::
Generator
::
Plist
.
new
(
@target_definition
,
@pods
)
end
it
"returns the correct number of licenses (including header and footnote)"
do
@plist
.
licenses
.
count
.
should
==
3
end
# TODO Test with a pod that has no licence
it
"returns a correctly formed license hash for each pod"
do
@plist
.
hash_for_pod
(
@pods
[
0
]).
should
==
{
:Type
=>
"PSGroupSpecifier"
,
:Title
=>
"BananaLib"
,
:FooterText
=>
"Permission is hereby granted ..."
}
end
it
"returns a plist containg the licenses"
do
@plist
.
plist
.
should
==
{
:Title
=>
"Acknowledgements"
,
:StringsTable
=>
"Acknowledgements"
,
:PreferenceSpecifiers
=>
@plist
.
licenses
}
end
it
"writes a plist to disk"
do
path
=
@sandbox
.
root
+
"
#{
@target_definition
.
label
}
-Acknowledgements.plist"
@plist
.
save_as
(
path
).
should
.
be
.
true
end
end
spec/unit/generator/acknowledgements_spec.rb
View file @
cdad6fe4
...
...
@@ -14,29 +14,16 @@ describe Pod::Generator::Acknowledgements do
@acknowledgements
=
Pod
::
Generator
::
Acknowledgements
.
new
(
@target_definition
,
@pods
)
end
it
"returns the correct number of licenses (including header and footnote)"
do
@acknowledgements
.
licenses
.
count
.
should
==
3
end
# TODO Test with a pod that has no licence
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
}
it
"calls save_as on a Plist generator"
do
Pod
::
Generator
::
Plist
.
any_instance
.
expects
(
:save_as
)
path
=
@sandbox
.
root
+
"
#{
@target_definition
.
label
}
-Acknowledgements.plist"
@acknowledgements
.
save_as
(
path
)
end
it
"writes a plist to disk"
do
path
=
@sandbox
.
root
+
"
#{
@target_definition
.
label
}
-Acknowledgements.plist"
@acknowledgements
.
save_as
(
path
).
should
.
be
.
true
it
"returns a string for each header and footnote text method"
do
@acknowledgements
.
header_title
.
should
.
be
.
kind_of
(
String
)
@acknowledgements
.
header_text
.
should
.
be
.
kind_of
(
String
)
@acknowledgements
.
footnote_title
.
should
.
be
.
kind_of
(
String
)
@acknowledgements
.
footnote_text
.
should
.
be
.
kind_of
(
String
)
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment