tuvi 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.DS_Store +0 -0
- data/.gitignore +18 -2
- data/lib/tuvi/step.rb +1 -1
- data/lib/tuvi/version.rb +1 -1
- data/lib/tuvi.rb +12 -11
- data/spec/tuvi_spec.rb +4 -2
- metadata +3 -3
data/.DS_Store
CHANGED
Binary file
|
data/.gitignore
CHANGED
data/lib/tuvi/step.rb
CHANGED
data/lib/tuvi/version.rb
CHANGED
data/lib/tuvi.rb
CHANGED
@@ -10,32 +10,33 @@ module Tuvi
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def run
|
13
|
-
|
13
|
+
current_step_position = 1
|
14
14
|
while true do
|
15
|
-
|
15
|
+
current_step_position = execute_step(current_step_position)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
def execute_step(
|
20
|
-
@steps[
|
19
|
+
def execute_step(step_position)
|
20
|
+
current_step = @steps[step_position]
|
21
|
+
current_step.code_blocks.each do |block|
|
21
22
|
block.call
|
22
23
|
end
|
23
|
-
puts
|
24
|
-
exit if
|
25
|
-
puts
|
24
|
+
puts current_step.get_message
|
25
|
+
exit if current_step.exit_program
|
26
|
+
puts current_step.formatted_answers
|
26
27
|
input = gets.downcase.chomp
|
27
28
|
exit_program if input == "exit"
|
28
29
|
determine_next_step(current_step, input)
|
29
30
|
end
|
30
31
|
|
31
32
|
def determine_next_step(current_step, input)
|
32
|
-
if
|
33
|
-
|
33
|
+
if current_step.answer_paths[input]
|
34
|
+
next_step_position = current_step.answer_paths[input]
|
34
35
|
else
|
35
36
|
puts "Sorry, I don't understand that answer. Please try again:"
|
36
|
-
|
37
|
+
next_step_position = current_step.position
|
37
38
|
end
|
38
|
-
|
39
|
+
next_step_position
|
39
40
|
end
|
40
41
|
|
41
42
|
def exit_program
|
data/spec/tuvi_spec.rb
CHANGED
@@ -44,12 +44,14 @@ describe Tuvi do
|
|
44
44
|
|
45
45
|
it "should determine the next step based on answer paths" do
|
46
46
|
@program.step(1){answer "yes", 2}
|
47
|
-
@program.
|
47
|
+
current_step = @program.instance_eval{@steps[1]}
|
48
|
+
@program.determine_next_step(current_step, "yes").should == 2
|
48
49
|
end
|
49
50
|
|
50
51
|
it "should set the next step to be the current step if input is invalid" do
|
51
52
|
@program.step(1){answer "yes", 2}
|
52
|
-
@program.
|
53
|
+
current_step = @program.instance_eval{@steps[1]}
|
54
|
+
@program.determine_next_step(current_step, "blah").should == 1
|
53
55
|
end
|
54
56
|
|
55
57
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tuvi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -96,7 +96,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
96
96
|
version: '0'
|
97
97
|
segments:
|
98
98
|
- 0
|
99
|
-
hash:
|
99
|
+
hash: -2407453219098423058
|
100
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
101
|
none: false
|
102
102
|
requirements:
|
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
version: '0'
|
106
106
|
segments:
|
107
107
|
- 0
|
108
|
-
hash:
|
108
|
+
hash: -2407453219098423058
|
109
109
|
requirements: []
|
110
110
|
rubyforge_project:
|
111
111
|
rubygems_version: 1.8.25
|