muflax 0.2.5 → 0.2.6

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: c3c658af855414bea8ca9b03391eef441f7a3706
4
- data.tar.gz: 7c45ee303680f6c7bffe588ff345ddecd04dc1cc
3
+ metadata.gz: 4e70421f893de0859ccaa17fa1a9c1494d5886d9
4
+ data.tar.gz: 802a0fed3386db1e8a9b1129cbf136c4da9348a1
5
5
  SHA512:
6
- metadata.gz: 0bfa5c9b931ddd083e37e42c7908cdda757c8bf62b8e4c202d374dffb38ec1de66e58cde98520f2d3f43add24461fbca60a020ffc4ae0f67e98b99580911ef4c
7
- data.tar.gz: 5d4af076c5f8c31569c1a0c9392cf9a37365b0e8b660e484ade2901b4ce0afd258926388ffa7afacdbbb4a43851cbdc7a0adfc471169e20f3b2dacafabac5ca9
6
+ metadata.gz: 7e7457a9c3c6462c4eac1e2137693cede786c9340c4448556c2931abdf864658f4f0296507b464d76c4cd15b53319c1249117edd127ab4ae73c3e0b7351923e6
7
+ data.tar.gz: 2a87180a6af908e7a4f397e0065776bb7382864c5e122200d99e50621a25a2d9de239c910188135f243ca44fd71b7f75bf34fb50eea7051d64bd67212813b393
checksums.yaml.gz.sig CHANGED
Binary file
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- muflax (0.2.5)
4
+ muflax (0.2.6)
5
5
  activesupport (~> 5)
6
6
  awesome_print
7
7
  debug_inspector
data/lib/muflax/panes.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # -*- encoding: utf-8 -*-
3
- # Copyright Stefan Dorn <mail@muflax.com>, 2017
3
+ # Copyright Steffi Dorn <mail@muflax.com>, 2017
4
4
  # License: GNU GPLv3 (or later) <http://www.gnu.org/copyleft/gpl.html>
5
5
 
6
6
  module Kernel
@@ -55,12 +55,12 @@ class Panes
55
55
  @sections.last
56
56
  end
57
57
 
58
- def total_lines ; @height * @columns ; end
59
- def remaining_lines ; total_lines - @used_lines ; end
60
- def remaining_lines_on_column ; remaining_lines % @height ; end
61
- def used_columns ; @used_lines / @height ; end
62
- def remaining_columns ; @columns - used_columns ; end
63
- def column_full? ; remaining_lines_on_column <= 1 ; end
58
+ def total_lines ; @height * @columns ; end
59
+ def remaining_lines ; [total_lines - @used_lines, 0].max ; end
60
+ def remaining_lines_on_column ; remaining_lines <= 0 ? 0 : (remaining_lines % @column_height) ; end
61
+ def used_columns ; @used_lines / @height ; end
62
+ def remaining_columns ; @columns - used_columns ; end
63
+ def column_full? ; remaining_lines_on_column <= 0 ; end
64
64
 
65
65
  def new_column
66
66
  unless column_full?
@@ -74,8 +74,7 @@ class Panes
74
74
  lines = [*lines].flatten
75
75
  section = new_section
76
76
  left = remaining_lines_on_column
77
-
78
- # ap h: @height, t: total_lines, r: remaining_lines, rc: remaining_lines_on_column, l: lines
77
+ rem = remaining_lines
79
78
 
80
79
  num = case max
81
80
  when :all ; lines.size
@@ -87,22 +86,34 @@ class Panes
87
86
  num = [num, remaining_lines].min
88
87
  @used_lines += num
89
88
 
90
- if @need_divider
91
- if header
92
- h = lines.first
93
- lines = lines[1..-1]
94
- div = h.sub(/^\s+/){|s| @divider*s.size}.sub(/\s+$/){|s| @divider*s.size}
95
- section.divider = div + @divider * (@column_width - div.str_length)
96
- else
97
- @used_lines += 1
98
- num -= 1 unless max == :all # compensate for the divider
99
- section.divider = @divider * @column_width
100
- end
89
+ case
90
+ when header
91
+ h = lines.first
92
+ lines = lines[1..-1]
93
+ div = h.sub(/^\s+/){|s| @divider*s.size}.sub(/\s+$/){|s| @divider*s.size}
94
+ section.divider = div + @divider * (@column_width - div.str_length)
95
+
96
+ when @need_divider
97
+ @used_lines += 1
98
+ num -= 1 if max != :all or num >= rem # compensate for the divider
99
+ section.divider = @divider * @column_width
101
100
  end
102
101
 
102
+ num = [num, rem].min
103
103
  to_print = tail ? lines.last(num) : lines.first(num)
104
104
  @need_divider = ! column_full?
105
105
 
106
+ # ap(
107
+ # height: @height,
108
+ # total: total_lines,
109
+ # rem: rem,
110
+ # left: left,
111
+ # rem_lines: remaining_lines,
112
+ # rem_column: remaining_lines_on_column,
113
+ # lines: lines,
114
+ # num: num
115
+ # )
116
+
106
117
  to_print.each do |line|
107
118
  section << line.truncate(@column_width, omission: "⇏")
108
119
  end
data/lib/muflax/table.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # -*- encoding: utf-8 -*-
3
- # Copyright Stefan Dorn <mail@muflax.com>, 2017
3
+ # Copyright Steffi Dorn <mail@muflax.com>, 2017
4
4
  # License: GNU GPLv3 (or later) <http://www.gnu.org/copyleft/gpl.html>
5
5
 
6
6
  class Table
data/lib/muflax/value.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # -*- encoding: utf-8 -*-
3
- # Copyright Stefan Dorn <mail@muflax.com>, 2016
3
+ # Copyright Steffi Dorn <mail@muflax.com>, 2016
4
4
  # License: GNU GPLv3 (or later) <http://www.gnu.org/copyleft/gpl.html>
5
5
 
6
6
  class Value
data/muflax.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "muflax"
3
- s.version = "0.2.5"
3
+ s.version = "0.2.6"
4
4
 
5
5
  s.authors = ["muflax"]
6
6
  s.summary = "muflax standard library"
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: muflax
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - muflax
@@ -28,7 +28,7 @@ cert_chain:
28
28
  9xjevPGDZ+8y8wc8/mXBPK1pTaBh2oi8947HaTq8EadxezFs2Je+oSnMbygfo/a7
29
29
  0rbAHpJPtzql3a4+gjK54qkJUWSUjWuLMHFIHhMt1laowNJUio6ASGx8tfzgLLnZ
30
30
  -----END CERTIFICATE-----
31
- date: 2017-07-19 00:00:00.000000000 Z
31
+ date: 2017-07-27 00:00:00.000000000 Z
32
32
  dependencies:
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: activesupport
metadata.gz.sig CHANGED
Binary file