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
34efc528
Commit
34efc528
authored
Jan 16, 2013
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Sandbox] Add #relativize from LocalPod#relativize_from_sandbox
parent
d24245fc
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
55 deletions
+52
-55
Gemfile.lock
Gemfile.lock
+5
-5
target_installer.rb
lib/cocoapods/installer/target_installer.rb
+2
-2
local_pod.rb
lib/cocoapods/local_pod.rb
+4
-46
sandbox.rb
lib/cocoapods/sandbox.rb
+22
-0
sandbox_spec.rb
spec/unit/sandbox_spec.rb
+19
-2
No files found.
Gemfile.lock
View file @
34efc528
GIT
GIT
remote: git://github.com/CocoaPods/Core.git
remote: git://github.com/CocoaPods/Core.git
revision:
294d7b2d911aad3e0ab70272115f2c3ee5307cda
revision:
72bb4fd0e0df8a9dd731ca3885ef4203967acce1
specs:
specs:
cocoapods-core (0.17.0.alpha)
cocoapods-core (0.17.0.alpha)
activesupport (~> 3.2.6)
activesupport (~> 3.2.6)
...
@@ -78,7 +78,7 @@ GEM
...
@@ -78,7 +78,7 @@ GEM
multi_json (1.5.0)
multi_json (1.5.0)
multipart-post (1.1.5)
multipart-post (1.1.5)
netrc (0.7.7)
netrc (0.7.7)
octokit (1.2
1
.0)
octokit (1.2
2
.0)
addressable (~> 2.2)
addressable (~> 2.2)
faraday (~> 0.8)
faraday (~> 0.8)
faraday_middleware (~> 0.9)
faraday_middleware (~> 0.9)
...
@@ -87,17 +87,17 @@ GEM
...
@@ -87,17 +87,17 @@ GEM
netrc (~> 0.7.7)
netrc (~> 0.7.7)
open4 (1.3.0)
open4 (1.3.0)
posix-spawn (0.3.6)
posix-spawn (0.3.6)
pry (0.9.1
0
)
pry (0.9.1
1.1
)
coderay (~> 1.0.5)
coderay (~> 1.0.5)
method_source (~> 0.8)
method_source (~> 0.8)
slop (~> 3.
3.1
)
slop (~> 3.
4
)
pygments.rb (0.3.7)
pygments.rb (0.3.7)
posix-spawn (~> 0.3.6)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.1.0)
yajl-ruby (~> 1.1.0)
rake (0.9.6)
rake (0.9.6)
rb-fsevent (0.9.3)
rb-fsevent (0.9.3)
redcarpet (2.2.2)
redcarpet (2.2.2)
slop (3.
3
.3)
slop (3.
4
.3)
terminal-notifier (1.4.2)
terminal-notifier (1.4.2)
yajl-ruby (1.1.0)
yajl-ruby (1.1.0)
yard (0.8.3)
yard (0.8.3)
...
...
lib/cocoapods/installer/target_installer.rb
View file @
34efc528
...
@@ -234,7 +234,7 @@ module Pod
...
@@ -234,7 +234,7 @@ module Pod
if
target_definition
.
podfile
.
generate_bridge_support?
if
target_definition
.
podfile
.
generate_bridge_support?
path
=
library
.
bridge_support_path
path
=
library
.
bridge_support_path
UI
.
message
"- Generating BridgeSupport metadata at
#{
UI
.
path
(
path
)
}
"
do
UI
.
message
"- Generating BridgeSupport metadata at
#{
UI
.
path
(
path
)
}
"
do
relative_headers
=
pods
.
map
{
|
pod
|
pod
.
relative_header_files
}.
flatten
relative_headers
=
pods
.
map
{
|
pod
|
pod
.
header_files
.
map
{
|
head
|
sandbox
.
relativize
(
head
)}
}.
flatten
headers
=
relative_headers
.
map
{
|
header
|
sandbox
.
root
+
header
}
headers
=
relative_headers
.
map
{
|
header
|
sandbox
.
root
+
header
}
generator
=
Generator
::
BridgeSupport
.
new
(
headers
)
generator
=
Generator
::
BridgeSupport
.
new
(
headers
)
generator
.
save_as
(
path
)
generator
.
save_as
(
path
)
...
@@ -255,7 +255,7 @@ module Pod
...
@@ -255,7 +255,7 @@ module Pod
def
create_copy_resources_script
def
create_copy_resources_script
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
resources
=
pods
.
map
{
|
p
|
p
.
re
lative_resource_files
}.
flatten
resources
=
pods
.
map
{
|
p
|
p
.
re
source_files
.
map
{
|
res
|
sandbox
.
relativize
(
res
)}
}.
flatten
resources
<<
bridge_support_file
if
bridge_support_file
resources
<<
bridge_support_file
if
bridge_support_file
generator
=
Generator
::
CopyResourcesScript
.
new
(
resources
)
generator
=
Generator
::
CopyResourcesScript
.
new
(
resources
)
generator
.
save_as
(
path
)
generator
.
save_as
(
path
)
...
...
lib/cocoapods/local_pod.rb
View file @
34efc528
...
@@ -21,6 +21,7 @@ module Pod
...
@@ -21,6 +21,7 @@ module Pod
# returns absolute paths.
# returns absolute paths.
#
#
class
LocalPod
class
LocalPod
autoload
:PathList
,
'cocoapods/local_pod/path_list'
autoload
:PathList
,
'cocoapods/local_pod/path_list'
# @return [Specification] The specification that describes the pod.
# @return [Specification] The specification that describes the pod.
...
@@ -208,26 +209,6 @@ module Pod
...
@@ -208,26 +209,6 @@ module Pod
# @!group Files
# @!group Files
# @return [Pathname] Returns the relative path from the sandbox.
#
# @note If the two abosule paths don't share the same root directory an
# extra `../` is added to the result of {Pathname#relative_path_from}
#
# path = Pathname.new('/Users/dir')
# @sandbox
# #=> Pathname('/tmp/CocoaPods/Lint/Pods')
#
# p.relative_path_from(@sandbox
# #=> '../../../../Users/dir'
#
# relativize_from_sandbox(path)
# #=> '../../../../../Users/dir'
#
def
relativize_from_sandbox
(
path
)
result
=
path
.
relative_path_from
(
@sandbox
.
root
)
result
=
Pathname
.
new
(
'../'
)
+
result
unless
@sandbox
.
root
.
to_s
.
split
(
'/'
)[
1
]
==
path
.
to_s
.
split
(
'/'
)[
1
]
result
end
# @return [Array<Pathname>] The paths of the source files.
# @return [Array<Pathname>] The paths of the source files.
#
#
...
@@ -235,19 +216,7 @@ module Pod
...
@@ -235,19 +216,7 @@ module Pod
source_files_by_spec
.
values
.
flatten
source_files_by_spec
.
values
.
flatten
end
end
# @return [Array<Pathname>] The *relative* paths of the source files.
#
def
relative_source_files
source_files
.
map
{
|
p
|
relativize_from_sandbox
(
p
)
}
end
def
relative_source_files_by_spec
result
=
{}
source_files_by_spec
.
each
do
|
spec
,
paths
|
result
[
spec
]
=
paths
.
map
{
|
p
|
relativize_from_sandbox
(
p
)
}
end
result
end
# Finds the source files that every activated {Specification} requires.
# Finds the source files that every activated {Specification} requires.
#
#
...
@@ -268,12 +237,6 @@ module Pod
...
@@ -268,12 +237,6 @@ module Pod
header_files_by_spec
.
values
.
flatten
header_files_by_spec
.
values
.
flatten
end
end
# @return [Array<Pathname>] The *relative* paths of the source files.
#
def
relative_header_files
header_files
.
map
{
|
p
|
relativize_from_sandbox
(
p
)
}
end
# @return [Hash{Specification => Array<Pathname>}] The paths of the header
# @return [Hash{Specification => Array<Pathname>}] The paths of the header
# files grouped by {Specification}.
# files grouped by {Specification}.
#
#
...
@@ -330,12 +293,6 @@ module Pod
...
@@ -330,12 +293,6 @@ module Pod
alias
:resources
:resource_files
alias
:resources
:resource_files
# @return [Array<Pathname>] The *relative* paths of the resources.
#
def
relative_resource_files
resource_files
.
map
{
|
p
|
relativize_from_sandbox
(
p
)
}
end
# @return [Pathname] The absolute path of the prefix header file
# @return [Pathname] The absolute path of the prefix header file
#
#
def
prefix_header_file
def
prefix_header_file
...
@@ -471,11 +428,12 @@ module Pod
...
@@ -471,11 +428,12 @@ module Pod
@file_references_by_spec
=
{}
@file_references_by_spec
=
{}
parent_group
=
local?
?
project
.
local_pods
:
project
.
pods
parent_group
=
local?
?
project
.
local_pods
:
project
.
pods
relative_
source_files_by_spec
.
each
do
|
spec
,
paths
|
source_files_by_spec
.
each
do
|
spec
,
paths
|
group
=
project
.
add_spec_group
(
spec
.
name
,
parent_group
)
group
=
project
.
add_spec_group
(
spec
.
name
,
parent_group
)
file_references
=
[]
file_references
=
[]
paths
.
each
do
|
path
|
paths
.
each
do
|
path
|
file_references
<<
group
.
new_file
(
path
)
relative
=
sandbox
.
relativize
(
path
)
file_references
<<
group
.
new_file
(
relative
)
end
end
@file_references_by_spec
[
spec
]
=
file_references
@file_references_by_spec
[
spec
]
=
file_references
end
end
...
...
lib/cocoapods/sandbox.rb
View file @
34efc528
...
@@ -78,6 +78,28 @@ module Pod
...
@@ -78,6 +78,28 @@ module Pod
root
.
rmtree
root
.
rmtree
end
end
# @return [Pathname] Returns the relative path from the sandbox.
#
# @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
)
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 suitable for debugging.
# @return [String] a string representation suitable for debugging.
#
#
def
inspect
def
inspect
...
...
spec/unit/sandbox_spec.rb
View file @
34efc528
...
@@ -3,7 +3,7 @@ require File.expand_path('../../spec_helper', __FILE__)
...
@@ -3,7 +3,7 @@ require File.expand_path('../../spec_helper', __FILE__)
module
Pod
module
Pod
describe
Sandbox
do
describe
Sandbox
do
before
do
before
do
@sandbox
=
Pod
::
Sandbox
.
new
(
temporary_directory
+
'Sandbox'
)
@sandbox
=
Pod
::
Sandbox
.
new
(
temporary_directory
+
'Sandbox'
)
...
@@ -34,6 +34,23 @@ module Pod
...
@@ -34,6 +34,23 @@ module Pod
File
.
directory?
(
temporary_directory
+
'Sandbox'
).
should
.
be
.
false
File
.
directory?
(
temporary_directory
+
'Sandbox'
).
should
.
be
.
false
end
end
it
"can return the relative path of a given absolute path"
do
path
=
temporary_directory
+
'Sandbox/file'
@sandbox
.
relativize
(
path
).
should
==
Pathname
.
new
(
'file'
)
end
it
"can return the relative path of a given absolute path outside the sandbox root"
do
path
=
temporary_directory
+
'file'
@sandbox
.
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'
)
@sandbox
.
instance_variable_set
(
:@root
,
Pathname
.
new
(
'/Users/sandbox'
))
@sandbox
.
relativize
(
path
).
should
==
expected
end
#--------------------------------------#
#--------------------------------------#
it
"returns the path of the manifest"
do
it
"returns the path of the manifest"
do
...
@@ -79,7 +96,7 @@ module Pod
...
@@ -79,7 +96,7 @@ module Pod
#---------------------------------------------------------------------------#
#---------------------------------------------------------------------------#
describe
Sandbox
::
HeadersStore
do
describe
Sandbox
::
HeadersStore
do
before
do
before
do
@sandbox
=
Pod
::
Sandbox
.
new
(
temporary_directory
+
'Sandbox'
)
@sandbox
=
Pod
::
Sandbox
.
new
(
temporary_directory
+
'Sandbox'
)
...
...
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