Use Librato Metrics to finally say something which should have been said long before.
Note: not all characters are supported yet, please feel free to contribute some. check lib/say_it_with_graphs/characters for available characters.
Installation
Install it yourself as:
$ gem install say_it_with_graphsOr add this line to your application's Gemfile:
gem 'say_it_with_graphs'And then execute:
$ bundleConfigure
You need LIBRATO_USER and LIBRATO_TOKEN in your environment in order to make it work ✨
You can find your tokens here: https://metrics.librato.com/account/api_tokens or simply create a new one.
Quick Start
Getting started in 5 minutes.
$ gem 'say_it_with_graphs'
$ export LIBRATO_USER='<your user email here>'
$ export LIBRATO_TOKEN='<your api token here>'
$ say-it-with-graphs "I <3 GRAPHS!"
"making 'I <3 GRAPHS!' with <3 and graphs"
"Painting to say-it-with-graphs-82 ... ETA: 29 minutes"
"=> https://metrics.librato.com/metrics/say-it-with-graphs-82"
"Frame 0 of 29"
"Line[9f9845] pos: 0"
"Line[9f9845] pos: 100"
"Line[9f9845] pos: 0"
"Frame 1 of 29"
"Frame 2 of 29"
"Line[27018a] pos: 50"
"Line[db03f4] pos: 50"
...........say-it-with-graphs will paint your sentence onto a graph. you can find the url in the output.
Usage
The usage of the execuatable is described at Quick Start. In this section we will discuss the API to create your own characters in lib/say_it_with_graphs/characters.
The frame
Every frame has access to unlimited amount of lines. The most characters can be drawn with 2 or 3. Every character has to respond to two methods:
-
defineDefines returns the character which will be mathed against the user input.
def define
'i'
end-
drawDraw does the actual magic. When you have theSayItWithGraphs::GraphControlsincluded in your class, you can just call theframemethod and pass it a block which gets aframepassed to it. As mentioned above the frame has access to a unlimited number of lines, you can access them in several ways, the easiest isf.linewhich gives back aLineobject, you can set it's source with[](defaults to 0).
def draw
frame do |f|
f.line.at 0
f.line.at 100
f.line.at 0
end
endWith this methods given, only graphs with a limited number of lines would be possible. It's hard to draw the characters with a single line (one could try implementing cursive handwriting). You have also access to a helper method called rnd_line which gives a key one can use to refer to a line which will not be used at other places in the drawning.
def define
'l'
end
def draw
a = rnd_line
frame do |f|
f.line[a].at 100
f.line[a].at 0
end
frame do |f|
f.line[a].at 0
end
frame do |f|
f.line[a].at 0
end
endYou can check out more complex examples like lib/say_it_with_graphs/characters/r.rb to see what's possible.
Disclaimer
This is a weekend hack. There are a few ways this thing could be improved.
Contributing
- Fork it ( https://github.com/nesQuick/say_it_with_graphs/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request