RubyFlow The Ruby and Rails community linklog

×

The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

Shellable: Open a REPL within the context of any Ruby object

Imagine you’re building a new Ruby library, and you’d like to provide users with a simple way to experiment with that new library from the inside. Try Shellable.

Comments

I’m very sorry to do this, but you can just do irb obj or if you have pry, then pry obj, and if you want to create a small console like script, you can write all the setup code in your script and in the end add Pry.start

thank you for the feedback! i am struggling to see how to use the irb approach you mentioned above. i do see the way forward with pry, i guess i just have become conditioned to using pry when something is wrong. so i wanted to try to bring it all up in an irb session. and from what i can tell, irb doesn’t want to take any arguments without some of the multi-irb magic pulled in.

i’m always excited to learn new things though, so don’t ever hesitate to provide feedback, and if you have a simpler way forward, i’d love to consider it! i would just like to stick with irb over pry, so i’m definitely intrigued by the possibility of simplification.

Hm, I didn’t even know about multi-irb, but it seems to come standard? At least in my oldest installed ruby (2.2.3) multi-irb is loaded in irb without me having done anything (no RUBY_OPT, no gem installed). And then this works: ``` 2.2.3 :001 > ary = [1,2,3] # => [1, 2, 3] 2.2.3 :002 > irb ary 2.2.3 :001 > self # => [1, 2, 3] 2.2.3 :002 > RUBY_VERSION # => “2.2.3” ``

urgh, seems this comment section does not understand triple-backtick for code. Let’s try HTML: <pre> 2.2.3 :001 > ary = [1,2,3] # => [1, 2, 3] 2.2.3 :002 > irb ary 2.2.3 :001 > self # => [1, 2, 3] 2.2.3 :002 > RUBY_VERSION # => “2.2.3” </pre>

I give up 😂

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in