Can you 'require' ruby file in irb session, automatically, on every command?

后端 未结 3 450
小鲜肉
小鲜肉 2021-01-11 17:56

I am currently editing a file, and I\'m using irb to test the api:

> require \'./file.rb\'
> o = Object.new
> o.method

I then want

3条回答
  •  情话喂你
    2021-01-11 18:19

    This won't run every command, but you can include a file on every IRb session. ~/.irbrc is loaded each time you start an IRb session.

    ~/.irbrc

    require "~/somefile.rb"
    

    ~/somefile.rb

    puts "somefile loaded"
    

    terminal

    > irb
    somefile loaded
    irb(main):001:0> 
    

    ~/.irbrc is loaded each time you start an irb session

提交回复
热议问题