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
1f62fbd2
Commit
1f62fbd2
authored
Oct 30, 2012
by
Eloy Durán
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PathList] Cleanup a bit and remove unused copy of strings.
parent
2d8bebdd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
29 deletions
+22
-29
path_list.rb
lib/cocoapods/local_pod/path_list.rb
+21
-28
path_list_spec.rb
spec/unit/local_pod/path_list_spec.rb
+1
-1
No files found.
lib/cocoapods/local_pod/path_list.rb
View file @
1f62fbd2
...
...
@@ -44,12 +44,10 @@ module Pod
#
def
read_file_system
root_length
=
root
.
to_s
.
length
+
1
paths
=
Dir
.
glob
(
root
+
"**/*"
,
File
::
FNM_DOTMATCH
)
paths
=
paths
.
map
{
|
p
|
p
[
root_length
..-
1
]
}
paths
=
paths
.
reject
do
|
p
|
p
==
'.'
||
p
==
'..'
end
dirs_entries
=
paths
.
select
{
|
path
|
path
.
end_with?
(
'/.'
,
'/..'
)
}
paths
=
Dir
.
glob
(
root
+
"**/*"
,
File
::
FNM_DOTMATCH
)
paths
=
paths
.
map
{
|
p
|
p
[
root_length
..-
1
]
}
paths
=
paths
.
reject
{
|
p
|
p
==
'.'
||
p
==
'..'
}
dirs_entries
=
paths
.
select
{
|
path
|
path
.
end_with?
(
'/.'
,
'/..'
)
}
@files
=
paths
-
dirs_entries
@dirs
=
dirs_entries
.
map
{
|
d
|
d
.
gsub
(
/\/\.\.?$/
,
''
)
}.
uniq
end
...
...
@@ -61,19 +59,21 @@ module Pod
relative_glob
(
patterns
,
dir_pattern
,
exclude_patterns
).
map
{
|
p
|
root
+
p
}
end
# @return [Array<Pathname>] The list of
the relative paths that ar
e
#
case
insensitively matched by a given pattern. This method emulates
# @return [Array<Pathname>] The list of
relative paths that are cas
e
# insensitively matched by a given pattern. This method emulates
# {Dir#glob} with the {File::FNM_CASEFOLD} option.
#
# @param [Array<String>] patterns A {Dir#glob} like pattern.
# @param [String,Array<String>] patterns A signle {Dir#glob} like
# pattern, or a list of patterns.
#
# @param [String] dir_pattern An optional pattern to append to
# pattern, if
this one is the path of
a
# @param [String] dir_pattern 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
)
return
[]
if
patterns
.
empty?
patterns
=
[
patterns
]
if
patterns
.
is_a?
String
list
=
patterns
.
map
do
|
pattern
|
if
pattern
.
is_a?
(
String
)
pattern
+=
'/'
+
dir_pattern
if
directory?
(
pattern
)
&&
dir_pattern
...
...
@@ -84,14 +84,12 @@ module Pod
end
end
else
pattern
.
to_s
.
cyan
files
.
select
{
|
path
|
path
.
match
(
pattern
)
}
end
end
.
flatten
if
exclude_patterns
excluded
=
relative_glob
(
exclude_patterns
)
list
=
exclude_patterns
?
list
-
excluded
:
list
end
list
-=
relative_glob
(
exclude_patterns
)
if
exclude_patterns
list
.
map
{
|
path
|
Pathname
.
new
(
path
)
}
end
...
...
@@ -101,29 +99,24 @@ module Pod
# @param [String, Pathname] sub_path The path that could be a directory.
#
def
directory?
(
sub_path
)
sub_path
=
sub_path
.
to_s
.
downcase
.
g
sub
(
/\/$/
,
''
)
dirs
.
any?
{
|
dir
|
dir
.
downcase
==
sub_path
}
sub_path
=
sub_path
.
to_s
.
downcase
.
sub
(
/\/$/
,
''
)
dirs
.
any?
{
|
dir
|
dir
.
downcase
==
sub_path
}
end
# @return [Array<String>] An array containing the list of patterns for
# necessary to emulate {Dir#glob} with #{File.fnmatch}. If
# #{File.fnmatch} invoked with the File::FNM_PATHNAME matches any of
# the returned patterns {Dir#glob} would have matched the original
# pattern.
# @return [Array<String>] An array of patterns converted from a
# {Dir.glob} pattern to patterns that {File.fnmatch} can handle. This
# is used by the {#relative_glob} method to emulate {Dir.glob}.
#
# The expansion provides support for:
#
# - Literals
#
#
expand_pattern_literal
s('{file1,file2}.{h,m}')
#
dir_glob_equivalent_pattern
s('{file1,file2}.{h,m}')
# => ["file1.h", "file1.m", "file2.h", "file2.m"]
#
# expand_pattern_literals('file*.*')
# => ["file*.*"]
#
# - Matching the direct children of a directory with `**`
#
#
expand_pattern_literal
s('Classes/**/file.m')
#
dir_glob_equivalent_pattern
s('Classes/**/file.m')
# => ["Classes/**/file.m", "Classes/file.m"]
#
# @param [String] pattern A {Dir#glob} like pattern.
...
...
spec/unit/local_pod/path_list_spec.rb
View file @
1f62fbd2
...
...
@@ -65,7 +65,7 @@ describe Pod::LocalPod::PathList do
patterns
.
sort
.
should
==
%w| file1.h file1.m file2.h file2.m |
end
it
"returns the original patter if there are no Dir#glob expansions"
do
it
"returns the original patter
n
if there are no Dir#glob expansions"
do
patterns
=
@path_list
.
dir_glob_equivalent_patterns
(
'file*.*'
)
patterns
.
sort
.
should
==
%w| file*.* |
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