Fix offenses

parent 482f0669
...@@ -114,7 +114,7 @@ module Pod ...@@ -114,7 +114,7 @@ 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
query_word_regexps = query.split.map{ |word| /#{word}/i } 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|
...@@ -161,7 +161,7 @@ module Pod ...@@ -161,7 +161,7 @@ module Pod
unless index[source_name] unless index[source_name]
UI.print "Creating search index for spec repo '#{source_name}'.." UI.print "Creating search index for spec repo '#{source_name}'.."
index[source_name] = aggregate.generate_search_index_for_source(source) index[source_name] = aggregate.generate_search_index_for_source(source)
UI.puts " Done!" UI.puts ' Done!'
end end
end end
save_search_index(index) save_search_index(index)
...@@ -216,6 +216,7 @@ module Pod ...@@ -216,6 +216,7 @@ module Pod
# Update is performed incrementally. Only the changed pods' search data is re-generated and updated. # Update is performed incrementally. Only the changed pods' search data is re-generated and updated.
# @param [Hash{Source => Array<String>}] changed_spec_paths # @param [Hash{Source => Array<String>}] changed_spec_paths
# A hash containing changed specification paths for each source. # A hash containing changed specification paths for each source.
#
def update_search_index_if_needed(changed_spec_paths) def update_search_index_if_needed(changed_spec_paths)
search_index = stored_search_index search_index = stored_search_index
return unless search_index return unless search_index
...@@ -242,6 +243,9 @@ module Pod ...@@ -242,6 +243,9 @@ module Pod
end end
# Updates search index for changed pods in background # Updates search index for changed pods in background
# @param [Hash{Source => Array<String>}] changed_spec_paths
# A hash containing changed specification paths for each source.
#
def update_search_index_if_needed_in_background(changed_spec_paths) def update_search_index_if_needed_in_background(changed_spec_paths)
Process.fork do Process.fork do
Process.daemon Process.daemon
...@@ -540,7 +544,6 @@ module Pod ...@@ -540,7 +544,6 @@ module Pod
executable :git executable :git
def update_git_repo(show_output = false) def update_git_repo(show_output = false)
begin
output = git! %w(pull --ff-only) output = git! %w(pull --ff-only)
UI.puts output if show_output UI.puts output if show_output
rescue rescue
...@@ -550,5 +553,4 @@ module Pod ...@@ -550,5 +553,4 @@ module Pod
'`pod repo update --verbose`' '`pod repo update --verbose`'
end end
end end
end
end end
...@@ -28,12 +28,12 @@ module Pod ...@@ -28,12 +28,12 @@ module Pod
repo2 = repo_clone('repo1', 'repo2') repo2 = repo_clone('repo1', 'repo2')
repo_make_readme_change(repo1, 'Updated') repo_make_readme_change(repo1, 'Updated')
Dir.chdir(repo1) { `git commit -a -m "Update"` } Dir.chdir(repo1) { `git commit -a -m "Update"` }
SourcesManager.expects(:update_search_index_if_needed_in_background).with() { |value| SourcesManager.expects(:update_search_index_if_needed_in_background).with do |value|
value.each_pair { |source, paths| value.each_pair do |source, paths|
source.name.should == 'repo2' source.name.should == 'repo2'
paths.should == ['README'] paths.should == ['README']
} end
} end
run_command('repo', 'update', 'repo2') run_command('repo', 'update', 'repo2')
(repo2 + 'README').read.should.include 'Updated' (repo2 + 'README').read.should.include 'Updated'
end end
......
...@@ -244,14 +244,14 @@ module Pod ...@@ -244,14 +244,14 @@ module Pod
end end
it 'updates search index for changed paths if source is updated' do it 'updates search index for changed paths if source is updated' do
prev_index = {@test_source.name => {}} prev_index = { @test_source.name => {} }
SourcesManager.expects(:stored_search_index).returns(prev_index) SourcesManager.expects(:stored_search_index).returns(prev_index)
SourcesManager.expects(:save_search_index).with() { |value| SourcesManager.expects(:save_search_index).with do |value|
value[@test_source.name]['BananaLib'].should.include(:BananaLib) value[@test_source.name]['BananaLib'].should.include(:BananaLib)
value[@test_source.name]['JSONKit'].should.include(:JSONKit) value[@test_source.name]['JSONKit'].should.include(:JSONKit)
} end
changed_paths = {@test_source => %w(BananaLib/1.0/BananaLib.podspec JSONKit/1.4/JSONKit.podspec)} changed_paths = { @test_source => %w(BananaLib/1.0/BananaLib.podspec JSONKit/1.4/JSONKit.podspec) }
SourcesManager.update_search_index_if_needed(changed_paths) SourcesManager.update_search_index_if_needed(changed_paths)
end end
...@@ -259,10 +259,10 @@ module Pod ...@@ -259,10 +259,10 @@ module Pod
prev_index = {} prev_index = {}
SourcesManager.expects(:stored_search_index).returns(prev_index) SourcesManager.expects(:stored_search_index).returns(prev_index)
SourcesManager.expects(:save_search_index).with() { |value| SourcesManager.expects(:save_search_index).with do |value|
value[@test_source.name].should.be.nil value[@test_source.name].should.be.nil
} end
changed_paths = {@test_source => %w(BananaLib/1.0/BananaLib.podspec JSONKit/1.4/JSONKit.podspec)} changed_paths = { @test_source => %w(BananaLib/1.0/BananaLib.podspec JSONKit/1.4/JSONKit.podspec) }
SourcesManager.update_search_index_if_needed(changed_paths) SourcesManager.update_search_index_if_needed(changed_paths)
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment