const fs = require('fs');
const path = require('path');

/**
 * Ruby LSP adapter — ruby-lsp (Shopify).
 *
 * Installed as a gem; system-mode. Users on Bundler-managed projects may
 * prefer to add `gem 'ruby-lsp', group: :development` to their Gemfile and
 * `bundle install` instead — we print the simple gem install command for
 * portability.
 */
class RubyAdapter {
  constructor(cwd = process.cwd()) { this.cwd = cwd; }

  get name() { return 'ruby'; }
  get label() { return 'Ruby (ruby-lsp)'; }
  get binary() { return 'ruby-lsp'; }
  get installMode() { return 'system'; }

  installCommand() { return 'gem install ruby-lsp'; }
  verifyCommand() { return 'ruby-lsp --version'; }
  claudePluginId() { return 'ruby-lsp@claude-plugins-official'; }

  static detect(cwd = process.cwd()) {
    const markers = ['Gemfile', '.ruby-version', 'config.ru'];
    return markers.some(m => fs.existsSync(path.join(cwd, m)));
  }
}

module.exports = RubyAdapter;
