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
ddc30310
Commit
ddc30310
authored
Nov 03, 2015
by
Dimitris Koutsogiorgas
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into master
parents
4cbec90f
c12cc39d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
89 additions
and
3 deletions
+89
-3
CHANGELOG.md
CHANGELOG.md
+5
-0
Gemfile.lock
Gemfile.lock
+2
-2
sources_manager.rb
lib/cocoapods/sources_manager.rb
+31
-1
sources_manager_spec.rb
spec/unit/sources_manager_spec.rb
+51
-0
No files found.
CHANGELOG.md
View file @
ddc30310
...
@@ -18,6 +18,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
...
@@ -18,6 +18,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[
#4487
](
https://github.com/CocoaPods/CocoaPods/pull/4487
)
[
#4487
](
https://github.com/CocoaPods/CocoaPods/pull/4487
)
*
Improve
`pod search`
performance while using _
`--full`
_ flag
*
Improve
`pod search`
performance while using _
`--full`
_ flag
*
Improve sorting algorithm for
`pod search`
.
[
Muhammed Yavuz Nuzumlalı
](
https://github.com/manuyavuz
)
[
cocoapods-search#12
](
https://github.com/CocoaPods/cocoapods-search/issues/12
)
*
Improve
`pod search`
performance while using _
`--full`
_ flag.
[
Muhammed Yavuz Nuzumlalı
](
https://github.com/manuyavuz
)
[
Muhammed Yavuz Nuzumlalı
](
https://github.com/manuyavuz
)
[
cocoapods-search#8
](
https://github.com/CocoaPods/cocoapods-search/issues/8
)
[
cocoapods-search#8
](
https://github.com/CocoaPods/cocoapods-search/issues/8
)
...
...
Gemfile.lock
View file @
ddc30310
...
@@ -7,7 +7,7 @@ GIT
...
@@ -7,7 +7,7 @@ GIT
GIT
GIT
remote: https://github.com/CocoaPods/Core.git
remote: https://github.com/CocoaPods/Core.git
revision:
d66fcb7160f060198c3808eb2ff3f51edf21268
7
revision:
ce26e1eb797a6ad1f1d94b0304a50c491bc4123
7
branch: master
branch: master
specs:
specs:
cocoapods-core (0.39.0)
cocoapods-core (0.39.0)
...
@@ -49,7 +49,7 @@ GIT
...
@@ -49,7 +49,7 @@ GIT
GIT
GIT
remote: https://github.com/CocoaPods/cocoapods-search.git
remote: https://github.com/CocoaPods/cocoapods-search.git
revision: 4
e7de92e477f47918d869a7c4819251633efca0d
revision: 4
281e740769875ba4e48748b73c7ff832a8d336e
branch: master
branch: master
specs:
specs:
cocoapods-search (0.1.0)
cocoapods-search (0.1.0)
...
...
lib/cocoapods/sources_manager.rb
View file @
ddc30310
...
@@ -113,8 +113,8 @@ module Pod
...
@@ -113,8 +113,8 @@ module Pod
# @return [Array<Set>] The sets that contain the search term.
# @return [Array<Set>] The sets that contain the search term.
#
#
def
search_by_name
(
query
,
full_text_search
=
false
)
def
search_by_name
(
query
,
full_text_search
=
false
)
query_word_regexps
=
query
.
split
.
map
{
|
word
|
/
#{
word
}
/i
}
if
full_text_search
if
full_text_search
query_word_regexps
=
query
.
split
.
map
{
|
word
|
/
#{
word
}
/i
}
query_word_results_hash
=
{}
query_word_results_hash
=
{}
updated_search_index
.
each_value
do
|
word_spec_hash
|
updated_search_index
.
each_value
do
|
word_spec_hash
|
word_spec_hash
.
each_pair
do
|
word
,
spec_symbols
|
word_spec_hash
.
each_pair
do
|
word
,
spec_symbols
|
...
@@ -125,6 +125,7 @@ module Pod
...
@@ -125,6 +125,7 @@ module Pod
end
end
end
end
found_set_symbols
=
query_word_results_hash
.
values
.
reduce
(
:&
)
found_set_symbols
=
query_word_results_hash
.
values
.
reduce
(
:&
)
found_set_symbols
||=
[]
sets
=
found_set_symbols
.
map
do
|
symbol
|
sets
=
found_set_symbols
.
map
do
|
symbol
|
aggregate
.
representative_set
(
symbol
.
to_s
)
aggregate
.
representative_set
(
symbol
.
to_s
)
end
end
...
@@ -138,6 +139,35 @@ module Pod
...
@@ -138,6 +139,35 @@ module Pod
raise
Informative
,
"Unable to find a pod with name
#{
extra
}
"
\
raise
Informative
,
"Unable to find a pod with name
#{
extra
}
"
\
"matching `
#{
query
}
`"
"matching `
#{
query
}
`"
end
end
sorted_sets
(
sets
,
query_word_regexps
)
end
# Returns given set array by sorting it in-place.
#
# @param [Array<Set>] sets
# Array of sets to be sorted.
#
# @param [Array<Regexp>] query_word_regexps
# Array of regexp objects for user query.
#
# @return [Array<Set>] Given sets parameter itself after sorting it in-place.
#
def
sorted_sets
(
sets
,
query_word_regexps
)
sets
.
sort_by!
do
|
set
|
pre_match_length
=
nil
found_query_index
=
nil
found_query_count
=
0
query_word_regexps
.
each_with_index
do
|
q
,
idx
|
if
(
m
=
set
.
name
.
match
(
/
#{
q
}
/i
))
pre_match_length
||=
(
m
.
pre_match
.
length
)
found_query_index
||=
idx
found_query_count
+=
1
end
end
pre_match_length
||=
1000
found_query_index
||=
1000
[
-
found_query_count
,
pre_match_length
,
found_query_index
,
set
.
name
.
downcase
]
end
sets
sets
end
end
...
...
spec/unit/sources_manager_spec.rb
View file @
ddc30310
...
@@ -84,6 +84,57 @@ module Pod
...
@@ -84,6 +84,57 @@ module Pod
sets
.
any?
{
|
s
|
s
.
name
==
'BananaLib'
}.
should
.
be
.
true
sets
.
any?
{
|
s
|
s
.
name
==
'BananaLib'
}.
should
.
be
.
true
end
end
describe
'Sorting algorithm'
do
before
do
@test_search_results
=
%w(HockeyKit DLSuit VCLReachability NPReachability AVReachability PYNetwork
SCNetworkReachability AFNetworking Networking)
.
map
do
|
name
|
Specification
::
Set
.
new
(
name
)
end
end
it
'puts pod with exact match at the first index while sorting'
do
regexps
=
[
/networking/i
]
sets
=
SourcesManager
.
sorted_sets
(
@test_search_results
,
regexps
)
sets
[
0
].
name
.
should
==
'Networking'
end
it
'puts pod with less prefix length before pods with more prefix length in search results'
do
regexps
=
[
/reachability/i
]
sets
=
SourcesManager
.
sorted_sets
(
@test_search_results
,
regexps
)
sets
.
index
{
|
s
|
s
.
name
==
'AVReachability'
}.
should
.
be
<
sets
.
index
{
|
s
|
s
.
name
==
'VCLReachability'
}
end
it
'puts pod with more query word match before pods with less match in multi word query search results'
do
regexps
=
[
/network/i
,
/reachability/i
]
sets
=
SourcesManager
.
sorted_sets
(
@test_search_results
,
regexps
)
sets
.
index
{
|
s
|
s
.
name
==
'SCNetworkReachability'
}.
should
.
be
<
sets
.
index
{
|
s
|
s
.
name
==
'AVReachability'
}
end
it
'puts pod matching first query word before pods matching later words in multi word query search results'
do
regexps
=
[
/network/i
,
/reachability/i
]
sets
=
SourcesManager
.
sorted_sets
(
@test_search_results
,
regexps
)
sets
.
index
{
|
s
|
s
.
name
==
'PYNetwork'
}.
should
.
be
<
sets
.
index
{
|
s
|
s
.
name
==
'AVReachability'
}
end
it
'puts pod matching first query word before pods matching later words in multi word query search results'
do
regexps
=
[
/network/i
,
/reachability/i
]
sets
=
SourcesManager
.
sorted_sets
(
@test_search_results
,
regexps
)
sets
.
index
{
|
s
|
s
.
name
==
'PYNetwork'
}.
should
.
be
<
sets
.
index
{
|
s
|
s
.
name
==
'AVReachability'
}
end
it
'alphabetically sorts pods having exact other conditions'
do
regexps
=
[
/reachability/i
]
sets
=
SourcesManager
.
sorted_sets
(
@test_search_results
,
regexps
)
sets
.
index
{
|
s
|
s
.
name
==
'AVReachability'
}.
should
.
be
<
sets
.
index
{
|
s
|
s
.
name
==
'NPReachability'
}
end
it
'alphabetically sorts pods whose names does not match query'
do
regexps
=
[
/reachability/i
]
sets
=
SourcesManager
.
sorted_sets
(
@test_search_results
,
regexps
)
sets
.
index
{
|
s
|
s
.
name
==
'DLSuit'
}.
should
.
be
<
sets
.
index
{
|
s
|
s
.
name
==
'HockeyKit'
}
end
end
it
"generates the search index before performing a search if it doesn't exits"
do
it
"generates the search index before performing a search if it doesn't exits"
do
SourcesManager
.
stubs
(
:all
).
returns
([
@test_source
])
SourcesManager
.
stubs
(
:all
).
returns
([
@test_source
])
Source
::
Aggregate
.
any_instance
.
expects
(
:generate_search_index_for_source
).
with
(
@test_source
).
returns
(
'BananaLib'
=>
[
'BananaLib'
])
Source
::
Aggregate
.
any_instance
.
expects
(
:generate_search_index_for_source
).
with
(
@test_source
).
returns
(
'BananaLib'
=>
[
'BananaLib'
])
...
...
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