yap-shell 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +9 -24
  3. data/Gemfile +1 -5
  4. data/LICENSE.txt +17 -18
  5. data/README.md +28 -14
  6. data/Rakefile +4 -1
  7. data/bin/yap +1 -3
  8. data/lib/.gitkeep +0 -0
  9. data/yap-shell.gemspec +12 -11
  10. metadata +19 -184
  11. data/.rspec +0 -2
  12. data/.travis.yml +0 -11
  13. data/DESIGN.md +0 -87
  14. data/Gemfile.travis +0 -8
  15. data/Gemfile.travis.lock +0 -104
  16. data/WISHLIST.md +0 -54
  17. data/bin/yap-dev +0 -45
  18. data/lib/tasks/gem.rake +0 -62
  19. data/lib/yap.rb +0 -52
  20. data/lib/yap/addon.rb +0 -24
  21. data/lib/yap/addon/base.rb +0 -52
  22. data/lib/yap/addon/export_as.rb +0 -12
  23. data/lib/yap/addon/loader.rb +0 -84
  24. data/lib/yap/addon/path.rb +0 -56
  25. data/lib/yap/addon/rc_file.rb +0 -21
  26. data/lib/yap/addon/reference.rb +0 -22
  27. data/lib/yap/cli.rb +0 -4
  28. data/lib/yap/cli/commands.rb +0 -6
  29. data/lib/yap/cli/commands/addon.rb +0 -14
  30. data/lib/yap/cli/commands/addon/disable.rb +0 -35
  31. data/lib/yap/cli/commands/addon/enable.rb +0 -35
  32. data/lib/yap/cli/commands/addon/list.rb +0 -37
  33. data/lib/yap/cli/commands/addon/search.rb +0 -99
  34. data/lib/yap/cli/commands/generate.rb +0 -13
  35. data/lib/yap/cli/commands/generate/addon.rb +0 -258
  36. data/lib/yap/cli/commands/generate/addonrb.template +0 -22
  37. data/lib/yap/cli/commands/generate/gemspec.template +0 -25
  38. data/lib/yap/cli/commands/generate/license.template +0 -21
  39. data/lib/yap/cli/commands/generate/rakefile.template +0 -6
  40. data/lib/yap/cli/commands/generate/readme.template +0 -40
  41. data/lib/yap/cli/options.rb +0 -162
  42. data/lib/yap/cli/options/addon.rb +0 -64
  43. data/lib/yap/cli/options/addon/disable.rb +0 -62
  44. data/lib/yap/cli/options/addon/enable.rb +0 -63
  45. data/lib/yap/cli/options/addon/list.rb +0 -65
  46. data/lib/yap/cli/options/addon/search.rb +0 -76
  47. data/lib/yap/cli/options/generate.rb +0 -59
  48. data/lib/yap/cli/options/generate/addon.rb +0 -63
  49. data/lib/yap/configuration.rb +0 -74
  50. data/lib/yap/gem_helper.rb +0 -195
  51. data/lib/yap/gem_tasks.rb +0 -6
  52. data/lib/yap/shell.rb +0 -116
  53. data/lib/yap/shell/aliases.rb +0 -58
  54. data/lib/yap/shell/builtins.rb +0 -18
  55. data/lib/yap/shell/builtins/alias.rb +0 -42
  56. data/lib/yap/shell/builtins/cd.rb +0 -57
  57. data/lib/yap/shell/builtins/env.rb +0 -11
  58. data/lib/yap/shell/commands.rb +0 -163
  59. data/lib/yap/shell/evaluation.rb +0 -439
  60. data/lib/yap/shell/evaluation/shell_expansions.rb +0 -99
  61. data/lib/yap/shell/event_emitter.rb +0 -18
  62. data/lib/yap/shell/execution.rb +0 -16
  63. data/lib/yap/shell/execution/builtin_command_execution.rb +0 -20
  64. data/lib/yap/shell/execution/command_execution.rb +0 -30
  65. data/lib/yap/shell/execution/context.rb +0 -128
  66. data/lib/yap/shell/execution/file_system_command_execution.rb +0 -137
  67. data/lib/yap/shell/execution/result.rb +0 -18
  68. data/lib/yap/shell/execution/ruby_command_execution.rb +0 -80
  69. data/lib/yap/shell/execution/shell_command_execution.rb +0 -30
  70. data/lib/yap/shell/prompt.rb +0 -21
  71. data/lib/yap/shell/repl.rb +0 -237
  72. data/lib/yap/shell/version.rb +0 -5
  73. data/lib/yap/world.rb +0 -286
  74. data/rcfiles/yaprc +0 -390
  75. data/scripts/4 +0 -8
  76. data/scripts/bg-vim +0 -4
  77. data/scripts/fail +0 -3
  78. data/scripts/letters +0 -8
  79. data/scripts/lots-of-output +0 -6
  80. data/scripts/pass +0 -3
  81. data/scripts/simulate-long-running +0 -4
  82. data/scripts/write-to-stderr.rb +0 -3
  83. data/scripts/write-to-stdout.rb +0 -3
  84. data/spec/features/addons/generating_an_addon_spec.rb +0 -55
  85. data/spec/features/addons/using_an_addon_spec.rb +0 -182
  86. data/spec/features/aliases_spec.rb +0 -78
  87. data/spec/features/environment_variables_spec.rb +0 -69
  88. data/spec/features/filesystem_commands_spec.rb +0 -61
  89. data/spec/features/first_time_spec.rb +0 -45
  90. data/spec/features/grouping_spec.rb +0 -81
  91. data/spec/features/line_editing_spec.rb +0 -174
  92. data/spec/features/range_spec.rb +0 -35
  93. data/spec/features/redirection_spec.rb +0 -234
  94. data/spec/features/repetition_spec.rb +0 -118
  95. data/spec/features/shell_expansions_spec.rb +0 -127
  96. data/spec/spec_helper.rb +0 -172
  97. data/spec/support/matchers/have_not_printed.rb +0 -30
  98. data/spec/support/matchers/have_printed.rb +0 -68
  99. data/spec/support/very_soon.rb +0 -9
  100. data/spec/support/yap_spec_dsl.rb +0 -258
  101. data/test.rb +0 -206
  102. data/update-rawline.sh +0 -6
@@ -1,174 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Line editing', type: :feature do
4
- let(:left_arrow) { [?\e, ?[, ?D].join }
5
- let(:right_arrow) { [?\e, ?[, ?C].join }
6
- let(:backspace){ [?\C-?].join }
7
- let(:delete){ [?\e, ?[, ?3, ?~].join }
8
-
9
- it 'Left/Right arrow keys move cursor one position left/right' do
10
- # cursor is right the 'o'
11
- type 'echo hli'
12
-
13
- # let's fix this
14
- type left_arrow
15
- type left_arrow
16
- type 'e'
17
-
18
- type right_arrow
19
- type right_arrow
20
- type 'copter'
21
- enter
22
- expect { output }.to have_printed('helicopter')
23
- end
24
-
25
- it 'Backspace deletes one character left of the cursor, moving the cursor with it' do
26
- type 'echo hello worfd'
27
- type left_arrow
28
- type backspace
29
- type 'l'
30
- enter
31
- expect { output }.to have_printed('hello world')
32
- end
33
-
34
- it 'Delete deletes the character under the cursor, leaving the cursor where it is' do
35
- type 'echo hello world'
36
- 6.times { type left_arrow }
37
- 6.times { type delete }
38
-
39
- expect { output }.to have_printed_lines('yap> echo hello')
40
- clear_all_output(console: false)
41
-
42
- enter
43
- expect { output }.to have_printed_lines('hello')
44
- expect { output }.to have_not_printed('world')
45
- end
46
-
47
- describe 'line navigation (default key bindings)' do
48
- it 'Ctrl-a moves to beginning of line' do
49
- type 'o hello world'
50
- type ?\C-a
51
- type 'ech'
52
- enter
53
- expect { output }.to have_printed('hello world')
54
- end
55
-
56
- it 'Ctrl-e moves to end of line' do
57
- type 'o hello'
58
- type ?\C-a
59
- type 'ech'
60
- type ?\C-e
61
- type ' world'
62
- enter
63
- expect { output }.to have_printed('hello world')
64
- end
65
-
66
- it 'Ctrl-b moves backward one line at a time' do
67
- type 'echo hello ld'
68
- type ?\C-b
69
- type 'wor'
70
- enter
71
- expect { output }.to have_printed(/^hello world/)
72
- clear_all_output
73
-
74
- type 'echo hello world' #, ?\C-b, ?\C-b, 'foo'].join
75
- type ?\C-b
76
- type ?\C-b
77
- type 'foo '
78
- enter
79
- expect { output }.to have_printed(/^foo hello world/)
80
- end
81
-
82
- it 'Ctrl-f moves forward one word at a time' do
83
- type 'echo hello world'
84
- type ?\C-a
85
- type ?\C-f
86
- type 'bob says '
87
- enter
88
- expect { output }.to have_printed('bob says hello world')
89
- clear_all_output
90
-
91
- type 'echo hello world'
92
- type ?\C-a
93
- type ?\C-f
94
- type ?\C-f
95
- type 'foo '
96
- enter
97
- expect { output }.to have_printed('hello foo world')
98
- end
99
-
100
- it 'Ctrl-k kills text forward from the cursor position' do
101
- type 'echo hello world'
102
- type ?\C-b
103
- type ?\C-k
104
- enter
105
- expect { output }.to have_printed('hello')
106
- clear_all_output
107
-
108
- type 'echo hello world'
109
- type ?\C-b
110
- type ?\C-b
111
- type ?\C-k
112
- type 'foo'
113
- enter
114
- expect { output }.to have_printed('foo')
115
- end
116
-
117
- it 'Ctrl-y does not insert when there is no killed text' do
118
- type 'echo "hello world"'
119
- type left_arrow
120
- type ?\C-y
121
- enter
122
- expect { output }.to have_printed('hello world')
123
- clear_all_output
124
- end
125
-
126
- it 'Ctrl-y inserts the last killed text where the cursor is' do
127
- type 'echo hello world'
128
- type ?\C-b
129
- type ?\C-k
130
- type 'delightful '
131
- type ?\C-y
132
- enter
133
- expect { output }.to have_printed('hello delightful world')
134
- clear_all_output
135
- end
136
-
137
- it 'Ctrl-w deletes a word backwards, adding it to the kill ring' do
138
- type 'echo hello world'
139
- type ?\C-w
140
- enter
141
- expect { output }.to have_printed('hello')
142
- clear_all_output
143
-
144
- type 'echo hello world'
145
- type ?\C-w
146
- type ?\C-w
147
- type 'nope'
148
-
149
- expect { output }.to have_printed_line('yap> echo nope')
150
- clear_all_output(console: false)
151
-
152
- enter
153
- expect { output }.to have_printed('nope')
154
- expect { output }.to have_not_printed('hello world')
155
-
156
- type 'echo '
157
- type ?\C-y
158
- enter
159
- expect { output }.to have_printed('hello')
160
- expect { output }.to have_not_printed('world')
161
- end
162
-
163
- it 'Ctrl-u deletes from the cursor to the beginning of the line, adding to the killing as ring' do
164
- type 'echo hello world'
165
- type ?\C-u
166
- type 'echo '
167
- type ?\C-y
168
- enter
169
- expect { output }.to have_printed('echo hello world')
170
- end
171
-
172
- end
173
-
174
- end
@@ -1,35 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Ranges', type: :feature do
4
- describe 'line repetition: (M..N): statement' do
5
- it 'runs the line N times' do
6
- type '(0..2) : echo foo'
7
- enter
8
- expect { output }.to have_printed(/(.*foo){3}/m)
9
- end
10
- end
11
-
12
- describe 'line repetition w/parameter: (M..N) as n: statement' do
13
- it 'runs the line N times supplying an index' do
14
- type '(0..2) as n: echo foo $n'
15
- enter
16
- expect { output }.to have_printed(/foo 0.*\n.*foo 1.*\n.*foo 2/m)
17
- end
18
- end
19
-
20
- describe 'block repetition: (M..N) { statement } ; echo bar' do
21
- it 'runs the block N times' do
22
- type 'echo baz; (0..2) { echo foo } ; echo bar'
23
- enter
24
- expect { output }.to have_printed(/baz.*\n(.*foo){3}.*\n.*bar/m)
25
- end
26
- end
27
-
28
- describe 'block repetition w/parameter: (M..N) { |n| statement }' do
29
- it 'runs the block N times supplying an index' do
30
- type 'echo baz ; (0..2) { |n| echo foo $n } ; echo bar'
31
- enter
32
- expect { output }.to have_printed(/baz.*\n.*foo 0.*\n.*foo 1.*\n.*foo 2.*\n.*bar/m)
33
- end
34
- end
35
- end
@@ -1,234 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'I/O Redirection', type: :feature do
4
- before do
5
- write_executable_script 'fail', <<-SCRIPT.strip_heredoc
6
- |#!/bin/sh
7
- |>&2 echo fail $1
8
- |exit 1
9
- SCRIPT
10
- end
11
-
12
- describe 'STDOUT' do
13
- it 'redirects with: >' do
14
- type 'echo foo > output.txt'
15
- enter
16
- clear_all_output
17
-
18
- type 'cat output.txt'
19
- enter
20
- expect { output }.to have_printed('foo')
21
- end
22
-
23
- it 'redirects with: 1>' do
24
- type 'echo hrm 1> output.txt'
25
- enter
26
- clear_all_output
27
-
28
- type 'cat output.txt'
29
- enter
30
- expect { output }.to have_printed('hrm')
31
- end
32
-
33
- it 'overwrites the file' do
34
- type 'echo foo > output.txt'
35
- enter
36
- type 'echo bar > output.txt'
37
- enter
38
- clear_all_output
39
-
40
- type 'cat output.txt'
41
- enter
42
- expect { output }.to have_printed('bar')
43
- expect { output }.to have_not_printed('foo')
44
- end
45
-
46
- describe 'appending' do
47
- before do
48
- type 'echo foo > output.txt'
49
- enter
50
- clear_all_output
51
-
52
- type 'cat output.txt'
53
- enter
54
- expect { output }.to have_printed_line('foo')
55
- clear_all_output
56
- end
57
-
58
- it 'appends with: >>' do
59
- type 'echo bar >> output.txt'
60
- enter
61
- clear_all_output
62
-
63
- type 'cat output.txt'
64
- enter
65
- expect { output }.to have_printed(/foo.*\n.*bar/)
66
- end
67
-
68
- it 'appends with: 1>>' do
69
- type 'echo bar 1>> output.txt'
70
- enter
71
- clear_all_output
72
-
73
- type 'cat output.txt'
74
- enter
75
- expect { output }.to have_printed(/foo.*\n.*bar/)
76
- end
77
- end
78
- end
79
-
80
- describe 'STDERR' do
81
- it 'redirects with: 2>' do
82
- type './fail foo 2> error.txt'
83
- enter
84
- clear_all_output
85
-
86
- type 'cat error.txt'
87
- enter
88
- expect { output }.to have_printed('fail foo')
89
- end
90
-
91
- it 'overwrites the file' do
92
- type './fail foo 2> error.txt'
93
- enter
94
- type './fail bar 2> error.txt'
95
- enter
96
- clear_all_output
97
-
98
- type 'cat error.txt'
99
- enter
100
- expect { output }.to have_printed('fail bar')
101
- expect { output }.to have_not_printed('fail foo')
102
- clear_all_output
103
- end
104
-
105
- describe 'appending' do
106
- before do
107
- type './fail caz 2> error.txt'
108
- enter
109
- clear_all_output
110
-
111
- type 'cat error.txt'
112
- enter
113
- expect { output }.to have_printed_line('fail caz')
114
- end
115
-
116
- it 'appends with: 2>>' do
117
- type './fail box 2>> error.txt'
118
- enter
119
- clear_all_output
120
-
121
- type 'cat error.txt'
122
- enter
123
- expect { output }.to have_printed(/fail caz.*\n.*fail box/)
124
- end
125
- end
126
- end
127
-
128
- describe 'STDOUT and STDERR separately for a command' do
129
- before do
130
- write_executable_script 'print-stuff', <<-SCRIPT.strip_heredoc
131
- |#!/bin/sh
132
- |echo 'normal foo'
133
- |(>&2 echo 'error foo')
134
- SCRIPT
135
- end
136
-
137
- it 'redirects with: > and 2>' do
138
- type './print-stuff > stdout.txt 2> stderr.txt'
139
- enter
140
- clear_all_output
141
-
142
- type 'cat stdout.txt'
143
- enter
144
- expect { output }.to have_printed('normal foo')
145
- clear_all_output
146
-
147
- type 'cat stdout.txt'
148
- enter
149
- expect { output }.to have_not_printed('error foo')
150
- clear_all_output
151
-
152
- type 'cat stderr.txt'
153
- enter
154
- expect { output }.to have_printed('error foo')
155
- clear_all_output
156
-
157
- type 'cat stderr.txt'
158
- enter
159
- expect { output }.to have_not_printed('normal foo')
160
- end
161
-
162
- it 'redirects with: 1> and 2>' do
163
- type './print-stuff 1> stdout.txt 2> stderr.txt'
164
- enter
165
- clear_all_output
166
-
167
- type 'cat stdout.txt'
168
- enter
169
- expect { output }.to have_printed('normal foo')
170
- clear_all_output
171
-
172
- type 'cat stdout.txt'
173
- enter
174
- expect { output }.to have_not_printed('error foo')
175
- clear_all_output
176
-
177
- type 'cat stderr.txt'
178
- enter
179
- expect { output }.to have_printed('error foo')
180
- clear_all_output
181
-
182
- type 'cat stderr.txt'
183
- enter
184
- expect { output }.to have_not_printed('normal foo')
185
- end
186
- end
187
-
188
- describe 'STDOUT and STDERR pointing to the same file' do
189
- before do
190
- write_executable_script 'echo-stdout-and-stderr', <<-SCRIPT.strip_heredoc
191
- |#!/bin/sh
192
- |echo $1
193
- |>&2 echo $2
194
- SCRIPT
195
- end
196
-
197
- it 'redirects and overwrites with: &>' do
198
- type './echo-stdout-and-stderr foo bar &> output-and-error.txt'
199
- enter
200
- type 'cat output-and-error.txt'
201
- enter
202
- expect { output }.to have_printed(/foo.*\n.*bar/m)
203
- end
204
-
205
- it 'redirects and overwrites with: 2>&1' do
206
- type './echo-stdout-and-stderr bar foo 2>&1 output-and-error.txt'
207
- enter
208
- type 'cat output-and-error.txt'
209
- enter
210
- expect { output }.to have_printed(/bar.*\n.*foo/m)
211
- end
212
-
213
- it 'redirects and appends with: &>>' do
214
- type './echo-stdout-and-stderr howdy hey &>> output-and-error.txt'
215
- enter
216
- type 'cat output-and-error.txt'
217
- enter
218
- expect { output }.to have_printed(/howdy.*\n.*hey/m)
219
- end
220
- end
221
-
222
- describe 'STDIN' do
223
- it 'redirect with: <' do
224
- type 'echo foo > stdin.txt'
225
- enter
226
- clear_all_output
227
-
228
- type 'cat < stdin.txt'
229
- enter
230
- expect { output }.to have_printed('foo')
231
- end
232
- end
233
-
234
- end
@@ -1,118 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Repetition', type: :feature do
4
- describe 'N.times: statement' do
5
- it 'runs the line N times' do
6
- type '5.times : echo foo'
7
- enter
8
- expect { output }.to have_printed(/(.*foo){5}/m)
9
- end
10
-
11
- it 'is not white-space sensitive' do
12
- type '5.times : echo foo'
13
- enter
14
- expect { output }.to have_printed(/(.*foo){5}/m)
15
- end
16
- end
17
-
18
- describe 'N.times: statement1 ; statement2' do
19
- it 'runs all the statements on the line N times' do
20
- type '3.times : echo foo ; echo bar'
21
- enter
22
- expect { output }.to have_printed(/(.*foo.*bar){3}/m)
23
- end
24
-
25
- it 'is not white-space sensitive' do
26
- type '3.times:echo foo ; echo bar'
27
- enter
28
- expect { output }.to have_printed(/(.*foo.*bar){3}/m)
29
- end
30
- end
31
-
32
- describe 'parameters' do
33
- it 'supplies an index for each execution' do
34
- type '3.times as n: echo foo$n ; echo bar$n '
35
- enter
36
- expect { output }.to have_printed(/foo1.*bar1.*foo2.*bar2.*foo3.*bar3/m)
37
- end
38
-
39
- it 'does not overwrite existing variables with the same name' do
40
- type "n='hello world'"
41
- enter
42
- type '3.times as n: echo $n'
43
- enter
44
- expect { output }.to have_printed(/1.*2.*3/m)
45
- clear_all_output
46
-
47
- type 'echo $n'
48
- enter
49
- expect { output }.to have_printed('hello world')
50
- end
51
- end
52
-
53
- describe 'repetition with blocks' do
54
- it 'runs the code inside the block N times' do
55
- type '4.times { echo foo }'
56
- enter
57
- expect { output }.to have_printed(/(.*foo){4}/m)
58
- end
59
-
60
- xit 'requires white-space before the opening curly brace' do
61
- # this breaks everything :(
62
- type '4.times{ echo foo }'
63
- enter
64
- expect { output }.to have_printed(/Infinite loop detected/m)
65
- skip 'Provide a better error message for the user.'
66
- end
67
-
68
- it 'requires white-space before the closing curly brace' do
69
- type '4.times { echo foo}'
70
- enter
71
- expect { output }.to have_printed(/Parse error/m)
72
- # should this be an error? Really? We can't tell that we're in a block
73
- # and we've got a closing curly brace right there?
74
- skip 'Provide a better error message for the user.'
75
- end
76
-
77
- it 'does not require white-space after the opening curly brace' do
78
- type '4.times {echo foo }'
79
- enter
80
- expect { output }.to have_printed(/(.*foo){4}/m)
81
- end
82
-
83
- it 'does not require white-space after the closing curly brace' do
84
- type '4.times { echo foo };'
85
- enter
86
- expect { output }.to have_printed(/Parse error/m)
87
- skip "This shouldn't be an error"
88
- end
89
-
90
- describe 'block parameters' do
91
- it 'supplies an index for each execution' do
92
- type 'echo beg ; 4.times { |n| echo $n } ; echo end'
93
- enter
94
- expect { output }.to have_printed(/beg.*\n.*1.*2.*3.*4.*\n.*end/m)
95
- end
96
-
97
- it 'does not overwrite existing variables with the same name' do
98
- type "n='hello world'"
99
- enter
100
- type 'echo beg ; 3.times { |n| echo $n } ; echo end'
101
- enter
102
- expect { output }.to have_printed(/beg.*\n.*1.*2.*3.*\n.*end/m)
103
- clear_all_output
104
-
105
- type 'echo $n'
106
- enter
107
- expect { output }.to have_printed('hello world')
108
- end
109
-
110
- it 'can step thru the repetition in groups based on how many block params are provided' do
111
- type 'echo beg ; 5.times { |a, b| echo $a $b } ; echo end'
112
- enter
113
- expect { output }.to have_printed(/beg.*\n.*1 2.*\n.*3 4.*\n.*5.*\n.*end/m)
114
- end
115
- end
116
- end
117
-
118
- end