Class: Legion::CLI::Doctor::BundleCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/cli/doctor/bundle_check.rb

Instance Method Summary collapse

Instance Method Details

#fixObject



40
41
42
# File 'lib/legion/cli/doctor/bundle_check.rb', line 40

def fix
  system('bundle install')
end

#nameObject



9
10
11
# File 'lib/legion/cli/doctor/bundle_check.rb', line 9

def name
  'Bundle status'
end

#runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/legion/cli/doctor/bundle_check.rb', line 13

def run
  gemfile = find_gemfile
  return Result.new(name: name, status: :skip, message: 'No Gemfile found') unless gemfile

  stdout, stderr, status = Open3.capture3('bundle check')
  if status.success?
    Result.new(name: name, status: :pass, message: 'All gems installed')
  else
    detail = (stdout + stderr).strip
    Result.new(
      name:         name,
      status:       :fail,
      message:      "Gems missing or outdated: #{detail.lines.first&.strip}",
      prescription: 'Run `bundle install`',
      auto_fixable: true
    )
  end
rescue Errno::ENOENT => e
  Legion::Logging.warn("BundleCheck#run bundler not found: #{e.message}") if defined?(Legion::Logging)
  Result.new(
    name:         name,
    status:       :fail,
    message:      'bundler not found',
    prescription: 'Install bundler: `gem install bundler`'
  )
end