tty-box 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,82 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe TTY::Box, ":padding option" do
4
- it "padds internal content without width and height" do
5
- box = TTY::Box.frame(padding: 1) do
6
- "Drawing a box in terminal emulator"
7
- end
8
-
9
- expect(box).to eq([
10
- "┌────────────────────────────────────┐\n",
11
- "│ │\n",
12
- "│ Drawing a box in terminal emulator │\n",
13
- "│ │\n",
14
- "└────────────────────────────────────┘\n"
15
- ].join)
16
- end
17
-
18
- it "padds internal content without position arguments" do
19
- box = TTY::Box.frame(width: 30, height: 6, padding: 1) do
20
- "Drawing a box in terminal emulator"
21
- end
22
-
23
- expect(box).to eq([
24
- "┌────────────────────────────┐\n",
25
- "│ │\n",
26
- "│ Drawing a box in terminal │\n",
27
- "│ emulator │\n",
28
- "│ │\n",
29
- "└────────────────────────────┘\n"
30
- ].join)
31
- end
32
-
33
- it "padds internal content with with padding as integer" do
34
- box = TTY::Box.frame(top: 0, left: 0, width: 30, height: 6, padding: 1) do
35
- "Drawing a box in terminal emulator"
36
- end
37
-
38
- expect(box).to eq([
39
- "\e[1;1H┌────────────────────────────┐",
40
- "\e[2;1H│ \e[2;30H│",
41
- "\e[3;1H│ Drawing a box in terminal \e[3;30H│",
42
- "\e[4;1H│ emulator \e[4;30H│",
43
- "\e[5;1H│ \e[5;30H│",
44
- "\e[6;1H└────────────────────────────┘"
45
- ].join)
46
- end
47
-
48
- it "padds internal content with padding as array" do
49
- box = TTY::Box.frame(top: 0, left: 0, width: 30, height: 6, padding: [1,3,1,3]) do
50
- "Drawing a box in terminal emulator"
51
- end
52
-
53
- expect(box).to eq([
54
- "\e[1;1H┌────────────────────────────┐",
55
- "\e[2;1H│ \e[2;30H│",
56
- "\e[3;1H│ Drawing a box in \e[3;30H│",
57
- "\e[4;1H│ terminal emulator \e[4;30H│",
58
- "\e[5;1H│ \e[5;30H│",
59
- "\e[6;1H└────────────────────────────┘"
60
- ].join)
61
- end
62
-
63
- it "handles \r\n line breaks when padding" do
64
- box = TTY::Box.frame(
65
- width: 29,
66
- height: 7,
67
- padding: 1
68
- ) do
69
- "Closes #360\r\n\r\nCloses !217"
70
- end
71
-
72
- expect(box).to eq([
73
- "┌───────────────────────────┐\r\n",
74
- "│ │\r\n",
75
- "│ Closes #360 │\r\n",
76
- "│ │\r\n",
77
- "│ Closes !217 │\r\n",
78
- "│ │\r\n",
79
- "└───────────────────────────┘\r\n"
80
- ].join)
81
- end
82
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe TTY::Box, ':top, :left options' do
4
- it "skips positioning when no top & left values provided" do
5
- output = TTY::Box.frame(width: 35, height: 4)
6
-
7
- expect(output).to eq([
8
- "┌─────────────────────────────────┐\n",
9
- "│ │\n",
10
- "│ │\n",
11
- "└─────────────────────────────────┘\n"
12
- ].join)
13
- end
14
-
15
- it "allows to absolutely position within the terminal window" do
16
- output = TTY::Box.frame(top: 10, left: 40, width: 35, height: 4)
17
-
18
- expect(output).to eq([
19
- "\e[11;41H┌─────────────────────────────────┐",
20
- "\e[12;41H│\e[12;75H│",
21
- "\e[13;41H│\e[13;75H│",
22
- "\e[14;41H└─────────────────────────────────┘"
23
- ].join)
24
- end
25
- end
@@ -1,123 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe TTY::Box, ":style option" do
4
- it "applies styling to content and border" do
5
- box = TTY::Box.frame(
6
- top: 0,
7
- left: 0,
8
- width: 30,
9
- height: 4,
10
- border: :thick,
11
- title: {
12
- top_left: ' file1 '
13
- },
14
- style: {
15
- fg: :bright_yellow,
16
- bg: :blue,
17
- border: {
18
- fg: :bright_yellow,
19
- bg: :blue
20
- }
21
- }
22
- ) do
23
- "Midnight Commander\nis the best"
24
- end
25
-
26
- expect(box).to eq([
27
- "\e[1;1H\e[44m\e[93m╔\e[0m\e[0m\e[44m\e[93m file1 \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",
28
- "\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",
29
- "\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",
30
- "\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"
31
- ].join)
32
- end
33
-
34
- it "creates box without corners and only color fill" do
35
- box = TTY::Box.frame(
36
- width: 10, height: 4,
37
- border: {
38
- top_left: false,
39
- top_right: false,
40
- bottom_left: false,
41
- bottom_right: false,
42
- },
43
- style: {
44
- fg: :bright_yellow,
45
- bg: :blue,
46
- }
47
- )
48
-
49
- expect(box).to eq([
50
- "──────────\n",
51
- "│\e[44m\e[93m \e[0m\e[0m│\n",
52
- "│\e[44m\e[93m \e[0m\e[0m│\n",
53
- "──────────\n"
54
- ].join)
55
- end
56
-
57
- it "creates box without left & right borders and only color fill" do
58
- box = TTY::Box.frame(
59
- width: 10, height: 4,
60
- border: {
61
- left: false,
62
- right: false
63
- },
64
- style: {
65
- fg: :bright_yellow,
66
- bg: :blue,
67
- }
68
- )
69
-
70
- expect(box).to eq([
71
- "──────────\n",
72
- "\e[44m\e[93m \e[0m\e[0m\n",
73
- "\e[44m\e[93m \e[0m\e[0m\n",
74
- "──────────\n"
75
- ].join)
76
- end
77
-
78
- it "creates box without top & bottom borders and only color fill" do
79
- box = TTY::Box.frame(
80
- width: 10, height: 4,
81
- border: {
82
- top: false,
83
- bottom: false
84
- },
85
- style: {
86
- fg: :bright_yellow,
87
- bg: :blue,
88
- }
89
- )
90
-
91
- expect(box).to eq([
92
- "│\e[44m\e[93m \e[0m\e[0m│\n",
93
- "│\e[44m\e[93m \e[0m\e[0m│\n",
94
- "│\e[44m\e[93m \e[0m\e[0m│\n",
95
- "│\e[44m\e[93m \e[0m\e[0m│\n",
96
- ].join)
97
- end
98
-
99
- it "creates box without top & left borders and only color fill" do
100
- box = TTY::Box.frame(
101
- width: 10, height: 4,
102
- border: {
103
- top: false,
104
- left: false
105
- },
106
- style: {
107
- fg: :bright_yellow,
108
- bg: :blue,
109
- border: {
110
- fg: :bright_yellow,
111
- bg: :blue
112
- }
113
- }
114
- )
115
-
116
- expect(box).to eq([
117
- "\e[44m\e[93m \e[0m\e[0m\e[44m\e[93m│\e[0m\e[0m\n",
118
- "\e[44m\e[93m \e[0m\e[0m\e[44m\e[93m│\e[0m\e[0m\n",
119
- "\e[44m\e[93m \e[0m\e[0m\e[44m\e[93m│\e[0m\e[0m\n",
120
- "\e[44m\e[93m────\e[0m\e[0m\e[44m\e[93m─────\e[0m\e[0m\e[44m\e[93m┘\e[0m\e[0m\n"
121
- ].join)
122
- end
123
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe TTY::Box, ':title option' do
4
- it "allows to specify top border titles" do
5
- output = TTY::Box.frame(
6
- top: 0, left: 0,
7
- width: 35, height: 4,
8
- title: {
9
- top_left: 'left',
10
- top_right: 'right',
11
- top_center: 'center'
12
- })
13
-
14
- expect(output).to eq([
15
- "\e[1;1H┌left─────────center─────────right┐",
16
- "\e[2;1H│\e[2;35H│\e[3;1H│\e[3;35H│",
17
- "\e[4;1H└─────────────────────────────────┘"
18
- ].join)
19
- end
20
-
21
- it "allows to specify bottom border titles" do
22
- output = TTY::Box.frame(
23
- top: 0, left: 0,
24
- width: 35, height: 4,
25
- title: {
26
- bottom_left: 'left',
27
- bottom_right: 'right',
28
- bottom_center: 'center'
29
- })
30
-
31
- expect(output).to eq([
32
- "\e[1;1H┌─────────────────────────────────┐",
33
- "\e[2;1H│\e[2;35H│\e[3;1H│\e[3;35H│",
34
- "\e[4;1H└left─────────center─────────right┘"
35
- ].join)
36
- end
37
- end
@@ -1,11 +0,0 @@
1
- # encoding: utf-8
2
-
3
- desc 'Load gem inside irb console'
4
- task :console do
5
- require 'irb'
6
- require 'irb/completion'
7
- require File.join(__FILE__, '../../lib/tty-box')
8
- ARGV.clear
9
- IRB.start
10
- end
11
- task c: %w[ console ]
@@ -1,11 +0,0 @@
1
- # encoding: utf-8
2
-
3
- desc 'Measure code coverage'
4
- task :coverage do
5
- begin
6
- original, ENV['COVERAGE'] = ENV['COVERAGE'], 'true'
7
- Rake::Task['spec'].invoke
8
- ensure
9
- ENV['COVERAGE'] = original
10
- end
11
- end
@@ -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
@@ -1,30 +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 = ["me@piotrmurach.com"]
10
- spec.summary = %q{Draw various frames and boxes in your terminal interface.}
11
- spec.description = %q{Draw various frames and boxes in your terminal interface.}
12
- spec.homepage = "https://piotrmurach.github.io/tty"
13
- spec.license = "MIT"
14
-
15
- spec.files = Dir["{lib,spec,examples}/**/*.rb"]
16
- spec.files += Dir["{bin,tasks}/*", "tty-box.gemspec"]
17
- spec.files += Dir["README.md", "CHANGELOG.md", "LICENSE.txt", "Rakefile"]
18
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
- spec.require_paths = ["lib"]
20
-
21
- spec.required_ruby_version = ">= 2.0.0"
22
-
23
- spec.add_dependency "pastel", "~> 0.7.2"
24
- spec.add_dependency "tty-cursor", "~> 0.7"
25
- spec.add_dependency "strings", "~> 0.1.6"
26
-
27
- spec.add_development_dependency "bundler", ">= 1.5"
28
- spec.add_development_dependency "rake"
29
- spec.add_development_dependency "rspec", "~> 3.0"
30
- end