• Stars
    star
    151
  • Rank 237,439 (Top 5 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 10 years ago
  • Updated over 9 years ago

Reviews

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

Repository Details

▁▂▃▅▂▇ in Ruby (and your shell)

Sparkr Build Status Code Climate Inline docs

Sparkr is a port of spark for Ruby.

It lets you create ASCII sparklines for your Ruby CLIs: ▁▂▃▅▇

Installation

Add this line to your application's Gemfile:

gem 'sparkr'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sparkr

Usage

Shell

After installation, just run sparkr and pass it a list of numbers, like you would with spark. The output is what you would expect:

$ sparkr 0 30 55 80 33 150
▁▂▃▅▂▇

It is also possible to pipe data into sparkr:

$ echo 9 13 5 17 1 | sparkr
▄▆▂█▁

Ruby

The real reason for this port:

Sparkr.sparkline([0, 30, 55, 80, 33, 150])
# => "▁▂▃▅▂▇"

Coloring

Let's say you have your list of open and closed issues.

require 'sparkr'

open_issue_count = 3
closed_issue_count = 13

list = [open_issue_count, closed_issue_count]
puts "Issues: " + Sparkr.sparkline(list)
# => "Issues: ▁█"

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.

require 'sparkr'
require 'term/ansicolor'

class String
  include Term::ANSIColor
end

open_issue_count = 3
closed_issue_count = 13

list = [open_issue_count, closed_issue_count]
sparkline = Sparkr.sparkline(list) do |tick, count, index|
  if index == 0
    tick.color(:red)
  else
    tick.color(:green)
  end
end
puts "Issues: " + sparkline
# => "Issues: ▁█" (colored, trust me)

To see how this looks live and in full colour, take a look at Inch.

Contributing

  1. Fork it ( http://github.com/rrrene/sparkr/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Author

René Föhring (@rrrene)

Credits

Sparkr would not exist without Zach Holman's spark.

License

Sparkr is released under the MIT License. See the LICENSE.txt file for further details.

More Repositories

1

credo

A static code analysis tool for the Elixir language with a focus on code consistency and teaching.
Elixir
4,720
star
2

inch

A documentation analysis tool for the Ruby language
Ruby
517
star
3

elixir-style-guide

Style Guide for the Elixir language, implemented by Credo
Elixir
395
star
4

elixirstatus-web

Community site for Elixir project/blog post/version updates
Elixir
279
star
5

html_sanitize_ex

HTML sanitizer for Elixir
Elixir
250
star
6

inch_ex

Provides a Mix task that gives you hints where to improve your inline docs.
Elixir
200
star
7

bunt

256 color ANSI coloring in Elixir CLIs
Elixir
113
star
8

inchjs

A documentation tool for JavaScript/NodeJS
JavaScript
48
star
9

tipsy.hovercard

Hovercard extension for tipsy tooltip
JavaScript
33
star
10

inch-pages

Jekyll Page generator for Inch Pages
Ruby
25
star
11

outline

Outline is an open source knowledge management application inspired by timeline focused apps like Facebook and Twitter.
Ruby
9
star
12

inch-badge

Badge generator for Inch
HTML
7
star
13

credo-proposals

Proposals for Credo, the Elixir code analysis tool with a focus on code consistency and teaching
7
star
14

sherlock

A library for filtering lists of files and performing actions on their content.
Ruby
5
star
15

dotfiles

Personal dotfiles
Shell
4
star
16

homecoming

Easy upwards directory traversal in Ruby
Ruby
4
star
17

custom_attributes

CustomAttributes allows you to add custom attributes to ActiveRecord objects, optionally scoped by another model (e.g. users).
Ruby
3
star
18

texas

Texas provides an easy way to create PDFs from LaTeX documents using ERb templates.
Ruby
3
star
19

tps-report

Excel friendly reports for your bosses, clients and the rest.
Ruby
2
star
20

freight-exchange

Source code for a European Online Rail Transport Spot Exchange
Ruby
2
star
21

credo_demo_plugin

A Demo Plugin for Credo
Elixir
2
star
22

outline.github.com

JavaScript
1
star
23

repomen

Interface wrapper for retrieving repos
Ruby
1
star
24

easy_type

Build a complex puppet custom type and provider, the easy way
Ruby
1
star
25

credo-elixir-benchmark

Elixir
1
star