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
fb38487b
Commit
fb38487b
authored
Aug 27, 2013
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Project] Cleanup
parent
1f5d4f0e
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
40 additions
and
105 deletions
+40
-105
file_references_installer.rb
lib/cocoapods/installer/file_references_installer.rb
+6
-6
aggregate_target_installer.rb
.../installer/target_installer/aggregate_target_installer.rb
+1
-1
project.rb
lib/cocoapods/project.rb
+11
-64
file_references_installer_spec.rb
spec/unit/installer/file_references_installer_spec.rb
+2
-2
aggregate_target_installer_spec.rb
...aller/target_installer/aggregate_target_installer_spec.rb
+4
-1
pod_target_installer_spec.rb
...t/installer/target_installer/pod_target_installer_spec.rb
+4
-1
target_installer_spec.rb
spec/unit/installer/target_installer_spec.rb
+4
-1
project_spec.rb
spec/unit/project_spec.rb
+8
-29
No files found.
lib/cocoapods/installer/file_references_installer.rb
View file @
fb38487b
...
@@ -73,7 +73,7 @@ module Pod
...
@@ -73,7 +73,7 @@ module Pod
#
#
def
add_source_files_references
def
add_source_files_references
UI
.
message
"- Adding source files to Pods project"
do
UI
.
message
"- Adding source files to Pods project"
do
add_file_acessors_paths_to_pods_group
(
:source_files
,
:source_files
)
add_file_ac
c
essors_paths_to_pods_group
(
:source_files
,
:source_files
)
end
end
end
end
...
@@ -83,7 +83,7 @@ module Pod
...
@@ -83,7 +83,7 @@ module Pod
#
#
def
add_frameworks_bundles
def
add_frameworks_bundles
UI
.
message
"- Adding frameworks to Pods project"
do
UI
.
message
"- Adding frameworks to Pods project"
do
add_file_acessors_paths_to_pods_group
(
:vendored_frameworks
,
:frameworks_and_libraries
)
add_file_ac
c
essors_paths_to_pods_group
(
:vendored_frameworks
,
:frameworks_and_libraries
)
end
end
end
end
...
@@ -93,7 +93,7 @@ module Pod
...
@@ -93,7 +93,7 @@ module Pod
#
#
def
add_vendored_libraries
def
add_vendored_libraries
UI
.
message
"- Adding frameworks to Pods project"
do
UI
.
message
"- Adding frameworks to Pods project"
do
add_file_acessors_paths_to_pods_group
(
:vendored_libraries
,
:frameworks_and_libraries
)
add_file_ac
c
essors_paths_to_pods_group
(
:vendored_libraries
,
:frameworks_and_libraries
)
end
end
end
end
...
@@ -106,8 +106,8 @@ module Pod
...
@@ -106,8 +106,8 @@ module Pod
#
#
def
add_resources
def
add_resources
UI
.
message
"- Adding resources to Pods project"
do
UI
.
message
"- Adding resources to Pods project"
do
add_file_acessors_paths_to_pods_group
(
:resources
,
:resources
)
add_file_ac
c
essors_paths_to_pods_group
(
:resources
,
:resources
)
add_file_acessors_paths_to_pods_group
(
:resource_bundle_files
,
:resources
)
add_file_ac
c
essors_paths_to_pods_group
(
:resource_bundle_files
,
:resources
)
end
end
end
end
...
@@ -160,7 +160,7 @@ module Pod
...
@@ -160,7 +160,7 @@ module Pod
#
#
# @return [void]
# @return [void]
#
#
def
add_file_acessors_paths_to_pods_group
(
file_accessor_key
,
group_key
)
def
add_file_ac
c
essors_paths_to_pods_group
(
file_accessor_key
,
group_key
)
file_accessors
.
each
do
|
file_accessor
|
file_accessors
.
each
do
|
file_accessor
|
paths
=
file_accessor
.
send
(
file_accessor_key
)
paths
=
file_accessor
.
send
(
file_accessor_key
)
paths
.
each
do
|
path
|
paths
.
each
do
|
path
|
...
...
lib/cocoapods/installer/target_installer/aggregate_target_installer.rb
View file @
fb38487b
...
@@ -90,7 +90,7 @@ module Pod
...
@@ -90,7 +90,7 @@ module Pod
path
=
library
.
copy_resources_script_path
path
=
library
.
copy_resources_script_path
UI
.
message
"- Generating copy resources script at
#{
UI
.
path
(
path
)
}
"
do
UI
.
message
"- Generating copy resources script at
#{
UI
.
path
(
path
)
}
"
do
file_accessors
=
library
.
pod_targets
.
map
(
&
:file_accessors
).
flatten
file_accessors
=
library
.
pod_targets
.
map
(
&
:file_accessors
).
flatten
resource_paths
=
file_accessors
.
map
{
|
accessor
|
accessor
.
resources
.
flatten
.
map
{
|
res
|
project
.
relativize
(
res
)}
}.
flatten
resource_paths
=
file_accessors
.
map
{
|
accessor
|
accessor
.
resources
.
flatten
.
map
{
|
res
|
res
.
relative_path_from
(
project
.
path
)
}
}.
flatten
resource_bundles
=
file_accessors
.
map
{
|
accessor
|
accessor
.
resource_bundles
.
keys
.
map
{
|
name
|
"${TARGET_BUILD_DIR}/
#{
name
}
.bundle"
}
}.
flatten
resource_bundles
=
file_accessors
.
map
{
|
accessor
|
accessor
.
resource_bundles
.
keys
.
map
{
|
name
|
"${TARGET_BUILD_DIR}/
#{
name
}
.bundle"
}
}.
flatten
resources
=
[]
resources
=
[]
resources
.
concat
(
resource_paths
)
resources
.
concat
(
resource_paths
)
...
...
lib/cocoapods/project.rb
View file @
fb38487b
...
@@ -9,7 +9,6 @@ module Pod
...
@@ -9,7 +9,6 @@ module Pod
#
#
class
Project
<
Xcodeproj
::
Project
class
Project
<
Xcodeproj
::
Project
# @return [Sandbox] the sandbox which returns the information about which
# @return [Sandbox] the sandbox which returns the information about which
# Pods are local.
# Pods are local.
#
#
...
@@ -18,12 +17,9 @@ module Pod
...
@@ -18,12 +17,9 @@ module Pod
# @param [Sandbox] sandbox @see #sandbox
# @param [Sandbox] sandbox @see #sandbox
#
#
def
initialize
(
sandbox
)
def
initialize
(
sandbox
)
super
(
sandbox
.
project_path
)
# Recreate the project from scratch for now.
super
(
sandbox
.
project_path
)
# TODO
raise
unless
sandbox
.
is_a?
(
Sandbox
)
@sandbox
=
sandbox
@sandbox
=
sandbox
@support_files_group
=
new_group
(
'Targets Support Files'
)
@support_files_group
=
new_group
(
'Targets Support Files'
)
@refs_by_absolute_path
=
{}
@refs_by_absolute_path
=
{}
end
end
...
@@ -33,46 +29,17 @@ module Pod
...
@@ -33,46 +29,17 @@ module Pod
@root
||=
path
.
dirname
@root
||=
path
.
dirname
end
end
# @return [Pathname] Returns the relative path from the project root.
#
# @param [Pathname] path
# The path that needs to be converted to the relative format.
#
# @note If the two absolute paths don't share the same root directory an
# extra `../` is added to the result of
# {Pathname#relative_path_from}.
#
# @example
#
# path = Pathname.new('/Users/dir')
# @sandbox.root #=> Pathname('/tmp/CocoaPods/Lint/Pods')
#
# @sandbox.relativize(path) #=> '../../../../Users/dir'
# @sandbox.relativize(path) #=> '../../../../../Users/dir'
#
def
relativize
(
path
)
unless
path
.
absolute?
raise
StandardError
,
"[Bug] Attempt to add relative path `
#{
path
}
` to the Pods project"
end
result
=
path
.
relative_path_from
(
root
)
unless
root
.
to_s
.
split
(
'/'
)[
1
]
==
path
.
to_s
.
split
(
'/'
)[
1
]
result
=
Pathname
.
new
(
'../'
)
+
result
end
result
end
# @return [String] a string representation suited for debugging.
# @return [String] a string representation suited for debugging.
#
#
def
inspect
def
inspect
"#<
#{
self
.
class
}
> path:
#{
path
}
"
"#<
#{
self
.
class
}
> path:
#{
path
}
"
end
end
#-------------------------------------------------------------------------#
public
public
# @!group Groups
# @!group Groups
#-------------------------------------------------------------------------#
# @return [PBXGroup] the group where the support files for the Pod
# @return [PBXGroup] the group where the support files for the Pod
# libraries should be added.
# libraries should be added.
...
@@ -96,16 +63,6 @@ module Pod
...
@@ -96,16 +63,6 @@ module Pod
@local_pods
||=
new_group
(
'Local Pods'
)
@local_pods
||=
new_group
(
'Local Pods'
)
end
end
# Returns the `Local Pods` group, creating it if needed. This group is used
# to contain locally sourced pods.
#
# @return [PBXGroup] the group.
#
def
resources
@resources
||=
new_group
(
'Resources'
)
end
# @return [PBXGroup] the group for the spec with the given name.
# @return [PBXGroup] the group for the spec with the given name.
#
#
def
group_for_spec
(
spec_name
,
type
=
nil
)
def
group_for_spec
(
spec_name
,
type
=
nil
)
...
@@ -126,11 +83,11 @@ module Pod
...
@@ -126,11 +83,11 @@ module Pod
end
end
end
end
#-------------------------------------------------------------------------#
public
public
# @!group File references
# @!group File references
#-------------------------------------------------------------------------#
# Adds a file reference for each one of the given files in the specified
# Adds a file reference for each one of the given files in the specified
# group, namespaced by specification unless a file reference for the given
# group, namespaced by specification unless a file reference for the given
...
@@ -151,23 +108,13 @@ module Pod
...
@@ -151,23 +108,13 @@ module Pod
#
#
# @return [void]
# @return [void]
#
#
def
add_file_references
(
absolute_path
,
spec_name
,
parent_group
)
group
=
group_for_spec
(
spec_name
,
:source_files
)
absolute_path
.
each
do
|
file
|
existing
=
file_reference
(
file
)
unless
existing
file
=
Pathname
.
new
(
file
)
ref
=
group
.
new_file
(
file
)
@refs_by_absolute_path
[
file
]
=
ref
end
end
end
# TODO: missing customization for file reference
#
def
add_file_reference
(
absolute_path
,
group
)
def
add_file_reference
(
absolute_path
,
group
)
# existing = file_reference(absolute_paths)
# unless existing
absolute_path
=
Pathname
.
new
(
absolute_path
)
ref
=
group
.
new_file
(
absolute_path
)
ref
=
group
.
new_file
(
absolute_path
)
@refs_by_absolute_path
[
absolute_path
]
=
ref
@refs_by_absolute_path
[
absolute_path
]
=
ref
# end
end
end
# Returns the file reference for the given absolute file path.
# Returns the file reference for the given absolute file path.
...
@@ -186,9 +133,9 @@ module Pod
...
@@ -186,9 +133,9 @@ module Pod
# Adds a file reference to the podfile.
# Adds a file reference to the podfile.
#
#
# @param [Pathname,String] podfile_path
# @param [Pathname,String] podfile_path
#
the path of the podfile
#
The path of the Podfile.
#
#
# @return [PBXFileReference]
t
he file reference.
# @return [PBXFileReference]
T
he file reference.
#
#
def
add_podfile
(
podfile_path
)
def
add_podfile
(
podfile_path
)
podfile_path
=
Pathname
.
new
(
podfile_path
)
podfile_path
=
Pathname
.
new
(
podfile_path
)
...
@@ -198,11 +145,11 @@ module Pod
...
@@ -198,11 +145,11 @@ module Pod
podfile_ref
podfile_ref
end
end
#-------------------------------------------------------------------------#
private
private
# @!group Private helpers
# @!group Private helpers
#-------------------------------------------------------------------------#
# @return [Hash{Pathname => PBXFileReference}] The file references grouped
# @return [Hash{Pathname => PBXFileReference}] The file references grouped
# by absolute path.
# by absolute path.
...
@@ -219,7 +166,7 @@ module Pod
...
@@ -219,7 +166,7 @@ module Pod
# The group where to add the specification. Either `Pods` or `Local
# The group where to add the specification. Either `Pods` or `Local
# Pods`.
# Pods`.
#
#
# @return [PBXGroup]
t
he group for the spec with the given name.
# @return [PBXGroup]
T
he group for the spec with the given name.
#
#
def
add_spec_group
(
spec_name
,
root_group
)
def
add_spec_group
(
spec_name
,
root_group
)
current_group
=
root_group
current_group
=
root_group
...
...
spec/unit/installer/file_references_installer_spec.rb
View file @
fb38487b
...
@@ -93,13 +93,13 @@ module Pod
...
@@ -93,13 +93,13 @@ module Pod
end
end
end
end
describe
"#add_file_acessors_paths_to_pods_group"
do
describe
"#add_file_ac
c
essors_paths_to_pods_group"
do
xit
"adds the paths of the paths of the file accessor corresponding to the given key to the Pods project"
do
xit
"adds the paths of the paths of the file accessor corresponding to the given key to the Pods project"
do
end
end
end
end
describe
"#add_file_acessors_paths_to_pods_group"
do
describe
"#add_file_ac
c
essors_paths_to_pods_group"
do
it
"returns the header mappings"
do
it
"returns the header mappings"
do
headers_sandbox
=
Pathname
.
new
(
'BananaLib'
)
headers_sandbox
=
Pathname
.
new
(
'BananaLib'
)
headers
=
[
Pathname
.
new
(
'BananaLib/Banana.h'
)]
headers
=
[
Pathname
.
new
(
'BananaLib/Banana.h'
)]
...
...
spec/unit/installer/target_installer/aggregate_target_installer_spec.rb
View file @
fb38487b
...
@@ -15,7 +15,10 @@ module Pod
...
@@ -15,7 +15,10 @@ module Pod
path_list
=
Sandbox
::
PathList
.
new
(
fixture
(
'banana-lib'
))
path_list
=
Sandbox
::
PathList
.
new
(
fixture
(
'banana-lib'
))
@spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
file_accessor
=
Sandbox
::
FileAccessor
.
new
(
path_list
,
@spec
.
consumer
(
:ios
))
file_accessor
=
Sandbox
::
FileAccessor
.
new
(
path_list
,
@spec
.
consumer
(
:ios
))
@project
.
add_file_references
(
file_accessor
.
source_files
,
'BananaLib'
,
@project
.
pods
)
group
=
@project
.
group_for_spec
(
'BananaLib'
,
:source_files
)
file_accessor
.
source_files
.
each
do
|
file
|
@project
.
add_file_reference
(
file
,
group
)
end
@target
=
AggregateTarget
.
new
(
@target_definition
,
config
.
sandbox
)
@target
=
AggregateTarget
.
new
(
@target_definition
,
config
.
sandbox
)
@target
.
stubs
(
:platform
).
returns
(
Platform
.
new
(
:ios
,
'6.0'
))
@target
.
stubs
(
:platform
).
returns
(
Platform
.
new
(
:ios
,
'6.0'
))
...
...
spec/unit/installer/target_installer/pod_target_installer_spec.rb
View file @
fb38487b
...
@@ -15,7 +15,10 @@ module Pod
...
@@ -15,7 +15,10 @@ module Pod
path_list
=
Sandbox
::
PathList
.
new
(
fixture
(
'banana-lib'
))
path_list
=
Sandbox
::
PathList
.
new
(
fixture
(
'banana-lib'
))
@spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
file_accessor
=
Sandbox
::
FileAccessor
.
new
(
path_list
,
@spec
.
consumer
(
:ios
))
file_accessor
=
Sandbox
::
FileAccessor
.
new
(
path_list
,
@spec
.
consumer
(
:ios
))
@project
.
add_file_references
(
file_accessor
.
source_files
,
'BananaLib'
,
@project
.
pods
)
group
=
@project
.
group_for_spec
(
'BananaLib'
,
:source_files
)
file_accessor
.
source_files
.
each
do
|
file
|
@project
.
add_file_reference
(
file
,
group
)
end
@pod_target
=
PodTarget
.
new
([
@spec
],
@target_definition
,
config
.
sandbox
)
@pod_target
=
PodTarget
.
new
([
@spec
],
@target_definition
,
config
.
sandbox
)
@pod_target
.
stubs
(
:platform
).
returns
(
Platform
.
new
(
:ios
,
'6.0'
))
@pod_target
.
stubs
(
:platform
).
returns
(
Platform
.
new
(
:ios
,
'6.0'
))
...
...
spec/unit/installer/target_installer_spec.rb
View file @
fb38487b
...
@@ -15,7 +15,10 @@ module Pod
...
@@ -15,7 +15,10 @@ module Pod
path_list
=
Sandbox
::
PathList
.
new
(
fixture
(
'banana-lib'
))
path_list
=
Sandbox
::
PathList
.
new
(
fixture
(
'banana-lib'
))
@spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
file_accessor
=
Sandbox
::
FileAccessor
.
new
(
path_list
,
@spec
.
consumer
(
:ios
))
file_accessor
=
Sandbox
::
FileAccessor
.
new
(
path_list
,
@spec
.
consumer
(
:ios
))
@project
.
add_file_references
(
file_accessor
.
source_files
,
'BananaLib'
,
@project
.
pods
)
group
=
@project
.
group_for_spec
(
'BananaLib'
,
:source_files
)
file_accessor
.
source_files
.
each
do
|
file
|
@project
.
add_file_reference
(
file
,
group
)
end
@pod_target
=
PodTarget
.
new
([
@spec
],
@target_definition
,
config
.
sandbox
)
@pod_target
=
PodTarget
.
new
([
@spec
],
@target_definition
,
config
.
sandbox
)
@pod_target
.
stubs
(
:platform
).
returns
(
Platform
.
new
(
:ios
,
'6.0'
))
@pod_target
.
stubs
(
:platform
).
returns
(
Platform
.
new
(
:ios
,
'6.0'
))
...
...
spec/unit/project_spec.rb
View file @
fb38487b
...
@@ -15,23 +15,6 @@ module Pod
...
@@ -15,23 +15,6 @@ module Pod
@project
.
support_files_group
.
name
.
should
==
'Targets Support Files'
@project
.
support_files_group
.
name
.
should
==
'Targets Support Files'
end
end
it
"can return the relative path of a given absolute path"
do
path
=
temporary_directory
+
'Pods/BananaLib/file'
@project
.
relativize
(
path
).
should
==
Pathname
.
new
(
'BananaLib/file'
)
end
it
"can return the relative path of a given absolute path outside its root"
do
path
=
temporary_directory
+
'file'
@project
.
relativize
(
path
).
should
==
Pathname
.
new
(
'../file'
)
end
it
"can return the relative path of a given absolute path with another root directory"
do
path
=
Pathname
(
'/tmp/Lint'
)
expected
=
Pathname
.
new
(
'../../../tmp/Lint'
)
@project
.
instance_variable_set
(
:@root
,
Pathname
.
new
(
'/Users/sandbox'
))
@project
.
relativize
(
path
).
should
==
expected
end
end
end
#-------------------------------------------------------------------------#
#-------------------------------------------------------------------------#
...
@@ -46,25 +29,20 @@ module Pod
...
@@ -46,25 +29,20 @@ module Pod
@project
.
local_pods
.
name
.
should
==
'Local Pods'
@project
.
local_pods
.
name
.
should
==
'Local Pods'
end
end
it
"returns the `Resources` group"
do
@project
.
resources
.
name
.
should
==
'Resources'
end
end
end
#-------------------------------------------------------------------------#
#-------------------------------------------------------------------------#
describe
"File references"
do
describe
"File references"
do
it
"adds the file references for the given source files"
do
it
"adds a file references to the given file"
do
source_files
=
[
config
.
sandbox
.
root
+
"A_POD/some_file.m"
]
source_file
=
config
.
sandbox
.
root
+
"A_POD/some_file.m"
@project
.
add_file_references
(
source_files
,
'BananaLib'
,
@project
.
pods
)
group
=
@project
.
group_for_spec
(
'BananaLib'
,
:source_files
)
group
=
@project
[
'Pods/BananaLib/Source Files'
]
@project
.
add_file_reference
(
source_file
,
group
)
group
.
should
.
not
.
be
.
nil
group
.
children
.
map
(
&
:path
).
should
==
[
"A_POD/some_file.m"
]
group
.
children
.
map
(
&
:path
).
should
==
[
"A_POD/some_file.m"
]
end
end
it
"adds the only one file reference for a given absolute path"
do
x
it
"adds the only one file reference for a given absolute path"
do
source_files
=
[
config
.
sandbox
.
root
+
"A_POD/some_file.m"
]
source_files
=
[
config
.
sandbox
.
root
+
"A_POD/some_file.m"
]
@project
.
add_file_references
(
source_files
,
'BananaLib'
,
@project
.
pods
)
@project
.
add_file_references
(
source_files
,
'BananaLib'
,
@project
.
pods
)
@project
.
add_file_references
(
source_files
,
'BananaLib'
,
@project
.
pods
)
@project
.
add_file_references
(
source_files
,
'BananaLib'
,
@project
.
pods
)
...
@@ -73,7 +51,7 @@ module Pod
...
@@ -73,7 +51,7 @@ module Pod
group
.
children
.
first
.
path
.
should
==
"A_POD/some_file.m"
group
.
children
.
first
.
path
.
should
==
"A_POD/some_file.m"
end
end
it
"returns the file reference for a given source file"
do
x
it
"returns the file reference for a given source file"
do
file
=
config
.
sandbox
.
root
+
"A_POD/some_file.m"
file
=
config
.
sandbox
.
root
+
"A_POD/some_file.m"
@project
.
add_file_references
([
file
],
'BananaLib'
,
@project
.
pods
)
@project
.
add_file_references
([
file
],
'BananaLib'
,
@project
.
pods
)
file_reference
=
@project
.
file_reference
(
file
)
file_reference
=
@project
.
file_reference
(
file
)
...
@@ -97,7 +75,8 @@ module Pod
...
@@ -97,7 +75,8 @@ module Pod
describe
"#refs_by_absolute_path"
do
describe
"#refs_by_absolute_path"
do
it
"stores the references by absolute path"
do
it
"stores the references by absolute path"
do
file
=
config
.
sandbox
.
root
+
"A_POD/some_file.m"
file
=
config
.
sandbox
.
root
+
"A_POD/some_file.m"
@project
.
add_file_references
([
file
],
'BananaLib'
,
@project
.
pods
)
group
=
@project
.
group_for_spec
(
'BananaLib'
,
:source_files
)
@project
.
add_file_reference
(
file
,
group
)
refs_by_absolute_path
=
@project
.
send
(
:refs_by_absolute_path
)
refs_by_absolute_path
=
@project
.
send
(
:refs_by_absolute_path
)
refs_by_absolute_path
.
should
==
{
refs_by_absolute_path
.
should
==
{
file
=>
@project
.
file_reference
(
file
)
file
=>
@project
.
file_reference
(
file
)
...
...
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