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
1546afe6
Commit
1546afe6
authored
Feb 19, 2013
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FileAccessor] Include folders in resources.
parent
815f8c16
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
31 deletions
+54
-31
file_accessor.rb
lib/cocoapods/sandbox/file_accessor.rb
+9
-7
path_list.rb
lib/cocoapods/sandbox/path_list.rb
+15
-5
banana-lib.tar.gz
spec/fixtures/banana-lib.tar.gz
+0
-0
file_accessor_spec.rb
spec/unit/sandbox/file_accessor_spec.rb
+10
-7
path_list_spec.rb
spec/unit/sandbox/path_list_spec.rb
+20
-12
No files found.
lib/cocoapods/sandbox/file_accessor.rb
View file @
1546afe6
...
...
@@ -85,7 +85,7 @@ module Pod
def
resources
result
=
{}
spec_consumer
.
resources
.
each
do
|
destination
,
patterns
|
result
[
destination
]
=
expanded_paths
(
patterns
)
result
[
destination
]
=
expanded_paths
(
patterns
,
{
:include_dirs
=>
true
}
)
end
result
end
...
...
@@ -138,9 +138,11 @@ module Pod
#
def
paths_for_attribute
(
attribute
)
file_patterns
=
spec_consumer
.
send
(
attribute
)
dir_pattern
=
glob_for_attribute
(
attribute
)
exclude_files
=
spec_consumer
.
exclude_files
expanded_paths
(
file_patterns
,
dir_pattern
,
exclude_files
)
options
=
{
:exclude_patterns
=>
spec_consumer
.
exclude_files
,
:dir_pattern
=>
glob_for_attribute
(
attribute
)
}
expanded_paths
(
file_patterns
,
options
)
end
# Returns the pattern to use to glob a directory for an attribute.
...
...
@@ -150,7 +152,7 @@ module Pod
#
# @return [String] the glob pattern.
#
# @todo
m
ove to the cocoapods-core so it appears in the docs?
# @todo
M
ove to the cocoapods-core so it appears in the docs?
#
def
glob_for_attribute
(
attrbute
)
globs
=
{
...
...
@@ -178,14 +180,14 @@ module Pod
#
# @todo Implement case insensitive search
#
def
expanded_paths
(
patterns
,
dir_pattern
=
nil
,
exclude_patterns
=
nil
)
def
expanded_paths
(
patterns
,
options
=
{}
)
return
[]
if
patterns
.
empty?
file_lists
=
patterns
.
select
{
|
p
|
p
.
is_a?
(
FileList
)
}
glob_patterns
=
patterns
-
file_lists
result
=
[]
result
<<
path_list
.
glob
(
glob_patterns
,
dir_pattern
,
exclude_patter
ns
)
result
<<
path_list
.
glob
(
glob_patterns
,
optio
ns
)
result
<<
file_lists
.
map
do
|
file_list
|
file_list
.
prepend_patterns
(
path_list
.
root
)
file_list
.
glob
...
...
lib/cocoapods/sandbox/path_list.rb
View file @
1546afe6
...
...
@@ -65,8 +65,8 @@ module Pod
# @return [Array<Pathname>] Similar to {glob} but returns the absolute
# paths.
#
def
glob
(
patterns
,
dir_pattern
=
nil
,
exclude_patterns
=
nil
)
relative_glob
(
patterns
,
dir_pattern
,
exclude_patter
ns
).
map
{
|
p
|
root
+
p
}
def
glob
(
patterns
,
options
=
{}
)
relative_glob
(
patterns
,
optio
ns
).
map
{
|
p
|
root
+
p
}
end
# @return [Array<Pathname>] The list of relative paths that are case
...
...
@@ -80,20 +80,30 @@ module Pod
# An optional pattern to append to a pattern, if it is the path
# to a directory.
#
def
relative_glob
(
patterns
,
dir_pattern
=
nil
,
exclude_patterns
=
nil
)
def
relative_glob
(
patterns
,
options
=
{}
)
return
[]
if
patterns
.
empty?
dir_pattern
=
options
[
:dir_pattern
]
exclude_patterns
=
options
[
:exclude_patterns
]
include_dirs
=
options
[
:include_dirs
]
if
include_dirs
full_list
=
files
+
dirs
else
full_list
=
files
end
list
=
Array
(
patterns
).
map
do
|
pattern
|
if
pattern
.
is_a?
(
String
)
pattern
+=
'/'
+
dir_pattern
if
directory?
(
pattern
)
&&
dir_pattern
expanded_patterns
=
dir_glob_equivalent_patterns
(
pattern
)
f
iles
.
select
do
|
path
|
f
ull_list
.
select
do
|
path
|
expanded_patterns
.
any?
do
|
p
|
File
.
fnmatch
(
p
,
path
,
File
::
FNM_CASEFOLD
|
File
::
FNM_PATHNAME
)
end
end
else
f
iles
.
select
{
|
path
|
path
.
match
(
pattern
)
}
f
ull_list
.
select
{
|
path
|
path
.
match
(
pattern
)
}
end
end
.
flatten
...
...
spec/fixtures/banana-lib.tar.gz
View file @
1546afe6
No preview for this file type
spec/unit/sandbox/file_accessor_spec.rb
View file @
1546afe6
...
...
@@ -70,9 +70,10 @@ module Pod
end
it
"returns the resources"
do
@accessor
.
resources
.
should
==
{
:resources
=>
[
@root
+
"Resources/logo-sidebar.png"
]
}
@accessor
.
resources
[
:resources
].
sort
.
should
==
[
@root
+
"Resources/logo-sidebar.png"
,
@root
+
"Resources/sub_dir"
,
]
end
it
"returns the preserve path"
do
...
...
@@ -113,10 +114,12 @@ module Pod
it
"takes into account dir patterns and excluded files"
do
file_patterns
=
[
"Classes/*.{h,m}"
,
"Vendor"
]
dir_pattern
=
"*.{h,hpp,hh,m,mm,c,cpp}"
exclude_files
=
[
"Classes/**/osx/**/*"
,
"Resources/**/osx/**/*"
]
@spec
.
exclude_files
=
exclude_files
@accessor
.
expects
(
:expanded_paths
).
with
(
file_patterns
,
dir_pattern
,
exclude_files
)
options
=
{
:exclude_patterns
=>
[
"Classes/**/osx/**/*"
,
"Resources/**/osx/**/*"
],
:dir_pattern
=>
"*.{h,hpp,hh,m,mm,c,cpp}"
}
@spec
.
exclude_files
=
options
[
:exclude_patterns
]
@accessor
.
expects
(
:expanded_paths
).
with
(
file_patterns
,
options
)
@accessor
.
send
(
:paths_for_attribute
,
:source_files
)
end
...
...
spec/unit/sandbox/path_list_spec.rb
View file @
1546afe6
...
...
@@ -22,6 +22,7 @@ module Pod
Classes/BananaPrivate.h
README
Resources/logo-sidebar.png
Resources/sub_dir/logo-sidebar.png
preserve_me.txt
sub-dir/sub-dir-2/somefile.txt
]
...
...
@@ -34,7 +35,7 @@ module Pod
dirs
.
reject!
do
|
f
|
f
.
include?
(
'libPusher'
)
||
f
.
include?
(
'.git'
)
end
dirs
.
sort
.
should
==
%w| Classes Resources sub-dir sub-dir/sub-dir-2 |
dirs
.
sort
.
should
==
%w| Classes Resources
Resources/sub_dir
sub-dir sub-dir/sub-dir-2 |
end
end
...
...
@@ -42,8 +43,6 @@ module Pod
#-------------------------------------------------------------------------#
describe
"Globbing"
do
it
"can glob the root for a given pattern"
do
paths
=
@path_list
.
relative_glob
(
'Classes/*.{h,m}'
).
map
(
&
:to_s
)
paths
.
sort
.
should
==
%w[
...
...
@@ -53,6 +52,16 @@ module Pod
]
end
it
"can return the absolute paths from glob"
do
paths
=
@path_list
.
glob
(
'Classes/*.{h,m}'
)
paths
.
all?
{
|
p
|
p
.
absolute?
}.
should
==
true
end
it
"can return the relative paths from glob"
do
paths
=
@path_list
.
relative_glob
(
'Classes/*.{h,m}'
)
paths
.
any?
{
|
p
|
p
.
absolute?
}.
should
==
false
end
it
"supports the `**` glob pattern"
do
paths
=
@path_list
.
relative_glob
(
'Classes/**/*.{h,m}'
).
map
(
&
:to_s
)
paths
.
sort
.
should
==
%w[
...
...
@@ -63,7 +72,7 @@ module Pod
end
it
"supports an optional pattern for globbing directories"
do
paths
=
@path_list
.
relative_glob
(
'Classes'
,
'*.{h,m}'
).
map
(
&
:to_s
)
paths
=
@path_list
.
relative_glob
(
'Classes'
,
{
:dir_pattern
=>
'*.{h,m}'
}
).
map
(
&
:to_s
)
paths
.
sort
.
should
==
%w[
Classes/Banana.h
Classes/Banana.m
...
...
@@ -73,22 +82,21 @@ module Pod
it
"supports an optional list of patterns to exclude"
do
exclude_patterns
=
[
'**/*.m'
,
'**/*Private*.*'
]
paths
=
@path_list
.
relative_glob
(
'Classes/*'
,
nil
,
exclude_patterns
).
map
(
&
:to_s
)
paths
=
@path_list
.
relative_glob
(
'Classes/*'
,
{
:exclude_patterns
=>
exclude_patterns
}
).
map
(
&
:to_s
)
paths
.
sort
.
should
==
%w[
Classes/Banana.h
Classes/BananaLib.pch
]
end
it
"can return the absolute paths from glob"
do
paths
=
@path_list
.
glob
(
'Classes/*.{h,m}'
)
paths
.
all?
{
|
p
|
p
.
absolute?
}.
should
==
true
it
"can optionally include the directories in the results"
do
paths
=
@path_list
.
relative_glob
(
'Resources/*'
,
{
:include_dirs
=>
true
}).
map
(
&
:to_s
)
paths
.
sort
.
should
==
%w[
Resources/logo-sidebar.png
Resources/sub_dir
]
end
it
"can return the relative paths from glob"
do
paths
=
@path_list
.
relative_glob
(
'Classes/*.{h,m}'
)
paths
.
any?
{
|
p
|
p
.
absolute?
}.
should
==
false
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