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
a5d5db1c
Commit
a5d5db1c
authored
Dec 19, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TargetIntegrator] Standadize generators usage.
parent
90a5ea6b
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
434 additions
and
394 deletions
+434
-394
Gemfile.lock
Gemfile.lock
+1
-1
markdown.rb
lib/cocoapods/generator/acknowledgements/markdown.rb
+4
-3
plist.rb
lib/cocoapods/generator/acknowledgements/plist.rb
+4
-3
installer.rb
lib/cocoapods/installer.rb
+1
-1
target_installer.rb
lib/cocoapods/installer/target_installer.rb
+122
-106
library.rb
lib/cocoapods/library.rb
+3
-17
local_pod.rb
lib/cocoapods/local_pod.rb
+5
-1
user_interface.rb
lib/cocoapods/user_interface.rb
+2
-1
integration_spec.rb
spec/integration_spec.rb
+5
-5
markdown_spec.rb
spec/unit/generator/acknowledgements/markdown_spec.rb
+2
-1
plist_spec.rb
spec/unit/generator/acknowledgements/plist_spec.rb
+2
-1
acknowledgements_spec.rb
spec/unit/generator/acknowledgements_spec.rb
+3
-5
target_installer_spec.rb
spec/unit/installer/target_installer_spec.rb
+13
-1
library_spec.rb
spec/unit/library_spec.rb
+2
-10
local_pod_spec.rb
spec/unit/local_pod_spec.rb
+265
-238
No files found.
Gemfile.lock
View file @
a5d5db1c
GIT
remote: git://github.com/CocoaPods/Core.git
revision: 4
63b02c0c1cd6d0b77ee2ef3efab1334f8066fc8
revision: 4
23f7364a74324db85238d3e8f8587b8191d7372
specs:
cocoapods-core (0.17.0.alpha)
activesupport (~> 3.2.6)
...
...
lib/cocoapods/generator/acknowledgements/markdown.rb
View file @
a5d5db1c
...
...
@@ -3,10 +3,11 @@ module Pod
class
Markdown
<
Acknowledgements
def
self
.
path_from_basepath
(
path
)
Pathname
.
new
(
path
.
dirname
+
"
#{
path
.
basename
.
to_s
}
.markdown"
)
end
def
save_as
(
path
)
if
(
path
.
extname
!=
".markdown"
)
path
=
Pathname
.
new
(
path
.
dirname
+
"
#{
path
.
basename
.
to_s
}
.markdown"
)
end
file
=
File
.
new
(
path
,
"w"
)
file
.
write
(
licenses
)
file
.
close
...
...
lib/cocoapods/generator/acknowledgements/plist.rb
View file @
a5d5db1c
...
...
@@ -4,10 +4,11 @@ module Pod
class
Plist
<
Acknowledgements
require
"xcodeproj/xcodeproj_ext"
def
self
.
path_from_basepath
(
path
)
Pathname
.
new
(
path
.
dirname
+
"
#{
path
.
basename
.
to_s
}
.plist"
)
end
def
save_as
(
path
)
if
(
path
.
extname
!=
".plist"
)
path
=
Pathname
.
new
(
path
.
dirname
+
"
#{
path
.
basename
.
to_s
}
.plist"
)
end
Xcodeproj
.
write_plist
(
plist
,
path
)
end
...
...
lib/cocoapods/installer.rb
View file @
a5d5db1c
...
...
@@ -403,8 +403,8 @@ module Pod
#
def
write_pod_project
UI
.
message
"- Writing Xcode project file to
#{
UI
.
path
sandbox
.
project_path
}
"
do
pods_project
[
'Frameworks'
].
sort_by_type!
pods_project
.
main_group
.
sort_by_type!
pods_project
[
'Frameworks'
].
sort_by_type!
pods_project
.
save_as
(
sandbox
.
project_path
)
end
end
...
...
lib/cocoapods/installer/target_installer.rb
View file @
a5d5db1c
...
...
@@ -2,27 +2,27 @@ module Pod
class
Installer
# Controller class responsible of creating and configuring the static
# library target in Pods project.
Every target is generated from a target
#
definition of the Podfile
.
# library target in Pods project.
It also creates the support file needed
#
by the target
.
#
class
TargetInstaller
# @param [Project]
project @see project
# @param [
TargetDefinition] target_definition @see target_definition
# @param [Project] project @see project
# @param [
Library] library @see library
#
def
initialize
(
sandbox
,
library
)
@sandbox
=
sandbox
@library
=
library
end
# Creates the target in the Pods project and
its
support files.
# Creates the target in the Pods project and
the relative
support files.
#
# @return [void]
#
def
install!
add_file_reference_for_support_files
add_target
add_pod_references
create_suport_files_group
create_xcconfig_file
create_prefix_header
...
...
@@ -34,12 +34,12 @@ module Pod
#-----------------------------------------------------------------------#
public
# @!group API
#
# This is the tentative API for the podfile and the specification hooks.
public
# @return [Sandbox] sandbox the sandbox where the support files should
# be generated.
#
...
...
@@ -56,6 +56,24 @@ module Pod
#
attr_reader
:target
# @return [Project] the Pods project of the sandbox.
#
def
project
sandbox
.
project
end
# @return [Array<LocalPod>] the local pods of this target.
#
def
pods
library
.
local_pods
end
# @return [TargetDefinition] the target definition of the library.
#
def
target_definition
library
.
target_definition
end
#--------------------------------------#
# @!group Hooks compatiblity
...
...
@@ -65,49 +83,39 @@ module Pod
#
def
prefix_header_filename
UI
.
warn
"The usage of the TargetInstaller#prefix_header_filename is deprecated."
library
.
prefix_header_
name
library
.
prefix_header_
path
.
relative_path_from
(
sandbox
.
root
)
end
#-----------------------------------------------------------------------#
# @!group Installation steps
private
# Adds the file references for the support files that are generated by
# the installation process to the Pods project.
#
# @return [void]
#
def
add_file_reference_for_support_files
g
=
project
.
support_files_group
.
new_group
(
target_definition
.
label
)
g
.
new_file
(
library
.
copy_resources_script_name
)
g
.
new_file
(
library
.
prefix_header_name
)
@xcconfig_file_ref
=
g
.
new_file
(
library
.
xcconfig_name
)
end
# @!group Installation steps
# Adds the target for the library to the Pods project with the
# appropriate build configurations.
#
# @note The `PODS_HEADERS_SEARCH_PATHS` overrides the xcconfig.
#
# @todo Should we add the build configurations only to the target?
# @todo Add integration test for build configurations and don't add the
# build configurations to the project if they are not needed.
#
# @return [void]
#
def
add_target
name
=
library
.
label
name
=
library
.
label
platform
=
library
.
platform
.
name
settings
=
build_settings_for_platform
(
library
.
platform
)
settings
[
'GCC_PREFIX_HEADER'
]
=
library
.
prefix_header_name
if
target_definition
.
inhibit_all_warnings?
settings
[
'GCC_WARN_INHIBIT_ALL_WARNINGS'
]
=
'YES'
deployment_target
=
library
.
platform
.
deployment_target
.
to_s
@target
=
project
.
new_target
(
:static_library
,
name
,
platform
,
deployment_target
)
settings
=
{}
if
library
.
platform
.
requires_legacy_ios_archs?
settings
[
'ARCHS'
]
=
"armv6 armv7"
end
Generator
::
XCConfig
.
pods_project_settings
.
each
do
|
key
,
value
|
settings
[
key
]
=
value
if
target_definition
.
inhibit_all_warnings?
settings
[
'GCC_WARN_INHIBIT_ALL_WARNINGS'
]
=
'YES'
end
@target
=
project
.
new_target
(
:static_library
,
name
,
platform
)
@target
.
build_settings
(
'Debug'
).
merge!
(
settings
)
@target
.
build_settings
(
'Release'
).
merge!
(
settings
)
...
...
@@ -122,10 +130,6 @@ module Pod
end
end
@target
.
build_configurations
.
each
do
|
c
|
c
.
base_configuration_reference
=
xcconfig_file_ref
end
library
.
target
=
@target
end
...
...
@@ -147,6 +151,18 @@ module Pod
end
end
# Creates the group that holds the references to the support files
# generated by this installer.
#
# @return [void]
#
def
create_suport_files_group
name
=
target_definition
.
label
@support_files_group
=
project
.
support_files_group
.
new_group
(
name
)
end
#--------------------------------------#
# Generates the contents of the xcconfig file and saves it to disk.
#
# @note The `ALWAYS_SEARCH_USER_PATHS` flag is enabled to support
...
...
@@ -155,30 +171,46 @@ module Pod
# @return [void]
#
def
create_xcconfig_file
UI
.
message
"- Generating xcconfig file at
#{
UI
.
path
(
library
.
xcconfig_path
)
}
"
do
path
=
library
.
xcconfig_path
UI
.
message
"- Generating xcconfig file at
#{
UI
.
path
(
path
)
}
"
do
gen
=
Generator
::
XCConfig
.
new
(
sandbox
,
pods
,
library
.
relative_pods_root
)
gen
.
set_arc_compatibility_flag
=
target_definition
.
podfile
.
set_arc_compatibility_flag?
gen
.
save_as
(
library
.
xcconfig_
path
)
gen
.
save_as
(
path
)
library
.
xcconfig
=
gen
.
xcconfig
xcconfig_file_ref
=
add_file_to_support_group
(
path
)
target
.
build_configurations
.
each
do
|
c
|
c
.
base_configuration_reference
=
xcconfig_file_ref
Generator
::
XCConfig
.
pods_project_settings
.
each
do
|
key
,
value
|
c
.
build_settings
[
key
]
=
value
end
end
end
end
# Creates a prefix header file which imports `UIKit` or `Cocoa`
. This
#
file also include any prefix header content reported by the
# specification of the pods.
# Creates a prefix header file which imports `UIKit` or `Cocoa`
according
#
to the platform of the target. This file also include any prefix header
#
content reported by the
specification of the pods.
#
# @return [void]
#
def
create_prefix_header
UI
.
message
"- Generating prefix header at
#{
UI
.
path
(
library
.
prefix_header_path
)
}
"
do
path
=
library
.
prefix_header_path
UI
.
message
"- Generating prefix header at
#{
UI
.
path
(
path
)
}
"
do
gen
=
Generator
::
PrefixHeader
.
new
(
target_definition
.
platform
,
pods
)
gen
.
save_as
(
library
.
prefix_header_path
)
gen
.
save_as
(
path
)
add_file_to_support_group
(
path
)
target
.
build_configurations
.
each
do
|
c
|
relative_path
=
path
.
relative_path_from
(
sandbox
.
root
)
c
.
build_settings
[
'GCC_PREFIX_HEADER'
]
=
relative_path
.
to_s
end
end
end
# Generates the bridge support metadata if requested by the {Podfile}.
#
# @note
t
he bridge support metadata is added to the resources of the
# @note
T
he bridge support metadata is added to the resources of the
# library because it is needed for environments interpreted at
# runtime.
#
...
...
@@ -186,12 +218,14 @@ module Pod
#
def
create_bridge_support_file
if
target_definition
.
podfile
.
generate_bridge_support?
UI
.
message
"- Generating BridgeSupport metadata at
#{
UI
.
path
library
.
bridge_support_path
}
"
do
generator
=
Generator
::
BridgeSupport
.
new
(
pods
.
map
do
|
pod
|
pod
.
relative_header_files
.
map
{
|
header
|
sandbox
.
root
+
header
}
end
.
flatten
)
generator
.
save_as
(
library
.
bridge_support_path
)
copy_resources_script
.
resources
<<
library
.
bridge_support_name
path
=
library
.
bridge_support_path
UI
.
message
"- Generating BridgeSupport metadata at
#{
UI
.
path
(
path
)
}
"
do
relative_headers
=
pods
.
map
{
|
pod
|
pod
.
relative_header_files
}.
flatten
headers
=
relative_headers
.
map
{
|
header
|
sandbox
.
root
+
header
}
generator
=
Generator
::
BridgeSupport
.
new
(
headers
)
generator
.
save_as
(
path
)
add_file_to_support_group
(
path
)
@bridge_support_file
=
path
.
relative_path_from
(
sandbox
.
root
)
end
end
end
...
...
@@ -199,14 +233,19 @@ module Pod
# Creates a script that copies the resources to the bundle of the client
# target.
#
# @todo This should be replaced by an Xcode copy resources build phase.
# @note The bridge support file needs to be created before the prefix
# header, otherwise it will not be added to the resources script.
#
# @return [void]
#
def
create_copy_resources_script
UI
.
message
"- Generating copy resources script at
#{
UI
.
path
(
library
.
copy_resources_script_path
)
}
"
do
copy_resources_script
.
resources
<<
pods
.
map
{
|
p
|
p
.
relative_resource_files
}.
flatten
copy_resources_script
.
save_as
(
library
.
copy_resources_script_path
)
path
=
library
.
copy_resources_script_path
UI
.
message
"- Generating copy resources script at
#{
UI
.
path
(
path
)
}
"
do
resources
=
pods
.
map
{
|
p
|
p
.
relative_resource_files
}.
flatten
resources
<<
bridge_support_file
if
bridge_support_file
generator
=
Generator
::
CopyResourcesScript
.
new
(
resources
)
generator
.
save_as
(
path
)
add_file_to_support_group
(
path
)
end
end
...
...
@@ -215,8 +254,15 @@ module Pod
# @return [void]
#
def
create_acknowledgements
path
=
library
.
acknowledgements_path
Generator
::
Acknowledgements
.
new
(
target_definition
,
pods
).
save_as
(
path
)
basepath
=
library
.
acknowledgements_basepath
Generator
::
Acknowledgements
.
generators
.
each
do
|
generator_class
|
path
=
generator_class
.
path_from_basepath
(
basepath
)
UI
.
message
"- Generating acknowledgements at
#{
UI
.
path
(
path
)
}
"
do
generator
=
generator_class
.
new
(
target_definition
,
pods
)
generator
.
save_as
(
path
)
add_file_to_support_group
(
path
)
end
end
end
# Generates a dummy source file for each target so libraries that contain
...
...
@@ -226,73 +272,43 @@ module Pod
#
def
create_dummy_source
path
=
library
.
dummy_source_path
Generator
::
DummySource
.
new
(
library
.
label
).
save_as
(
path
)
relative_path
=
path
.
relative_path_from
(
sandbox
.
root
)
file_reference
=
project
.
new_file
(
relative_path
,
"Targets Support Files"
)
target
.
source_build_phase
.
add_file_reference
(
file_reference
)
UI
.
message
"- Generating acknowledgements at
#{
UI
.
path
(
path
)
}
"
do
generator
=
Generator
::
DummySource
.
new
(
library
.
label
)
generator
.
save_as
(
path
)
file_reference
=
add_file_to_support_group
(
path
)
target
.
source_build_phase
.
add_file_reference
(
file_reference
)
end
end
#-----------------------------------------------------------------------#
# @!group Private helpers.
private
# @return [PBXFileReference] the file reference to the xcconfig file of
# the target.
#
# @note Generated by the {#add_file_reference_for_support_files} step.
#
attr_reader
:xcconfig_file_ref
# @return [Project] the Pods project of the sandbox.
#
def
project
sandbox
.
project
end
def
pods
library
.
local_pods
end
# @!group Private helpers.
# @return [TargetDefinition] the target definition of the library.
# @return [PBXGroup] the group where the file references to the support
# files should be stored.
#
def
target_definition
library
.
target_definition
end
attr_reader
:support_files_group
# Creates and caches the copy resource script.
# @return [Pathname] the path of the bridge support file relative to the
# sandbox.
#
# @return [
CopyResourcesScript]
# @return [
Nil] if no bridge support file was generated.
#
def
copy_resources_script
@copy_resources_script
||=
Generator
::
CopyResourcesScript
.
new
end
attr_reader
:bridge_support_file
#
Returns the Xcode build settings for a target with the given platform
.
#
Adds a reference to the given file in the support group of this target
.
#
# @param [P
latform] platform
#
the platform for which the build settings are nee
ded.
# @param [P
athname] path
#
The path of the file to which the reference should be ad
ded.
#
# @return [
Hash] the build settings
.
# @return [
PBXFileReference] the file reference of the added file
.
#
def
build_settings_for_platform
(
platform
)
settings
=
{}
settings
[
'ARCHS'
]
=
"armv6 armv7"
if
platform
.
requires_legacy_ios_archs?
if
dt
=
platform
.
deployment_target
if
platform
==
:ios
settings
[
'IPHONEOS_DEPLOYMENT_TARGET'
]
=
dt
.
to_s
elsif
platform
==
:osx
settings
[
'MACOSX_DEPLOYMENT_TARGET'
]
=
dt
.
to_s
else
raise
Informative
,
"Unknown platform
#{
platform
}
"
end
end
settings
def
add_file_to_support_group
(
path
)
relative_path
=
path
.
relative_path_from
(
sandbox
.
root
)
support_files_group
.
new_file
(
relative_path
)
end
end
end
end
...
...
lib/cocoapods/library.rb
View file @
a5d5db1c
...
...
@@ -142,30 +142,16 @@ module Pod
"${SRCROOT}/
#{
relative_to_srcroot
(
"
#{
copy_resources_script_name
}
"
)
}
"
end
# @return [String] the name of the prefix header file relative to this
# target.
#
def
prefix_header_name
"
#{
label
}
-prefix.pch"
end
# @return [Pathname] the absolute path of the prefix header file.
#
def
prefix_header_path
support_files_root
+
prefix_header_name
end
# @return [String] the name of the bridge support file relative to this
# target.
#
def
bridge_support_name
"
#{
label
}
.bridgesupport"
support_files_root
+
"
#{
label
}
-prefix.pch"
end
# @return [Pathname] the absolute path of the bridge support file.
#
def
bridge_support_path
support_files_root
+
bridge_support_name
support_files_root
+
"
#{
label
}
.bridgesupport"
end
# @return [Pathname] the absolute path of acknowledgements file.
...
...
@@ -173,7 +159,7 @@ module Pod
# @note The acknowledgements generators add the extension according to
# the file type.
#
def
acknowledgements_path
def
acknowledgements_
base
path
support_files_root
+
"
#{
label
}
-Acknowledgements"
end
...
...
lib/cocoapods/local_pod.rb
View file @
a5d5db1c
...
...
@@ -407,8 +407,12 @@ module Pod
config
end
# Returns also weak frameworks.
#
def
frameworks
specifications
.
map
{
|
spec
|
spec
.
frameworks
}.
flatten
.
uniq
frameworks
=
specifications
.
map
{
|
spec
|
spec
.
frameworks
}
weak_frameworks
=
specifications
.
map
{
|
spec
|
spec
.
weak_frameworks
}
(
frameworks
+
weak_frameworks
).
flatten
.
uniq
end
# Computes the paths of all the public headers of the pod including every
...
...
lib/cocoapods/user_interface.rb
View file @
a5d5db1c
...
...
@@ -135,7 +135,8 @@ module Pod
#
def
path
(
pathname
)
if
pathname
"`./
#{
pathname
.
relative_path_from
(
config
.
podfile_path
.
dirname
||
Pathname
.
pwd
)
}
'"
path
=
pathname
.
relative_path_from
(
config
.
podfile_path
.
dirname
||
Pathname
.
pwd
)
"`
#{
path
}
`"
else
''
end
...
...
spec/integration_spec.rb
View file @
a5d5db1c
...
...
@@ -127,7 +127,7 @@ module Pod
# @note ASIHTTPRequest depends on Reachability in iOS.
#
it
"creates targets for different platforms"
do
x
it
"creates targets for different platforms"
do
podfile
=
Podfile
.
new
do
platform
:ios
xcodeproj
'dummy'
...
...
@@ -290,14 +290,16 @@ module Pod
root
=
config
.
project_pods_root
(
root
+
'Pods.xcconfig'
).
read
.
should
==
installer
.
libraries
.
first
.
xcconfig
.
to_s
project_file
=
(
root
+
'Pods.xcodeproj/project.pbxproj'
).
to_s
Xcodeproj
.
read_plist
(
project_file
).
should
==
installer
.
project
.
to_hash
saved_project
=
Xcodeproj
.
read_plist
(
project_file
)
saved_project
.
to_hash
.
recursive_diff
(
installer
.
project
.
to_hash
).
should
.
be
.
nil
saved_project
.
should
==
installer
.
project
.
to_hash
should_xcodebuild
(
podfile
.
target_definitions
[
:default
])
end
#--------------------------------------#
it
"adds resources to the xcode copy script"
do
x
it
"adds resources to the xcode copy script"
do
podfile
=
Podfile
.
new
do
platform
test_platform
xcodeproj
'dummy'
...
...
@@ -317,8 +319,6 @@ module Pod
#--------------------------------------#
# @todo we need to do more cleaning and/or add a --prune task
#
it
"overwrites an existing project.pbxproj file"
do
podfile
=
Podfile
.
new
do
platform
test_platform
...
...
spec/unit/generator/acknowledgements/markdown_spec.rb
View file @
a5d5db1c
...
...
@@ -29,7 +29,8 @@ describe Pod::Generator::Markdown do
end
it
"writes a markdown file to disk"
do
given_path
=
@sandbox
.
root
+
"Pods-Acknowledgements"
basepath
=
@sandbox
.
root
+
"Pods-Acknowledgements"
given_path
=
@markdown
.
class
.
path_from_basepath
(
basepath
)
expected_path
=
@sandbox
.
root
+
"Pods-Acknowledgements.markdown"
mockFile
=
mock
mockFile
.
expects
(
:write
).
with
(
equals
(
@markdown
.
licenses
))
...
...
spec/unit/generator/acknowledgements/plist_spec.rb
View file @
a5d5db1c
...
...
@@ -44,7 +44,8 @@ describe Pod::Generator::Plist do
end
it
"writes a plist to disk at the given path"
do
given_path
=
@sandbox
.
root
+
"Pods-Acknowledgements"
basepath
=
@sandbox
.
root
+
"Pods-Acknowledgements"
given_path
=
@plist
.
class
.
path_from_basepath
(
basepath
)
expected_path
=
@sandbox
.
root
+
"Pods-Acknowledgements.plist"
Xcodeproj
.
expects
(
:write_plist
).
with
(
equals
(
@plist
.
plist
),
equals
(
expected_path
))
@plist
.
save_as
(
given_path
)
...
...
spec/unit/generator/acknowledgements_spec.rb
View file @
a5d5db1c
...
...
@@ -8,11 +8,9 @@ describe Pod::Generator::Acknowledgements do
@acknowledgements
=
Pod
::
Generator
::
Acknowledgements
.
new
(
@target_definition
,
@pods
)
end
it
"calls save_as on both a Plist and a Markdown generator"
do
path
=
@sandbox
.
root
+
"Pods-Acknowledgements.plist"
Pod
::
Generator
::
Plist
.
any_instance
.
expects
(
:save_as
).
with
(
equals
(
path
))
Pod
::
Generator
::
Markdown
.
any_instance
.
expects
(
:save_as
).
with
(
equals
(
path
))
@acknowledgements
.
save_as
(
path
)
it
"the the generators"
do
generators
=
Pod
::
Generator
::
Acknowledgements
.
generators
generators
.
map
{
|
g
|
g
.
name
.
split
(
'::'
).
last
}.
should
==
[
'Plist'
,
'Markdown'
]
end
it
"returns a string for each header and footnote text method"
do
...
...
spec/unit/installer/target_installer_spec.rb
View file @
a5d5db1c
...
...
@@ -34,7 +34,12 @@ module Pod
@installer
.
install!
group
=
@project
.
support_files_group
[
'Pods'
]
group
.
children
.
map
(
&
:display_name
).
sort
.
should
==
[
"Pods-prefix.pch"
,
"Pods-resources.sh"
,
"Pods.xcconfig"
"Pods-Acknowledgements.markdown"
,
"Pods-Acknowledgements.plist"
,
"Pods-Dummy.m"
,
"Pods-prefix.pch"
,
"Pods-resources.sh"
,
"Pods.xcconfig"
]
end
...
...
@@ -126,6 +131,13 @@ module Pod
names
.
should
.
include
(
"Banana.m"
)
end
it
'adds the frameworks required by to the pod to the project for informative purposes'
do
Specification
.
any_instance
.
stubs
(
:frameworks
).
returns
([
'QuartzCore'
])
@installer
.
install!
names
=
@installer
.
project
[
'Frameworks'
].
children
.
map
(
&
:name
)
names
.
sort
.
should
==
[
"Foundation.framework"
,
"QuartzCore.framework"
]
end
#--------------------------------------#
it
"creates and xcconfig file"
do
...
...
spec/unit/library_spec.rb
View file @
a5d5db1c
...
...
@@ -58,24 +58,16 @@ module Pod
@lib
.
copy_resources_script_relative_path
.
should
==
'${SRCROOT}/Pods/Pods-resources.sh'
end
it
"returns the prefix header file name"
do
@lib
.
prefix_header_name
.
should
==
'Pods-prefix.pch'
end
it
"returns the absolute path of the prefix header file"
do
@lib
.
prefix_header_path
.
to_s
.
should
.
include?
(
'Pods/Pods-prefix.pch'
)
end
it
"returns the bridge support file name"
do
@lib
.
bridge_support_name
.
should
==
'Pods.bridgesupport'
end
it
"returns the absolute path of the bridge support file"
do
@lib
.
bridge_support_path
.
to_s
.
should
.
include?
(
'Pods/Pods.bridgesupport'
)
end
it
"returns the absolute path of the acknowledgements file"
do
@lib
.
acknowledgements_path
.
to_s
.
should
.
include?
(
'Pods/Pods-Acknowledgements'
)
it
"returns the absolute path of the acknowledgements file
s without extension
"
do
@lib
.
acknowledgements_
base
path
.
to_s
.
should
.
include?
(
'Pods/Pods-Acknowledgements'
)
end
end
end
...
...
spec/unit/local_pod_spec.rb
View file @
a5d5db1c
require
File
.
expand_path
(
'../../spec_helper'
,
__FILE__
)
describe
Pod
::
LocalPod
do
describe
"in general"
do
before
do
@sandbox
=
temporary_sandbox
@spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@pod
=
Pod
::
LocalPod
.
new
(
@spec
,
@sandbox
,
Pod
::
Platform
.
new
(
:ios
))
copy_fixture_to_pod
(
'banana-lib'
,
@pod
)
end
module
Pod
describe
LocalPod
do
describe
"in general"
do
before
do
@sandbox
=
temporary_sandbox
@spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@pod
=
LocalPod
.
new
(
@spec
,
@sandbox
,
Platform
.
new
(
:ios
))
copy_fixture_to_pod
(
'banana-lib'
,
@pod
)
end
it
"returns the Pod root directory path"
do
@pod
.
root
.
should
==
@sandbox
.
root
+
'BananaLib'
end
it
"returns the Pod root directory path"
do
@pod
.
root
.
should
==
@sandbox
.
root
+
'BananaLib'
end
it
"creates it's own root directory if it doesn't exist"
do
@pod
.
create
File
.
directory?
(
@pod
.
root
).
should
.
be
.
true
end
it
"creates it's own root directory if it doesn't exist"
do
@pod
.
create
File
.
directory?
(
@pod
.
root
).
should
.
be
.
true
end
it
"can execute a block within the context of it's root"
do
@pod
.
chdir
{
FileUtils
.
touch
(
"foo"
)
}
Pathname
(
@pod
.
root
+
"foo"
).
should
.
exist
end
it
"can execute a block within the context of it's root"
do
@pod
.
chdir
{
FileUtils
.
touch
(
"foo"
)
}
Pathname
(
@pod
.
root
+
"foo"
).
should
.
exist
end
it
"can delete itself"
do
@pod
.
create
@pod
.
implode
@pod
.
root
.
should
.
not
.
exist
end
it
"can delete itself"
do
@pod
.
create
@pod
.
implode
@pod
.
root
.
should
.
not
.
exist
end
it
"returns an expanded list of source files, relative to the sandbox root"
do
@pod
.
relative_source_files
.
sort
.
should
==
[
Pathname
.
new
(
"BananaLib/Classes/Banana.m"
),
Pathname
.
new
(
"BananaLib/Classes/Banana.h"
)
].
sort
end
it
"returns an expanded list of source files, relative to the sandbox root"
do
@pod
.
relative_source_files
.
sort
.
should
==
[
Pathname
.
new
(
"BananaLib/Classes/Banana.m"
),
Pathname
.
new
(
"BananaLib/Classes/Banana.h"
)
].
sort
end
it
"returns the source files grouped by specification"
do
files
=
@pod
.
source_files_by_spec
[
@pod
.
specifications
.
first
].
sort
files
.
should
==
[
@pod
.
root
+
"Classes/Banana.m"
,
@pod
.
root
+
"Classes/Banana.h"
].
sort
end
it
"returns the source files grouped by specification"
do
files
=
@pod
.
source_files_by_spec
[
@pod
.
specifications
.
first
].
sort
files
.
should
==
[
@pod
.
root
+
"Classes/Banana.m"
,
@pod
.
root
+
"Classes/Banana.h"
].
sort
end
it
"returns a list of header files"
do
@pod
.
relative_header_files
.
should
==
[
Pathname
.
new
(
"BananaLib/Classes/Banana.h"
)]
end
it
"returns a list of header files"
do
@pod
.
relative_header_files
.
should
==
[
Pathname
.
new
(
"BananaLib/Classes/Banana.h"
)]
end
it
"returns a list of header files by specification"
do
files
=
@pod
.
header_files_by_spec
[
@pod
.
specifications
.
first
].
sort
files
.
should
==
[
@pod
.
root
+
"Classes/Banana.h"
]
end
it
"returns a list of header files by specification"
do
files
=
@pod
.
header_files_by_spec
[
@pod
.
specifications
.
first
].
sort
files
.
should
==
[
@pod
.
root
+
"Classes/Banana.h"
]
end
it
"returns an expanded list the files to clean"
do
clean_paths
=
@pod
.
clean_paths
.
map
{
|
p
|
p
.
to_s
.
gsub
(
/.*Pods\/BananaLib/
,
''
)
}
clean_paths
.
should
.
include
"/.git/config"
# * There are some hidden files on Travis
# * The submodule of the repo (libPusher) can be ignore, to reduce noise of this test
clean_files_without_hidden
=
clean_paths
.
reject
{
|
p
|
p
.
to_s
.
include?
(
'/.'
)
||
p
.
to_s
.
include?
(
'libPusher'
)
}
clean_files_without_hidden
.
should
==
%W[ /sub-dir /sub-dir/sub-dir-2 /sub-dir/sub-dir-2/somefile.txt ]
end
it
"returns an expanded list the files to clean"
do
clean_paths
=
@pod
.
clean_paths
.
map
{
|
p
|
p
.
to_s
.
gsub
(
/.*Pods\/BananaLib/
,
''
)
}
clean_paths
.
should
.
include
"/.git/config"
# * There are some hidden files on Travis
# * The submodule of the repo (libPusher) can be ignore, to reduce noise of this test
clean_files_without_hidden
=
clean_paths
.
reject
{
|
p
|
p
.
to_s
.
include?
(
'/.'
)
||
p
.
to_s
.
include?
(
'libPusher'
)
}
clean_files_without_hidden
.
should
==
%W[ /sub-dir /sub-dir/sub-dir-2 /sub-dir/sub-dir-2/somefile.txt ]
end
it
"returns an expanded list of resources, relative to the sandbox root"
do
@pod
.
relative_resource_files
.
should
==
[
Pathname
.
new
(
"BananaLib/Resources/logo-sidebar.png"
)]
end
it
"returns an expanded list of resources, relative to the sandbox root"
do
@pod
.
relative_resource_files
.
should
==
[
Pathname
.
new
(
"BananaLib/Resources/logo-sidebar.png"
)]
end
it
"can link it's headers into the sandbox"
do
@pod
.
link_headers
expected_header_path
=
@sandbox
.
build_headers
.
root
+
"BananaLib/Banana.h"
expected_header_path
.
should
.
be
.
symlink
File
.
read
(
expected_header_path
).
should
==
(
@sandbox
.
root
+
@pod
.
header_files
[
0
]).
read
end
it
"can link it's headers into the sandbox"
do
@pod
.
link_headers
expected_header_path
=
@sandbox
.
build_headers
.
root
+
"BananaLib/Banana.h"
expected_header_path
.
should
.
be
.
symlink
File
.
read
(
expected_header_path
).
should
==
(
@sandbox
.
root
+
@pod
.
header_files
[
0
]).
read
end
it
"can link it's public headers into the sandbox"
do
@pod
.
link_headers
expected_header_path
=
@sandbox
.
public_headers
.
root
+
"BananaLib/Banana.h"
expected_header_path
.
should
.
be
.
symlink
File
.
read
(
expected_header_path
).
should
==
(
@sandbox
.
root
+
@pod
.
header_files
[
0
]).
read
end
it
"can link it's public headers into the sandbox"
do
@pod
.
link_headers
expected_header_path
=
@sandbox
.
public_headers
.
root
+
"BananaLib/Banana.h"
expected_header_path
.
should
.
be
.
symlink
File
.
read
(
expected_header_path
).
should
==
(
@sandbox
.
root
+
@pod
.
header_files
[
0
]).
read
end
it
"can add it's source files to an Xcode project target"
do
project
=
Pod
::
Project
.
new
()
@pod
.
add_file_references_to_project
(
project
)
project
[
'Pods/BananaLib/Banana.h'
].
path
.
should
==
"BananaLib/Classes/Banana.h"
project
[
'Pods/BananaLib/Banana.m'
].
path
.
should
==
"BananaLib/Classes/Banana.m"
end
it
"can add it's source files to an Xcode project target"
do
project
=
Project
.
new
()
@pod
.
add_file_references_to_project
(
project
)
project
[
'Pods/BananaLib/Banana.h'
].
path
.
should
==
"BananaLib/Classes/Banana.h"
project
[
'Pods/BananaLib/Banana.m'
].
path
.
should
==
"BananaLib/Classes/Banana.m"
end
it
"can add it's source files to a target with any specially configured compiler flags"
do
project
=
Pod
::
Project
.
new
()
target
=
project
.
new_target
(
:static
,
'Pods'
,
:ios
)
@pod
.
top_specification
.
compiler_flags
=
'-d some_flag'
@pod
.
add_file_references_to_project
(
project
)
@pod
.
add_build_files_to_target
(
target
)
it
"can add it's source files to a target with any specially configured compiler flags"
do
project
=
Project
.
new
()
target
=
project
.
new_target
(
:static
,
'Pods'
,
:ios
)
@pod
.
top_specification
.
compiler_flags
=
'-d some_flag'
@pod
.
add_file_references_to_project
(
project
)
@pod
.
add_build_files_to_target
(
target
)
h_build_file
=
target
.
headers_build_phase
.
files
.
first
h_build_file
.
file_ref
.
path
.
should
==
"BananaLib/Classes/Banana.h"
h_build_file
.
settings
.
should
==
{
"ATTRIBUTES"
=>
[
"Public"
]}
h_build_file
=
target
.
headers_build_phase
.
files
.
first
h_build_file
.
file_ref
.
path
.
should
==
"BananaLib/Classes/Banana.h"
h_build_file
.
settings
.
should
==
{
"ATTRIBUTES"
=>
[
"Public"
]}
m_build_file
=
target
.
source_build_phase
.
files
.
first
m_build_file
.
file_ref
.
path
.
should
==
"BananaLib/Classes/Banana.m"
m_build_file
.
settings
.
should
==
{
"COMPILER_FLAGS"
=>
"-d some_flag"
}
end
m_build_file
=
target
.
source_build_phase
.
files
.
first
m_build_file
.
file_ref
.
path
.
should
==
"BananaLib/Classes/Banana.m"
m_build_file
.
settings
.
should
==
{
"COMPILER_FLAGS"
=>
"-d some_flag"
}
end
it
"returns the platform"
do
@pod
.
platform
.
should
==
:ios
end
it
"returns the platform"
do
@pod
.
platform
.
should
==
:ios
end
it
"raises if the files are accessed before creating the pod dir"
do
@pod
.
implode
lambda
{
@pod
.
source_files
}.
should
.
raise
Pod
::
Informative
it
"raises if the files are accessed before creating the pod dir"
do
@pod
.
implode
lambda
{
@pod
.
source_files
}.
should
.
raise
Informative
end
end
end
#---------------------------------------------------------------------------#
#---------------------------------------------------------------------------#
describe
"with installed source and multiple subspecs"
do
describe
"with installed source and multiple subspecs"
do
def
assert_array_equals
(
expected
,
computed
)
delta1
=
computed
-
expected
delta1
.
should
==
[]
delta2
=
expected
-
computed
delta2
.
should
==
[]
end
def
assert_array_equals
(
expected
,
computed
)
delta1
=
computed
-
expected
delta1
.
should
==
[]
delta2
=
expected
-
computed
delta2
.
should
==
[]
end
before
do
@sandbox
=
temporary_sandbox
subspecs
=
fixture_spec
(
'chameleon/Chameleon.podspec'
).
subspecs
@pod
=
Pod
::
LocalPod
.
new
(
subspecs
[
0
],
@sandbox
,
Pod
::
Platform
.
new
(
:osx
))
@pod
.
add_specification
(
subspecs
[
1
])
copy_fixture_to_pod
(
'chameleon'
,
@pod
)
end
before
do
@sandbox
=
temporary_sandbox
subspecs
=
fixture_spec
(
'chameleon/Chameleon.podspec'
).
subspecs
@pod
=
LocalPod
.
new
(
subspecs
[
0
],
@sandbox
,
Platform
.
new
(
:osx
))
@pod
.
add_specification
(
subspecs
[
1
])
copy_fixture_to_pod
(
'chameleon'
,
@pod
)
end
it
"identifies the top level specification"
do
@pod
.
top_specification
.
name
.
should
==
'Chameleon'
end
it
"identifies the top level specification"
do
@pod
.
top_specification
.
name
.
should
==
'Chameleon'
end
it
"returns the subspecs"
do
@pod
.
specifications
.
map
(
&
:name
).
should
==
%w[ Chameleon/UIKit Chameleon/StoreKit ]
end
it
"returns the subspecs"
do
@pod
.
specifications
.
map
(
&
:name
).
should
==
%w[ Chameleon/UIKit Chameleon/StoreKit ]
end
it
"resolve the source files"
do
computed
=
@pod
.
relative_source_files
.
map
(
&
:to_s
)
expected
=
%w[
it
"resolve the source files"
do
computed
=
@pod
.
relative_source_files
.
map
(
&
:to_s
)
expected
=
%w[
Chameleon/UIKit/Classes/UIKit.h
Chameleon/UIKit/Classes/UIView.h
Chameleon/UIKit/Classes/UIWindow.h
...
...
@@ -152,18 +153,18 @@ describe Pod::LocalPod do
Chameleon/StoreKit/Classes/StoreKit.h
Chameleon/StoreKit/Classes/SKPayment.m ]
assert_array_equals
(
expected
,
computed
)
end
assert_array_equals
(
expected
,
computed
)
end
it
"resolve the resources"
do
@pod
.
relative_resource_files
.
map
(
&
:to_s
).
sort
.
should
==
[
"Chameleon/UIKit/Resources/<UITabBar> background.png"
,
"Chameleon/UIKit/Resources/<UITabBar> background@2x.png"
]
end
it
"resolve the resources"
do
@pod
.
relative_resource_files
.
map
(
&
:to_s
).
sort
.
should
==
[
"Chameleon/UIKit/Resources/<UITabBar> background.png"
,
"Chameleon/UIKit/Resources/<UITabBar> background@2x.png"
]
end
it
"resolve the clean paths"
do
# fake_git serves to check that source control files are deleted
expected
=
%w[
it
"resolve the clean paths"
do
# fake_git serves to check that source control files are deleted
expected
=
%w[
/.fake_git
/.fake_git/branches
/.fake_git/HEAD
...
...
@@ -215,14 +216,14 @@ describe Pod::LocalPod do
/MessageUI/MessageUI_Prefix.pch
/StoreKit/StoreKit_Prefix.pch
/UIKit/UIKit_Prefix.pch
]
root
=
@pod
.
root
.
to_s
computed
=
@pod
.
clean_paths
.
each
{
|
p
|
p
.
gsub!
(
root
,
''
)
}
assert_array_equals
(
expected
,
computed
)
end
]
root
=
@pod
.
root
.
to_s
computed
=
@pod
.
clean_paths
.
each
{
|
p
|
p
.
gsub!
(
root
,
''
)
}
assert_array_equals
(
expected
,
computed
)
end
it
"resolves the used files"
do
expected
=
%w[
it
"resolves the used files"
do
expected
=
%w[
/UIKit/Classes/UIKit.h
/UIKit/Classes/UIView.h
/UIKit/Classes/UIWindow.h
...
...
@@ -234,37 +235,37 @@ describe Pod::LocalPod do
/Chameleon.podspec
/README.md
/LICENSE
]
+
[
"/UIKit/Resources/<UITabBar> background.png"
,
"/UIKit/Resources/<UITabBar> background@2x.png"
]
computed
=
@pod
.
used_files
.
map
{
|
p
|
p
.
gsub!
(
@pod
.
root
.
to_s
,
''
).
to_s
}
assert_array_equals
(
expected
,
computed
)
end
]
+
[
"/UIKit/Resources/<UITabBar> background.png"
,
"/UIKit/Resources/<UITabBar> background@2x.png"
]
computed
=
@pod
.
used_files
.
map
{
|
p
|
p
.
gsub!
(
@pod
.
root
.
to_s
,
''
).
to_s
}
assert_array_equals
(
expected
,
computed
)
end
it
"resolved the header files"
do
expected
=
%w[
it
"resolved the header files"
do
expected
=
%w[
Chameleon/UIKit/Classes/UIKit.h
Chameleon/UIKit/Classes/UIView.h
Chameleon/UIKit/Classes/UIWindow.h
Chameleon/StoreKit/Classes/SKPayment.h
Chameleon/StoreKit/Classes/StoreKit.h ]
computed
=
@pod
.
relative_header_files
.
map
(
&
:to_s
)
assert_array_equals
(
expected
,
computed
)
end
computed
=
@pod
.
relative_header_files
.
map
(
&
:to_s
)
assert_array_equals
(
expected
,
computed
)
end
it
"resolves the documentation header files including not activated subspecs"
do
subspecs
=
fixture_spec
(
'chameleon/Chameleon.podspec'
).
subspecs
spec
=
subspecs
[
0
]
spec
.
stubs
(
:public_header_files
).
returns
(
"UIKit/Classes/*Kit.h"
)
@pod
=
Pod
::
LocalPod
.
new
(
spec
,
@sandbox
,
Pod
::
Platform
.
new
(
:osx
))
# Note we only activated UIKit but all the specs need to be resolved
computed
=
@pod
.
documentation_headers
.
map
{
|
p
|
p
.
relative_path_from
(
@pod
.
root
).
to_s
}
# The Following headers are private:
# UIKit/Classes/UIView.h
# UIKit/Classes/UIWindow.h
expected
=
%w[
it
"resolves the documentation header files including not activated subspecs"
do
subspecs
=
fixture_spec
(
'chameleon/Chameleon.podspec'
).
subspecs
spec
=
subspecs
[
0
]
spec
.
stubs
(
:public_header_files
).
returns
(
"UIKit/Classes/*Kit.h"
)
@pod
=
LocalPod
.
new
(
spec
,
@sandbox
,
Platform
.
new
(
:osx
))
# Note we only activated UIKit but all the specs need to be resolved
computed
=
@pod
.
documentation_headers
.
map
{
|
p
|
p
.
relative_path_from
(
@pod
.
root
).
to_s
}
# The Following headers are private:
# UIKit/Classes/UIView.h
# UIKit/Classes/UIWindow.h
expected
=
%w[
UIKit/Classes/UIKit.h
StoreKit/Classes/SKPayment.h
StoreKit/Classes/StoreKit.h
...
...
@@ -284,105 +285,131 @@ describe Pod::LocalPod do
AssetsLibrary/Classes/ALAssetsGroup.h
AssetsLibrary/Classes/ALAssetsLibrary.h
AssetsLibrary/Classes/AssetsLibrary.h
]
assert_array_equals
(
expected
,
computed
)
end
]
assert_array_equals
(
expected
,
computed
)
end
it
"merges the xcconfigs without duplicates"
do
@pod
.
xcconfig
.
should
==
{
"OTHER_LDFLAGS"
=>
"-framework AppKit -framework Foundation -framework IOKit -framework QTKit -framework QuartzCore -framework SystemConfiguration -framework WebKit"
}
end
it
"merges the xcconfigs without duplicates"
do
@pod
.
xcconfig
.
should
==
{
"OTHER_LDFLAGS"
=>
"-framework AppKit -framework Foundation -framework IOKit -framework QTKit -framework QuartzCore -framework SystemConfiguration -framework WebKit"
}
end
it
"returns a hash of mappings with a custom header dir prefix"
do
mappings
=
@pod
.
send
(
:header_mappings
,
@pod
.
header_files_by_spec
)
mappings
=
mappings
.
map
do
|
folder
,
headers
|
"
#{
folder
}
>
#{
headers
.
sort
.
map
{
|
p
|
p
.
relative_path_from
(
@pod
.
root
).
to_s
}
.join(' ')}"
it
"returns a hash of mappings with a custom header dir prefix"
do
mappings
=
@pod
.
send
(
:header_mappings
,
@pod
.
header_files_by_spec
)
mappings
=
mappings
.
map
do
|
folder
,
headers
|
"
#{
folder
}
>
#{
headers
.
sort
.
map
{
|
p
|
p
.
relative_path_from
(
@pod
.
root
).
to_s
}
.join(' ')}"
end
mappings
.
sort
.
should
==
[
"Chameleon/StoreKit > StoreKit/Classes/SKPayment.h StoreKit/Classes/StoreKit.h"
,
"Chameleon/UIKit > UIKit/Classes/UIKit.h UIKit/Classes/UIView.h UIKit/Classes/UIWindow.h"
]
end
mappings
.
sort
.
should
==
[
"Chameleon/StoreKit > StoreKit/Classes/SKPayment.h StoreKit/Classes/StoreKit.h"
,
"Chameleon/UIKit > UIKit/Classes/UIKit.h UIKit/Classes/UIView.h UIKit/Classes/UIWindow.h"
]
end
# TODO this is a stub
xit
"respects the exclude files attribute of the specifications"
do
@pod
.
stubs
(
:exclude_files
).
returns
([
@pod
.
root
+
'UIKit/Classes/UIKit.h'
])
mappings
=
@pod
.
send
(
:header_mappings
,
@pod
.
header_files_by_spec
)
mappings
=
mappings
.
map
do
|
folder
,
headers
|
"
#{
folder
}
>
#{
headers
.
sort
.
map
{
|
p
|
p
.
relative_path_from
(
@pod
.
root
).
to_s
}
.join(' ')}"
# TODO this is a stub
xit
"respects the exclude files attribute of the specifications"
do
@pod
.
stubs
(
:exclude_files
).
returns
([
@pod
.
root
+
'UIKit/Classes/UIKit.h'
])
mappings
=
@pod
.
send
(
:header_mappings
,
@pod
.
header_files_by_spec
)
mappings
=
mappings
.
map
do
|
folder
,
headers
|
"
#{
folder
}
>
#{
headers
.
sort
.
map
{
|
p
|
p
.
relative_path_from
(
@pod
.
root
).
to_s
}
.join(' ')}"
end
mappings
.
sort
.
should
==
[
"Chameleon/StoreKit > StoreKit/Classes/SKPayment.h StoreKit/Classes/StoreKit.h"
,
"Chameleon/UIKit > UIKit/Classes/UIView.h UIKit/Classes/UIWindow.h"
]
end
mappings
.
sort
.
should
==
[
"Chameleon/StoreKit > StoreKit/Classes/SKPayment.h StoreKit/Classes/StoreKit.h"
,
"Chameleon/UIKit > UIKit/Classes/UIView.h UIKit/Classes/UIWindow.h"
]
end
xit
"includes the sandbox of the pod's headers while linking"
do
@sandbox
.
build_headers
.
expects
(
:add_search_path
).
with
(
Pathname
.
new
(
'Chameleon'
))
@sandbox
.
public_headers
.
expects
(
:add_search_path
).
with
(
Pathname
.
new
(
'Chameleon'
))
@pod
.
link_headers
end
xit
"includes the sandbox of the pod's headers while linking"
do
@sandbox
.
build_headers
.
expects
(
:add_search_path
).
with
(
Pathname
.
new
(
'Chameleon'
))
@sandbox
.
public_headers
.
expects
(
:add_search_path
).
with
(
Pathname
.
new
(
'Chameleon'
))
@pod
.
link_headers
end
it
"differentiates among public and build headers"
do
subspecs
=
fixture_spec
(
'chameleon/Chameleon.podspec'
).
subspecs
spec
=
subspecs
[
0
]
spec
.
stubs
(
:public_header_files
).
returns
(
"UIKit/Classes/*Kit.h"
)
@pod
=
Pod
::
LocalPod
.
new
(
spec
,
@sandbox
,
Pod
::
Platform
.
new
(
:osx
))
build_headers
=
@pod
.
header_files_by_spec
.
values
.
flatten
.
map
{
|
p
|
p
.
basename
.
to_s
}
public_headers
=
@pod
.
public_header_files_by_spec
.
values
.
flatten
.
map
{
|
p
|
p
.
basename
.
to_s
}
build_headers
.
sort
.
should
==
%w{ UIKit.h UIView.h UIWindow.h }
public_headers
.
should
==
%w{ UIKit.h }
it
"differentiates among public and build headers"
do
subspecs
=
fixture_spec
(
'chameleon/Chameleon.podspec'
).
subspecs
spec
=
subspecs
[
0
]
spec
.
stubs
(
:public_header_files
).
returns
(
"UIKit/Classes/*Kit.h"
)
@pod
=
LocalPod
.
new
(
spec
,
@sandbox
,
Platform
.
new
(
:osx
))
build_headers
=
@pod
.
header_files_by_spec
.
values
.
flatten
.
map
{
|
p
|
p
.
basename
.
to_s
}
public_headers
=
@pod
.
public_header_files_by_spec
.
values
.
flatten
.
map
{
|
p
|
p
.
basename
.
to_s
}
build_headers
.
sort
.
should
==
%w{ UIKit.h UIView.h UIWindow.h }
public_headers
.
should
==
%w{ UIKit.h }
end
end
end
describe
"concerning a Pod with a local source"
do
#---------------------------------------------------------------------------#
before
do
@local_path
=
temporary_directory
+
'localBanana'
@sandbox
=
temporary_sandbox
@spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@spec
.
source
=
{
:local
=>
@local_path
}
@pod
=
Pod
::
LocalPod
::
LocalSourcedPod
.
new
(
@spec
,
@sandbox
,
Pod
::
Platform
.
new
(
:ios
))
end
describe
"concerning a Pod with a local source"
do
it
"is marked as local"
do
@pod
.
to_s
.
should
.
include?
'[LOCAL]'
end
before
do
@local_path
=
temporary_directory
+
'localBanana'
@sandbox
=
temporary_sandbox
@spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@spec
.
source
=
{
:local
=>
@local_path
}
@pod
=
LocalPod
::
LocalSourcedPod
.
new
(
@spec
,
@sandbox
,
Platform
.
new
(
:ios
))
end
it
"is marked as downloaded
"
do
@pod
.
downloaded?
.
should
.
be
.
true
end
it
"is marked as local
"
do
@pod
.
to_s
.
should
.
include?
'[LOCAL]'
end
it
"correctly repports the root of the po
d"
do
@pod
.
root
.
should
==
@local_path
end
it
"is marked as downloade
d"
do
@pod
.
downloaded?
.
should
.
be
.
true
end
it
"doesn't create the root"
do
@pod
.
create
@local_path
.
exist?
.
should
.
be
.
false
end
it
"correctly repports the root of the pod"
do
@pod
.
root
.
should
==
@local_path
end
before
do
FileUtils
.
cp_r
(
fixture
(
'banana-lib'
),
@local_path
)
end
it
"doesn't create the root"
do
@pod
.
create
@local_path
.
exist?
.
should
.
be
.
false
end
it
"doesn't cleans the user files"
do
useless_file
=
@local_path
+
'useless.txt'
FileUtils
.
touch
(
useless_file
)
@pod
.
root
.
should
==
@local_path
@pod
.
clean!
useless_file
.
exist?
.
should
.
be
.
true
end
before
do
FileUtils
.
cp_r
(
fixture
(
'banana-lib'
),
@local_path
)
end
it
"doesn't cleans the user files"
do
useless_file
=
@local_path
+
'useless.txt'
FileUtils
.
touch
(
useless_file
)
@pod
.
root
.
should
==
@local_path
@pod
.
clean!
useless_file
.
exist?
.
should
.
be
.
true
end
it
"doesn't implode"
do
@pod
.
implode
@local_path
.
exist?
.
should
.
be
.
true
it
"doesn't implode"
do
@pod
.
implode
@local_path
.
exist?
.
should
.
be
.
true
end
it
"detects the files of the pod"
do
@pod
.
source_files
.
map
{
|
path
|
path
.
to_s
.
gsub
(
/.*tmp\//
,
''
)
}.
sort
.
should
==
[
"localBanana/Classes/Banana.m"
,
"localBanana/Classes/Banana.h"
].
sort
end
end
it
"detects the files of the pod"
do
@pod
.
source_files
.
map
{
|
path
|
path
.
to_s
.
gsub
(
/.*tmp\//
,
''
)
}.
sort
.
should
==
[
"localBanana/Classes/Banana.m"
,
"localBanana/Classes/Banana.h"
].
sort
#---------------------------------------------------------------------------#
describe
"concerning a Pod with a local source"
do
it
"it supports rake file list"
do
local_path
=
temporary_directory
+
'localBanana'
FileUtils
.
cp_r
(
fixture
(
'banana-lib'
),
local_path
)
sandbox
=
temporary_sandbox
spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
spec
.
source
=
{
:local
=>
local_path
}
spec
.
source_files
=
FileList
[
'Classes'
]
pod
=
LocalPod
::
LocalSourcedPod
.
new
(
spec
,
sandbox
,
Platform
.
ios
)
pod
.
source_files
.
map
{
|
path
|
path
.
to_s
.
gsub
(
/.*tmp\//
,
''
)
}.
sort
.
should
==
[
"localBanana/Classes/Banana.m"
,
"localBanana/Classes/Banana.h"
].
sort
end
end
#---------------------------------------------------------------------------#
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