tty_string 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9abd5adac382e5520dc2699ff14dd2e213a9fed0d7aa3807e0b054a610ca9c46
4
- data.tar.gz: 254d7adb36f29313bc441c237dc760399f9e3e9f4a4447c348a1387282d43b33
3
+ metadata.gz: b638ef2c66276f621f7ae5620e25af1ccfb1d79f634202aa59935e181baf53e2
4
+ data.tar.gz: ecce132aa8201f22a69c2c2a201143bb1f2775abf4ea0785553592a2f2615640
5
5
  SHA512:
6
- metadata.gz: b2883d488aa1ba89ddc5535ccf6c50d9b5722d3d9e906f5b856bca53a237f6901069f85e9d51a20d2c2fc9d10d9cab2ef14a37fa23665ddf7310c66fcdfde53e
7
- data.tar.gz: c048606897448877ba108a78555697f7cbaad9578abd381313be692bb8dc16dd0bd1594c9b33e0fc32646b1529187ef873b60882d8e00d54765337d1507aa7d3
6
+ metadata.gz: 5799b2b9a14ecdb5d86cfd8d6af0d10f896c20de36dfed2801756172fe73afebb427d5cd5816a7bd18502a08640d5c9a691d6f65b2cde9cbf2e9932ca4ca55e8
7
+ data.tar.gz: 76d8856718792bcf2f4da207e6cb5aa69b8bf0cb81e9cc6e60aaf9ec1f8734ce0ca6abb4dca54ec04d97d95604badba2b9ba316ba7079fd3d6b198e34193c474
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # v1.1.0
2
+ - suppress bracketed paste mode codes
3
+
1
4
  # v1.0.1
2
5
  - test push to rubygems, no functional changes
3
6
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # TTYString
2
2
 
3
- [![Build Status](https://travis-ci.com/robotdana/tty_string.svg?branch=master)](https://travis-ci.com/robotdana/tty_string)
3
+ [![Build Status](https://travis-ci.com/robotdana/tty_string.svg?branch=main)](https://travis-ci.com/robotdana/tty_string)
4
4
  [![Gem Version](https://badge.fury.io/rb/tty_string.svg)](https://rubygems.org/gems/tty_string)
5
5
 
6
6
  Render to a string like your terminal does by (narrowly) parsing ANSI TTY codes.
@@ -8,7 +8,7 @@ Intended for use in tests of command line interfaces.
8
8
 
9
9
  ## Features
10
10
 
11
- - supports ruby 2.4 - 2.7, and jruby
11
+ - supports ruby 2.4 - 3.0.0.preview1, and jruby
12
12
  - has no dependencies outside ruby stdlib
13
13
 
14
14
  ## Supported codes
@@ -33,6 +33,10 @@ Intended for use in tests of command line interfaces.
33
33
  | `\e[nS` | scroll up _n_ rows | _n_=`1` |
34
34
  | `\e[nT` | scroll down _n_ rows | _n_=`1` |
35
35
  | `\e[m` | styling codes: optionally suppressed with `clear_style: false` | |
36
+ | `\e[?2004h` | enabled bracketed paste: suppressed | |
37
+ | `\e[?2004l` | disable bracketed paste: suppressed | |
38
+ | `\e[200~` | bracketed paste start: suppressed | |
39
+ | `\e[201~` | bracketed paste end: suppressed | |
36
40
 
37
41
  ## Installation
38
42
 
data/lib/tty_string.rb CHANGED
@@ -26,6 +26,5 @@ class TTYString
26
26
 
27
27
  private
28
28
 
29
- attr_reader :clear_style
30
- attr_reader :parser
29
+ attr_reader :clear_style, :parser
31
30
  end
@@ -11,6 +11,8 @@ class TTYString
11
11
  @@descendants ||= [] # rubocop:disable Style/ClassVars I want it to be shared between subclasses.
12
12
  @@descendants << klass
13
13
  @@descendants.uniq!
14
+
15
+ super
14
16
  end
15
17
 
16
18
  def render(parser)
@@ -17,18 +17,21 @@ class TTYString
17
17
  end
18
18
 
19
19
  def args(parser)
20
- parser.matched.slice(2..-2).split(';')
21
- .map { |n| n.empty? ? default_arg : n.to_i }
20
+ a = parser.matched.slice(2..-2).split(';')
21
+ a = a.slice(0, max_args) unless max_args == -1
22
+ a.map! { |n| n.empty? ? default_arg : n.to_i }
23
+ a
22
24
  end
23
25
 
24
26
  def re
25
27
  @re ||= /\e\[#{args_re}#{char}/
26
28
  end
27
29
 
28
- def args_re
30
+ def args_re # rubocop:disable Metrics/MethodLength
29
31
  case max_args
32
+ when 0 then nil
30
33
  when 1 then /#{arg_re}?/
31
- when nil then /(#{arg_re}?(;#{arg_re})*)?/
34
+ when -1 then /(#{arg_re}?(;#{arg_re})*)?/
32
35
  else /(#{arg_re}?(;#{arg_re}){0,#{max_args - 1}})?/
33
36
  end
34
37
  end
@@ -38,12 +41,7 @@ class TTYString
38
41
  end
39
42
 
40
43
  def max_args
41
- @max_args ||= begin
42
- params = instance_method(:action).parameters
43
- return if params.assoc(:rest)
44
-
45
- params.length
46
- end
44
+ @max_args ||= instance_method(:action).arity
47
45
  end
48
46
  end
49
47
  end
@@ -57,6 +57,10 @@ class TTYString
57
57
  end
58
58
  end
59
59
 
60
+ class LowH < TTYString::CSICode # leftovers:allow
61
+ char(/\?2004h/)
62
+ end
63
+
60
64
  class LowF < TTYString::CSICode::H # leftovers:allow
61
65
  char 'f'
62
66
  end
@@ -64,7 +68,7 @@ class TTYString
64
68
  class J < TTYString::CSICode # leftovers:allow
65
69
  default_arg 0
66
70
 
67
- def self.args_re
71
+ def self.arg_re
68
72
  /[0-3]?/
69
73
  end
70
74
 
@@ -97,12 +101,16 @@ class TTYString
97
101
  end
98
102
  end
99
103
 
104
+ class LowL < TTYString::CSICode # leftovers:allow
105
+ char(/\?2004l/)
106
+ end
107
+
100
108
  class LowM < TTYString::CSICode # leftovers:allow
101
109
  char 'm'
102
110
 
103
111
  def self.arg_re
104
112
  # 0-255
105
- /(\d|\d\d|1\d\d|2[0-4]\d|25[0-5])?/
113
+ /(?:\d|\d\d|1\d\d|2[0-4]\d|25[0-5])?/
106
114
  end
107
115
 
108
116
  def self.render(renderer)
@@ -123,5 +131,9 @@ class TTYString
123
131
  rows.times { screen.scroll_down }
124
132
  end
125
133
  end
134
+
135
+ class Tilde < TTYString::CSICode # leftovers:allow
136
+ char(/(?:200|201)~/)
137
+ end
126
138
  end
127
139
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class TTYString
4
- VERSION = '1.0.1'
4
+ VERSION = '1.1.0'
5
5
  end
data/tty_string.gemspec CHANGED
@@ -14,6 +14,12 @@ Gem::Specification.new do |spec|
14
14
  spec.homepage = 'https://github.com/robotdana/tty_string'
15
15
  spec.license = 'MIT'
16
16
 
17
+ if spec.respond_to?(:metadata)
18
+ spec.metadata['homepage_uri'] = spec.homepage
19
+ spec.metadata['source_code_uri'] = spec.homepage
20
+ spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/main/CHANGELOG.md"
21
+ end
22
+
17
23
  spec.files = Dir.glob('{lib}/**/*') + %w{
18
24
  CHANGELOG.md
19
25
  Gemfile
@@ -25,13 +31,15 @@ Gem::Specification.new do |spec|
25
31
  spec.require_paths = ['lib']
26
32
 
27
33
  spec.add_development_dependency 'bundler', '~> 2.0'
34
+ spec.add_development_dependency 'fast_ignore', '>= 0.15.1'
28
35
  spec.add_development_dependency 'leftovers', '>= 0.2.0'
29
36
  spec.add_development_dependency 'pry', '~> 0.12'
30
37
  spec.add_development_dependency 'rake', '>= 12.3.3'
31
38
  spec.add_development_dependency 'rspec', '~> 3.0'
32
- spec.add_development_dependency 'rubocop', '~> 0.74'
33
- spec.add_development_dependency 'rubocop-performance', '~> 1.4'
34
- spec.add_development_dependency 'rubocop-rspec', '~> 1.35'
39
+ spec.add_development_dependency 'rubocop', '~> 0.93.1'
40
+ spec.add_development_dependency 'rubocop-performance', '~> 1.8.1'
41
+ spec.add_development_dependency 'rubocop-rspec', '~> 1.44.1'
35
42
  spec.add_development_dependency 'simplecov', '~> 0.18.5'
43
+ spec.add_development_dependency 'simplecov-console'
36
44
  spec.add_development_dependency 'spellr', '>= 0.8.1'
37
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tty_string
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dana Sherson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-20 00:00:00.000000000 Z
11
+ date: 2021-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: fast_ignore
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.15.1
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.15.1
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: leftovers
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -86,42 +100,42 @@ dependencies:
86
100
  requirements:
87
101
  - - "~>"
88
102
  - !ruby/object:Gem::Version
89
- version: '0.74'
103
+ version: 0.93.1
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: '0.74'
110
+ version: 0.93.1
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rubocop-performance
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: '1.4'
117
+ version: 1.8.1
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
122
  - - "~>"
109
123
  - !ruby/object:Gem::Version
110
- version: '1.4'
124
+ version: 1.8.1
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: rubocop-rspec
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
129
  - - "~>"
116
130
  - !ruby/object:Gem::Version
117
- version: '1.35'
131
+ version: 1.44.1
118
132
  type: :development
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
136
  - - "~>"
123
137
  - !ruby/object:Gem::Version
124
- version: '1.35'
138
+ version: 1.44.1
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: simplecov
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -136,6 +150,20 @@ dependencies:
136
150
  - - "~>"
137
151
  - !ruby/object:Gem::Version
138
152
  version: 0.18.5
153
+ - !ruby/object:Gem::Dependency
154
+ name: simplecov-console
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
139
167
  - !ruby/object:Gem::Dependency
140
168
  name: spellr
141
169
  requirement: !ruby/object:Gem::Requirement
@@ -174,7 +202,10 @@ files:
174
202
  homepage: https://github.com/robotdana/tty_string
175
203
  licenses:
176
204
  - MIT
177
- metadata: {}
205
+ metadata:
206
+ homepage_uri: https://github.com/robotdana/tty_string
207
+ source_code_uri: https://github.com/robotdana/tty_string
208
+ changelog_uri: https://github.com/robotdana/tty_string/blob/main/CHANGELOG.md
178
209
  post_install_message:
179
210
  rdoc_options: []
180
211
  require_paths:
@@ -190,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
221
  - !ruby/object:Gem::Version
191
222
  version: '0'
192
223
  requirements: []
193
- rubygems_version: 3.1.2
224
+ rubygems_version: 3.0.3
194
225
  signing_key:
195
226
  specification_version: 4
196
227
  summary: Render a string using ANSI TTY codes