tuvi 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.DS_Store +0 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +27 -0
- data/LICENSE.txt +22 -0
- data/README.md +21 -0
- data/Rakefile +6 -0
- data/example.rb +26 -0
- data/lib/.DS_Store +0 -0
- data/lib/tuvi.rb +25 -0
- data/lib/tuvi/step.rb +27 -0
- data/lib/tuvi/version.rb +3 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/tuvi/step_spec.rb +15 -0
- data/spec/tuvi_spec.rb +49 -0
- data/tuvi.gemspec +24 -0
- metadata +113 -0
data/.DS_Store
ADDED
Binary file
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
tuvi (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.2.4)
|
10
|
+
rake (10.1.0)
|
11
|
+
rspec (2.14.1)
|
12
|
+
rspec-core (~> 2.14.0)
|
13
|
+
rspec-expectations (~> 2.14.0)
|
14
|
+
rspec-mocks (~> 2.14.0)
|
15
|
+
rspec-core (2.14.5)
|
16
|
+
rspec-expectations (2.14.2)
|
17
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
18
|
+
rspec-mocks (2.14.3)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
bundler (~> 1.3)
|
25
|
+
rake
|
26
|
+
rspec
|
27
|
+
tuvi!
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Jay Wengrow
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# Tuvi
|
2
|
+
|
3
|
+
Tuvi is a computer language for kids to create text-based games and applications. It is a Ruby DSL which supplies a declarative format which dictates the flow of the program as a series of steps.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install Tuvi simply with:
|
8
|
+
|
9
|
+
$ gem install tuvi
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
Coming Soon!
|
14
|
+
|
15
|
+
## Contributing
|
16
|
+
|
17
|
+
1. Fork it
|
18
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
19
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
20
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
21
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/example.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative 'lib/tuvi.rb'
|
2
|
+
|
3
|
+
class Example
|
4
|
+
|
5
|
+
extend Tuvi
|
6
|
+
|
7
|
+
step 1 do
|
8
|
+
message "This is Step 1. Type yes to go to Step 2. Type no to go to Step 3."
|
9
|
+
answer "Yes", 2
|
10
|
+
answer "No", 3
|
11
|
+
end
|
12
|
+
|
13
|
+
step 2 do
|
14
|
+
message "This is Step 2. Type hi to go to Step 3. Type bye to go to step 1."
|
15
|
+
answer "Hi", 3
|
16
|
+
answer "Bye", 1
|
17
|
+
end
|
18
|
+
|
19
|
+
step 3 do
|
20
|
+
message "You've reached the end!"
|
21
|
+
stop
|
22
|
+
end
|
23
|
+
|
24
|
+
run
|
25
|
+
|
26
|
+
end
|
data/lib/.DS_Store
ADDED
Binary file
|
data/lib/tuvi.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative "tuvi/version"
|
2
|
+
require_relative "tuvi/step"
|
3
|
+
|
4
|
+
module Tuvi
|
5
|
+
|
6
|
+
def step(position, &block)
|
7
|
+
@steps ||= {}
|
8
|
+
@steps[position] = Step.new(position, &block)
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
current_step = 1
|
13
|
+
while true do
|
14
|
+
puts @steps[current_step].get_message
|
15
|
+
exit if @steps[current_step].exit_program
|
16
|
+
input = gets.downcase.chomp
|
17
|
+
if @steps[current_step].answer_paths[input]
|
18
|
+
current_step = @steps[current_step].answer_paths[input]
|
19
|
+
else
|
20
|
+
puts "Sorry, I don't understand that answer. Please try again:"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/lib/tuvi/step.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
class Step
|
2
|
+
|
3
|
+
attr_accessor :position, :answer_paths, :exit_program
|
4
|
+
|
5
|
+
def initialize(position, &block)
|
6
|
+
@position = position
|
7
|
+
@answer_paths = {}
|
8
|
+
instance_eval(&block) if block_given?
|
9
|
+
end
|
10
|
+
|
11
|
+
def message(text)
|
12
|
+
@message = text
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_message
|
16
|
+
@message
|
17
|
+
end
|
18
|
+
|
19
|
+
def answer(input, step_number)
|
20
|
+
@answer_paths[input.downcase] = step_number
|
21
|
+
end
|
22
|
+
|
23
|
+
def stop
|
24
|
+
@exit_program = true
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
data/lib/tuvi/version.rb
ADDED
data/spec/spec_helper.rb
ADDED
data/spec/tuvi_spec.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Tuvi do
|
4
|
+
|
5
|
+
class Program
|
6
|
+
include Tuvi
|
7
|
+
end
|
8
|
+
|
9
|
+
before(:each) do
|
10
|
+
@program = Program.new
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "The Tuvi language helper methods" do
|
14
|
+
|
15
|
+
describe "step" do
|
16
|
+
|
17
|
+
it "should return a new step" do
|
18
|
+
@program.step(1)
|
19
|
+
@program.instance_eval{@steps[1]}.class.should == Step
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should assign number parameter to step's position" do
|
23
|
+
@program.step(1)
|
24
|
+
@program.instance_eval{@steps[1]}.position.should == 1
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should assign a message based on message passed in block" do
|
28
|
+
@program.step(1){message "Hello!"}
|
29
|
+
@program.instance_eval{@steps[1]}.get_message.should == "Hello!"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should assign answer paths based on answers passed in block" do
|
33
|
+
@program.step(1){answer "yes", 2}
|
34
|
+
@program.instance_eval{@steps[1]}.answer_paths["yes"].should == 2
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should mark a step as exit_program if 'stop' is passed in block" do
|
38
|
+
@program.step(1){stop}
|
39
|
+
@program.instance_eval{@steps[1]}.exit_program.should be_true
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "run" do
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
data/tuvi.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'tuvi/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "tuvi"
|
8
|
+
spec.version = Tuvi::VERSION
|
9
|
+
spec.authors = ["Jay Wengrow"]
|
10
|
+
spec.email = ["jaywngrw@gmail.com"]
|
11
|
+
spec.description = %q{Tuvi is a computer language for kids to create text-based games and applications.}
|
12
|
+
spec.summary = %q{Tuvi is a Ruby DSL which supplies a declarative format which dictates the flow of the program as a series of steps.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tuvi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jay Wengrow
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-08-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
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: '0'
|
62
|
+
description: Tuvi is a computer language for kids to create text-based games and applications.
|
63
|
+
email:
|
64
|
+
- jaywngrw@gmail.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .DS_Store
|
70
|
+
- Gemfile
|
71
|
+
- Gemfile.lock
|
72
|
+
- LICENSE.txt
|
73
|
+
- README.md
|
74
|
+
- Rakefile
|
75
|
+
- example.rb
|
76
|
+
- lib/.DS_Store
|
77
|
+
- lib/tuvi.rb
|
78
|
+
- lib/tuvi/step.rb
|
79
|
+
- lib/tuvi/version.rb
|
80
|
+
- spec/spec_helper.rb
|
81
|
+
- spec/tuvi/step_spec.rb
|
82
|
+
- spec/tuvi_spec.rb
|
83
|
+
- tuvi.gemspec
|
84
|
+
homepage: ''
|
85
|
+
licenses:
|
86
|
+
- MIT
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 1.8.25
|
106
|
+
signing_key:
|
107
|
+
specification_version: 3
|
108
|
+
summary: Tuvi is a Ruby DSL which supplies a declarative format which dictates the
|
109
|
+
flow of the program as a series of steps.
|
110
|
+
test_files:
|
111
|
+
- spec/spec_helper.rb
|
112
|
+
- spec/tuvi/step_spec.rb
|
113
|
+
- spec/tuvi_spec.rb
|