-
Notifications
You must be signed in to change notification settings - Fork 348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes search index format to fasten pod search --full
command.
#265
Changes search index format to fasten pod search --full
command.
#265
Conversation
rescue | ||
CoreUI.warn "Skipping `#{set.name}` because the podspec contains " \ | ||
'errors.' | ||
result | ||
return [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return
keyword is superfluous
index['BananaLib'].should == ['BananaLib'] | ||
index['JSONKit'].should == ['JSONKit'] | ||
index['JSONSpec'].should == ['JSONSpec'] | ||
index['Faulty_spec'].should.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should.be.nil
Got an offense from RuboCop about using return while returning two parameters. I think I have to use return in this case, so we can ignore it. Or maybe I can return an array value including two parameters. Which makes more sense? |
output = `git pull --ff-only` | ||
changed_spec_paths = (`git diff --name-only #{prev_commit_hash}..HEAD`).strip.split("\n") | ||
end | ||
return output, changed_spec_paths |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[output, changed_spec_paths]
, no return
@manuyavuz are these PRs ready for final review? |
It lacks specs but I think we should be in the same line about the implementation before starting specs. So I think it's ready for review regarng implementation. What do you think? |
# Returns the list of changed spec paths. | ||
# | ||
def update(show_output = false) | ||
changed_spec_paths = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be []
If we're OK with the current state, I'll move on adding specs. Just let me know. |
I am, but maybe @floere has some thoughts |
result | ||
string = set.name.dup | ||
if spec.summary | ||
string << ' ' << spec.summary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Ruby, it's generally better to avoid string << ' ' << spec.summary
because with each <<
, a String is created. Use arrays to <<
the strings, then join
once at the end.
Or better yet, in this case, only split where necessary (e.g. in summary) and append the result to the array using +=
, then uniq
at the end.
Only one comment, repeated here, refering to the latest commit where this code is located, |
Happy to wait for the specs now 😊 Thanks for all your work!!! |
Great hint @floere 👏🏼 I'm starting to specs 💥 |
Done with specs. You can check out and review now. I'll rewrite history a little to have a convenient history. Other than that, I think this is ready to go to master. |
Looks amazing to me 👍 |
(`git rev-parse HEAD` || '').strip | ||
end | ||
|
||
def update_git_repo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should override this in CocoaPods/CocoaPods to use executable, so the output is still streamed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is needed because it's output is handled and streamed in update
method above.
Look at the lines between 292-300. It uses CoreUI which is handled by CocoaPods by default in user_interface.rb
as far as I understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the output here will no longer be streamed -- it will only be printed after the command is finished.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, this prints after command is finished. So what should we do?
I think we're gonna remove CoreUI.puts output if show_output
part in update method here in order not to have duplicate output. However, I didn't fully get how to override a method of Source class in cocoapods code (probably in sources_manager.rb but how)?
I'm not a native ruby person so probably I miss sth :)
I think I've found the way to override class Source
extend Executable
executable :git
alias_method :_original_update_git_repo, :update_git_repo
def update_git_repo
git %w(pull --ff-only)
end
end I will add to CocoaPods/CocoaPods#4249 in next commit. |
@manuyavuz no need to alias |
It was really simple then 👍 Regarding this, we may completely remove UI printing here, and handle it in sources_manager again, this time in above overridden method. What do you think? |
Sure |
result = {} | ||
sets.each do |set| | ||
word_list_from_set(set).each do |w| | ||
(result[w] ||= []).push(set.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depending on the average number of words in a wordlist, using the set name/identifier as a symbol will use a bit less space. If it's only used to generate the file index, and not for storing it in memory (and search operations) it's not that crucial.
Looks good – only had comments on the index creation. Thanks again for your work, @manuyavuz! 🚀 |
@floere Actually the new specs I've added implicitly verify this method's correctness. What type of checks you think needed more? Like specs having no description, or authors part? Or like checking if strings are splitted correctly? Could you share if you have edge cases in your mind which you feel does not being tested now? I can add them accordingly. |
@manuyavuz Just checking how strings are split. Very simple, maybe something as simple as |
- Previous implementation was having the drawback of traversing and performing `gsub` on all index strings for each pod specification. - New implementation stores words as keys and list of pods containing corresponding word inside their specification as the values for corresponding hash keys. By this way, sources manager can perform a faster search operation.
@floere I've added a spec for |
@manuyavuz All good! 👍 🚀 |
Assuming this is ready to ⛵️, should I wait this to be merged in order to finish the last commit in CocoaPods/CocoaPods#4249? You remember I was directed Core repo to my branch for specs to be passed. If we merge this, I can revert it and submit last commit, so that we see green lights from boss travis. |
Added changelog. |
🚀 🚢 |
Changes search index format to fasten `pod search --full` command.
…formance Changes search index format to fasten `pod search --full` command.
Detailed discussion can be found here: CocoaPods/cocoapods-search#8
gsub
on all index strings for each pod specification.