shellout 0.4 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.ruby-version +1 -0
- data/.travis.yml +2 -0
- data/CHANGES +5 -0
- data/Gemfile +2 -3
- data/README.md +56 -53
- data/Rakefile +8 -1
- data/example/bin/hunger.rb +67 -0
- data/example/features/order_a_pizza.feature +12 -0
- data/example/features/start_the_app.feature +11 -0
- data/example/features/step_definitions/hunger_steps.rb +71 -0
- data/example/features/support/env.rb +1 -0
- data/example/features/view_order.feature +14 -0
- data/lib/shellout/calendar.rb +6 -2
- data/lib/shellout/command_loop.rb +21 -0
- data/lib/shellout/date.rb +55 -0
- data/lib/shellout/date_query.rb +50 -0
- data/lib/shellout/menu.rb +4 -2
- data/lib/shellout/menu_query.rb +51 -0
- data/lib/shellout/paragraph.rb +31 -0
- data/lib/shellout/query.rb +31 -0
- data/lib/shellout/task.rb +41 -0
- data/lib/shellout/version.rb +1 -1
- data/shellout.gemspec +6 -3
- data/spec/shellout/calendar_spec.rb +30 -1
- data/spec/shellout/command_loop_spec.rb +9 -0
- data/spec/shellout/date_query_spec.rb +9 -0
- data/spec/shellout/date_spec.rb +87 -0
- data/spec/shellout/menu_query_spec.rb +39 -0
- data/spec/shellout/menu_spec.rb +29 -18
- data/spec/shellout/paragraph_spec.rb +39 -0
- data/spec/shellout/query_spec.rb +39 -0
- data/spec/shellout/task_spec.rb +43 -0
- metadata +121 -19
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'shellout/paragraph'
|
2
|
+
|
3
|
+
module Shellout
|
4
|
+
describe Paragraph do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@out = StringIO.new
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should leave short lines alone" do
|
11
|
+
Paragraph.new('A short paragraph').print(@out)
|
12
|
+
@out.string.should == "A short paragraph\n"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should wrap a long line" do
|
16
|
+
Paragraph.new('A really long paragraph containing nonsense, gibberish, and foobar').width(20).print(@out)
|
17
|
+
@out.string.should == <<EOT
|
18
|
+
A really long
|
19
|
+
paragraph containing
|
20
|
+
nonsense, gibberish,
|
21
|
+
and foobar
|
22
|
+
EOT
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should add padding in the left margin if specified" do
|
26
|
+
Paragraph.new('A really long paragraph containing nonsense, gibberish, and foobar').width(20).padding(2).print(@out)
|
27
|
+
@out.string.should == <<EOT
|
28
|
+
A really long
|
29
|
+
paragraph
|
30
|
+
containing
|
31
|
+
nonsense,
|
32
|
+
gibberish, and
|
33
|
+
foobar
|
34
|
+
EOT
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'shellout/query'
|
2
|
+
|
3
|
+
module Shellout
|
4
|
+
describe Query do
|
5
|
+
|
6
|
+
it "should show a nice prompt containing the given question" do
|
7
|
+
query = Query.new("what?")
|
8
|
+
io = double('io')
|
9
|
+
io.should_receive(:readline).with("\e[1mwhat?> \e[0m", true).and_return('')
|
10
|
+
query.io = io
|
11
|
+
query.call
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should show a nice prompt containing the given question and default" do
|
15
|
+
query = Query.new("what?", "what what?")
|
16
|
+
io = double('io')
|
17
|
+
io.should_receive(:readline).with("\e[1mwhat? [what what?]> \e[0m", true).and_return('')
|
18
|
+
query.io = io
|
19
|
+
query.call
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should return the default when an empty answer is given" do
|
23
|
+
query = Query.new("The Ultimate Answer to the Ultimate Question of Life, The Universe, and Everything", "42")
|
24
|
+
io = double('io')
|
25
|
+
io.should_receive(:readline).and_return("\n")
|
26
|
+
query.io = io
|
27
|
+
query.call.should == "42"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should return the answer given" do
|
31
|
+
query = Query.new("The Ultimate Answer to the Ultimate Question of Life, The Universe, and Everything")
|
32
|
+
io = double('io')
|
33
|
+
io.should_receive(:readline).and_return("42\n")
|
34
|
+
query.io = io
|
35
|
+
query.call.should == "42"
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'shellout/task'
|
2
|
+
require 'stringio'
|
3
|
+
|
4
|
+
module Shellout
|
5
|
+
describe Task do
|
6
|
+
|
7
|
+
it "should execute it's sub tasks" do
|
8
|
+
st1 = double('subtask1')
|
9
|
+
st2 = double('subtask2')
|
10
|
+
[st1, st2].each {|st| st.should_receive(:call)}
|
11
|
+
|
12
|
+
task = Task.new do |t|
|
13
|
+
t.step_one = st1
|
14
|
+
t.step_two = st2
|
15
|
+
end
|
16
|
+
task.call
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should call the on_call_done callback when all sub tasks are done executing" do
|
20
|
+
callback = double('callback')
|
21
|
+
callback.should_receive(:call)
|
22
|
+
t = Task.new
|
23
|
+
t.on_call_done = callback
|
24
|
+
t.call
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should allow formatted printing of sub task results" do
|
28
|
+
begin
|
29
|
+
$stdout = StringIO.new
|
30
|
+
task = Task.new do |t|
|
31
|
+
t.foo = ->{"Hello"}
|
32
|
+
t.bar = ->{"World!"}
|
33
|
+
t.printf("%{foo} %{bar}\n")
|
34
|
+
end
|
35
|
+
task.call
|
36
|
+
$stdout.string.should == "Hello World!\n"
|
37
|
+
ensure
|
38
|
+
$stdout = STDOUT
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shellout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.5'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,44 +9,107 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-12-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 2.14.1
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - '='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.14.1
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: guard
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
|
-
- -
|
35
|
+
- - '='
|
31
36
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
37
|
+
version: 1.8.2
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - '='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.8.2
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: guard-rspec
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
|
-
- -
|
51
|
+
- - '='
|
42
52
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
53
|
+
version: 3.0.2
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.0.2
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - '='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 10.1.0
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - '='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 10.1.0
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: cucumber
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - '='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.3.10
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - '='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.3.10
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: aruba
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - '='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 0.5.3
|
44
102
|
type: :development
|
45
103
|
prerelease: false
|
46
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - '='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 0.5.3
|
47
110
|
- !ruby/object:Gem::Dependency
|
48
111
|
name: rb-fsevent
|
49
|
-
requirement:
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
50
113
|
none: false
|
51
114
|
requirements:
|
52
115
|
- - ! '>='
|
@@ -54,10 +117,15 @@ dependencies:
|
|
54
117
|
version: '0'
|
55
118
|
type: :development
|
56
119
|
prerelease: false
|
57
|
-
version_requirements:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
58
126
|
- !ruby/object:Gem::Dependency
|
59
127
|
name: growl_notify
|
60
|
-
requirement:
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
61
129
|
none: false
|
62
130
|
requirements:
|
63
131
|
- - ! '>='
|
@@ -65,7 +133,12 @@ dependencies:
|
|
65
133
|
version: '0'
|
66
134
|
type: :development
|
67
135
|
prerelease: false
|
68
|
-
version_requirements:
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
69
142
|
description: Contains classes for printing tables and boxes
|
70
143
|
email:
|
71
144
|
- kjellm@acm.org
|
@@ -74,22 +147,44 @@ extensions: []
|
|
74
147
|
extra_rdoc_files: []
|
75
148
|
files:
|
76
149
|
- .gitignore
|
150
|
+
- .ruby-version
|
151
|
+
- .travis.yml
|
77
152
|
- CHANGES
|
78
153
|
- Gemfile
|
79
154
|
- Guardfile
|
80
155
|
- README.md
|
81
156
|
- Rakefile
|
157
|
+
- example/bin/hunger.rb
|
158
|
+
- example/features/order_a_pizza.feature
|
159
|
+
- example/features/start_the_app.feature
|
160
|
+
- example/features/step_definitions/hunger_steps.rb
|
161
|
+
- example/features/support/env.rb
|
162
|
+
- example/features/view_order.feature
|
82
163
|
- lib/shellout.rb
|
83
164
|
- lib/shellout/calendar.rb
|
165
|
+
- lib/shellout/command_loop.rb
|
166
|
+
- lib/shellout/date.rb
|
167
|
+
- lib/shellout/date_query.rb
|
84
168
|
- lib/shellout/menu.rb
|
169
|
+
- lib/shellout/menu_query.rb
|
170
|
+
- lib/shellout/paragraph.rb
|
171
|
+
- lib/shellout/query.rb
|
85
172
|
- lib/shellout/shadowbox.rb
|
86
173
|
- lib/shellout/table.rb
|
174
|
+
- lib/shellout/task.rb
|
87
175
|
- lib/shellout/version.rb
|
88
176
|
- shellout.gemspec
|
89
177
|
- spec/shellout/calendar_spec.rb
|
178
|
+
- spec/shellout/command_loop_spec.rb
|
179
|
+
- spec/shellout/date_query_spec.rb
|
180
|
+
- spec/shellout/date_spec.rb
|
181
|
+
- spec/shellout/menu_query_spec.rb
|
90
182
|
- spec/shellout/menu_spec.rb
|
183
|
+
- spec/shellout/paragraph_spec.rb
|
184
|
+
- spec/shellout/query_spec.rb
|
91
185
|
- spec/shellout/shadowbox_spec.rb
|
92
186
|
- spec/shellout/table_spec.rb
|
187
|
+
- spec/shellout/task_spec.rb
|
93
188
|
homepage: https://github.com/kjellm/shellout
|
94
189
|
licenses:
|
95
190
|
- MIT
|
@@ -111,12 +206,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
206
|
version: '0'
|
112
207
|
requirements: []
|
113
208
|
rubyforge_project:
|
114
|
-
rubygems_version: 1.8.
|
209
|
+
rubygems_version: 1.8.25
|
115
210
|
signing_key:
|
116
211
|
specification_version: 3
|
117
212
|
summary: Tools for writing terminal interfaces
|
118
213
|
test_files:
|
119
214
|
- spec/shellout/calendar_spec.rb
|
215
|
+
- spec/shellout/command_loop_spec.rb
|
216
|
+
- spec/shellout/date_query_spec.rb
|
217
|
+
- spec/shellout/date_spec.rb
|
218
|
+
- spec/shellout/menu_query_spec.rb
|
120
219
|
- spec/shellout/menu_spec.rb
|
220
|
+
- spec/shellout/paragraph_spec.rb
|
221
|
+
- spec/shellout/query_spec.rb
|
121
222
|
- spec/shellout/shadowbox_spec.rb
|
122
223
|
- spec/shellout/table_spec.rb
|
224
|
+
- spec/shellout/task_spec.rb
|