tty-box 0.2.1 → 0.6.0
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/CHANGELOG.md +52 -0
- data/README.md +212 -33
- data/lib/tty/box.rb +291 -65
- data/lib/tty/box/border.rb +54 -14
- data/lib/tty/box/version.rb +1 -1
- metadata +31 -53
- data/Rakefile +0 -8
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/examples/commander.rb +0 -52
- data/spec/spec_helper.rb +0 -29
- data/spec/unit/align_spec.rb +0 -27
- data/spec/unit/border_spec.rb +0 -70
- data/spec/unit/frame_spec.rb +0 -49
- data/spec/unit/padding_spec.rb +0 -46
- data/spec/unit/position_spec.rb +0 -23
- data/spec/unit/style_spec.rb +0 -31
- data/spec/unit/title_spec.rb +0 -35
- data/tasks/console.rake +0 -11
- data/tasks/coverage.rake +0 -11
- data/tasks/spec.rake +0 -29
- data/tty-box.gemspec +0 -29
data/spec/unit/frame_spec.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
RSpec.describe TTY::Box, '#frame' do
|
2
|
-
it "creates frame with only width & height values" do
|
3
|
-
output = TTY::Box.frame(width: 35, height: 4)
|
4
|
-
|
5
|
-
expect(output).to eq([
|
6
|
-
"┌─────────────────────────────────┐\n",
|
7
|
-
"│ │\n",
|
8
|
-
"│ │\n",
|
9
|
-
"└─────────────────────────────────┘\n"
|
10
|
-
].join)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "creates frame at a position with direct width & height values" do
|
14
|
-
output = TTY::Box.frame(top: 0, left: 0, width: 35, height: 4)
|
15
|
-
|
16
|
-
expect(output).to eq([
|
17
|
-
"\e[1;1H┌─────────────────────────────────┐",
|
18
|
-
"\e[2;1H│\e[2;35H│",
|
19
|
-
"\e[3;1H│\e[3;35H│",
|
20
|
-
"\e[4;1H└─────────────────────────────────┘"
|
21
|
-
].join)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "displays content when block provided" do
|
25
|
-
output = TTY::Box.frame(top: 0, left: 0, width: 35, height: 4) do
|
26
|
-
"Hello world!"
|
27
|
-
end
|
28
|
-
|
29
|
-
expect(output).to eq([
|
30
|
-
"\e[1;1H┌─────────────────────────────────┐",
|
31
|
-
"\e[2;1H│Hello world! \e[2;35H│",
|
32
|
-
"\e[3;1H│\e[3;35H│",
|
33
|
-
"\e[4;1H└─────────────────────────────────┘"
|
34
|
-
].join)
|
35
|
-
end
|
36
|
-
|
37
|
-
it "wraps content when exceeding width" do
|
38
|
-
box = TTY::Box.frame(top: 0, left: 0, width: 20, height: 4) do
|
39
|
-
"Drawing a box in terminal emulator"
|
40
|
-
end
|
41
|
-
|
42
|
-
expect(box).to eq([
|
43
|
-
"\e[1;1H┌──────────────────┐",
|
44
|
-
"\e[2;1H│Drawing a box in \e[2;20H│",
|
45
|
-
"\e[3;1H│terminal emulator \e[3;20H│",
|
46
|
-
"\e[4;1H└──────────────────┘"
|
47
|
-
].join)
|
48
|
-
end
|
49
|
-
end
|
data/spec/unit/padding_spec.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
RSpec.describe TTY::Box, ':padding option' do
|
2
|
-
it "padds internal content without position arguments" do
|
3
|
-
box = TTY::Box.frame(width: 30, height: 6, padding: 1) do
|
4
|
-
"Drawing a box in terminal emulator"
|
5
|
-
end
|
6
|
-
|
7
|
-
expect(box).to eq([
|
8
|
-
"┌────────────────────────────┐\n",
|
9
|
-
"│ │\n",
|
10
|
-
"│ Drawing a box in terminal │\n",
|
11
|
-
"│ emulator │\n",
|
12
|
-
"│ │\n",
|
13
|
-
"└────────────────────────────┘\n"
|
14
|
-
].join)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "padds internal content with with padding as integer" do
|
18
|
-
box = TTY::Box.frame(top: 0, left: 0, width: 30, height: 6, padding: 1) do
|
19
|
-
"Drawing a box in terminal emulator"
|
20
|
-
end
|
21
|
-
|
22
|
-
expect(box).to eq([
|
23
|
-
"\e[1;1H┌────────────────────────────┐",
|
24
|
-
"\e[2;1H│ \e[2;30H│",
|
25
|
-
"\e[3;1H│ Drawing a box in terminal \e[3;30H│",
|
26
|
-
"\e[4;1H│ emulator \e[4;30H│",
|
27
|
-
"\e[5;1H│ \e[5;30H│",
|
28
|
-
"\e[6;1H└────────────────────────────┘"
|
29
|
-
].join)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "padds internal content with padding as array" do
|
33
|
-
box = TTY::Box.frame(top: 0, left: 0, width: 30, height: 6, padding: [1,3,1,3]) do
|
34
|
-
"Drawing a box in terminal emulator"
|
35
|
-
end
|
36
|
-
|
37
|
-
expect(box).to eq([
|
38
|
-
"\e[1;1H┌────────────────────────────┐",
|
39
|
-
"\e[2;1H│ \e[2;30H│",
|
40
|
-
"\e[3;1H│ Drawing a box in \e[3;30H│",
|
41
|
-
"\e[4;1H│ terminal emulator \e[4;30H│",
|
42
|
-
"\e[5;1H│ \e[5;30H│",
|
43
|
-
"\e[6;1H└────────────────────────────┘"
|
44
|
-
].join)
|
45
|
-
end
|
46
|
-
end
|
data/spec/unit/position_spec.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
RSpec.describe TTY::Box, ':top, :left options' do
|
2
|
-
it "skips positioning when no top & left values provided" do
|
3
|
-
output = TTY::Box.frame(width: 35, height: 4)
|
4
|
-
|
5
|
-
expect(output).to eq([
|
6
|
-
"┌─────────────────────────────────┐\n",
|
7
|
-
"│ │\n",
|
8
|
-
"│ │\n",
|
9
|
-
"└─────────────────────────────────┘\n"
|
10
|
-
].join)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "allows to absolutely position within the terminal window" do
|
14
|
-
output = TTY::Box.frame(top: 10, left: 40, width: 35, height: 4)
|
15
|
-
|
16
|
-
expect(output).to eq([
|
17
|
-
"\e[11;41H┌─────────────────────────────────┐",
|
18
|
-
"\e[12;41H│\e[12;75H│",
|
19
|
-
"\e[13;41H│\e[13;75H│",
|
20
|
-
"\e[14;41H└─────────────────────────────────┘"
|
21
|
-
].join)
|
22
|
-
end
|
23
|
-
end
|
data/spec/unit/style_spec.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
RSpec.describe TTY::Box, ":style option" do
|
2
|
-
it "applies styling to content and border" do
|
3
|
-
box = TTY::Box.frame(
|
4
|
-
top: 0,
|
5
|
-
left: 0,
|
6
|
-
width: 30,
|
7
|
-
height: 4,
|
8
|
-
border: :thick,
|
9
|
-
title: {
|
10
|
-
top_left: ' file1 '
|
11
|
-
},
|
12
|
-
style: {
|
13
|
-
fg: :bright_yellow,
|
14
|
-
bg: :blue,
|
15
|
-
border: {
|
16
|
-
fg: :bright_yellow,
|
17
|
-
bg: :blue
|
18
|
-
}
|
19
|
-
}
|
20
|
-
) do
|
21
|
-
"Midnight Commander\nis the best"
|
22
|
-
end
|
23
|
-
|
24
|
-
expect(box).to eq([
|
25
|
-
"\e[1;1H\e[44m\e[93m╔\e[0m\e[0m\e[44m file1 \e[0m\e[44m\e[93m══════════\e[0m\e[0m\e[44m\e[93m═══════════\e[0m\e[0m\e[44m\e[93m╗\e[0m\e[0m",
|
26
|
-
"\e[2;1H\e[44m\e[93m║\e[0m\e[0m\e[44m\e[93mMidnight Commander \e[0m\e[0m\e[2;30H\e[44m\e[93m║\e[0m\e[0m",
|
27
|
-
"\e[3;1H\e[44m\e[93m║\e[0m\e[0m\e[44m\e[93mis the best \e[0m\e[0m\e[3;30H\e[44m\e[93m║\e[0m\e[0m",
|
28
|
-
"\e[4;1H\e[44m\e[93m╚\e[0m\e[0m\e[44m\e[93m══════════════\e[0m\e[0m\e[44m\e[93m══════════════\e[0m\e[0m\e[44m\e[93m╝\e[0m\e[0m"
|
29
|
-
].join)
|
30
|
-
end
|
31
|
-
end
|
data/spec/unit/title_spec.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
RSpec.describe TTY::Box, ':title option' do
|
2
|
-
it "allows to specify top border titles" do
|
3
|
-
output = TTY::Box.frame(
|
4
|
-
top: 0, left: 0,
|
5
|
-
width: 35, height: 4,
|
6
|
-
title: {
|
7
|
-
top_left: 'left',
|
8
|
-
top_right: 'right',
|
9
|
-
top_center: 'center'
|
10
|
-
})
|
11
|
-
|
12
|
-
expect(output).to eq([
|
13
|
-
"\e[1;1H┌left─────────center─────────right┐",
|
14
|
-
"\e[2;1H│\e[2;35H│\e[3;1H│\e[3;35H│",
|
15
|
-
"\e[4;1H└─────────────────────────────────┘"
|
16
|
-
].join)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "allows to specify bottom border titles" do
|
20
|
-
output = TTY::Box.frame(
|
21
|
-
top: 0, left: 0,
|
22
|
-
width: 35, height: 4,
|
23
|
-
title: {
|
24
|
-
bottom_left: 'left',
|
25
|
-
bottom_right: 'right',
|
26
|
-
bottom_center: 'center'
|
27
|
-
})
|
28
|
-
|
29
|
-
expect(output).to eq([
|
30
|
-
"\e[1;1H┌─────────────────────────────────┐",
|
31
|
-
"\e[2;1H│\e[2;35H│\e[3;1H│\e[3;35H│",
|
32
|
-
"\e[4;1H└left─────────center─────────right┘"
|
33
|
-
].join)
|
34
|
-
end
|
35
|
-
end
|
data/tasks/console.rake
DELETED
data/tasks/coverage.rake
DELETED
data/tasks/spec.rake
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'rspec/core/rake_task'
|
5
|
-
|
6
|
-
desc 'Run all specs'
|
7
|
-
RSpec::Core::RakeTask.new(:spec) do |task|
|
8
|
-
task.pattern = 'spec/{unit,integration}{,/*/**}/*_spec.rb'
|
9
|
-
end
|
10
|
-
|
11
|
-
namespace :spec do
|
12
|
-
desc 'Run unit specs'
|
13
|
-
RSpec::Core::RakeTask.new(:unit) do |task|
|
14
|
-
task.pattern = 'spec/unit{,/*/**}/*_spec.rb'
|
15
|
-
end
|
16
|
-
|
17
|
-
desc 'Run integration specs'
|
18
|
-
RSpec::Core::RakeTask.new(:integration) do |task|
|
19
|
-
task.pattern = 'spec/integration{,/*/**}/*_spec.rb'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
rescue LoadError
|
24
|
-
%w[spec spec:unit spec:integration].each do |name|
|
25
|
-
task name do
|
26
|
-
$stderr.puts "In order to run #{name}, do `gem install rspec`"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/tty-box.gemspec
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
lib = File.expand_path("../lib", __FILE__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require "tty/box/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "tty-box"
|
7
|
-
spec.version = TTY::Box::VERSION
|
8
|
-
spec.authors = ["Piotr Murach"]
|
9
|
-
spec.email = [""]
|
10
|
-
|
11
|
-
spec.summary = %q{Draw various frames and boxes in your terminal interface.}
|
12
|
-
spec.description = %q{Draw various frames and boxes in your terminal interface.}
|
13
|
-
spec.homepage = "https://piotrmurach.github.io/tty"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = Dir['{lib,spec,examples}/**/*.rb']
|
17
|
-
spec.files += Dir['{bin,tasks}/*', 'tty-box.gemspec']
|
18
|
-
spec.files += Dir['README.md', 'CHANGELOG.md', 'LICENSE.txt', 'Rakefile']
|
19
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
-
spec.require_paths = ["lib"]
|
21
|
-
|
22
|
-
spec.add_dependency 'pastel', '~> 0.7.2'
|
23
|
-
spec.add_dependency 'tty-cursor', '~> 0.6.0'
|
24
|
-
spec.add_dependency 'strings', '~> 0.1.4'
|
25
|
-
|
26
|
-
spec.add_development_dependency "bundler", "~> 1.16"
|
27
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
29
|
-
end
|