• Stars
    star
    248
  • Rank 163,560 (Top 4 %)
  • Language
    Ruby
  • License
    BSD 3-Clause "New...
  • Created over 15 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Pure-Ruby Readline Implementation

Description

The readline library provides a pure Ruby implementation of the GNU readline C library, as well as the Readline extension that ships as part of the standard library.

Installation

gem install rb-readline

Or in a Gemfile:

gem 'rb-readline'

Synopsis

require 'readline'

loop do
  line = Readline::readline('> ')
  break if line.nil? || line == 'quit'
  Readline::HISTORY.push(line)
  puts "You typed: #{line}"
end

Compatibility

rb-readline should work on all Unix-like systems and Windows. It is regularly used with MRI 1.8/1.9 and Rubinius. JRuby is not supported and there are no plans to support it in the future - it comes bundled with a Java implementation of Readline.

Motivation

First, building the GNU readline library on MS Windows with Visual C++ is almost impossible. However, certain libraries depend on readline. By providing a pure Ruby version we eliminate the entire compiler compatibility issue.

Second, even on distributions of Windows built with MinGW (that include the readline library for Windows), the behavior was sometimes erratic and would break.

Third, even on certain Unix distributions the GNU readline library is not guaranteed to be installed. Providing a pure Ruby readline eliminates the need to install a C library first. It's also one less link in the dependency chain, meaning we don't need to worry about possible changes in the underlying C library affecting our interface.

Fourth, by making the interface pure Ruby, we increase the likelihood of receiving patches, feature requests, documentation updates, etc from the community at large, since not everyone knows C.

Lastly, the Readline interface that ships as part of the standard library is weak, and only provides a very limited subset of the actual GNU readline library. By providing a pure Ruby implementation we allow 3rd party library authors to write their own interface as they see fit.

Tutorial

For an excellent tutorial on how to use Readline in practice, please see Joseph Pecoraro's examples at http://bogojoker.com/readline/.

You can also take a look at Ruby 1.9 stdlib Readline documentation located at http://rubydoc.info/stdlib/readline/1.9.2/frames

Alternatives

See Rawline for a library that began life in pure Ruby and provides an interface that's probably more comfortable to Ruby programmer. It has certain features that Readline does not. In addition, it provides a Readline compatibility mode.

Authors

  • Park Heesob (C translation, code donated as part of bounty)
  • Daniel Berger (Documentation and testing)
  • Luis Lavena
  • Mark Somerville (Maintainer)
  • Connor Atherton (Maintainer)

More Repositories

1

loaders.css

Delightful, performance-focused pure css loading animations.
CSS
10,208
star
2

walkway

An easy way to animate SVG elements.
JavaScript
4,371
star
3

typeout

Type and retype text in the browser.
JavaScript
86
star
4

OctoPanel

A simple, clean and responsive theme for Octopress.
CSS
57
star
5

TypeWriter

Simulate typing on a page.
JavaScript
48
star
6

uiscript

A web UI manipulation language for humans
JavaScript
30
star
7

git-identify

Easily configure different git identities on the same machine
Shell
13
star
8

Progress

Progress.js is an online tool that allows students to visualise and forecast academic grades
JavaScript
13
star
9

Spotlight.js

A lightweight JavaScript library to bring attention to any page element
JavaScript
8
star
10

meteor-foundation-5

An atmosphere smart package for foundation 5.
CSS
7
star
11

headway

Easy ansi style string parsing for the terminal
JavaScript
5
star
12

angular-hackathon

An opinionated node boilerplate for angular applications.
JavaScript
4
star
13

laravel-auth-skeleton

A boilerplate Laravel application that implements basic authentication.
PHP
4
star
14

Sweet

A sweet VPN desktop client
JavaScript
4
star
15

js-structures

A playground for creating interesting data structures in JavaScript.
JavaScript
3
star
16

node-todo

JavaScript
3
star
17

checks

Standalone type checks for JavaScript
JavaScript
2
star
18

learning-rust

A Rust playground.
Rust
2
star
19

ancee

ansi style color codes
JavaScript
2
star
20

owlci

A continuous integration tool for diffing visual layouts.
Ruby
2
star
21

shell-helpers

A repo full of helpful shell code snippets
Shell
2
star
22

grader

Meteor application to forecast grades
JavaScript
1
star
23

oliver

Ask for permissions in the browser.
JavaScript
1
star
24

Konami

A tiny library for responding to the konami code
JavaScript
1
star
25

tasks

A small terminal task manager
JavaScript
1
star
26

godaddy-api

Ruby
1
star
27

go-task-manager

A simple terminal task manager written in Go
Go
1
star
28

strgen

A ruby string generator
Ruby
1
star
29

geeny

A tiny, go arg parser
Go
1
star
30

fcount

Recursively count file types.
JavaScript
1
star
31

clong

Collaborative pong in a web browser
JavaScript
1
star