tty 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +45 -115
- data/lib/tty.rb +3 -31
- data/lib/tty/plugins/plugin.rb +2 -2
- data/lib/tty/terminal.rb +2 -58
- data/lib/tty/terminal/home.rb +27 -9
- data/lib/tty/version.rb +1 -1
- data/spec/tty/plugins/plugin/load_spec.rb +10 -18
- data/spec/tty/system/editor/open_spec.rb +1 -1
- data/spec/tty/terminal/home_spec.rb +18 -26
- data/spec/tty/tty_spec.rb +1 -1
- data/spec/tty/vector/new_spec.rb +1 -1
- metadata +2 -83
- data/lib/tty/shell.rb +0 -211
- data/lib/tty/shell/distance.rb +0 -49
- data/lib/tty/shell/question.rb +0 -335
- data/lib/tty/shell/question/modifier.rb +0 -93
- data/lib/tty/shell/question/validation.rb +0 -92
- data/lib/tty/shell/reader.rb +0 -110
- data/lib/tty/shell/response.rb +0 -249
- data/lib/tty/shell/response_delegation.rb +0 -55
- data/lib/tty/shell/statement.rb +0 -60
- data/lib/tty/shell/suggestion.rb +0 -126
- data/lib/tty/support/utils.rb +0 -16
- data/lib/tty/terminal/echo.rb +0 -38
- data/lib/tty/terminal/raw.rb +0 -38
- data/spec/tty/shell/ask_spec.rb +0 -77
- data/spec/tty/shell/distance/distance_spec.rb +0 -75
- data/spec/tty/shell/distance/initialize_spec.rb +0 -14
- data/spec/tty/shell/error_spec.rb +0 -30
- data/spec/tty/shell/print_table_spec.rb +0 -24
- data/spec/tty/shell/question/argument_spec.rb +0 -30
- data/spec/tty/shell/question/character_spec.rb +0 -24
- data/spec/tty/shell/question/default_spec.rb +0 -25
- data/spec/tty/shell/question/in_spec.rb +0 -23
- data/spec/tty/shell/question/initialize_spec.rb +0 -24
- data/spec/tty/shell/question/modifier/apply_to_spec.rb +0 -34
- data/spec/tty/shell/question/modifier/letter_case_spec.rb +0 -27
- data/spec/tty/shell/question/modifier/whitespace_spec.rb +0 -33
- data/spec/tty/shell/question/modify_spec.rb +0 -44
- data/spec/tty/shell/question/valid_spec.rb +0 -46
- data/spec/tty/shell/question/validate_spec.rb +0 -30
- data/spec/tty/shell/question/validation/coerce_spec.rb +0 -24
- data/spec/tty/shell/question/validation/valid_value_spec.rb +0 -28
- data/spec/tty/shell/reader/getc_spec.rb +0 -42
- data/spec/tty/shell/response/read_bool_spec.rb +0 -40
- data/spec/tty/shell/response/read_char_spec.rb +0 -16
- data/spec/tty/shell/response/read_date_spec.rb +0 -20
- data/spec/tty/shell/response/read_email_spec.rb +0 -42
- data/spec/tty/shell/response/read_multiple_spec.rb +0 -23
- data/spec/tty/shell/response/read_number_spec.rb +0 -28
- data/spec/tty/shell/response/read_range_spec.rb +0 -31
- data/spec/tty/shell/response/read_spec.rb +0 -68
- data/spec/tty/shell/response/read_string_spec.rb +0 -19
- data/spec/tty/shell/say_spec.rb +0 -67
- data/spec/tty/shell/statement/initialize_spec.rb +0 -15
- data/spec/tty/shell/suggest_spec.rb +0 -50
- data/spec/tty/shell/warn_spec.rb +0 -30
- data/spec/tty/terminal/color_spec.rb +0 -16
- data/spec/tty/terminal/echo_spec.rb +0 -21
@@ -1,50 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe TTY::Shell, '#suggest' do
|
6
|
-
let(:input) { StringIO.new }
|
7
|
-
let(:output) { StringIO.new }
|
8
|
-
let(:object) { described_class }
|
9
|
-
let(:possible) { ['status', 'stage', 'stash', 'commit', 'branch', 'blame'] }
|
10
|
-
|
11
|
-
subject(:shell) { object.new(input, output) }
|
12
|
-
|
13
|
-
after { output.rewind }
|
14
|
-
|
15
|
-
context 'when few matches' do
|
16
|
-
let(:string) { 'sta' }
|
17
|
-
|
18
|
-
it 'suggests few matches' do
|
19
|
-
shell.suggest(string, possible)
|
20
|
-
expect(output.string).to eql("Did you mean one of these?\n stage\n stash\n")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'when one match' do
|
25
|
-
let(:string) { 'b' }
|
26
|
-
|
27
|
-
it 'suggests a single match' do
|
28
|
-
shell.suggest(string, possible)
|
29
|
-
expect(output.string).to eql("Did you mean this?\n blame\n")
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'when one match' do
|
34
|
-
let(:string) { 'co' }
|
35
|
-
|
36
|
-
it 'suggests a single match' do
|
37
|
-
shell.suggest(string, possible)
|
38
|
-
expect(output.string).to eql("Did you mean this?\n commit\n")
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'when custom options' do
|
43
|
-
let(:string) { 'b' }
|
44
|
-
|
45
|
-
it 'suggests with different text and indentation' do
|
46
|
-
shell.suggest(string, possible, :indent => 4, :single_text => 'Perhaps you meant?')
|
47
|
-
expect(output.string).to eql("Perhaps you meant?\n blame\n")
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
data/spec/tty/shell/warn_spec.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe TTY::Shell, '#warn' do
|
6
|
-
let(:input) { StringIO.new }
|
7
|
-
let(:output) { StringIO.new }
|
8
|
-
let(:color) { Pastel.new(enabled: true) }
|
9
|
-
|
10
|
-
subject(:shell) { TTY::Shell.new(input, output) }
|
11
|
-
|
12
|
-
before { allow(Pastel).to receive(:new).and_return(color) }
|
13
|
-
|
14
|
-
after { output.rewind }
|
15
|
-
|
16
|
-
it 'displays one message' do
|
17
|
-
shell.warn "Careful young apprentice!"
|
18
|
-
expect(output.string).to eql "\e[33mCareful young apprentice!\e[0m\n"
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'displays many messages' do
|
22
|
-
shell.warn "Careful there!", "It's dangerous!"
|
23
|
-
expect(output.string).to eql "\e[33mCareful there!\e[0m\n\e[33mIt's dangerous!\e[0m\n"
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'displays message with option' do
|
27
|
-
shell.warn "Careful young apprentice!", :newline => false
|
28
|
-
expect(output.string).to eql "\e[33mCareful young apprentice!\e[0m"
|
29
|
-
end
|
30
|
-
end # warn
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe TTY::Terminal, '#color' do
|
6
|
-
let(:color) { Pastel.new(enabled: true) }
|
7
|
-
|
8
|
-
it { expect(subject.color).to be_a(Pastel::Delegator) }
|
9
|
-
|
10
|
-
before { allow(Pastel).to receive(:new).and_return(color) }
|
11
|
-
|
12
|
-
it 'delegates color handling' do
|
13
|
-
string = 'text'
|
14
|
-
expect(subject.color.decorate(string, :red)).to eq("\e[31m#{string}\e[0m")
|
15
|
-
end
|
16
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe TTY::Terminal, '#echo' do
|
6
|
-
let(:instance) { described_class.new }
|
7
|
-
|
8
|
-
subject { instance.echo(&block) }
|
9
|
-
|
10
|
-
context 'without block' do
|
11
|
-
let(:block) { }
|
12
|
-
|
13
|
-
it { is_expected.to be_nil }
|
14
|
-
end
|
15
|
-
|
16
|
-
context 'with empty block' do
|
17
|
-
let(:block) { lambda { '' } }
|
18
|
-
|
19
|
-
it { is_expected.to eq('') }
|
20
|
-
end
|
21
|
-
end
|