Permalink
Browse files

Fix some rubocop warnings (thanks to @rafalchmiel)

  • Loading branch information...
1 parent 2487f03 commit 30d4039ed950691d0d1297e457eacea21a7e47d5 @rrrene committed Feb 2, 2014
Showing with 28 additions and 24 deletions.
  1. +1 −1 README.md
  2. +8 −4 bin/sparkr
  3. +1 −1 lib/sparkr.rb
  4. +3 −3 lib/sparkr/sparkline.rb
  5. +3 −2 test/sparkr/cli_test.rb
  6. +2 −2 test/sparkr/sparkline_test.rb
  7. +10 −11 test/sparkr_test.rb
View
@@ -37,7 +37,7 @@ you would expect:
The real reason for this port:
- Sparkr.sparkline([0,30,55,80,33,150])
+ Sparkr.sparkline([0, 30, 55, 80, 33, 150])
# => "▁▂▃▅▂▇"
View
@@ -1,10 +1,14 @@
#!/usr/bin/env ruby
-path = __FILE__
-while File.symlink?(path)
- path = File.expand_path(File.readlink(path), File.dirname(path))
+def find_lib_path
+ path = __FILE__
+ while File.symlink?(path)
+ path = File.expand_path(File.readlink(path), File.dirname(path))
+ end
+ File.join(File.dirname(File.expand_path(path)), '..', 'lib')
end
-$:.unshift(File.join(File.dirname(File.expand_path(path)), '..', 'lib'))
+
+$LOAD_PATH.unshift(find_lib_path)
require 'sparkr'
Sparkr::CLI.run(*ARGV)
View
@@ -32,7 +32,7 @@ module Sparkr
# line
# # => "▁█" (colored, trust me)
#
- # @param numbers [Array<String,Fixnum,Float>] the numbers to be rendered
+ # @param numbers [Array<String, Fixnum, Float>] the numbers to be rendered
# @param &block [Proc] optional, can be used to format the rendered string
#
# @return [String]
@@ -61,8 +61,8 @@ def format(&block)
# Returns the normalized equivalent of a given list
#
- # normalize_numbers([3,4,7])
- # # => [0,1,4]
+ # normalize_numbers([3, 4, 7])
+ # # => [0, 1, 4]
#
# @return [Fixnum] the normalized equivalent of the given +_numbers+
def normalize_numbers(_numbers)
@@ -90,7 +90,7 @@ def steps
TICKS.size - 1
end
- # @param sep [String,nil] separator used to join the bars of the sparkline
+ # @param sep [String, nil] separator used to join the bars of the sparkline
# @return [String] the sparkline, seperated by +sep+ (defaults to '')
def to_s(sep = nil)
@ticks.join(sep || DEFAULT_SEPARATOR)
@@ -3,9 +3,10 @@
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
describe ::Sparkr::CLI do
- it "should find work" do
+ it ".run should work with array of numbers as strings" do
+ string_numbers = %w(1 2 3 4 100 5 10 20 50 300)
out, err = capture_io do
- ::Sparkr::CLI.run("1", "2", "3", "4", "100", "5", "10", "20", "50", "300")
+ ::Sparkr::CLI.run(*string_numbers)
end
refute out.empty?, "there should be some output"
assert err.empty?, "there should be no errors"
@@ -10,7 +10,7 @@
end
it "format should work with arity == 2" do
- sparkline = Sparkr::Sparkline.new([5.5,20])
+ sparkline = Sparkr::Sparkline.new([5.5, 20])
sparkline.format do |tick, number|
if number < 6.0
tick = tick + "-"
@@ -22,7 +22,7 @@
end
it "format should work with arity == 3" do
- sparkline = Sparkr::Sparkline.new([5.5,20])
+ sparkline = Sparkr::Sparkline.new([5.5, 20])
sparkline.format do |tick, number, index|
if index == 1
tick = tick + "-"
View
@@ -4,23 +4,22 @@
describe ::Sparkr do
it "should find work like holman/spark" do
- assert_sparkline '▁▂▃▄▅▆▇█', [1,2,3,4,5,6,7,8]
- assert_sparkline '▁▂█▅▂', [1,5,22,13,5]
- assert_sparkline '▁█', [5.5,20]
- assert_sparkline '▁▁▁▁▃▁▁▁▂█', [1,2,3,4,100,5,10,20,50,300]
- assert_sparkline '▁▄█', [1,50,100]
- assert_sparkline '▁▃█', [2,4,8]
- assert_sparkline '▁▂▃▄▂█', [0,30,55,80,33,150]
- assert_sparkline '▁▂▄▆█', [1,2,3,4,5]
+ assert_sparkline '▁▂▃▄▅▆▇█', [1, 2, 3, 4, 5, 6, 7, 8]
+ assert_sparkline '▁▂█▅▂', [1, 5, 22, 13, 5]
+ assert_sparkline '▁█', [5.5, 20]
+ assert_sparkline '▁▁▁▁▃▁▁▁▂█', [1, 2, 3, 4, 100, 5, 10, 20, 50, 300]
+ assert_sparkline '▁▄█', [1, 50, 100]
+ assert_sparkline '▁▃█', [2, 4, 8]
+ assert_sparkline '▁▂▃▄▂█', [0, 30, 55, 80, 33, 150]
+ assert_sparkline '▁▂▄▆█', [1, 2, 3, 4, 5]
end
it "should find work with equal numbers" do
assert_sparkline '▁▁', [10, 10]
end
-
it ".sparkline should work with arity == 2" do
- sparkline = Sparkr.sparkline([5.5,20]) do |tick, number|
+ sparkline = Sparkr.sparkline([5.5, 20]) do |tick, number|
if number < 6.0
tick = tick + "-"
else
@@ -31,7 +30,7 @@
end
it ".sparkline should work with arity == 3" do
- sparkline = Sparkr.sparkline([5.5,20]) do |tick, number, index|
+ sparkline = Sparkr.sparkline([5.5, 20]) do |tick, number, index|
if index == 1
tick = tick + "-"
else

0 comments on commit 30d4039

Please sign in to comment.