Class: HolePicker::DirectGemfileFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/holepicker/direct_gemfile_finder.rb

Constant Summary collapse

SKIPPED_DIRECTORIES =
[
  "-name cached-copy",
  "-path '*/bundle/ruby'",
  "-name tmp",
  "-name '.*'"
]

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ DirectGemfileFinder

Returns a new instance of DirectGemfileFinder.



12
13
14
15
# File 'lib/holepicker/direct_gemfile_finder.rb', line 12

def initialize(options = {})
  @skip_ignored = options.fetch(:skip_ignored, true)
  @only_current = options.fetch(:only_current, false)
end

Instance Method Details

#find_gemfiles(path) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/holepicker/direct_gemfile_finder.rb', line 17

def find_gemfiles(path)
  full_path = File.expand_path(path)
  gemfiles = @only_current ? "-path '*/current/Gemfile.lock'" : "-name 'Gemfile.lock'"
  options = @skip_ignored ? "\\( #{skipped_directories} \\) -prune -or #{gemfiles} -print" : gemfiles

  FileFinder.find_files(full_path, options)
end