An open API service indexing awesome lists of open source software.

https://github.com/kevinstuffandthings/shellable

Open a REPL within the context of any Ruby object
https://github.com/kevinstuffandthings/shellable

repl ruby rubygems

Last synced: 9 months ago
JSON representation

Open a REPL within the context of any Ruby object

Awesome Lists containing this project

README

          

# Shellable ![Build Status](https://github.com/kevinstuffandthings/shellable/actions/workflows/ruby.yml/badge.svg) [![Gem Version](https://badge.fury.io/rb/shellable.svg)](https://badge.fury.io/rb/shellable)

Open a [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop) within the context of any Ruby object.
Originally written for the [TimeBoss](https://github.com/kevinstuffandthings/timeboss) gem.

## Installation
Add this line to your application's Gemfile:

```ruby
# update with the version of your choice
gem 'shellable'
```

And then execute:

```bash
$ bundle install
```

Or install it yourself as:

```bash
$ gem install shellable
```

## Usage

Imagine you're building a new Ruby library, and you'd like to provide users with a way to experiment with that new library from the inside.
When developing the `TimeBoss` gem, I wanted to create a [Rake task](https://github.com/kevinstuffandthings/timeboss#repl) to do just that.

```ruby
require 'timeboss/calendars'

calendar = TimeBoss::Calendars[:broadcast]
# => #
```

Once the desired target object for our REPL has been created, we can simply make it "shellable":

```ruby
require 'shellable'
Shellable.open(calendar)
```

To check out a real-life example, head over to the TimeBoss [`timeboss:calendars:*:repl`](https://github.com/kevinstuffandthings/timeboss/blob/1e7a27de0add7da4fe77b49af62b650a7771021b/lib/tasks/calendars.rake#L12-L16) task definition.

```
$ rake timeboss:calendars:broadcast:repl
2.4.1 :001 > this_week
=> #
2.4.1 :002 > parse('2020Q4..2021Q2')
=> #..#] start_date=2020-09-28, end_date=2021-06-27>
2.4.1 :003 >
```

# Problems?
Please submit an [issue](https://github.com/kevinstuffandthings/shellable/issues).
We'll figure out how to get you up and running with Shellable as smoothly as possible.