Sha256: 6085c26928a6e098b561598a8a025ecbab01cf68e146a256475c62c5670b19ec

Contents?: true

Size: 813 Bytes

Versions: 12

Compression:

Stored size: 813 Bytes

Contents

module Hobo
  module Helper
    def locate(pattern, opts = {}, &block)
      match = nil

      Dir.chdir Hobo.project_path do
        match = locate_git(pattern, &block)
      end

      return true if match

      Hobo.ui.warning opts[:missing] if opts[:missing]
      return false
    end

    private

    def locate_git pattern, &block
      args = [ 'git', 'ls-files', pattern ]
      output = Hobo::Helper.shell *args, :capture => true
      paths = output.split("\n")
      found = false
      paths.each do |path|
        path.strip!
        Dir.chdir File.dirname(path) do
          Hobo::Logging.logger.debug "helper.locator: Found #{path} for #{pattern}"
          yield File.basename(path), path
        end

        found = true
      end

      return found
    end
  end
end

include Hobo::Helper

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
hobo-inviqa-0.0.14 lib/hobo/helper/file_locator.rb
hobo-inviqa-0.0.13 lib/hobo/helper/file_locator.rb
hobo-inviqa-0.0.11 lib/hobo/helper/file_locator.rb
hobo-inviqa-0.0.10 lib/hobo/helper/file_locator.rb
hobo-inviqa-0.0.10.pre.rc11 lib/hobo/helper/file_locator.rb
hobo-inviqa-0.0.10.pre.rc10 lib/hobo/helper/file_locator.rb
hobo-inviqa-0.0.10.pre.rc9 lib/hobo/helper/file_locator.rb
hobo-inviqa-0.0.10.pre.rc8 lib/hobo/helper/file_locator.rb
hobo-inviqa-0.0.10.pre.rc7 lib/hobo/helper/file_locator.rb
hobo-inviqa-0.0.10.pre.rc6 lib/hobo/helper/file_locator.rb
hobo-inviqa-0.0.10.pre.rc4 lib/hobo/helper/file_locator.rb
hobo-inviqa-0.0.10.pre.rc2 lib/hobo/helper/file_locator.rb