Date や String のメソッドに関しては pry-doc のリファレンスを参照することができますがクラスそのものにジャンプすることはできません (Can’t find the location になる)
一応たどる方法があるので紹介します
環境
macOS 11.7
emacs 28.1
方法: pry で show-source を実行し CRuby のソースコードを入手する
emacs で pry バッファに移動して以下のように show-source Date を実行しましょう
[11] pry(main)> show-source Date
Identifier not found - do you want to install CRuby sources to attempt to resolve the identifier there?
This allows the lookup of C internals Y/N Y
Downloading and setting up Ruby 3_1_2 source...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 14.3M 0 14.3M 0 0 2518k 0 --:--:-- 0:00:05 --:--:-- 2429k
Generating tagfile!
...Finished!
これで再度 Date からジャンプすればソースコードを参照できるようになります
最後に
ちなみに Date を継承している DateTime はこの方法でも参照できないようです
おそらく pry-doc で show-source DateTime すると親クラスの Date のソースが確認できるのでそもそも無理なのかもしれません
例えば pry ファイルに上記のロードスクリプトを一行足しても OK です
サンプルは相対パスを使っていますがフルパスでも OK です
vim vendor/ruby/3.1.0/bin/pry
#!/usr/bin/env ruby## This file was generated by RubyGems.## The application 'pry' is installed as part of a gem, and# this file is here to facilitate running it.#require'rubygems'Dir["#{__dir__}/../../../../lib/*.rb"].each{|file|require file }Gem.use_gemdeps
version =">= 0.a"
str =ARGV.first
if str
str = str.b[/\A_(.*)_\z/,1]if str andGem::Version.correct?(str)
version = str
ARGV.shift
endendifGem.respond_to?(:activate_bin_path)
load Gem.activate_bin_path('pry','pry', version)else
gem "pry", version
load Gem.bin_path("pry","pry", version)end
#!/usr/bin/env ruby## This file was generated by RubyGems.## The application 'pry' is installed as part of a gem, and# this file is here to facilitate running it.#require'bundler'Bundler.requireDir["#{__dir__}/../../../../lib/*.rb"].each{|file|require file }require'rubygems'Gem.use_gemdeps
version =">= 0.a"
str =ARGV.first
if str
str = str.b[/\A_(.*)_\z/,1]if str andGem::Version.correct?(str)
version = str
ARGV.shift
endendifGem.respond_to?(:activate_bin_path)
load Gem.activate_bin_path('pry','pry', version)else
gem "pry", version
load Gem.bin_path("pry","pry", version)end
Bundler.require は基本的に追記して OK だと思います
自分で作成したスクリプトを require する場合はメインとなるスクリプトを require してしまうと実行されてしまうので注意しましょう
ファイルが追加されたり gem が追加された場合は
pry を再起動したくなります
簡単なのは emacs をまるごと再起動すれば OK です
emacs を起動したまま robe を再起動したい場合は pry バッファを kill して再度 robe-start すれば OK です