Newer
Older
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.
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
```
> 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
```
## Installation
Install the gem and add to the application's Gemfile by executing:
```bash
```
If bundler is not being used to manage dependencies, install the gem by executing:
```bash
In your REPL or Ruby file, run `Rubic::run` to start Rubic. Alternatively, run the CLI from your terminal with the `rubic` command.
## 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
Bug reports and pull requests are welcome at https://gitlab.scd31.com/stephen/rubic