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 +4 -4
- data/README.md +1 -1
- data/lib/sparkr/sparkline.rb +4 -2
- data/lib/sparkr/version.rb +1 -1
- data/sparkr.gemspec +2 -2
- data/test/sparkr_test.rb +8 -8
- data/test/test_helper.rb +5 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aee5d3645985bf8644aafd37b96c4b9431204b05
|
4
|
+
data.tar.gz: 546ae2e5aba6ac1da35d03f931409184b0a5b31d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3689591a7bd6c57ccdd8219bb01ee32e5668eafdab825c44c747b0946beaed88ba5f9fac8ee90634c38668175eae093dbabfbb904d2743acc6c950f0ab21fddf
|
7
|
+
data.tar.gz: 3ac3b156b8eb4445fd3b87db872b897f53d397c3e22b9ae16eec3038ba8557a3d07021255ec147208ddb820aadc092951d1a433a66cdd38ea217015b0e882362
|
data/README.md
CHANGED
data/lib/sparkr/sparkline.rb
CHANGED
@@ -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
|
data/lib/sparkr/version.rb
CHANGED
data/sparkr.gemspec
CHANGED
@@ -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
|
12
|
-
spec.description = %q{Sparklines in
|
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
|
|
data/test/sparkr_test.rb
CHANGED
@@ -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 '▁▂▃▄▅▆▇█',
|
6
|
-
assert_sparkline '▁▂█▅▂',
|
7
|
-
assert_sparkline '▁█',
|
8
|
-
assert_sparkline '▁▁▁▁▃▁▁▁▂█',
|
9
|
-
assert_sparkline '▁▄█',
|
10
|
-
assert_sparkline '▁▃█',
|
11
|
-
assert_sparkline '▁▂▃▄▂█',
|
12
|
-
assert_sparkline '▁▂▄▆█',
|
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
|
data/test/test_helper.rb
CHANGED
@@ -8,8 +8,10 @@ require 'minitest/autorun'
|
|
8
8
|
require 'bundler'
|
9
9
|
Bundler.require
|
10
10
|
|
11
|
-
def assert_sparkline(expected,
|
12
|
-
|
13
|
-
|
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.
|
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
|
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: '["
|
88
|
+
summary: '["ASCII", "Sparklines", "in", "Ruby"]'
|
89
89
|
test_files:
|
90
90
|
- test/cli_test.rb
|
91
91
|
- test/sparkr_test.rb
|