tty 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/README.md +45 -115
  4. data/lib/tty.rb +3 -31
  5. data/lib/tty/plugins/plugin.rb +2 -2
  6. data/lib/tty/terminal.rb +2 -58
  7. data/lib/tty/terminal/home.rb +27 -9
  8. data/lib/tty/version.rb +1 -1
  9. data/spec/tty/plugins/plugin/load_spec.rb +10 -18
  10. data/spec/tty/system/editor/open_spec.rb +1 -1
  11. data/spec/tty/terminal/home_spec.rb +18 -26
  12. data/spec/tty/tty_spec.rb +1 -1
  13. data/spec/tty/vector/new_spec.rb +1 -1
  14. metadata +2 -83
  15. data/lib/tty/shell.rb +0 -211
  16. data/lib/tty/shell/distance.rb +0 -49
  17. data/lib/tty/shell/question.rb +0 -335
  18. data/lib/tty/shell/question/modifier.rb +0 -93
  19. data/lib/tty/shell/question/validation.rb +0 -92
  20. data/lib/tty/shell/reader.rb +0 -110
  21. data/lib/tty/shell/response.rb +0 -249
  22. data/lib/tty/shell/response_delegation.rb +0 -55
  23. data/lib/tty/shell/statement.rb +0 -60
  24. data/lib/tty/shell/suggestion.rb +0 -126
  25. data/lib/tty/support/utils.rb +0 -16
  26. data/lib/tty/terminal/echo.rb +0 -38
  27. data/lib/tty/terminal/raw.rb +0 -38
  28. data/spec/tty/shell/ask_spec.rb +0 -77
  29. data/spec/tty/shell/distance/distance_spec.rb +0 -75
  30. data/spec/tty/shell/distance/initialize_spec.rb +0 -14
  31. data/spec/tty/shell/error_spec.rb +0 -30
  32. data/spec/tty/shell/print_table_spec.rb +0 -24
  33. data/spec/tty/shell/question/argument_spec.rb +0 -30
  34. data/spec/tty/shell/question/character_spec.rb +0 -24
  35. data/spec/tty/shell/question/default_spec.rb +0 -25
  36. data/spec/tty/shell/question/in_spec.rb +0 -23
  37. data/spec/tty/shell/question/initialize_spec.rb +0 -24
  38. data/spec/tty/shell/question/modifier/apply_to_spec.rb +0 -34
  39. data/spec/tty/shell/question/modifier/letter_case_spec.rb +0 -27
  40. data/spec/tty/shell/question/modifier/whitespace_spec.rb +0 -33
  41. data/spec/tty/shell/question/modify_spec.rb +0 -44
  42. data/spec/tty/shell/question/valid_spec.rb +0 -46
  43. data/spec/tty/shell/question/validate_spec.rb +0 -30
  44. data/spec/tty/shell/question/validation/coerce_spec.rb +0 -24
  45. data/spec/tty/shell/question/validation/valid_value_spec.rb +0 -28
  46. data/spec/tty/shell/reader/getc_spec.rb +0 -42
  47. data/spec/tty/shell/response/read_bool_spec.rb +0 -40
  48. data/spec/tty/shell/response/read_char_spec.rb +0 -16
  49. data/spec/tty/shell/response/read_date_spec.rb +0 -20
  50. data/spec/tty/shell/response/read_email_spec.rb +0 -42
  51. data/spec/tty/shell/response/read_multiple_spec.rb +0 -23
  52. data/spec/tty/shell/response/read_number_spec.rb +0 -28
  53. data/spec/tty/shell/response/read_range_spec.rb +0 -31
  54. data/spec/tty/shell/response/read_spec.rb +0 -68
  55. data/spec/tty/shell/response/read_string_spec.rb +0 -19
  56. data/spec/tty/shell/say_spec.rb +0 -67
  57. data/spec/tty/shell/statement/initialize_spec.rb +0 -15
  58. data/spec/tty/shell/suggest_spec.rb +0 -50
  59. data/spec/tty/shell/warn_spec.rb +0 -30
  60. data/spec/tty/terminal/color_spec.rb +0 -16
  61. 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
@@ -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