Class: AsdfDiscover::Searchers::Gemfile

Inherits:
Object
  • Object
show all
Defined in:
lib/asdf_discover/searchers/gemfile.rb

Overview

Searches for a Ruby version in a Gemfile

Constant Summary collapse

GEMFILE =
"Gemfile".freeze

Instance Method Summary collapse

Instance Method Details

#callObject



7
8
9
10
11
12
13
14
15
# File 'lib/asdf_discover/searchers/gemfile.rb', line 7

def call
  return NotFound unless File.exist?(GEMFILE)

  File.open(GEMFILE, "r").each_line do |line|
    return Found.new("ruby", Regexp.last_match(1), GEMFILE) if line =~ /ruby ['"]([0-9.]+)['"]$/
  end

  NotFound
end