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 CHANGED
Binary file
data/.gitignore CHANGED
@@ -1,2 +1,18 @@
1
- /pkg
2
- Gemfile.lock
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .DS_Store
data/lib/tuvi/step.rb CHANGED
@@ -26,7 +26,7 @@ class Step
26
26
  end
27
27
 
28
28
  def formatted_answers
29
- "You can type one of the following: [#{@answer_paths.keys.join(", ")}]"
29
+ "You can type one of the following: [#{@answer_paths.keys.join(", ")}] Enter 'exit' to quit."
30
30
  end
31
31
 
32
32
  def code(&block)
data/lib/tuvi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tuvi
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
data/lib/tuvi.rb CHANGED
@@ -10,32 +10,33 @@ module Tuvi
10
10
  end
11
11
 
12
12
  def run
13
- current_step = 1
13
+ current_step_position = 1
14
14
  while true do
15
- current_step = execute_step(current_step)
15
+ current_step_position = execute_step(current_step_position)
16
16
  end
17
17
  end
18
18
 
19
- def execute_step(current_step)
20
- @steps[current_step].code_blocks.each do |block|
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 @steps[current_step].get_message
24
- exit if @steps[current_step].exit_program
25
- puts @steps[current_step].formatted_answers
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 @steps[current_step].answer_paths[input]
33
- next_step = @steps[current_step].answer_paths[input]
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
- next_step = current_step
37
+ next_step_position = current_step.position
37
38
  end
38
- next_step
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.determine_next_step(1, "yes").should == 2
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.determine_next_step(1, "blah").should == 1
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.6
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: 213786611821158706
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: 213786611821158706
108
+ hash: -2407453219098423058
109
109
  requirements: []
110
110
  rubyforge_project:
111
111
  rubygems_version: 1.8.25