cli-ui 1.2.1 → 1.5.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.
@@ -0,0 +1,56 @@
1
+ # coding: utf-8
2
+ require 'cli/ui'
3
+ require 'cli/ui/frame/frame_stack'
4
+ require 'cli/ui/frame/frame_style'
5
+
6
+ module CLI
7
+ module UI
8
+ class Wrap
9
+ def initialize(input)
10
+ @input = input
11
+ end
12
+
13
+ def wrap
14
+ max_width = Terminal.width - Frame.prefix_width
15
+ width = 0
16
+ final = []
17
+ # Create an alternation of format codes of parameter lengths 1-20, since + and {1,n} not allowed in lookbehind
18
+ format_codes = (1..20).map { |n| /\x1b\[[\d;]{#{n}}m/ }.join('|')
19
+ codes = ''
20
+ @input.split(/(?=\s|\x1b\[[\d;]+m|\r)|(?<=\s|#{format_codes})/).each do |token|
21
+ case token
22
+ when '\x1B[0?m'
23
+ codes = ''
24
+ final << token
25
+ when /\x1b\[[\d;]+m/
26
+ codes += token # Track in use format codes so that they are resent after frame coloring
27
+ final << token
28
+ when "\n"
29
+ final << "\n#{codes}"
30
+ width = 0
31
+ when /\s/
32
+ token_width = ANSI.printing_width(token)
33
+ if width + token_width <= max_width
34
+ final << token
35
+ width += token_width
36
+ else
37
+ final << "\n#{codes}"
38
+ width = 0
39
+ end
40
+ else
41
+ token_width = ANSI.printing_width(token)
42
+ if width + token_width <= max_width
43
+ final << token
44
+ width += token_width
45
+ else
46
+ final << "\n#{codes}"
47
+ final << token
48
+ width = token_width
49
+ end
50
+ end
51
+ end
52
+ final.join
53
+ end
54
+ end
55
+ end
56
+ end
metadata CHANGED
@@ -1,45 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cli-ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Burke Libbey
8
8
  - Julian Nadeau
9
9
  - Lisa Ugray
10
- autorequire:
10
+ autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2018-11-06 00:00:00.000000000 Z
13
+ date: 2021-04-14 00:00:00.000000000 Z
14
14
  dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: bundler
17
- requirement: !ruby/object:Gem::Requirement
18
- requirements:
19
- - - "~>"
20
- - !ruby/object:Gem::Version
21
- version: '1.15'
22
- type: :development
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- requirements:
26
- - - "~>"
27
- - !ruby/object:Gem::Version
28
- version: '1.15'
29
15
  - !ruby/object:Gem::Dependency
30
16
  name: rake
31
17
  requirement: !ruby/object:Gem::Requirement
32
18
  requirements:
33
19
  - - "~>"
34
20
  - !ruby/object:Gem::Version
35
- version: '10.0'
21
+ version: '13.0'
36
22
  type: :development
37
23
  prerelease: false
38
24
  version_requirements: !ruby/object:Gem::Requirement
39
25
  requirements:
40
26
  - - "~>"
41
27
  - !ruby/object:Gem::Version
42
- version: '10.0'
28
+ version: '13.0'
43
29
  - !ruby/object:Gem::Dependency
44
30
  name: minitest
45
31
  requirement: !ruby/object:Gem::Requirement
@@ -63,10 +49,14 @@ executables: []
63
49
  extensions: []
64
50
  extra_rdoc_files: []
65
51
  files:
52
+ - ".dependabot/config.yml"
53
+ - ".github/CODEOWNERS"
54
+ - ".github/probots.yml"
66
55
  - ".gitignore"
67
56
  - ".rubocop.yml"
68
57
  - ".travis.yml"
69
58
  - Gemfile
59
+ - Gemfile.lock
70
60
  - LICENSE.txt
71
61
  - README.md
72
62
  - Rakefile
@@ -75,11 +65,16 @@ files:
75
65
  - dev.yml
76
66
  - lib/cli/ui.rb
77
67
  - lib/cli/ui/ansi.rb
78
- - lib/cli/ui/box.rb
79
68
  - lib/cli/ui/color.rb
80
69
  - lib/cli/ui/formatter.rb
81
70
  - lib/cli/ui/frame.rb
71
+ - lib/cli/ui/frame/frame_stack.rb
72
+ - lib/cli/ui/frame/frame_style.rb
73
+ - lib/cli/ui/frame/frame_style/box.rb
74
+ - lib/cli/ui/frame/frame_style/bracket.rb
82
75
  - lib/cli/ui/glyph.rb
76
+ - lib/cli/ui/os.rb
77
+ - lib/cli/ui/printer.rb
83
78
  - lib/cli/ui/progress.rb
84
79
  - lib/cli/ui/prompt.rb
85
80
  - lib/cli/ui/prompt/interactive_options.rb
@@ -91,11 +86,15 @@ files:
91
86
  - lib/cli/ui/terminal.rb
92
87
  - lib/cli/ui/truncater.rb
93
88
  - lib/cli/ui/version.rb
89
+ - lib/cli/ui/widgets.rb
90
+ - lib/cli/ui/widgets/base.rb
91
+ - lib/cli/ui/widgets/status.rb
92
+ - lib/cli/ui/wrap.rb
94
93
  homepage: https://github.com/shopify/cli-ui
95
94
  licenses:
96
95
  - MIT
97
96
  metadata: {}
98
- post_install_message:
97
+ post_install_message:
99
98
  rdoc_options: []
100
99
  require_paths:
101
100
  - lib
@@ -110,9 +109,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
109
  - !ruby/object:Gem::Version
111
110
  version: '0'
112
111
  requirements: []
113
- rubyforge_project:
114
- rubygems_version: 2.7.6
115
- signing_key:
112
+ rubygems_version: 3.0.2
113
+ signing_key:
116
114
  specification_version: 4
117
115
  summary: Terminal UI framework
118
116
  test_files: []
data/lib/cli/ui/box.rb DELETED
@@ -1,15 +0,0 @@
1
- require 'cli/ui'
2
-
3
- module CLI
4
- module UI
5
- module Box
6
- module Heavy
7
- VERT = '┃'
8
- HORZ = '━'
9
- DIV = "┣"
10
- TL = '┏'
11
- BL = '┗'
12
- end
13
- end
14
- end
15
- end