Skip to content

Instantly share code, notes, and snippets.

@kgilpin
Last active February 10, 2021 21:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kgilpin/3c8cf4e67e5cbc80c5c3221936bfcbe3 to your computer and use it in GitHub Desktop.
Save kgilpin/3c8cf4e67e5cbc80c5c3221936bfcbe3 to your computer and use it in GitHub Desktop.
VSCode project with Rails gem paths

Usage

  1. Save rails_gem_paths.rb to your local directory

  2. Run this command to open a VSCode project containing the local directory and all "active*" and "action*" gems. The script also prints out the gem names in appmap.yml form.

code . $(bundle exec ruby rails_gem_paths.rb)
# - gem: actioncable
# - gem: actionmailbox
# - gem: actionmailer
# - gem: actionpack
# - gem: actiontext
# - gem: actionview
# - gem: activejob
# - gem: activemodel
# - gem: activerecord
# - gem: activestorage
# - gem: activesupport

VSCode is now open. You can copy the - gem: snippet into your appmap.yml. Uncomment the ones that you want to use.

Note: actionpack doesn't work right now, due to a bug in the UI. If you get empty AppMaps, remove - gem: actionpack.

#!/usr/bin/env ruby
gems = Bundler.definition.resolve.select {|n| n.name =~ /^active/ || n.name =~ /^action/ }.sort { |a,b| a.name <=> b.name }
$stderr.puts gems.map { |gem| "# - gem: #{gem.name}" }.join("\n")
paths = gems.map { |gem| Gem.loaded_specs[gem.name].full_gem_path }
puts paths.join(' ')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment