yap-shell 0.7.1 → 0.7.2

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.
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,182 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Using an addon', type: :feature do
4
- let(:addons_path) { tmp_dir.join('addons/') }
5
- let(:yaprc_path) { tmp_dir.join('yaprc') }
6
- let(:yaprc_contents) { '' }
7
-
8
- let(:foo_addon_path) { addons_path.join('yap-shell-addon-foo-0.1.0') }
9
- let(:foo_lib_addon_path) { foo_addon_path.join('lib') }
10
- let(:foo_addon_rb_path) { foo_lib_addon_path.join('yap-shell-addon-foo.rb') }
11
- let(:create_foo_addon) do
12
- mkdir_p foo_lib_addon_path.to_s
13
- write_file foo_addon_rb_path.to_s, <<-RUBY.strip_heredoc
14
- |module YapShellAddonFoo
15
- | class Addon < ::Yap::Addon::Base
16
- | self.export_as :foo
17
- |
18
- | def initialize_world(world)
19
- | world.func('foo-addon') do |args:, stdout:|
20
- | stdout.puts \"You passed \#\{args.inspect\} to foo-addon\"
21
- | end
22
- | end
23
- | end
24
- |end
25
- RUBY
26
- end
27
-
28
- let(:bar_addon_path) { addons_path.join('yap-shell-addon-bar-0.1.0') }
29
- let(:bar_lib_addon_path) { bar_addon_path.join('lib') }
30
- let(:bar_addon_rb_path) { bar_lib_addon_path.join('yap-shell-addon-bar.rb') }
31
- let(:create_bar_addon) do
32
- mkdir_p bar_lib_addon_path.to_s
33
- write_file bar_addon_rb_path.to_s, <<-RUBY.strip_heredoc
34
- |module YapShellAddonBar
35
- | class Addon < ::Yap::Addon::Base
36
- | self.export_as :bar
37
- |
38
- | def initialize_world(world)
39
- | world.func('bar-addon') do |args:, stdout:|
40
- | stdout.puts \"You passed \#\{args.inspect\} to bar-addon\"
41
- | end
42
- | end
43
- | end
44
- |end
45
- RUBY
46
- end
47
-
48
- let(:create_yaprc_file) do
49
- write_file yaprc_path.to_s, <<-RUBY.strip_heredoc
50
- |#{yaprc_contents}
51
- RUBY
52
- end
53
-
54
- let(:yap_cli_args) do
55
- [
56
- '--addon-paths', addons_path.to_s,
57
- '--rcfiles', yaprc_path.to_s,
58
- '--no-history',
59
- '--no-rcfiles',
60
- '--skip-first-time'
61
- ]
62
- end
63
-
64
- before do
65
- set_yap_command_line_arguments yap_cli_args
66
-
67
- create_foo_addon
68
- create_bar_addon
69
- create_yaprc_file
70
-
71
- turn_on_debug_log(debug: 'editor')
72
- reinitialize_shell
73
- end
74
-
75
- it 'loads addons it finds in addon paths' do
76
- # foo-addon is a shell function added by the foo-addon defined above
77
- type 'foo-addon hello world'
78
- enter
79
-
80
- expect { output }.to have_printed("You passed [\"hello\", \"world\"] to foo-addon")
81
- end
82
-
83
- it 'makes addons available thru its export_as name' do
84
- type '!addons.keys.include?(:foo)'
85
- enter
86
- expect { output }.to have_printed('true')
87
- clear_all_output
88
-
89
- type '!addons.keys.include?(:non_existent_addon)'
90
- enter
91
- expect { output }.to have_printed('false')
92
- end
93
-
94
- describe 'disabling an addon', repl: false do
95
- let(:yap_cli_args) do
96
- [
97
- '--addon-paths', addons_path.to_s,
98
- 'addon', 'disable', 'foo'
99
- ]
100
- end
101
-
102
- it 'writes to disk that the addon has been disabled' do
103
- expect { output }.to have_printed("Addon foo has been disabled")
104
-
105
- expect(File.exists?(tmp_dir.join('.yap/addons.yml'))).to be(true)
106
-
107
- addons_config_hsh = YAML.load_file(tmp_dir.join('.yap/addons.yml'))
108
- expect(addons_config_hsh[:foo]).to include(disabled: true)
109
- end
110
- end
111
-
112
- describe 'enabling an addon', repl: false do
113
- let(:yap_cli_args) do
114
- [
115
- '--addon-paths', addons_path.to_s,
116
- 'addon', 'enable', 'foo'
117
- ]
118
- end
119
-
120
- it 'writes to disk that the addon has been enabled' do
121
- expect { output }.to have_printed("Addon foo has been enabled")
122
-
123
- expect(File.exists?(tmp_dir.join('.yap/addons.yml'))).to be(true)
124
-
125
- addons_config_hsh = YAML.load_file(tmp_dir.join('.yap/addons.yml'))
126
- expect(addons_config_hsh[:foo]).to include(disabled: false)
127
- end
128
- end
129
-
130
- describe 'listing addons', repl: false do
131
- let(:yap_cli_args) do
132
- [
133
- '--addon-paths', addons_path.to_s,
134
- 'addon', 'list'
135
- ]
136
- end
137
-
138
- before do
139
- mkdir tmp_dir.join('.yap')
140
- write_file(
141
- tmp_dir.join('.yap/addons.yml'),
142
- {
143
- bar: { disabled: true },
144
- foo: { disabled: false }
145
- }.to_yaml
146
- )
147
- reinitialize_shell
148
- end
149
-
150
- it 'lists all addons found in the addon-paths' do
151
- expect { output }.to have_printed(/bar.*foo/m)
152
- end
153
-
154
- describe 'enabled' do
155
- let(:yap_cli_args) do
156
- [
157
- '--addon-paths', addons_path.to_s,
158
- 'addon', 'list', '--enabled'
159
- ]
160
- end
161
-
162
- it 'lists enabled addons' do
163
- expect { output }.to have_printed(/foo/m)
164
- expect { output }.to have_not_printed(/bar/m)
165
- end
166
- end
167
-
168
- describe 'disabled' do
169
- let(:yap_cli_args) do
170
- [
171
- '--addon-paths', addons_path.to_s,
172
- 'addon', 'list', '--disabled'
173
- ]
174
- end
175
-
176
- it 'lists disabled addons' do
177
- expect { output }.to have_printed(/bar/m)
178
- expect { output }.to have_not_printed(/foo/m)
179
- end
180
- end
181
- end
182
- end
@@ -1,78 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Aliases', type: :feature do
4
- before do
5
- type "alias foo='echo bar'"
6
- enter
7
- expect { output }.to have_printed(/Setting alias foo done/)
8
- end
9
-
10
- it 'sets them' do
11
- type 'alias | grep foo'
12
- enter
13
- expect { output }.to have_printed(/alias foo='echo bar'/)
14
- end
15
-
16
- it 'executes them' do
17
- type 'foo'
18
- enter
19
- expect { output }.to have_printed(/^bar$/m)
20
- end
21
-
22
- it 'unsets them' do
23
- type 'unalias foo'
24
- enter
25
- expect { output }.to have_printed(/Removing alias foo done\n/)
26
-
27
- type 'alias | grep foo'
28
- enter
29
- expect(output).to_not match(/alias foo='echo bar'/)
30
- end
31
-
32
- describe 'conditionals' do
33
- before do
34
- type "alias fail='non-existent-command'"
35
- enter
36
- type "alias pass='echo pass'"
37
- enter
38
- clear_all_output
39
- end
40
-
41
- it 'supports logical AND: &&' do
42
- type "pass && pass"
43
- enter
44
- expect { output }.to have_printed(/^pass$.*^pass$/m)
45
- end
46
-
47
- it 'supports logical OR: &&' do
48
- type "fail || pass"
49
- enter
50
- expect { error_output }.to have_printed(/yap: command not found: non-existent-command/m)
51
- expect { output }.to have_printed(/^pass$/m)
52
- clear_all_output
53
-
54
- type "echo $?"
55
- enter
56
- expect { output }.to have_printed(/0/m)
57
- end
58
-
59
- it 'can combine logical AND and OR' do
60
- type "(pass && fail) || pass"
61
- enter
62
- expect { error_output }.to have_printed(/yap: command not found: non-existent-command/m)
63
- expect { output }.to have_printed(/^pass$.*^pass$/m)
64
- clear_all_output
65
-
66
- type "(pass || fail) && pass"
67
- enter
68
- expect { error_output }.to have_not_printed(/yap: command not found: non-existent-command/m)
69
- expect { output }.to have_printed(/^pass$.*^pass$/m)
70
- clear_all_output
71
-
72
- type "(fail && pass) && pass"
73
- enter
74
- expect { error_output }.to have_printed(/yap: command not found: non-existent-command/m)
75
- expect { output }.to have_not_printed(/^pass$.*^pass$/m)
76
- end
77
- end
78
- end
@@ -1,69 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Environment variables', type: :feature do
4
- it 'sets and gets them with: NAME=value' do
5
- type 'FOO=foobarbaz'
6
- enter
7
-
8
- type 'echo $FOO'
9
- enter
10
- expect { output }.to have_printed('foobarbaz')
11
- end
12
-
13
- it 'can set multiple on a single line: NAME1=value1 NAME2=value2 etc' do
14
- type 'A=b B=c C=d'
15
- enter
16
- clear_all_output
17
-
18
- type 'echo $A $B $C'
19
- enter
20
- expect { output }.to have_printed('b c d')
21
- clear_all_output
22
-
23
- type 'echo $A$B$C'
24
- enter
25
- expect { output }.to have_printed('bcd')
26
- end
27
-
28
- it 'expands env vars inside of double quotes' do
29
- type 'BAR=foobarbaz'
30
- enter
31
-
32
- type %|echo "BAR is $BAR"|
33
- enter
34
- expect { output }.to have_printed('BAR is foobarbaz')
35
- end
36
-
37
- it 'does not expand env vars inside of single quotes' do
38
- type 'BAR=foobarbaz'
39
- enter
40
-
41
- type %|echo 'BAR is $BAR'|
42
- enter
43
- expect { output }.to have_printed('BAR is $BAR')
44
- end
45
-
46
- describe 'setting env vars for a single statement' do
47
- it 'makes the env var available to the statement' do
48
- type 'BAZ=baz echo $BAZ'
49
- enter
50
- expect { output }.to have_printed('baz')
51
- end
52
-
53
- it 'does not keep the env var around for the next statement' do
54
- type 'BAZ=baz echo $BAZ'
55
- enter
56
- clear_all_output
57
-
58
- type 'echo $BAZ'
59
- enter
60
- expect { output }.to have_printed('$BAZ')
61
- end
62
-
63
- it 'can set multiple env vars for a statement' do
64
- type %|FOO=foo BAR='is the' BAZ="fastest pineapple" echo $FOO $BAR $BAZ|
65
- enter
66
- expect { output }.to have_printed('foo is the fastest pineapple')
67
- end
68
- end
69
- end
@@ -1,61 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Filesystem commands', type: :feature do
4
- it 'runs filesystem commands' do
5
- touch 'bar.txt'
6
- type 'ls .'
7
- enter
8
-
9
- expect { output }.to have_printed("bar.txt")
10
-
11
- type 'echo "hello there"'
12
- enter
13
- expect { output }.to have_printed("hello there\n")
14
- clear_all_output
15
- end
16
-
17
- it 'pipes filesystem commands' do
18
- type "echo 'food' | sed -e 's/o/_/g'"
19
- enter
20
- expect { output }.to have_printed(/^f__d\n/m)
21
- end
22
-
23
- describe 'conditionals' do
24
- it 'supports logical AND: &&' do
25
- type "echo foo && echo bar"
26
- enter
27
- expect { output }.to have_printed(/foo.*\n.*bar/m)
28
- end
29
-
30
- it 'supports logical OR: &&' do
31
- type "non-existent-command || echo bar"
32
- enter
33
- expect { error_output }.to have_printed(/yap: command not found: non-existent-command/m)
34
- expect { output }.to have_printed(/bar/m)
35
- clear_all_output
36
-
37
- type "echo $?"
38
- enter
39
- expect { output }.to have_printed(/0/m)
40
- end
41
-
42
- it 'can combine logical AND and OR' do
43
- type "(echo foo && non-existent-command) || echo bar"
44
- enter
45
- expect { error_output }.to have_printed(/yap: command not found: non-existent-command/m)
46
- expect { output }.to have_printed(/foo.*\n.*bar/m)
47
- clear_all_output
48
-
49
- type "(echo foo || non-existent-command) && echo bar"
50
- enter
51
- expect { error_output }.to have_not_printed(/yap: command not found: non-existent-command/m)
52
- expect { output }.to have_printed(/foo.*\n.*bar/m)
53
- clear_all_output
54
-
55
- type "(non-existent-command && echo foo) && echo bar"
56
- enter
57
- expect { error_output }.to have_printed(/yap: command not found: non-existent-command/m)
58
- expect { output }.to have_not_printed(/foo.*\n.*bar/m)
59
- end
60
- end
61
- end
@@ -1,45 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Running Yap for the first time', type: :feature, forks: true do
4
- before do
5
- # do not pass in --skip-first-time
6
- set_yap_command_line_arguments \
7
- '--no-history', '--no-addons', '--no-rcfiles'
8
-
9
- turn_on_debug_log(debug: 'editor')
10
- reinitialize_shell
11
- end
12
-
13
- it 'tells the user it has been initialized' do
14
- home_dir = tmp_dir.to_s
15
- message = <<-EOT.gsub(/^\s*\|/, '').chomp
16
- |Yap directory not found: #{home_dir}/.yap
17
- |
18
- |Initializing yap for the first time:
19
- |
20
- | Creating #{home_dir}/.yap done
21
- | Creating default #{home_dir}/.yap/yaprc done
22
- |
23
- |To tweak yap take a look at #{home_dir}/.yap/yaprc.
24
- |
25
- |Reloading shell
26
- EOT
27
- expect { output }.to have_printed(message)
28
- end
29
-
30
- it 'creates a $HOME/.yap/ directory for yap things to go' do
31
- expect { output }.to have_printed('Reloading shell')
32
-
33
- dot_yap_dir = tmp_dir.join('.yap').to_s
34
- expect(Dir.exist?(dot_yap_dir)).to be(true)
35
- end
36
-
37
- it 'creates a default .yap/yaprc rcfile' do
38
- expect { output }.to have_printed('Reloading shell')
39
-
40
- yaprc = tmp_dir.join('.yap/yaprc').to_s
41
- templaterc = yap_dir.join('rcfiles/yaprc')
42
- expect(File.exist?(yaprc)).to be(true)
43
- expect(IO.read(yaprc)).to eq(IO.read(templaterc))
44
- end
45
- end
@@ -1,81 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Grouping commands', type: :feature do
4
- before do
5
- write_executable_script 'pass', <<-SCRIPT.strip_heredoc
6
- |#!/bin/sh
7
- |echo pass $1
8
- |exit 0
9
- SCRIPT
10
-
11
- write_executable_script 'fail', <<-SCRIPT.strip_heredoc
12
- |#!/bin/sh
13
- |echo fail $1
14
- |exit 1
15
- SCRIPT
16
- end
17
-
18
- describe 'using parentheses' do
19
- it 'works with: (command1 && command2) || command3' do
20
- type '(./pass 1 && ./fail 2) || ./pass 3'
21
- enter
22
- expect { output }.to have_printed(/^pass 1$.*^fail 2$.*^pass 3$/m)
23
- clear_all_output
24
-
25
- type '(./fail 1 && ./pass 2) || ./pass 3'
26
- enter
27
- expect { output }.to have_printed(/^fail 1$.*^pass 3$/m)
28
- expect { output }.to have_not_printed(/^pass 2$/m)
29
- end
30
-
31
- it 'works with: (command1 && command2 && command3) || command4' do
32
- type '(./pass 1 && ./fail 2 && ./pass 3) || ./pass 4'
33
- enter
34
- expect { output }.to have_printed(/^pass 1$.*^fail 2$.*^pass 4$/m)
35
- expect { output }.to have_not_printed(/^pass 1$.*^fail 2$.*^pass 3$.*^pass 4$/m)
36
- clear_all_output
37
-
38
- type '(./fail 1 && ./pass 2 && ./pass 3) || ./pass 4'
39
- enter
40
- expect { output }.to have_printed(/^fail 1$.*^pass 4$/m)
41
- expect { output }.to have_not_printed(/^pass 2$.*^pass 3$/m)
42
- end
43
-
44
- it 'works with: (command1 || command2) && command4' do
45
- type '(./fail 1 || ./pass 2) && ./pass 3'
46
- enter
47
- expect { output }.to have_printed(/^fail 1$.*^pass 2$.*^pass 3$/m)
48
-
49
- type '(./pass 1 || ./fail 2) && ./pass 3'
50
- enter
51
- expect { output }.to have_printed(/^pass 1$.*^pass 3$/m)
52
- expect { output }.to have_not_printed(/^fail 2$/m)
53
- end
54
-
55
- it 'works with: (command1 && command2) && command4' do
56
- type '(./fail 1 && ./pass 2) && ./pass 3'
57
- enter
58
- expect { output }.to have_printed(/^fail 1$/m)
59
- expect { output }.to have_not_printed(/^pass 2$.*^pass 3$/m)
60
- clear_all_output
61
-
62
- type '(./pass 1 && ./fail 2) && ./pass 3'
63
- enter
64
- expect { output }.to have_printed(/^pass 1$.*^fail 2$/m)
65
- expect { output }.to have_not_printed(/^pass 3$/m)
66
- end
67
-
68
- it 'works with: (command1 || command2) || command4' do
69
- type '(./fail 1 || ./pass 2) || ./pass 3'
70
- enter
71
- expect { output }.to have_printed(/^fail 1$.*^pass 2$/m)
72
- expect { output }.to have_not_printed(/^pass 3$/m)
73
-
74
- type '(./pass 1 || ./fail 2) || ./pass 3'
75
- enter
76
- expect { output }.to have_printed(/^pass 1$/m)
77
- expect { output }.to have_not_printed(/^fail 2$.*^pass 3$/m)
78
- end
79
- end
80
-
81
- end