Skip to content

Instantly share code, notes, and snippets.

@kgilpin

kgilpin/README.md

Last active Feb 10, 2021
Embed
What would you like to do?
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