Last active
June 5, 2024 14:21
-
-
Save gmcabrita/b0912beaa6a1deee016e9e57fb160402 to your computer and use it in GitHub Desktop.
ruby-lsp .index.yml excluded_gems generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "yaml" | |
require "bundler" | |
config_file = ".index.yml" | |
config = if File.exist?(config_file) | |
YAML.load_file(config_file) | |
else | |
{} | |
end | |
bundler_gems = Bundler.locked_gems&.specs.map { _1.name } | |
ruby_gems = Dir.glob(File.join(RbConfig::CONFIG["rubylibdir"], "*")).map { Pathname.new(_1).basename.to_s.delete_suffix(".rb") } | |
config["excluded_gems"] = (bundler_gems + ruby_gems).uniq.sort | |
File.open(config_file, "w") { |f| YAML.dump(config, f) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment