Permalink
Browse files

Update README with coloring info

  • Loading branch information...
1 parent edd6341 commit 7a12da18c4648c5fcc381e6d31cddfe28464beb6 @rrrene committed Jan 29, 2014
Showing with 29 additions and 0 deletions.
  1. +29 −0 README.md
View
@@ -6,6 +6,7 @@ Sparkr is a port of [spark](https://github.com/holman/spark) for Ruby.
It let's you create ASCII sparklines for your Ruby CLIs: ▁▂▃▅▇
+
## Installation
Add this line to your application's Gemfile:
@@ -40,6 +41,34 @@ The real reason for this port:
# => "▁▂▃▅▂▇"
+### Coloring
+
+Let's say you have your list of open and closed issues.
+
+ list = [open_issue_count, closed_issue_count]
+ Sparkr.sparkline(list)
+ # => "▁█"
+
+But now you want to format the sparkline so that the open issues are red
+and the closed ones are green (to quickly see how you are doing).
+
+Let's further suppose you use a gem that adds a `#color` method to `String`
+for ANSI coloring, like
+[Term::ANSIColor](https://github.com/flori/term-ansicolor).
+
+ Sparkr.sparkline(list) do |tick, count, index|
+ if index == 0
+ tick.color(:red)
+ else
+ tick.color(:green)
+ end
+ end
+ # => "▁█" (colored, trust me)
+
+To see this how this looks live and in full colour, take a look at
+[Inch](http://rrrene.github.io/inch).
+
+
## Contributing
1. Fork it ( http://github.com/rrrene/sparkr/fork )

0 comments on commit 7a12da1

Please sign in to comment.