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
628a49b8
Commit
628a49b8
authored
Feb 15, 2013
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Project] Don't duplicate file references
parent
b806590e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
21 deletions
+38
-21
file_references_installer.rb
lib/cocoapods/installer/file_references_installer.rb
+0
-3
project.rb
lib/cocoapods/project.rb
+17
-9
integration_2.rb
spec/integration_2.rb
+12
-9
project_spec.rb
spec/unit/project_spec.rb
+9
-0
No files found.
lib/cocoapods/installer/file_references_installer.rb
View file @
628a49b8
...
@@ -99,9 +99,6 @@ module Pod
...
@@ -99,9 +99,6 @@ module Pod
# @return [Array<Sandbox::FileAccessor>] The file accessors for all the
# @return [Array<Sandbox::FileAccessor>] The file accessors for all the
# specs platform combinations.
# specs platform combinations.
#
#
# TODO Ideally the file accessors should be created one per spec per
# platform in a single installation.
#
def
file_accessors
def
file_accessors
@file_accessors
||=
libraries
.
map
(
&
:file_accessors
).
flatten
.
compact
@file_accessors
||=
libraries
.
map
(
&
:file_accessors
).
flatten
.
compact
end
end
...
...
lib/cocoapods/project.rb
View file @
628a49b8
...
@@ -92,8 +92,8 @@ module Pod
...
@@ -92,8 +92,8 @@ module Pod
def
add_spec_group
(
spec_name
,
root_group
)
def
add_spec_group
(
spec_name
,
root_group
)
current_group
=
root_group
current_group
=
root_group
group
=
nil
group
=
nil
spec_name
.
split
(
'/'
).
each
do
|
spec_
name
|
spec_name
.
split
(
'/'
).
each
do
|
name
|
group
=
current_group
[
spec_name
]
||
current_group
.
new_group
(
spec_
name
)
group
=
current_group
[
name
]
||
current_group
.
new_group
(
name
)
current_group
=
group
current_group
=
group
end
end
group
group
...
@@ -106,7 +106,12 @@ module Pod
...
@@ -106,7 +106,12 @@ module Pod
# @!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.
# group, namespaced by specification unless a file reference for the given
# path alrady exits.
#
# @note With this set-up different subspecs might not reference the same
# file (i.e. the first will win). Not sure thought if this is a
# limitation or a feature.
#
#
# @param [Array<Pathname,String>] paths
# @param [Array<Pathname,String>] paths
# The files for which the file reference is needed.
# The files for which the file reference is needed.
...
@@ -119,12 +124,15 @@ module Pod
...
@@ -119,12 +124,15 @@ module Pod
#
#
# @return [void]
# @return [void]
#
#
def
add_file_references
(
paths
,
spec_name
,
parent_group
)
def
add_file_references
(
absolute_path
,
spec_name
,
parent_group
)
group
=
add_spec_group
(
spec_name
,
parent_group
)
group
=
add_spec_group
(
spec_name
,
parent_group
)
paths
.
each
do
|
file
|
absolute_path
.
each
do
|
file
|
file
=
Pathname
.
new
(
file
)
existing
=
file_reference
(
file
)
ref
=
group
.
new_file
(
relativize
(
file
))
unless
existing
@refs_by_absolute_path
[
file
]
=
ref
file
=
Pathname
.
new
(
file
)
ref
=
group
.
new_file
(
relativize
(
file
))
@refs_by_absolute_path
[
file
]
=
ref
end
end
end
end
end
...
@@ -137,7 +145,7 @@ module Pod
...
@@ -137,7 +145,7 @@ module Pod
# @return [Nil] If no file reference could be found.
# @return [Nil] If no file reference could be found.
#
#
def
file_reference
(
absolute_path
)
def
file_reference
(
absolute_path
)
source_file
=
Pathname
.
new
(
absolute_path
)
absolute_path
=
Pathname
.
new
(
absolute_path
)
refs_by_absolute_path
[
absolute_path
]
refs_by_absolute_path
[
absolute_path
]
end
end
...
...
spec/integration_2.rb
View file @
628a49b8
...
@@ -52,7 +52,7 @@ $:.unshift((ROOT + 'spec').to_s)
...
@@ -52,7 +52,7 @@ $:.unshift((ROOT + 'spec').to_s)
require
'spec_helper/bacon'
require
'spec_helper/bacon'
require
'colored'
require
'colored'
require
'diffy'
require
'diffy'
require
'Xcodeproj'
require
'Xcodeproj'
# For Differ
# @return [Pathname The folder where the CocoaPods binary should operate.
# @return [Pathname The folder where the CocoaPods binary should operate.
#
#
...
@@ -221,11 +221,16 @@ def yaml_should_match(expected, produced)
...
@@ -221,11 +221,16 @@ def yaml_should_match(expected, produced)
# Remove CocoaPods version
# Remove CocoaPods version
expected_yaml
.
delete
(
'COCOAPODS'
)
expected_yaml
.
delete
(
'COCOAPODS'
)
produced_yaml
.
delete
(
'COCOAPODS'
)
produced_yaml
.
delete
(
'COCOAPODS'
)
desc
=
"YAML comparison error `
#{
expected
}
`"
desc
=
[]
desc
<<
"
\n
EXPECTED:
\n
#{
expected_yaml
.
inspect
.
cyan
}
\n
"
desc
<<
"YAML comparison error `
#{
expected
}
`"
desc
<<
"
\n
PRODUCED:
\n
#{
produced_yaml
.
inspect
.
cyan
}
\n
"
diff_options
=
{
:key_1
=>
"$produced"
,
:key_2
=>
"$expected"
}
# TODO extract Xcodeproj diff logic a provide a diff
diff
=
Xcodeproj
::
Differ
.
diff
(
produced_yaml
,
expected_yaml
,
diff_options
).
to_yaml
expected_yaml
.
should
.
satisfy
(
desc
)
do
|
expected_yaml
|
diff
.
gsub!
(
"$produced"
,
"produced"
.
green
)
diff
.
gsub!
(
"$expected"
,
"expected"
.
red
)
desc
<<
(
"--- DIFF "
<<
"-"
*
70
)
desc
<<
diff
desc
<<
(
"--- END "
<<
"-"
*
70
)
expected_yaml
.
should
.
satisfy
(
desc
*
"
\n\n
"
)
do
if
RUBY_VERSION
<
"1.9"
if
RUBY_VERSION
<
"1.9"
true
# CP is not sorting array derived from hashes whose order is
true
# CP is not sorting array derived from hashes whose order is
# undefined in 1.8.7
# undefined in 1.8.7
...
@@ -277,11 +282,9 @@ def file_should_match(expected, produced)
...
@@ -277,11 +282,9 @@ def file_should_match(expected, produced)
else
description
<<
line
.
gsub
(
"
\n
"
,
''
)
else
description
<<
line
.
gsub
(
"
\n
"
,
''
)
end
end
end
end
description
<<
""
<<
(
"--- PRODUCED "
<<
"-"
*
66
)
<<
""
description
<<
File
.
read
(
produced
)
description
<<
(
"--- END "
<<
"-"
*
70
)
description
<<
(
"--- END "
<<
"-"
*
70
)
description
<<
""
description
<<
""
is_equal
.
should
.
satisfy
(
description
*
"
\n
"
)
do
|
is_equal
|
is_equal
.
should
.
satisfy
(
description
*
"
\n
"
)
do
is_equal
==
true
is_equal
==
true
end
end
end
end
...
...
spec/unit/project_spec.rb
View file @
628a49b8
...
@@ -57,6 +57,15 @@ describe Pod::Project do
...
@@ -57,6 +57,15 @@ describe Pod::Project do
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
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
)
group
=
@project
[
'Pods/BananaLib'
]
group
.
children
.
count
.
should
==
1
group
.
children
.
first
.
path
.
should
==
"A_POD/some_file.m"
end
it
"returns the file reference for a given source file"
do
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
)
...
...
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