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
59c87ff3
Commit
59c87ff3
authored
Dec 03, 2013
by
Florian R. Hanke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add regexp-search capabilities to full text search and lower memory usage.
parent
73d5a97a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
5 deletions
+13
-5
sources_manager.rb
lib/cocoapods/sources_manager.rb
+6
-5
sources_manager_spec.rb
spec/unit/sources_manager_spec.rb
+7
-0
No files found.
lib/cocoapods/sources_manager.rb
View file @
59c87ff3
...
@@ -61,14 +61,15 @@ module Pod
...
@@ -61,14 +61,15 @@ module Pod
def
search_by_name
(
query
,
full_text_search
=
false
)
def
search_by_name
(
query
,
full_text_search
=
false
)
if
full_text_search
if
full_text_search
set_names
=
[]
set_names
=
[]
query_regexp
=
%r{
#{
query
}
}i
updated_search_index
.
each
do
|
name
,
set_data
|
updated_search_index
.
each
do
|
name
,
set_data
|
text
=
name
.
dup
text
s
=
[
name
]
if
full_text_search
if
full_text_search
text
<<
set_data
[
'authors'
].
to_s
if
set_data
[
'authors'
]
text
s
<<
set_data
[
'authors'
].
to_s
if
set_data
[
'authors'
]
text
<<
set_data
[
'summary'
]
if
set_data
[
'summary'
]
text
s
<<
set_data
[
'summary'
]
if
set_data
[
'summary'
]
text
<<
set_data
[
'description'
]
if
set_data
[
'description'
]
text
s
<<
set_data
[
'description'
]
if
set_data
[
'description'
]
end
end
set_names
<<
name
if
text
.
downcase
.
include?
(
query
.
downcase
)
set_names
<<
name
unless
texts
.
grep
(
query_regexp
).
empty?
end
end
sets
=
set_names
.
sort
.
map
{
|
name
|
aggregate
.
represenative_set
(
name
)
}
sets
=
set_names
.
sort
.
map
{
|
name
|
aggregate
.
represenative_set
(
name
)
}
else
else
...
...
spec/unit/sources_manager_spec.rb
View file @
59c87ff3
...
@@ -49,6 +49,13 @@ module Pod
...
@@ -49,6 +49,13 @@ module Pod
sets
.
all?
{
|
s
|
s
.
class
==
Specification
::
Set
}.
should
.
be
.
true
sets
.
all?
{
|
s
|
s
.
class
==
Specification
::
Set
}.
should
.
be
.
true
sets
.
any?
{
|
s
|
s
.
name
==
'BananaLib'
}.
should
.
be
.
true
sets
.
any?
{
|
s
|
s
.
name
==
'BananaLib'
}.
should
.
be
.
true
end
end
it
"can perform a full text regexp search of the sets"
do
Source
::
Aggregate
.
any_instance
.
stubs
(
:all
).
returns
([
@test_source
])
sets
=
SourcesManager
.
search_by_name
(
'Ch[aeiou]nky'
,
true
)
sets
.
all?
{
|
s
|
s
.
class
==
Specification
::
Set
}.
should
.
be
.
true
sets
.
any?
{
|
s
|
s
.
name
==
'BananaLib'
}.
should
.
be
.
true
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
Source
::
Aggregate
.
any_instance
.
stubs
(
:all
).
returns
([
@test_source
])
Source
::
Aggregate
.
any_instance
.
stubs
(
:all
).
returns
([
@test_source
])
...
...
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