lib/gitdocs/manager.rb in gitdocs-0.4.0 vs lib/gitdocs/manager.rb in gitdocs-0.4.1

- old
+ new

@@ -8,10 +8,21 @@ @config = Configuration.new(config_root) @debug = debug yield @config if block_given? end + RepoDescriptor = Struct.new(:name, :index) + + def search(term) + results = {} + @runners.each_with_index do |runner, index| + descriptor = RepoDescriptor.new(runner.root, index) + results[descriptor] = runner.search(term) + end + results + end + def run run = true trap('USR1') { run = true; EM.stop } while run run = false @@ -19,15 +30,15 @@ puts "Using configuration root: '#{self.config.config_root}'" if self.debug puts "Shares: #{config.shares.map(&:inspect).join(", ")}" if self.debug # Start the repo watchers runners = nil EM.run do - runners = config.shares.map { |share| Runner.new(share) } - runners.each(&:run) + @runners = config.shares.map { |share| Runner.new(share) } + @runners.each(&:run) # Start the web front-end if self.config.global.start_web_frontend - Server.new(self, *runners).start + Server.new(self, *@runners).start i = 0 web_started = false begin TCPSocket.open('127.0.0.1', 8888).close web_started = true @@ -37,10 +48,10 @@ retry if i <= 20 end system("open http://localhost:8888/") if self.config.global.load_browser_on_startup && web_started end end - sleep(10) if runners && runners.empty? + sleep(10) if @runners && @runners.empty? end end def restart Process.kill("USR1", Process.pid) \ No newline at end of file