guided_path 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rvmrc +52 -0
- data/Gemfile +18 -0
- data/Gemfile.lock +48 -0
- data/Guardfile +12 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/guided_path.gemspec +87 -0
- data/lib/guided_path/goto_node.rb +23 -0
- data/lib/guided_path/lead_in_node.rb +28 -0
- data/lib/guided_path/multimedia_node.rb +38 -0
- data/lib/guided_path/node.rb +33 -0
- data/lib/guided_path/parser/spec1.rb +206 -0
- data/lib/guided_path/program.rb +84 -0
- data/lib/guided_path/question_multiple_choice_node.rb +28 -0
- data/lib/guided_path/question_textbox_node.rb +31 -0
- data/lib/guided_path/script.rb +14 -0
- data/lib/guided_path/text_node.rb +26 -0
- data/lib/guided_path.rb +10 -0
- data/test/fixtures/spec1/empty_file.yml +0 -0
- data/test/fixtures/spec1/goto_jump_script_a.yml +7 -0
- data/test/fixtures/spec1/goto_jump_script_b.yml +6 -0
- data/test/fixtures/spec1/goto_node_jumps.yml +10 -0
- data/test/fixtures/spec1/goto_simple_jumps.yml +10 -0
- data/test/fixtures/spec1/image_captions.yml +10 -0
- data/test/fixtures/spec1/image_simple.yml +3 -0
- data/test/fixtures/spec1/leadin_multiple.yml +8 -0
- data/test/fixtures/spec1/multiple_simple.yml +5 -0
- data/test/fixtures/spec1/multiple_with_loops.yml +19 -0
- data/test/fixtures/spec1/multiple_with_sub_questions.yml +10 -0
- data/test/fixtures/spec1/sequences_three_textnodes.yml +7 -0
- data/test/fixtures/spec1/textbox_simple.yml +10 -0
- data/test/fixtures/spec1/textnode_simple_attribute_list.yml +3 -0
- data/test/fixtures/spec1/textnode_simple_hash.yml +1 -0
- data/test/fixtures/spec1/textnode_simple_string.yml +2 -0
- data/test/fixtures/spec1/yes_no_simple.yml +11 -0
- data/test/fixtures/spec1/youtube_captions.yml +10 -0
- data/test/fixtures/spec1/youtube_simple.yml +6 -0
- data/test/fixtures/test/a_fixture.yml +1 -0
- data/test/guided_path/parser/spec1/test_goto.rb +44 -0
- data/test/guided_path/parser/spec1/test_lead_in_nodes.rb +19 -0
- data/test/guided_path/parser/spec1/test_multimedia_nodes.rb +41 -0
- data/test/guided_path/parser/spec1/test_question_multiple.rb +37 -0
- data/test/guided_path/parser/spec1/test_question_textbox.rb +17 -0
- data/test/guided_path/parser/spec1/test_question_yes_no.rb +23 -0
- data/test/guided_path/parser/spec1/test_sequences.rb +22 -0
- data/test/guided_path/parser/spec1/test_text_nodes.rb +23 -0
- data/test/guided_path/program/test_program_output.rb +52 -0
- data/test/guided_path/program/test_program_script_handling.rb +29 -0
- data/test/guided_path/test_helper_functions.rb +16 -0
- data/test/guided_path/test_text_node.rb +26 -0
- data/test/helper.rb +32 -0
- metadata +280 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestProgramScriptHandling < MiniTest::Unit::TestCase
|
4
|
+
def test_scripts_required
|
5
|
+
# can't just pass in a script
|
6
|
+
assert_raises ArgumentError do
|
7
|
+
Program.new(:scripts => "test script")
|
8
|
+
end
|
9
|
+
|
10
|
+
# can't just pass in an empty hash
|
11
|
+
assert_raises ArgumentError do
|
12
|
+
Program.new(:scripts => {})
|
13
|
+
end
|
14
|
+
|
15
|
+
# can't pass in a hash of scripts without a starting script
|
16
|
+
assert_raises ArgumentError do
|
17
|
+
Program.new(scripts: {'test' => "testtextnode"})
|
18
|
+
end
|
19
|
+
|
20
|
+
# can't pass in a starting script that doesn't exist
|
21
|
+
assert_raises ArgumentError do
|
22
|
+
Program.new(scripts: {'test' => "testtextnode"}, starting_script: 'not_there')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestHelperFunctions < MiniTest::Unit::TestCase
|
4
|
+
|
5
|
+
def test_loading_fixtures
|
6
|
+
assert_kind_of String, load_fixture("test/a_fixture.yml")
|
7
|
+
assert_raises ArgumentError do
|
8
|
+
load_fixture("test/nonexistent_file.yml")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestTextNode < MiniTest::Unit::TestCase
|
4
|
+
def test_value_required
|
5
|
+
assert_raises ArgumentError do
|
6
|
+
TextNode.new()
|
7
|
+
end
|
8
|
+
|
9
|
+
# can't just send in a string
|
10
|
+
assert_raises ArgumentError do
|
11
|
+
TextNode.new("test")
|
12
|
+
end
|
13
|
+
|
14
|
+
# needs a value
|
15
|
+
assert_raises ArgumentError do
|
16
|
+
TextNode.new(section_title: 'Quiz: 2 of 4')
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
|
data/test/helper.rb
ADDED
@@ -0,0 +1,32 @@
|
|
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 'minitest/unit'
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
require 'guided_path'
|
15
|
+
|
16
|
+
|
17
|
+
class MiniTest::Unit::TestCase
|
18
|
+
include GuidedPath
|
19
|
+
|
20
|
+
def load_fixture(fixture_name)
|
21
|
+
filename = File.join(File.dirname(__FILE__), "fixtures", fixture_name)
|
22
|
+
raise(ArgumentError, "Fixture file #{filename} not found") unless File.exists?(filename)
|
23
|
+
File.open(filename, "rb").read
|
24
|
+
end
|
25
|
+
|
26
|
+
def assert_nodes_equal(program, nodes = {}, msg = nil)
|
27
|
+
program_nodes = program.nodes.values.inject(Hash.new(0)) {|h,i| h[i.class] += 1; h }
|
28
|
+
assert_equal(program_nodes, nodes, msg)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
MiniTest::Unit.autorun
|
metadata
ADDED
@@ -0,0 +1,280 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: guided_path
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- James
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-15 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activemodel
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: activesupport
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
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: guard
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
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
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: json
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: ruby_gntp
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rb-fsevent
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: minitest
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: guard-minitest
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :runtime
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: rdoc
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :runtime
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: bundler
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
type: :runtime
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: jeweler
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - ! '>='
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
type: :runtime
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
186
|
+
requirements:
|
187
|
+
- - ! '>='
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0'
|
190
|
+
description: Parser for making interactive exercises in a human readable DSL
|
191
|
+
email: github@jamesstuart.org
|
192
|
+
executables: []
|
193
|
+
extensions: []
|
194
|
+
extra_rdoc_files:
|
195
|
+
- LICENSE.txt
|
196
|
+
- README.rdoc
|
197
|
+
files:
|
198
|
+
- .document
|
199
|
+
- .rvmrc
|
200
|
+
- Gemfile
|
201
|
+
- Gemfile.lock
|
202
|
+
- Guardfile
|
203
|
+
- LICENSE.txt
|
204
|
+
- README.rdoc
|
205
|
+
- Rakefile
|
206
|
+
- VERSION
|
207
|
+
- guided_path.gemspec
|
208
|
+
- lib/guided_path.rb
|
209
|
+
- lib/guided_path/goto_node.rb
|
210
|
+
- lib/guided_path/lead_in_node.rb
|
211
|
+
- lib/guided_path/multimedia_node.rb
|
212
|
+
- lib/guided_path/node.rb
|
213
|
+
- lib/guided_path/parser/spec1.rb
|
214
|
+
- lib/guided_path/program.rb
|
215
|
+
- lib/guided_path/question_multiple_choice_node.rb
|
216
|
+
- lib/guided_path/question_textbox_node.rb
|
217
|
+
- lib/guided_path/script.rb
|
218
|
+
- lib/guided_path/text_node.rb
|
219
|
+
- test/fixtures/spec1/empty_file.yml
|
220
|
+
- test/fixtures/spec1/goto_jump_script_a.yml
|
221
|
+
- test/fixtures/spec1/goto_jump_script_b.yml
|
222
|
+
- test/fixtures/spec1/goto_node_jumps.yml
|
223
|
+
- test/fixtures/spec1/goto_simple_jumps.yml
|
224
|
+
- test/fixtures/spec1/image_captions.yml
|
225
|
+
- test/fixtures/spec1/image_simple.yml
|
226
|
+
- test/fixtures/spec1/leadin_multiple.yml
|
227
|
+
- test/fixtures/spec1/multiple_simple.yml
|
228
|
+
- test/fixtures/spec1/multiple_with_loops.yml
|
229
|
+
- test/fixtures/spec1/multiple_with_sub_questions.yml
|
230
|
+
- test/fixtures/spec1/sequences_three_textnodes.yml
|
231
|
+
- test/fixtures/spec1/textbox_simple.yml
|
232
|
+
- test/fixtures/spec1/textnode_simple_attribute_list.yml
|
233
|
+
- test/fixtures/spec1/textnode_simple_hash.yml
|
234
|
+
- test/fixtures/spec1/textnode_simple_string.yml
|
235
|
+
- test/fixtures/spec1/yes_no_simple.yml
|
236
|
+
- test/fixtures/spec1/youtube_captions.yml
|
237
|
+
- test/fixtures/spec1/youtube_simple.yml
|
238
|
+
- test/fixtures/test/a_fixture.yml
|
239
|
+
- test/guided_path/parser/spec1/test_goto.rb
|
240
|
+
- test/guided_path/parser/spec1/test_lead_in_nodes.rb
|
241
|
+
- test/guided_path/parser/spec1/test_multimedia_nodes.rb
|
242
|
+
- test/guided_path/parser/spec1/test_question_multiple.rb
|
243
|
+
- test/guided_path/parser/spec1/test_question_textbox.rb
|
244
|
+
- test/guided_path/parser/spec1/test_question_yes_no.rb
|
245
|
+
- test/guided_path/parser/spec1/test_sequences.rb
|
246
|
+
- test/guided_path/parser/spec1/test_text_nodes.rb
|
247
|
+
- test/guided_path/program/test_program_output.rb
|
248
|
+
- test/guided_path/program/test_program_script_handling.rb
|
249
|
+
- test/guided_path/test_helper_functions.rb
|
250
|
+
- test/guided_path/test_text_node.rb
|
251
|
+
- test/helper.rb
|
252
|
+
homepage: http://github.com/statisticalfool/guided_path
|
253
|
+
licenses:
|
254
|
+
- MIT
|
255
|
+
post_install_message:
|
256
|
+
rdoc_options: []
|
257
|
+
require_paths:
|
258
|
+
- lib
|
259
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
260
|
+
none: false
|
261
|
+
requirements:
|
262
|
+
- - ! '>='
|
263
|
+
- !ruby/object:Gem::Version
|
264
|
+
version: '0'
|
265
|
+
segments:
|
266
|
+
- 0
|
267
|
+
hash: -3149277032604404541
|
268
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
269
|
+
none: false
|
270
|
+
requirements:
|
271
|
+
- - ! '>='
|
272
|
+
- !ruby/object:Gem::Version
|
273
|
+
version: '0'
|
274
|
+
requirements: []
|
275
|
+
rubyforge_project:
|
276
|
+
rubygems_version: 1.8.24
|
277
|
+
signing_key:
|
278
|
+
specification_version: 3
|
279
|
+
summary: Parser for making interactive exercises in a human readable DSL
|
280
|
+
test_files: []
|