tty-box 0.3.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,24 +6,24 @@ module TTY
6
6
  #
7
7
  # @api private
8
8
  class Border
9
- BORDER_VALUES = [
10
- :corner_bottom_right,
11
- :corner_top_right,
12
- :corner_top_left,
13
- :corner_bottom_left,
14
- :divider_left,
15
- :divider_up,
16
- :divider_down,
17
- :divider_right,
18
- :line,
19
- :pipe,
20
- :cross
9
+ BORDER_VALUES = %i[
10
+ corner_bottom_right
11
+ corner_top_right
12
+ corner_top_left
13
+ corner_bottom_left
14
+ divider_left
15
+ divider_up
16
+ divider_down
17
+ divider_right
18
+ line
19
+ pipe
20
+ cross
21
21
  ].freeze
22
22
 
23
23
  def self.parse(border)
24
24
  case border
25
25
  when Hash
26
- new(border)
26
+ new(**border)
27
27
  when *TTY::Box::BOX_CHARS.keys
28
28
  new(type: border)
29
29
  else
@@ -68,14 +68,19 @@ module TTY
68
68
  private
69
69
 
70
70
  # Check if border values name is allowed
71
+ #
72
+ # @raise [ArgumentError]
73
+ #
71
74
  # @api private
72
75
  def check_name(key, value)
73
- unless (BORDER_VALUES.include?(:"#{value}") || [true, false].include?(value))
74
- raise ArgumentError, "Invalid border value: '#{value}' for #{key.inspect}"
76
+ unless BORDER_VALUES.include?(:"#{value}") ||
77
+ [true, false].include?(value)
78
+ raise ArgumentError, "invalid #{key.inspect} border value: " \
79
+ "#{value.inspect}"
75
80
  end
81
+
76
82
  value
77
83
  end
78
84
  end # Border
79
85
  end # Box
80
86
  end # TTY
81
-
@@ -2,6 +2,6 @@
2
2
 
3
3
  module TTY
4
4
  module Box
5
- VERSION = "0.3.0"
5
+ VERSION = "0.7.0"
6
6
  end # Box
7
7
  end # TTY
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tty-box
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Murach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-08 00:00:00.000000000 Z
11
+ date: 2020-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pastel
@@ -16,120 +16,97 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.7.2
19
+ version: '0.8'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.7.2
26
+ version: '0.8'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: tty-cursor
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.6.0
33
+ version: '0.7'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.6.0
40
+ version: '0.7'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: strings
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.1.4
47
+ version: 0.2.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.1.4
55
- - !ruby/object:Gem::Dependency
56
- name: bundler
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.16'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1.16'
54
+ version: 0.2.0
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: rake
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
- - - "~>"
59
+ - - ">="
74
60
  - !ruby/object:Gem::Version
75
- version: '10.0'
61
+ version: '0'
76
62
  type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
- - - "~>"
66
+ - - ">="
81
67
  - !ruby/object:Gem::Version
82
- version: '10.0'
68
+ version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: rspec
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
- - - "~>"
73
+ - - ">="
88
74
  - !ruby/object:Gem::Version
89
75
  version: '3.0'
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
- - - "~>"
80
+ - - ">="
95
81
  - !ruby/object:Gem::Version
96
82
  version: '3.0'
97
- description: Draw various frames and boxes in your terminal interface.
83
+ description: Draw various frames and boxes in the terminal window.
98
84
  email:
99
- - ''
85
+ - piotr@piotrmurach.com
100
86
  executables: []
101
87
  extensions: []
102
- extra_rdoc_files: []
88
+ extra_rdoc_files:
89
+ - README.md
90
+ - CHANGELOG.md
91
+ - LICENSE.txt
103
92
  files:
104
93
  - CHANGELOG.md
105
94
  - LICENSE.txt
106
95
  - README.md
107
- - Rakefile
108
- - bin/console
109
- - bin/setup
110
- - examples/commander.rb
111
- - examples/connected.rb
112
96
  - lib/tty-box.rb
113
97
  - lib/tty/box.rb
114
98
  - lib/tty/box/border.rb
115
99
  - lib/tty/box/version.rb
116
- - spec/spec_helper.rb
117
- - spec/unit/align_spec.rb
118
- - spec/unit/border/parse_spec.rb
119
- - spec/unit/border_spec.rb
120
- - spec/unit/frame_spec.rb
121
- - spec/unit/padding_spec.rb
122
- - spec/unit/position_spec.rb
123
- - spec/unit/style_spec.rb
124
- - spec/unit/title_spec.rb
125
- - tasks/console.rake
126
- - tasks/coverage.rake
127
- - tasks/spec.rake
128
- - tty-box.gemspec
129
- homepage: https://piotrmurach.github.io/tty
100
+ homepage: https://ttytoolkit.org
130
101
  licenses:
131
102
  - MIT
132
- metadata: {}
103
+ metadata:
104
+ allowed_push_host: https://rubygems.org
105
+ bug_tracker_uri: https://github.com/piotrmurach/tty-box/issues
106
+ changelog_uri: https://github.com/piotrmurach/tty-box/blob/master/CHANGELOG.md
107
+ documentation_uri: https://www.rubydoc.info/gems/tty-box
108
+ homepage_uri: https://ttytoolkit.org
109
+ source_code_uri: https://github.com/piotrmurach/tty-box
133
110
  post_install_message:
134
111
  rdoc_options: []
135
112
  require_paths:
@@ -138,16 +115,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
115
  requirements:
139
116
  - - ">="
140
117
  - !ruby/object:Gem::Version
141
- version: '0'
118
+ version: 2.0.0
142
119
  required_rubygems_version: !ruby/object:Gem::Requirement
143
120
  requirements:
144
121
  - - ">="
145
122
  - !ruby/object:Gem::Version
146
123
  version: '0'
147
124
  requirements: []
148
- rubyforge_project:
149
- rubygems_version: 2.7.3
125
+ rubygems_version: 3.1.2
150
126
  signing_key:
151
127
  specification_version: 4
152
- summary: Draw various frames and boxes in your terminal interface.
128
+ summary: Draw various frames and boxes in the terminal window.
153
129
  test_files: []
data/Rakefile DELETED
@@ -1,8 +0,0 @@
1
- require "bundler/gem_tasks"
2
-
3
- FileList['tasks/**/*.rake'].each(&method(:import))
4
-
5
- desc 'Run all specs'
6
- task ci: %w[ spec ]
7
-
8
- task default: :spec
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "tty/box"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -1,54 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../lib/tty-box'
4
-
5
- print TTY::Cursor.clear_screen
6
-
7
- box_1 = TTY::Box.frame(
8
- top: 2,
9
- left: 10,
10
- width: 30,
11
- height: 10,
12
- border: :thick,
13
- align: :center,
14
- padding: 3,
15
- title: {
16
- top_left: ' file1 '
17
- },
18
- style: {
19
- fg: :bright_yellow,
20
- bg: :blue,
21
- border: {
22
- fg: :bright_yellow,
23
- bg: :blue
24
- }
25
- }
26
- ) do
27
- "Drawing a box in terminal emulator"
28
- end
29
-
30
- box_2 = TTY::Box.frame(
31
- top: 8,
32
- left: 34,
33
- width: 30,
34
- height: 10,
35
- border: :thick,
36
- align: :center,
37
- padding: 3,
38
- title: {
39
- top_left: ' file2 '
40
- },
41
- style: {
42
- fg: :bright_yellow,
43
- bg: :blue,
44
- border: {
45
- fg: :bright_yellow,
46
- bg: :blue
47
- }
48
- }
49
- ) do
50
- "Drawing a box in terminal emulator"
51
- end
52
-
53
- puts box_1 + box_2
54
- print "\n" * 5
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../lib/tty-box'
4
-
5
- print TTY::Cursor.clear_screen
6
-
7
- box_1 = TTY::Box.frame(
8
- top: 3,
9
- left: 10,
10
- width: 15,
11
- height: 5,
12
- border: {
13
- type: :thick,
14
- right: false,
15
- },
16
- align: :center,
17
- padding: [1, 2],
18
- style: {
19
- bg: :red,
20
- border: {
21
- bg: :red
22
- }
23
- }
24
- ) { "Space" }
25
-
26
- box_2 = TTY::Box.frame(
27
- top: 3,
28
- left: 25,
29
- width: 15,
30
- height: 5,
31
- border: {
32
- type: :thick,
33
- top_left: :divider_down,
34
- bottom_left: :divider_up
35
- },
36
- align: :center,
37
- padding: [1,2],
38
- style: {
39
- bg: :red,
40
- border: {
41
- bg: :red
42
- }
43
- }
44
- ) { "Invaders!" }
45
-
46
- puts box_1 + box_2
47
- print "\n" * 5
@@ -1,29 +0,0 @@
1
- if ENV['COVERAGE'] || ENV['TRAVIS']
2
- require 'simplecov'
3
- require 'coveralls'
4
-
5
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
6
- SimpleCov::Formatter::HTMLFormatter,
7
- Coveralls::SimpleCov::Formatter
8
- ]
9
-
10
- SimpleCov.start do
11
- command_name 'spec'
12
- add_filter 'spec'
13
- end
14
- end
15
-
16
- require "bundler/setup"
17
- require "tty/box"
18
-
19
- RSpec.configure do |config|
20
- # Enable flags like --only-failures and --next-failure
21
- config.example_status_persistence_file_path = ".rspec_status"
22
-
23
- # Disable RSpec exposing methods globally on `Module` and `main`
24
- config.disable_monkey_patching!
25
-
26
- config.expect_with :rspec do |c|
27
- c.syntax = :expect
28
- end
29
- end
@@ -1,27 +0,0 @@
1
- RSpec.describe TTY::Box, ':align option' do
2
- it "aligns content without positioning" do
3
- box = TTY::Box.frame(width: 26, height: 4, align: :center) do
4
- "Drawing a box in terminal emulator"
5
- end
6
-
7
- expect(box).to eq([
8
- "┌────────────────────────┐\n",
9
- "│ Drawing a box in │\n",
10
- "│ terminal emulator │\n",
11
- "└────────────────────────┘\n"
12
- ].join)
13
- end
14
-
15
- it "aligns content with the option" do
16
- box = TTY::Box.frame(top: 0, left: 0, width: 26, height: 4, align: :center) do
17
- "Drawing a box in terminal emulator"
18
- end
19
-
20
- expect(box).to eq([
21
- "\e[1;1H┌────────────────────────┐",
22
- "\e[2;1H│ Drawing a box in \e[2;26H│",
23
- "\e[3;1H│ terminal emulator \e[3;26H│",
24
- "\e[4;1H└────────────────────────┘"
25
- ].join)
26
- end
27
- end