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
768b2c57
Commit
768b2c57
authored
May 14, 2016
by
Marc Boquet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PathList] Simplify read_file_system implementation
parent
420fac35
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
11 deletions
+16
-11
path_list.rb
lib/cocoapods/sandbox/path_list.rb
+13
-8
path_list_spec.rb
spec/unit/sandbox/path_list_spec.rb
+3
-3
No files found.
lib/cocoapods/sandbox/path_list.rb
View file @
768b2c57
...
@@ -50,15 +50,20 @@ module Pod
...
@@ -50,15 +50,20 @@ module Pod
unless
root
.
exist?
unless
root
.
exist?
raise
Informative
,
"Attempt to read non existent folder `
#{
root
}
`."
raise
Informative
,
"Attempt to read non existent folder `
#{
root
}
`."
end
end
root_length
=
root
.
to_s
.
length
+
1
files
=
[]
dirs
=
[]
escaped_root
=
escape_path_for_glob
(
root
)
escaped_root
=
escape_path_for_glob
(
root
)
paths
=
Dir
.
glob
(
escaped_root
+
'**/*'
,
File
::
FNM_DOTMATCH
).
sort_by
(
&
:upcase
)
paths
=
Pathname
.
glob
(
escaped_root
+
'**/*'
,
File
::
FNM_DOTMATCH
)
do
|
path
|
absolute_dirs
=
paths
.
select
{
|
path
|
File
.
directory?
(
path
)
}
next
if
path
.
basename
.
to_s
.
match
/\.\.?$/
relative_dirs
=
absolute_dirs
.
map
{
|
p
|
p
[
root_length
..-
1
]
}
relative_path
=
path
.
relative_path_from
(
root
)
absolute_paths
=
paths
.
reject
{
|
p
|
p
==
"
#{
root
}
/."
||
p
==
"
#{
root
}
/.."
}
if
path
.
directory?
relative_paths
=
absolute_paths
.
map
{
|
p
|
p
[
root_length
..-
1
]
}
dirs
<<
relative_path
.
to_s
@files
=
relative_paths
-
relative_dirs
else
@dirs
=
relative_dirs
.
map
{
|
d
|
d
.
gsub
(
/\/\.\.?$/
,
''
)
}.
reject
{
|
d
|
d
==
'.'
||
d
==
'..'
}
.
uniq
files
<<
relative_path
.
to_s
end
end
@files
=
files
.
sort_by
(
&
:upcase
)
@dirs
=
dirs
.
sort_by
(
&
:upcase
)
@glob_cache
=
{}
@glob_cache
=
{}
end
end
...
...
spec/unit/sandbox/path_list_spec.rb
View file @
768b2c57
...
@@ -170,9 +170,9 @@ module Pod
...
@@ -170,9 +170,9 @@ module Pod
it
'orders paths case insensitively'
do
it
'orders paths case insensitively'
do
root
=
fixture
(
'banana-lib'
)
root
=
fixture
(
'banana-lib'
)
# Let
Dir
.glob result be ordered case-sensitively
# Let
Pathname
.glob result be ordered case-sensitively
Dir
.
stubs
(
:glob
).
returns
([
"
#{
root
}
/Classes/NSFetchRequest+Banana.h"
,
Pathname
.
stubs
(
:glob
).
multiple_yields
(
Pathname
.
new
(
"
#{
root
}
/Classes/NSFetchRequest+Banana.h"
)
,
"
#{
root
}
/Classes/NSFetchedResultsController+Banana.h"
]
)
Pathname
.
new
(
"
#{
root
}
/Classes/NSFetchedResultsController+Banana.h"
)
)
File
.
stubs
(
:directory?
).
returns
(
false
)
File
.
stubs
(
:directory?
).
returns
(
false
)
path_list
=
Sandbox
::
PathList
.
new
(
fixture
(
'banana-lib'
))
path_list
=
Sandbox
::
PathList
.
new
(
fixture
(
'banana-lib'
))
...
...
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