Module: Capistrano::Ops::Helper

Included in:
TaskLoader
Defined in:
lib/capistrano/ops/helper.rb

Instance Method Summary collapse

Instance Method Details

#gem_in_gemfile?(gem_name) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
# File 'lib/capistrano/ops/helper.rb', line 6

def gem_in_gemfile?(gem_name)
  return false unless File.exist?('Gemfile')

  regex = Regexp.new("^\s*gem\s+['\"]#{gem_name}['\"].*?(?=#|$)", Regexp::MULTILINE)
  File.read('Gemfile').match?(regex)
end