make_menu 2.1.0 → 2.1.2

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
  SHA256:
3
- metadata.gz: 8b6cd27b7d216d9aafab18ee1ada5756d4623a293bc659a6b16a01d71c95d180
4
- data.tar.gz: 48f36e38f319a452675b3c45e8189e873d4679a71a8e8867684c8494cd850fff
3
+ metadata.gz: 8e8deea1b2ebda28848b35a6a976fddcd9240e5666a9e15ffd2fbbd38fd1e277
4
+ data.tar.gz: 73d9f77a5d67a1767a95eb0d40556e1dc739186a71f0cb505cad3bda25857caa
5
5
  SHA512:
6
- metadata.gz: 3a3d2c60b794b93e27dfa7de7da5fd1bf75c5b385209b5c2ee571d881824cda532a36b6b2bcdb4dddb70684dcab426ea1a0c544ff724177ff3c0b3eee13bf45d
7
- data.tar.gz: 8db18bd0530bc1118573efbe5d3df92663a8e52a9053d489118ec2ab3ceadc4f2e68427687809695de3ba0e6d41909c1f04f89feb675ca3acfae3afc96c1ca0e
6
+ metadata.gz: 94258bdbe5bf66a57e1419b3d0985afc2556535346c804568ccb15ba50c0bbf28ba4099b3c2d1fda319edff7133b986475f49b95c8140d9a50549f0c324bab0b
7
+ data.tar.gz: 24dd88d435a17d18ba62bc84d14dfad97fd88b57b402dde1bc602e2d0a8e9e2b342f4f78a8f656b722ebe3bf11f22bab293930062693e5b87ceced67486a0bde
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- make_menu (2.1.0)
4
+ make_menu (2.1.2)
5
5
  tty-screen (~> 0.8.2)
6
6
 
7
7
  GEM
@@ -12,12 +12,12 @@ module MakeMenu
12
12
  file = ".#{file}"
13
13
  end
14
14
 
15
- current = File.exists?(file) ? File.read(file).strip : ''
15
+ current = File.exist?(file) ? File.read(file).strip : ''
16
16
 
17
17
  response = prompt(text, input: current, obscure: obscure)
18
18
 
19
19
  if response.empty?
20
- File.delete(file) if File.exists?(file)
20
+ File.delete(file) if File.exist?(file)
21
21
  else
22
22
  File.write(file, response)
23
23
  end
@@ -22,7 +22,7 @@ module MakeMenu
22
22
  value_from_file = ".#{value_from_file}"
23
23
  end
24
24
  block = lambda do
25
- if File.exists? value_from_file
25
+ if File.exist? value_from_file
26
26
  value = File.read(value_from_file).strip
27
27
 
28
28
  return none if value.empty?
@@ -2,21 +2,23 @@
2
2
 
3
3
  module MakeMenu
4
4
  module Text
5
+ SPACING = 2
6
+
5
7
  # A column of text with a fixed with
6
8
  class Column
7
- def initialize(width)
8
- @width = width
9
+ def initialize
10
+ @width = nil
9
11
  @rows = []
10
12
  @row_index = 0
11
13
  end
12
14
 
13
- attr_reader :width
14
-
15
- attr_accessor :rows, :row_index
15
+ attr_accessor :rows, :row_index, :width
16
16
 
17
17
  # Add a block of text to the column. Each row will be padded to the column width
18
18
  def add(text)
19
19
  self.rows += text.split("\n").map do |row|
20
+ self.width = row.decolor.size + SPACING unless width
21
+ self.width = [width, row.decolor.size + SPACING].max
20
22
  row.gsub("\r", '')
21
23
  end
22
24
  self.row_index += text.lines.size
@@ -64,7 +64,7 @@ module MakeMenu
64
64
 
65
65
  # Add a new column to the table
66
66
  def column_break
67
- self.current_column = Column.new(column_width)
67
+ self.current_column = Column.new
68
68
  columns << current_column
69
69
  end
70
70
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MakeMenu
4
- VERSION = '2.1.0'
4
+ VERSION = '2.1.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: make_menu
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Barri Mason
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-07 00:00:00.000000000 Z
11
+ date: 2024-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-screen