more_math 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb1b7eaf071255d2a996c85a1f46394a21e30178a74940d8b88f7c538dac094b
4
- data.tar.gz: d6f4f436f85fd44dd57751190d1ba85f458b07eecc07a3fa78c7f1de69c3b160
3
+ metadata.gz: c2945331f84849efc01cafcdd9dec0e1402a6296c979d6b6d5ecb41ff49427a2
4
+ data.tar.gz: 2e25d9b28a5c326eb50d7ca12ef66d0562f8e5839a8f9c37a9db504fc13c286c
5
5
  SHA512:
6
- metadata.gz: 104e595a14fbb58f014ea5cd944552c8b85401c0d3bc2243489457cfbf3d5227104f7da6f1a891b21a551e7e11f830d100b2172593ba2932675a30f0dfb20200
7
- data.tar.gz: 44320e2edaa82a99f5629562130a807ccc4e3499cba750f8d564da8515aabcec363e182d76bbe86c0af7e8d587691703e87a1d0743016c3d6fbf4ccb2d00f934
6
+ metadata.gz: 11a42069a9e921c857849cceb0f912a3989a4bf046645be765c8acb54f9bea299ced8790be585fd04367531e6484847866cde89486c7aa6943fb396d80bfcf31
7
+ data.tar.gz: ee3e2b0ba782557eb94770833b0e98494254ce1a138caf493e72d208b54f56bb62645bd0779e71c84b32b949df2b8de3f4424c2c107b3c609a7bd5901a2cd471
data/CHANGES.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changes
2
2
 
3
+ ## 2024-09-30 v1.2.1
4
+
5
+ * Refactor histogram display logic for utf8 and ascii bars
6
+ + *Improved `utf8_bar` method to handle fractional bar widths.*
7
+ + *Updated test case in `histogram_test.rb` to reflect changes.*
8
+
3
9
  ## 2024-09-30 v1.2.0
4
10
 
5
11
  #### Significant Changes
@@ -53,7 +53,11 @@ module MoreMath
53
53
  def utf8_bar(bar_width)
54
54
  fract = bar_width - bar_width.floor
55
55
  bar = ?⣿ * bar_width.floor
56
- fract > 0.5 and bar << ?⡇
56
+ if fract > 0.5
57
+ bar << ?⡇
58
+ else
59
+ bar << ' '
60
+ end
57
61
  bar
58
62
  end
59
63
 
@@ -80,7 +84,15 @@ module MoreMath
80
84
  bar_width = (count * factor)
81
85
  bar = utf8? ? utf8_bar(bar_width) : ascii_bar(bar_width)
82
86
  if @with_counts
83
- bar += count.to_s.rjust(width - bar_width)
87
+ if utf8?
88
+ if bar[-1] == ' '
89
+ bar += count.to_s.rjust(width - bar_width - 1)
90
+ else
91
+ bar += count.to_s.rjust(width - bar_width)
92
+ end
93
+ else
94
+ bar += count.to_s.rjust(width - bar_width)
95
+ end
84
96
  end
85
97
  "%11.5f -|%s\n" % [ (left + right) / 2.0, bar ]
86
98
  end
@@ -1,6 +1,6 @@
1
1
  module MoreMath
2
2
  # MoreMath version
3
- VERSION = '1.2.0'
3
+ VERSION = '1.2.1'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
data/more_math.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: more_math 1.2.0 ruby lib
2
+ # stub: more_math 1.2.1 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "more_math".freeze
6
- s.version = "1.2.0".freeze
6
+ s.version = "1.2.1".freeze
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
@@ -60,9 +60,9 @@ class HistogramTest < Test::Unit::TestCase
60
60
  output = StringIO.new
61
61
  histogram.display output
62
62
  assert_equal <<~end, output.string
63
- 7.50000 -|⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
63
+ 7.50000 -|⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
64
64
  4.50000 -|⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇
65
- 1.50000 -|⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
65
+ 1.50000 -|⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
66
66
  max_count=420
67
67
  end
68
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: more_math
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank