sparkr 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a37bdfe0c66bc29bf3f9b61ee747c92353fed0c7
4
- data.tar.gz: be8bb033d057fec37216982df48e5b70f6d02b14
3
+ metadata.gz: aee5d3645985bf8644aafd37b96c4b9431204b05
4
+ data.tar.gz: 546ae2e5aba6ac1da35d03f931409184b0a5b31d
5
5
  SHA512:
6
- metadata.gz: 5358e3b58d18bc6e653f1fb18fa73cbe47cfd77f03e553f901edcdd5f59bb8d4c08e337ef8bb88065012918406edd53dda9554b84668a41b33934a316d7e2cbf
7
- data.tar.gz: f7e1322e94d506099a01c21a25e891a66be455343078f121e5f1d455a06a6335373055ca59736894a8fabf3da56dab3b014993661f941aed49028d2bc31d93fb
6
+ metadata.gz: 3689591a7bd6c57ccdd8219bb01ee32e5668eafdab825c44c747b0946beaed88ba5f9fac8ee90634c38668175eae093dbabfbb904d2743acc6c950f0ab21fddf
7
+ data.tar.gz: 3ac3b156b8eb4445fd3b87db872b897f53d397c3e22b9ae16eec3038ba8557a3d07021255ec147208ddb820aadc092951d1a433a66cdd38ea217015b0e882362
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Sparkr is a port of [spark](https://github.com/holman/spark) for Ruby.
4
4
 
5
- It let's you create sparklines for your Ruby CLIs: ▁▂▃▅▇
5
+ It let's you create ASCII sparklines for your Ruby CLIs: ▁▂▃▅▇
6
6
 
7
7
  ## Installation
8
8
 
@@ -1,10 +1,12 @@
1
1
  module Sparkr
2
2
  class Sparkline
3
3
  TICKS = %w(▁ ▂ ▃ ▄ ▅ ▆ ▇ █)
4
+ DEFAULT_SEPARATOR = ''
4
5
 
5
6
  def initialize(_numbers)
6
7
  numbers = _numbers.map(&:to_i)
7
8
  step_height = (numbers.max - numbers.min) / (TICKS.size - 1).to_f
9
+ step_height = 1 if step_height == 0
8
10
 
9
11
  @ticks = numbers.map do |n|
10
12
  index = ((n - numbers.min) / step_height).to_i
@@ -12,8 +14,8 @@ module Sparkr
12
14
  end
13
15
  end
14
16
 
15
- def to_s
16
- @ticks.join('')
17
+ def to_s(sep = nil)
18
+ @ticks.join(sep || DEFAULT_SEPARATOR)
17
19
  end
18
20
  end
19
21
  end
@@ -1,3 +1,3 @@
1
1
  module Sparkr
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Sparkr::VERSION
9
9
  spec.authors = ["René Föhring"]
10
10
  spec.email = ["rf@bamaru.de"]
11
- spec.summary = %w{Sparklines in your shell, in Ruby}
12
- spec.description = %q{Sparklines in your shell, in Ruby}
11
+ spec.summary = %w{ASCII Sparklines in Ruby}
12
+ spec.description = %q{ASCII Sparklines in Ruby}
13
13
  spec.homepage = ""
14
14
  spec.license = "MIT"
15
15
 
@@ -2,13 +2,13 @@ require File.expand_path(File.dirname(__FILE__) + '/test_helper')
2
2
 
3
3
  describe ::Sparkr do
4
4
  it "should find work" do
5
- assert_sparkline '▁▂▃▄▅▆▇█', Sparkr.sparkline([1,2,3,4,5,6,7,8])
6
- assert_sparkline '▁▂█▅▂', Sparkr.sparkline([1,5,22,13,5])
7
- assert_sparkline '▁█', Sparkr.sparkline([5.5,20])
8
- assert_sparkline '▁▁▁▁▃▁▁▁▂█', Sparkr.sparkline([1,2,3,4,100,5,10,20,50,300])
9
- assert_sparkline '▁▄█', Sparkr.sparkline([1,50,100])
10
- assert_sparkline '▁▃█', Sparkr.sparkline([2,4,8])
11
- assert_sparkline '▁▂▃▄▂█', Sparkr.sparkline([0,30,55,80,33,150])
12
- assert_sparkline '▁▂▄▆█', Sparkr.sparkline([1,2,3,4,5])
5
+ assert_sparkline '▁▂▃▄▅▆▇█', [1,2,3,4,5,6,7,8]
6
+ assert_sparkline '▁▂█▅▂', [1,5,22,13,5]
7
+ assert_sparkline '▁█', [5.5,20]
8
+ assert_sparkline '▁▁▁▁▃▁▁▁▂█', [1,2,3,4,100,5,10,20,50,300]
9
+ assert_sparkline '▁▄█', [1,50,100]
10
+ assert_sparkline '▁▃█', [2,4,8]
11
+ assert_sparkline '▁▂▃▄▂█', [0,30,55,80,33,150]
12
+ assert_sparkline '▁▂▄▆█', [1,2,3,4,5]
13
13
  end
14
14
  end
@@ -8,8 +8,10 @@ require 'minitest/autorun'
8
8
  require 'bundler'
9
9
  Bundler.require
10
10
 
11
- def assert_sparkline(expected, actual)
12
- assert actual.index('▁'), "there must be a minimum"
13
- assert actual.index('█'), "there must be a maximum"
11
+ def assert_sparkline(expected, numbers)
12
+ actual = Sparkr.sparkline(numbers)
13
+
14
+ assert actual.include?('▁'), "there must be a minimum"
15
+ assert actual.include?('█'), "there must be a maximum"
14
16
  assert_equal expected, actual
15
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sparkr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - René Föhring
@@ -38,7 +38,7 @@ dependencies:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- description: Sparklines in your shell, in Ruby
41
+ description: ASCII Sparklines in Ruby
42
42
  email:
43
43
  - rf@bamaru.de
44
44
  executables:
@@ -85,7 +85,7 @@ rubyforge_project:
85
85
  rubygems_version: 2.0.3
86
86
  signing_key:
87
87
  specification_version: 4
88
- summary: '["Sparklines", "in", "your", "shell,", "in", "Ruby"]'
88
+ summary: '["ASCII", "Sparklines", "in", "Ruby"]'
89
89
  test_files:
90
90
  - test/cli_test.rb
91
91
  - test/sparkr_test.rb