bombshell 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +93 -59
- data/bombshell.gemspec +3 -17
- data/lib/bombshell/shell.rb +2 -1
- data/lib/bombshell/version.rb +4 -0
- metadata +12 -24
- data/.document +0 -5
- data/.rspec +0 -1
- data/Gemfile +0 -2
- data/Rakefile +0 -17
- data/VERSION +0 -1
- data/doc/brainstorm.rb +0 -56
- data/features/callbacks.feature +0 -48
- data/features/completion.feature +0 -55
- data/features/prompts.feature +0 -69
- data/features/shell.feature +0 -45
- data/features/step_definitions/completion_steps.rb +0 -14
- data/features/subshells.feature +0 -48
- data/features/support/env.rb +0 -10
data/README.markdown
CHANGED
@@ -6,31 +6,37 @@ Really, you did? Weird.
|
|
6
6
|
|
7
7
|
## Simple example
|
8
8
|
|
9
|
+
(The source code for this example is in [`doc/pizza`](https://github.com/rossmeissl/bombshell/tree/master/doc/pizza).)
|
10
|
+
|
9
11
|
`pizza/bin/pizza`:
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
``` ruby
|
14
|
+
#!/usr/bin/env ruby
|
15
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib') unless $:.include?(File.dirname(__FILE__) + '/../lib')
|
16
|
+
|
17
|
+
require 'rubygems'
|
18
|
+
require 'pizza'
|
19
|
+
Bombshell.launch(Pizza::Shell)
|
20
|
+
```
|
17
21
|
|
18
22
|
`pizza/lib/pizza/shell.rb`:
|
19
23
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
24
|
+
``` ruby
|
25
|
+
require 'bombshell'
|
26
|
+
|
27
|
+
module Pizza
|
28
|
+
class Shell < Bombshell::Environment
|
29
|
+
include Bombshell::Shell
|
30
|
+
|
31
|
+
prompt_with 'pizzabot'
|
32
|
+
|
33
|
+
def order(size)
|
34
|
+
Pizza::Order.new(:size => size).place!
|
35
|
+
puts 'Your pizza has been ordered! Super!'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
```
|
34
40
|
|
35
41
|
Let's try it out:
|
36
42
|
|
@@ -39,28 +45,42 @@ Let's try it out:
|
|
39
45
|
Your pizza has been ordered! Super!
|
40
46
|
pizzabot>
|
41
47
|
|
48
|
+
If you have Bombshell's source checked out, you can try this at home:
|
49
|
+
|
50
|
+
``` console
|
51
|
+
$ cd doc/pizza
|
52
|
+
$ ./bin/pizza
|
53
|
+
```
|
54
|
+
|
42
55
|
## Prompts
|
43
56
|
|
44
57
|
You set your prompt like this:
|
45
58
|
|
59
|
+
``` ruby
|
46
60
|
prompt_with 'pizza_bot_loves_you'
|
61
|
+
```
|
47
62
|
|
48
63
|
Or like this:
|
49
64
|
|
65
|
+
``` ruby
|
50
66
|
prompt_with do
|
51
67
|
"pizza_bot / #{Time.now}" # binding is on your shell *class*
|
52
68
|
end
|
69
|
+
```
|
53
70
|
|
54
71
|
Or even like this:
|
55
72
|
|
73
|
+
``` ruby
|
56
74
|
prompt_with do |shell|
|
57
75
|
"pizza_bot / #{shell.size}" # the block gets the shell *instance* when it asks for it
|
58
76
|
end
|
77
|
+
```
|
59
78
|
|
60
79
|
## Callbacks
|
61
80
|
|
62
81
|
You can set callbacks like this:
|
63
82
|
|
83
|
+
``` ruby
|
64
84
|
before_launch do
|
65
85
|
init # binding is on your shell *class*
|
66
86
|
end
|
@@ -72,55 +92,62 @@ You can set callbacks like this:
|
|
72
92
|
having_launched do
|
73
93
|
puts size if size # binding is on your shell *instance*
|
74
94
|
end
|
95
|
+
```
|
75
96
|
|
76
97
|
## Subshells
|
77
98
|
|
78
|
-
If you dump all of your functionality into one shell, things could get a little messy. That's why we have *subshells
|
99
|
+
If you dump all of your functionality into one shell, things could get a little messy. That's why we have *subshells*.
|
100
|
+
|
101
|
+
(The source code for this example is in [`doc/pizza2`](https://github.com/rossmeissl/bombshell/tree/master/doc/pizza2).)
|
79
102
|
|
80
103
|
`pizza/lib/pizza/shell.rb`:
|
81
104
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
105
|
+
``` ruby
|
106
|
+
require 'bombshell'
|
107
|
+
|
108
|
+
module Pizza
|
109
|
+
class Shell < Bombshell::Environment
|
110
|
+
include Bombshell::Shell
|
111
|
+
prompt_with 'pizzabot'
|
112
|
+
|
113
|
+
def pizza
|
114
|
+
Order.launch
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
require 'pizza/shell/order'
|
120
|
+
```
|
94
121
|
|
95
122
|
`pizza/lib/pizza/shell/order.rb`:
|
96
123
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
puts 'You got it!'
|
108
|
-
end
|
109
|
-
|
110
|
-
def topping(t)
|
111
|
-
@toppings ||= []
|
112
|
-
@toppings << t
|
113
|
-
puts "Added #{t}"
|
114
|
-
end
|
115
|
-
|
116
|
-
def order
|
117
|
-
Pizza::Order.new :size => @size, :toppings => @toppings
|
118
|
-
puts 'Coming right up!'
|
119
|
-
quit
|
120
|
-
end
|
121
|
-
end
|
124
|
+
``` ruby
|
125
|
+
module Pizza
|
126
|
+
class Shell
|
127
|
+
class Order < Bombshell::Environment
|
128
|
+
include Bombshell::Shell
|
129
|
+
prompt_with 'new order'
|
130
|
+
|
131
|
+
def size(s)
|
132
|
+
@size = s
|
133
|
+
puts 'You got it!'
|
122
134
|
end
|
123
|
-
|
135
|
+
|
136
|
+
def topping(t)
|
137
|
+
@toppings ||= []
|
138
|
+
@toppings << t
|
139
|
+
puts "Added #{t}"
|
140
|
+
end
|
141
|
+
|
142
|
+
def order
|
143
|
+
Pizza::Order.new :size => @size, :toppings => @toppings
|
144
|
+
puts 'Coming right up!'
|
145
|
+
quit
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
```
|
124
151
|
|
125
152
|
Let's try it out:
|
126
153
|
|
@@ -133,6 +160,13 @@ Let's try it out:
|
|
133
160
|
Coming right up!
|
134
161
|
pizzabot>
|
135
162
|
|
163
|
+
If you have Bombshell's source checked out, you can try this at home:
|
164
|
+
|
165
|
+
``` console
|
166
|
+
$ cd doc/pizza2
|
167
|
+
$ ./bin/pizza
|
168
|
+
```
|
169
|
+
|
136
170
|
## Tab completion
|
137
171
|
|
138
172
|
It's there. Give it a whirl with TAB.
|
data/bombshell.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
|
9
9
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
10
10
|
s.authors = ["Andy Rossmeissl"]
|
11
|
-
s.date = "2011-
|
11
|
+
s.date = "2011-12-08"
|
12
12
|
s.description = %q{Give your application or gem an interactive shell, complete with custom prompts, tab completion, and various callbacks. Commands are defined as Ruby methods and can be grouped into logical subshells.}
|
13
13
|
s.email = %q{andy@rossmeissl.net}
|
14
14
|
s.extra_rdoc_files = [
|
@@ -16,26 +16,12 @@ Gem::Specification.new do |s|
|
|
16
16
|
"README.markdown"
|
17
17
|
]
|
18
18
|
s.files = [
|
19
|
-
".document",
|
20
|
-
".rspec",
|
21
|
-
"Gemfile",
|
22
|
-
"LICENSE.txt",
|
23
|
-
"README.markdown",
|
24
|
-
"Rakefile",
|
25
|
-
"VERSION",
|
26
19
|
"bombshell.gemspec",
|
27
|
-
"doc/brainstorm.rb",
|
28
|
-
"features/callbacks.feature",
|
29
|
-
"features/completion.feature",
|
30
|
-
"features/prompts.feature",
|
31
|
-
"features/shell.feature",
|
32
|
-
"features/step_definitions/completion_steps.rb",
|
33
|
-
"features/subshells.feature",
|
34
|
-
"features/support/env.rb",
|
35
20
|
"lib/bombshell.rb",
|
36
21
|
"lib/bombshell/completor.rb",
|
37
22
|
"lib/bombshell/environment.rb",
|
38
23
|
"lib/bombshell/irb.rb",
|
24
|
+
"lib/bombshell/version.rb",
|
39
25
|
"lib/bombshell/shell.rb",
|
40
26
|
"lib/bombshell/shell/commands.rb"
|
41
27
|
]
|
@@ -44,7 +30,7 @@ Gem::Specification.new do |s|
|
|
44
30
|
s.require_paths = ["lib"]
|
45
31
|
s.rubygems_version = %q{1.6.2}
|
46
32
|
s.summary = %q{Custom IRB consoles made easy}
|
47
|
-
s.add_development_dependency 'aruba'
|
33
|
+
s.add_development_dependency 'aruba', '>= 0.3.4'
|
48
34
|
s.add_development_dependency 'bueller'
|
49
35
|
end
|
50
36
|
|
data/lib/bombshell/shell.rb
CHANGED
@@ -55,7 +55,8 @@ module Bombshell
|
|
55
55
|
@bombshell_callbacks[:before_launch].each do |callback|
|
56
56
|
callback.call(*arguments.first(callback.arity > -1 ? callback.arity : 0))
|
57
57
|
end
|
58
|
-
|
58
|
+
number_of_requested_arguments = instance_method(:initialize).arity < 0 ? arguments.length : instance_method(:initialize).arity
|
59
|
+
shell = new(*arguments.first(number_of_requested_arguments))
|
59
60
|
@bombshell_callbacks[:having_launched].each do |callback|
|
60
61
|
shell.instance_eval &callback
|
61
62
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bombshell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 6
|
10
|
+
version: 0.1.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andy Rossmeissl
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
19
|
-
default_executable:
|
18
|
+
date: 2011-12-08 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
prerelease: false
|
@@ -27,10 +26,12 @@ dependencies:
|
|
27
26
|
requirements:
|
28
27
|
- - ">="
|
29
28
|
- !ruby/object:Gem::Version
|
30
|
-
hash:
|
29
|
+
hash: 27
|
31
30
|
segments:
|
32
31
|
- 0
|
33
|
-
|
32
|
+
- 3
|
33
|
+
- 4
|
34
|
+
version: 0.3.4
|
34
35
|
requirement: *id001
|
35
36
|
- !ruby/object:Gem::Dependency
|
36
37
|
prerelease: false
|
@@ -56,29 +57,16 @@ extra_rdoc_files:
|
|
56
57
|
- LICENSE.txt
|
57
58
|
- README.markdown
|
58
59
|
files:
|
59
|
-
- .document
|
60
|
-
- .rspec
|
61
|
-
- Gemfile
|
62
|
-
- LICENSE.txt
|
63
|
-
- README.markdown
|
64
|
-
- Rakefile
|
65
|
-
- VERSION
|
66
60
|
- bombshell.gemspec
|
67
|
-
- doc/brainstorm.rb
|
68
|
-
- features/callbacks.feature
|
69
|
-
- features/completion.feature
|
70
|
-
- features/prompts.feature
|
71
|
-
- features/shell.feature
|
72
|
-
- features/step_definitions/completion_steps.rb
|
73
|
-
- features/subshells.feature
|
74
|
-
- features/support/env.rb
|
75
61
|
- lib/bombshell.rb
|
76
62
|
- lib/bombshell/completor.rb
|
77
63
|
- lib/bombshell/environment.rb
|
78
64
|
- lib/bombshell/irb.rb
|
65
|
+
- lib/bombshell/version.rb
|
79
66
|
- lib/bombshell/shell.rb
|
80
67
|
- lib/bombshell/shell/commands.rb
|
81
|
-
|
68
|
+
- LICENSE.txt
|
69
|
+
- README.markdown
|
82
70
|
homepage: http://github.com/rossmeissl/bombshell
|
83
71
|
licenses:
|
84
72
|
- MIT
|
@@ -108,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
96
|
requirements: []
|
109
97
|
|
110
98
|
rubyforge_project:
|
111
|
-
rubygems_version: 1.
|
99
|
+
rubygems_version: 1.8.8
|
112
100
|
signing_key:
|
113
101
|
specification_version: 3
|
114
102
|
summary: Custom IRB consoles made easy
|
data/.document
DELETED
data/.rspec
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|
data/Gemfile
DELETED
data/Rakefile
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler'
|
3
|
-
begin
|
4
|
-
Bundler.setup(:default, :development)
|
5
|
-
rescue Bundler::BundlerError => e
|
6
|
-
$stderr.puts e.message
|
7
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
-
exit e.status_code
|
9
|
-
end
|
10
|
-
require 'rake'
|
11
|
-
|
12
|
-
require 'cucumber/rake/task'
|
13
|
-
Cucumber::Rake::Task.new
|
14
|
-
task :default => :cucumber
|
15
|
-
|
16
|
-
require 'bueller'
|
17
|
-
Bueller::Tasks.new
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.2
|
data/doc/brainstorm.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
$:.push File.join(File.dirname(__FILE__), '..', 'lib')
|
2
|
-
require 'bombshell'
|
3
|
-
|
4
|
-
module Foo
|
5
|
-
class Shell < Bombshell::Environment
|
6
|
-
include Bombshell::Shell
|
7
|
-
|
8
|
-
before_launch do
|
9
|
-
@punctuation = '!'
|
10
|
-
end
|
11
|
-
|
12
|
-
before_launch do |arg|
|
13
|
-
puts arg if arg
|
14
|
-
end
|
15
|
-
|
16
|
-
having_launched do
|
17
|
-
@msg = 'Done' + self.class.punctuation
|
18
|
-
end
|
19
|
-
|
20
|
-
having_launched do
|
21
|
-
puts 'Welcome to FooShell'
|
22
|
-
end
|
23
|
-
|
24
|
-
prompt_with do
|
25
|
-
punctuation
|
26
|
-
end
|
27
|
-
|
28
|
-
def do_something
|
29
|
-
puts @msg
|
30
|
-
end
|
31
|
-
|
32
|
-
def sub
|
33
|
-
Subshell.launch
|
34
|
-
end
|
35
|
-
|
36
|
-
class << self
|
37
|
-
def punctuation
|
38
|
-
@punctuation
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
module Foo
|
45
|
-
class Subshell < Bombshell::Environment
|
46
|
-
include Bombshell::Shell
|
47
|
-
|
48
|
-
def do_something_else
|
49
|
-
puts '... and done'
|
50
|
-
end
|
51
|
-
|
52
|
-
prompt_with '[foo::subshell]'
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
Bombshell.launch(Foo::Shell)
|
data/features/callbacks.feature
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
Feature: Callbacks
|
2
|
-
|
3
|
-
In order to have customization flexibility
|
4
|
-
As a Ruby library developer
|
5
|
-
I want to have access to callbacks
|
6
|
-
|
7
|
-
Scenario: Using a before_launch callback
|
8
|
-
Given a file named "fooshell.rb" with:
|
9
|
-
"""
|
10
|
-
require 'bombshell'
|
11
|
-
module Foo
|
12
|
-
class Shell < Bombshell::Environment
|
13
|
-
include Bombshell::Shell
|
14
|
-
before_launch do
|
15
|
-
puts "Hi, I'm #{name}"
|
16
|
-
end
|
17
|
-
def self.name; 'Foo' end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
Bombshell.launch Foo::Shell
|
21
|
-
"""
|
22
|
-
When I run "ruby fooshell.rb" interactively
|
23
|
-
And I type "quit"
|
24
|
-
Then the output should contain:
|
25
|
-
"""
|
26
|
-
Hi, I'm Foo
|
27
|
-
"""
|
28
|
-
|
29
|
-
Scenario: Using a having_launched callback
|
30
|
-
Given a file named "fooshell.rb" with:
|
31
|
-
"""
|
32
|
-
require 'bombshell'
|
33
|
-
module Foo
|
34
|
-
class Shell < Bombshell::Environment
|
35
|
-
include Bombshell::Shell
|
36
|
-
having_launched do
|
37
|
-
puts "Hi, I'm an instance of #{self.class}"
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
Bombshell.launch Foo::Shell
|
42
|
-
"""
|
43
|
-
When I run "ruby fooshell.rb" interactively
|
44
|
-
And I type "quit"
|
45
|
-
Then the output should contain:
|
46
|
-
"""
|
47
|
-
Hi, I'm an instance of Foo::Shell
|
48
|
-
"""
|
data/features/completion.feature
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
Feature: Completion
|
2
|
-
|
3
|
-
In order to expedite my exploration
|
4
|
-
As a user of a Bombshell-enabled Ruby library
|
5
|
-
I want to be able to use tab completion
|
6
|
-
|
7
|
-
Scenario: Single matching command
|
8
|
-
Given a file named "fooshell.rb" with:
|
9
|
-
"""
|
10
|
-
require 'bombshell'
|
11
|
-
module Foo
|
12
|
-
class Shell < Bombshell::Environment
|
13
|
-
include Bombshell::Shell
|
14
|
-
def abcdef; end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
Bombshell.launch Foo::Shell
|
18
|
-
"""
|
19
|
-
When I run "ruby fooshell.rb" interactively
|
20
|
-
And I type "abc" and hit tab
|
21
|
-
And I type "quit"
|
22
|
-
Then the output should contain:
|
23
|
-
"""
|
24
|
-
abcdef
|
25
|
-
"""
|
26
|
-
And the output should not contain:
|
27
|
-
"""
|
28
|
-
method_missing
|
29
|
-
"""
|
30
|
-
|
31
|
-
Scenario: Multiple matching commands
|
32
|
-
Given a file named "fooshell.rb" with:
|
33
|
-
"""
|
34
|
-
require 'bombshell'
|
35
|
-
module Foo
|
36
|
-
class Shell < Bombshell::Environment
|
37
|
-
include Bombshell::Shell
|
38
|
-
def abcd; end
|
39
|
-
def abcx; end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
Bombshell.launch Foo::Shell
|
43
|
-
"""
|
44
|
-
When I run "ruby fooshell.rb" interactively
|
45
|
-
And I type "abc" and hit tab twice
|
46
|
-
And I type "quit"
|
47
|
-
Then the output should contain:
|
48
|
-
"""
|
49
|
-
abcd
|
50
|
-
"""
|
51
|
-
And the output should contain:
|
52
|
-
"""
|
53
|
-
abcx
|
54
|
-
"""
|
55
|
-
|
data/features/prompts.feature
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
Feature: Prompts
|
2
|
-
|
3
|
-
In order to brand my custom shell experience
|
4
|
-
As a developer of a Bombshell-enabled Ruby library
|
5
|
-
I want to set custom prompts
|
6
|
-
|
7
|
-
Scenario: Static-string prompt
|
8
|
-
Given a file named "fooshell.rb" with:
|
9
|
-
"""
|
10
|
-
require 'bombshell'
|
11
|
-
module Foo
|
12
|
-
class Shell < Bombshell::Environment
|
13
|
-
include Bombshell::Shell
|
14
|
-
prompt_with 'fooprompt'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
Bombshell.launch Foo::Shell
|
18
|
-
"""
|
19
|
-
When I run "ruby fooshell.rb" interactively
|
20
|
-
And I type "quit"
|
21
|
-
Then the output should contain:
|
22
|
-
"""
|
23
|
-
fooprompt>
|
24
|
-
"""
|
25
|
-
|
26
|
-
Scenario: Class-oriented prompt
|
27
|
-
Given a file named "fooshell.rb" with:
|
28
|
-
"""
|
29
|
-
require 'bombshell'
|
30
|
-
module Foo
|
31
|
-
class Shell < Bombshell::Environment
|
32
|
-
include Bombshell::Shell
|
33
|
-
prompt_with do
|
34
|
-
_prompt
|
35
|
-
end
|
36
|
-
def self._prompt; 'fooprompt-class' end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
Bombshell.launch Foo::Shell
|
40
|
-
"""
|
41
|
-
When I run "ruby fooshell.rb" interactively
|
42
|
-
And I type "quit"
|
43
|
-
Then the output should contain:
|
44
|
-
"""
|
45
|
-
fooprompt-class>
|
46
|
-
"""
|
47
|
-
|
48
|
-
Scenario: Instance-oriented prompt
|
49
|
-
Given a file named "fooshell.rb" with:
|
50
|
-
"""
|
51
|
-
require 'bombshell'
|
52
|
-
module Foo
|
53
|
-
class Shell < Bombshell::Environment
|
54
|
-
include Bombshell::Shell
|
55
|
-
prompt_with do |foo|
|
56
|
-
foo._prompt
|
57
|
-
end
|
58
|
-
def _prompt; 'fooprompt-instance' end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
Bombshell.launch Foo::Shell
|
62
|
-
"""
|
63
|
-
When I run "ruby fooshell.rb" interactively
|
64
|
-
And I type "quit"
|
65
|
-
Then the output should contain:
|
66
|
-
"""
|
67
|
-
fooprompt-instance>
|
68
|
-
"""
|
69
|
-
|
data/features/shell.feature
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
Feature: Custom shell
|
2
|
-
|
3
|
-
In order to allow my users to explore my library
|
4
|
-
As a Ruby library developer
|
5
|
-
I want to give them an interactive shell
|
6
|
-
|
7
|
-
Scenario: Running the shell
|
8
|
-
Given a file named "fooshell.rb" with:
|
9
|
-
"""
|
10
|
-
require 'bombshell'
|
11
|
-
module Foo
|
12
|
-
class Shell < Bombshell::Environment
|
13
|
-
include Bombshell::Shell
|
14
|
-
end
|
15
|
-
end
|
16
|
-
Bombshell.launch Foo::Shell
|
17
|
-
"""
|
18
|
-
When I run "ruby fooshell.rb" interactively
|
19
|
-
And I type "quit"
|
20
|
-
Then the output should contain:
|
21
|
-
"""
|
22
|
-
[Bombshell]
|
23
|
-
"""
|
24
|
-
|
25
|
-
Scenario: Using a command
|
26
|
-
Given a file named "fooshell.rb" with:
|
27
|
-
"""
|
28
|
-
require 'bombshell'
|
29
|
-
module Foo
|
30
|
-
class Shell < Bombshell::Environment
|
31
|
-
include Bombshell::Shell
|
32
|
-
def hello
|
33
|
-
puts 'hello world'
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
Bombshell.launch Foo::Shell
|
38
|
-
"""
|
39
|
-
When I run "ruby fooshell.rb" interactively
|
40
|
-
And I type "hello"
|
41
|
-
And I type "quit"
|
42
|
-
Then the output should contain:
|
43
|
-
"""
|
44
|
-
[Bombshell]
|
45
|
-
"""
|
@@ -1,14 +0,0 @@
|
|
1
|
-
When /^I type "(.*)" and hit tab$/ do |command|
|
2
|
-
pending
|
3
|
-
_write_interactive(command)
|
4
|
-
_write_interactive("\t")
|
5
|
-
_write_interactive("\n")
|
6
|
-
end
|
7
|
-
|
8
|
-
When /^I type "(.*)" and hit tab twice$/ do |command|
|
9
|
-
pending
|
10
|
-
_write_interactive(command)
|
11
|
-
_write_interactive("\t")
|
12
|
-
_write_interactive("\t")
|
13
|
-
_write_interactive("\n")
|
14
|
-
end
|
data/features/subshells.feature
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
Feature: Subshells
|
2
|
-
|
3
|
-
In order to organize my shell commands
|
4
|
-
As a developer of a Bombshell-enabled Ruby library
|
5
|
-
I want to use subshells
|
6
|
-
|
7
|
-
Scenario: Using subshells
|
8
|
-
Given a file named "fooshell.rb" with:
|
9
|
-
"""
|
10
|
-
require 'bombshell'
|
11
|
-
module Foo
|
12
|
-
class Shell < Bombshell::Environment
|
13
|
-
include Bombshell::Shell
|
14
|
-
def deeper
|
15
|
-
Subshell.launch
|
16
|
-
end
|
17
|
-
prompt_with 'first'
|
18
|
-
class Subshell < Bombshell::Environment
|
19
|
-
include Bombshell::Shell
|
20
|
-
def foo; puts 'bar' end
|
21
|
-
prompt_with 'second'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
Bombshell.launch Foo::Shell
|
26
|
-
"""
|
27
|
-
When I run "ruby fooshell.rb" interactively
|
28
|
-
And I type "deeper"
|
29
|
-
And I type "foo"
|
30
|
-
And I type "quit"
|
31
|
-
And I type "quit"
|
32
|
-
Then the output should contain:
|
33
|
-
"""
|
34
|
-
first> deeper
|
35
|
-
"""
|
36
|
-
And the output should contain:
|
37
|
-
"""
|
38
|
-
second> foo
|
39
|
-
bar
|
40
|
-
"""
|
41
|
-
And the output should contain:
|
42
|
-
"""
|
43
|
-
second> quit
|
44
|
-
"""
|
45
|
-
And the output should contain:
|
46
|
-
"""
|
47
|
-
first> quit
|
48
|
-
"""
|
data/features/support/env.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
2
|
-
require 'aruba/cucumber'
|
3
|
-
require 'fileutils'
|
4
|
-
require 'rspec/expectations'
|
5
|
-
require 'bombshell'
|
6
|
-
|
7
|
-
Before do
|
8
|
-
@aruba_io_wait_seconds = 3
|
9
|
-
@dirs = [File.join(ENV['HOME'], 'bombshell_features')]
|
10
|
-
end
|