Class: Runfile::GemFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/runfile/gem_finder.rb

Overview

Finds the path of an installed or bundled gem Adapted from [Rubocop](github.com/rubocop/rubocop/blob/master/lib/rubocop/config_loader_resolver.rb#L268)

Class Method Summary collapse

Class Method Details

.find(gem_name, file = nil) ⇒ Object



6
7
8
9
10
11
# File 'lib/runfile/gem_finder.rb', line 6

def find(gem_name, file = nil)
  gem_path = find_gem_path gem_name
  file ? File.join(gem_path, file) : gem_path
rescue Gem::LoadError
  raise GemNotFound, "Cannot import gem nub`#{gem_name}`\nTry running g`gem install #{gem_name}`"
end