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
...
@@ -44,12 +44,10 @@ module Pod
#
#
def
read_file_system
def
read_file_system
root_length
=
root
.
to_s
.
length
+
1
root_length
=
root
.
to_s
.
length
+
1
paths
=
Dir
.
glob
(
root
+
"**/*"
,
File
::
FNM_DOTMATCH
)
paths
=
Dir
.
glob
(
root
+
"**/*"
,
File
::
FNM_DOTMATCH
)
paths
=
paths
.
map
{
|
p
|
p
[
root_length
..-
1
]
}
paths
=
paths
.
map
{
|
p
|
p
[
root_length
..-
1
]
}
paths
=
paths
.
reject
do
|
p
|
paths
=
paths
.
reject
{
|
p
|
p
==
'.'
||
p
==
'..'
}
p
==
'.'
||
p
==
'..'
dirs_entries
=
paths
.
select
{
|
path
|
path
.
end_with?
(
'/.'
,
'/..'
)
}
end
dirs_entries
=
paths
.
select
{
|
path
|
path
.
end_with?
(
'/.'
,
'/..'
)
}
@files
=
paths
-
dirs_entries
@files
=
paths
-
dirs_entries
@dirs
=
dirs_entries
.
map
{
|
d
|
d
.
gsub
(
/\/\.\.?$/
,
''
)
}.
uniq
@dirs
=
dirs_entries
.
map
{
|
d
|
d
.
gsub
(
/\/\.\.?$/
,
''
)
}.
uniq
end
end
...
@@ -61,19 +59,21 @@ module Pod
...
@@ -61,19 +59,21 @@ module Pod
relative_glob
(
patterns
,
dir_pattern
,
exclude_patterns
).
map
{
|
p
|
root
+
p
}
relative_glob
(
patterns
,
dir_pattern
,
exclude_patterns
).
map
{
|
p
|
root
+
p
}
end
end
# @return [Array<Pathname>] The list of
the relative paths that ar
e
# @return [Array<Pathname>] The list of
relative paths that are cas
e
#
case
insensitively matched by a given pattern. This method emulates
# insensitively matched by a given pattern. This method emulates
# {Dir#glob} with the {File::FNM_CASEFOLD} option.
# {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
# @param [String] dir_pattern An optional pattern to append to
a
# pattern, if
this one is the path of
a
# pattern, if
it is the path to
a
# directory.
# directory.
#
#
def
relative_glob
(
patterns
,
dir_pattern
=
nil
,
exclude_patterns
=
nil
)
def
relative_glob
(
patterns
,
dir_pattern
=
nil
,
exclude_patterns
=
nil
)
return
[]
if
patterns
.
empty?
return
[]
if
patterns
.
empty?
patterns
=
[
patterns
]
if
patterns
.
is_a?
String
patterns
=
[
patterns
]
if
patterns
.
is_a?
String
list
=
patterns
.
map
do
|
pattern
|
list
=
patterns
.
map
do
|
pattern
|
if
pattern
.
is_a?
(
String
)
if
pattern
.
is_a?
(
String
)
pattern
+=
'/'
+
dir_pattern
if
directory?
(
pattern
)
&&
dir_pattern
pattern
+=
'/'
+
dir_pattern
if
directory?
(
pattern
)
&&
dir_pattern
...
@@ -84,14 +84,12 @@ module Pod
...
@@ -84,14 +84,12 @@ module Pod
end
end
end
end
else
else
pattern
.
to_s
.
cyan
files
.
select
{
|
path
|
path
.
match
(
pattern
)
}
files
.
select
{
|
path
|
path
.
match
(
pattern
)
}
end
end
end
.
flatten
end
.
flatten
if
exclude_patterns
excluded
=
relative_glob
(
exclude_patterns
)
list
-=
relative_glob
(
exclude_patterns
)
if
exclude_patterns
list
=
exclude_patterns
?
list
-
excluded
:
list
end
list
.
map
{
|
path
|
Pathname
.
new
(
path
)
}
list
.
map
{
|
path
|
Pathname
.
new
(
path
)
}
end
end
...
@@ -101,29 +99,24 @@ module Pod
...
@@ -101,29 +99,24 @@ module Pod
# @param [String, Pathname] sub_path The path that could be a directory.
# @param [String, Pathname] sub_path The path that could be a directory.
#
#
def
directory?
(
sub_path
)
def
directory?
(
sub_path
)
sub_path
=
sub_path
.
to_s
.
downcase
.
g
sub
(
/\/$/
,
''
)
sub_path
=
sub_path
.
to_s
.
downcase
.
sub
(
/\/$/
,
''
)
dirs
.
any?
{
|
dir
|
dir
.
downcase
==
sub_path
}
dirs
.
any?
{
|
dir
|
dir
.
downcase
==
sub_path
}
end
end
# @return [Array<String>] An array containing the list of patterns for
# @return [Array<String>] An array of patterns converted from a
# necessary to emulate {Dir#glob} with #{File.fnmatch}. If
# {Dir.glob} pattern to patterns that {File.fnmatch} can handle. This
# #{File.fnmatch} invoked with the File::FNM_PATHNAME matches any of
# is used by the {#relative_glob} method to emulate {Dir.glob}.
# the returned patterns {Dir#glob} would have matched the original
# pattern.
#
#
# The expansion provides support for:
# The expansion provides support for:
#
#
# - Literals
# - 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"]
# => ["file1.h", "file1.m", "file2.h", "file2.m"]
#
#
# expand_pattern_literals('file*.*')
# => ["file*.*"]
#
# - Matching the direct children of a directory with `**`
# - 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"]
# => ["Classes/**/file.m", "Classes/file.m"]
#
#
# @param [String] pattern A {Dir#glob} like pattern.
# @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
...
@@ -65,7 +65,7 @@ describe Pod::LocalPod::PathList do
patterns
.
sort
.
should
==
%w| file1.h file1.m file2.h file2.m |
patterns
.
sort
.
should
==
%w| file1.h file1.m file2.h file2.m |
end
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
=
@path_list
.
dir_glob_equivalent_patterns
(
'file*.*'
)
patterns
.
sort
.
should
==
%w| file*.* |
patterns
.
sort
.
should
==
%w| file*.* |
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