Skip to content
Snippets Groups Projects
README.md 2.65 KiB
Newer Older
Stephen D's avatar
Stephen D committed
# Rubic

Stephen D's avatar
Stephen D committed
Rubic is a Ruby REPL. Aside from behaving like IRB, it also borrows some concepts from older BASIC REPLs. Mainly, this involves writing programs by specifying line numbers. For information on commands, use `help`. Otherwise, a basic example session lives below.
Stephen D's avatar
Stephen D committed

Stephen D's avatar
Stephen D committed
```
> 10 puts "what is your name?"
> 20 name = gets.chomp
> 30 puts "nice to meet you, #{name}!"
>
> list
10 puts "what is your name?"
20 name = gets.chomp
30 puts "nice to meet you, #{name}!"
> run
what is your name?
stephen
nice to meet you, stephen!
=> nil
> # but wouldn't it be nice if we printed the last line a few times?
=> nil
> 25 for _ in 0..5
> 35 end
> list
10 puts "what is your name?"
20 name = gets.chomp
25 for _ in 0..5
30 puts "nice to meet you, #{name}!"
35 end
> run
what is your name?
stephen
nice to meet you, stephen!
nice to meet you, stephen!
nice to meet you, stephen!
nice to meet you, stephen!
nice to meet you, stephen!
nice to meet you, stephen!
=> 0..5
> # but now our line numbers aren't equidistant anymore! let's clean them up
=> nil
> squish
> list
1 puts "what is your name?"
2 name = gets.chomp
3 for _ in 0..5
4 puts "nice to meet you, #{name}!"
5 end
> # or alternatively...
=> nil
> widen
> list
10 puts "what is your name?"
20 name = gets.chomp
30 for _ in 0..5
40 puts "nice to meet you, #{name}!"
50 end
> # alright, let's save our program
=> nil
> save greeter.rub
> # or if you just want a normal ruby file
=> nil
> export greeter.rb
> # with load/import you can also do the opposite (load an existing rub or rb file)
=> nil
```
Stephen D's avatar
Stephen D committed

## Installation

Install the gem and add to the application's Gemfile by executing:

```bash
Stephen D's avatar
Stephen D committed
bundle add rubic-repl
Stephen D's avatar
Stephen D committed
```

If bundler is not being used to manage dependencies, install the gem by executing:

```bash
Stephen D's avatar
Stephen D committed
gem install rubic-repl
Stephen D's avatar
Stephen D committed
```

## Usage

Stephen D's avatar
Stephen D committed
In your REPL or Ruby file, run `Rubic::run` to start Rubic. Alternatively, run the CLI from your terminal with the `rubic` command.
Stephen D's avatar
Stephen D committed

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).

## Contributing

Stephen D's avatar
Stephen D committed
Bug reports and pull requests are welcome at https://gitlab.scd31.com/stephen/rubic
Stephen D's avatar
Stephen D committed

## License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).