Skip to content

Commit

Permalink
convert rdoc to markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
janlelis committed Mar 22, 2015
1 parent 0e1ba78 commit eb6a5b2
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 113 deletions.
30 changes: 20 additions & 10 deletions CHANGELOG.rdoc → CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,46 @@
== 0.8.2
# CHANGELOG

## 0.8.2
* Support objects that don't support #inspect

== 0.8.1

## 0.8.1
* Use io/console correctly, fixes bug on mingw

== 0.8.0

## 0.8.0
* Internals partly refactored
* Bump paint and unicode-display_width dependencies
* Drop official support for Ruby 1
* Don't depend on ansicon specifics for windows (use io/console)
* Also patch input methods for ARGF
* Don't try to catch exception when printing to stderr
* Remove [:colorizer][:output] option
* Remove [:[colorizer]](:output) option
* Not patching Kernel anymore
* Only path String if east_asian_width option is used

== 0.7.3

## 0.7.3
* Don't colorize stdout by default
* Deactivate rocket for common system commands

== 0.7.2

## 0.7.2
* Fix a small bug that happens if there was no last line

== 0.7.1

## 0.7.1
* Deactivate buggy input coloring :/

== 0.7.0

## 0.7.0
* Use paint gem for terminal colors
* Fix some rocket issues (when using with colored content)

== 0.6.5

## 0.6.5
* Windows support

== < 0.6.5

## < 0.6.5
See https://github.com/janlelis/fancy_irb/commits/0.6.4
110 changes: 110 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# FancyIrb

* Colorizes prompts, errors, `stderr` and `stdout`
* Uses Hash Rockets to display evaluation results
* Allows you to apply a proc before showing the result


## Usage

require 'fancy_irb'
FancyIrb.start

You can pass an options hash. These are the default values:

DEFAULT_OPTIONS = {
:rocket_mode => true, # activate or deactivate #=> rocket output
:rocket_prompt => '#=> ', # prompt to use for the rocket
:result_prompt => '=> ', # prompt to use for normal output
:result_proc => DEFAULT_RESULT_PROC, # how to get the output result from IRB
:output_procs => [DEFAULT_COLORIZER_PROC], # output formatter procs
:east_asian_width => false, # set to true if you have double-width characters (slower)
:colorize => { # colors hash. Set to nil to deactivate colors
:rocket_prompt => [:blue],
:result_prompt => [:blue],
:input_prompt => nil,
:irb_errors => [:red, :clean],
:stderr => [:red, :bright],
:stdout => nil,
:input => nil,
},
}

Rocket mode means: Output result as comment if there is enough space left on
the terminal line and `stdout` does not output more than the current terminal
height.

For more information on which colors can be used, see the [paint
documentation](https://github.com/janlelis/paint).

## Example configurations
### Default
FancyIrb.start

### No colorization
FancyIrb.start :colorize => nil

### Use awesome_print for inspecting
require 'ap'
FancyIrb.start :rocket_mode => false,
:colorize => { :output => false,
:result_prompt => :yellow },
:result_proc => proc{ |context|
context.last_value.awesome_inspect
}

## Advanced: Hook into IRB
You can modify how to get and display the input. The `result_proc` is a proc
which takes the irb context object and should return the value. You can change
it with `FancyIrb.set_result_proc do (your code) end`. After that, each proc
in `output_procs` gets triggered. They take the value and can return a
modified one. You can use the `FancyIrb.add_output_proc` method for adding new
output filter procs.

### Default result_proc

DEFAULT_RESULT_PROC = proc{ |context|
if context.inspect?
if defined?(context.last_value.inspect)
context.last_value.inspect
else
"(Object doesn't support #inspect)"
end
else
context.last_value
end
}

### Default colorizer_proc

DEFAULT_COLORIZER_PROC = proc{ |value|
if defined?(Wirb)
Wirb.colorize_result value
else
value
end
}

## Troubleshooting
### Windows Support
You will need [ansicon](https://github.com/adoxa/ansicon).

### Wrong display widths?
When using double-width unicode chars, you should set `:east_asian_width` to
`true`. It is not activated by default, because of its performance impact.

### Known bugs
Not all stdin methods are patched properly to work with the rocket: The gems
focuses on the often used ones

## TODO
* Refactor to modern code
* Just count string lengths without ansi escape sequences (would be more
flexible than remembering)


## J-_-L
Inspired by the irb_rocket gem by genki.

Copyright (c) 2010-2012, 2015 Jan Lelis <http://janlelis.com> released under
the MIT license.
101 changes: 0 additions & 101 deletions README.rdoc

This file was deleted.

4 changes: 2 additions & 2 deletions fancy_irb.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Gem::Specification.new do |s|
s.add_dependency 'unicode-display_width', ">= 0.2.0"
s.files = [
"MIT-LICENSE.txt",
"README.rdoc",
"README.md",
"Rakefile",
"CHANGELOG.rdoc",
"CHANGELOG.md",
"fancy_irb.gemspec",
"lib/fancy_irb.rb",
"lib/fancy_irb/irb_ext.rb",
Expand Down

0 comments on commit eb6a5b2

Please sign in to comment.