-
CLI is the class for option parsing, and the gateway to the program
+
CLI is the class for option parsing, and the gateway to the program, on the
+command line
@@ -186,50 +187,71 @@ editing/creating a tree.
-179
-180
-181
-182
-183
-184
-185
-186
-187
-188
-189
-190
-191
-192
-193
-194
-195
-196
-197
-198
-199
-200
-201
-202
-203
-204
-205
-206
-207
-208
-209
-210
-211
-212
-213
-214
-215
-216
-217
-218
-219
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
- # File 'lib/sapling.rb', line 179
+ # File 'lib/sapling.rb', line 21
def talk(options)
opt_parser = OptionParser.new do |opt|
@@ -245,29 +267,50 @@ editing/creating a tree.
"Begin traversing the provided dialogue tree") do
if ARGV.empty?
+ puts "No tree file provided. Please provide a tree file."
puts opt_parser
exit
end
- unless Gardner.verify_tree(ARGV[0])
+ unless verify_tree(ARGV[0])
puts "\n#{opt}\n"
exit
end
+ puts "Welcome to Sapling, a Dialogue Tree Utility.\n"
speaker = Dialogue::Speaker.new
- speaker.file = ARGV
+ speaker.file = YAML.load_file(ARGV[0])
speaker.conversation
end
opt.on("-e", "--edit",
"Create or edit a dialogue tree") do
- puts "We gonna make a tree!"
+
+ if ARGV.empty?
+ puts "Creating a new tree."
+ tree = SKELETON_TREE
+ else
+ puts "Using tree at #{ARGV[0]}."
+ unless verify_tree(ARGV[0])
+ puts "\n#{opt}\n"
+ exit
+ end
+ tree = YAML.load_file(ARGV[0])
+ end
+
+ puts "Welcome to Sapling, a Dialogue Tree Utility.\n"
+ gardner = Planter::Spade.new
+ gardner.file = tree
+ gardner.plant
end
end
- opt_parser.parse!(options)
- if ARGV.empty?
+ begin
+ opt_parser.parse!(options)
+ rescue OptionParser::InvalidOption
+ puts "Invalid option."
puts opt_parser
exit
end
@@ -282,7 +325,7 @@ editing/creating a tree.
diff --git a/doc/_index.html b/doc/_index.html
index 0ad8a13..86da46c 100644
--- a/doc/_index.html
+++ b/doc/_index.html
@@ -84,6 +84,8 @@
Namespace Listing A-Z
+
+
@@ -141,6 +143,13 @@
+
+ Plot
+
+ (Planter)
+
+
+
@@ -154,6 +163,13 @@
+
+ Spade
+
+ (Planter)
+
+
+
Speaker
@@ -173,7 +189,7 @@
diff --git a/doc/class_list.html b/doc/class_list.html
index 1fed642..4edf910 100644
--- a/doc/class_list.html
+++ b/doc/class_list.html
@@ -43,7 +43,7 @@
diff --git a/doc/file.CONTRIBUTING.html b/doc/file.CONTRIBUTING.html
index fb05c4f..9b7f6a2 100644
--- a/doc/file.CONTRIBUTING.html
+++ b/doc/file.CONTRIBUTING.html
@@ -74,7 +74,7 @@ feel free to submit an issue or reach out to me directly.
diff --git a/doc/file.LICENSE.html b/doc/file.LICENSE.html
index 75a1ae6..70625c3 100644
--- a/doc/file.LICENSE.html
+++ b/doc/file.LICENSE.html
@@ -82,7 +82,7 @@ DEALINGS IN THE SOFTWARE.
diff --git a/doc/file.README.html b/doc/file.README.html
index 4468c94..1ab7dc9 100644
--- a/doc/file.README.html
+++ b/doc/file.README.html
@@ -75,7 +75,7 @@ branch represents a choice taken in the dialogue. Branches flow to each other
through leafs, which are the actual choices.
You can experience this yourself, by loading "Example Quest! - A Meta Dialogue
-Tree!". You can find the tree itself at trees/example_quest.yaml. To run it, just type sapling -t
+Tree!". You can find the tree itself at trees/example_quest.yaml. To run it, just type sapling -t
trees/example_quest.yaml .
Building a New Tree
@@ -83,16 +83,17 @@ trees/example_quest.yaml.
To build a new tree, you have two options. You can manually edit a configuration
file, or go through the construction wizard. Either way, the end result is a
plain-text configuration file, which can be easily shared, edited, and viewed.
-For more details on the configuration file itself, check out the Configuration
- File documentation, or the self-documented configuration
- file example. Alternatively, you can checkout
-Example Quest for a complete treel
+For more details on the configuration file itself, check out the Configuration
+File documentation, or the self-documented
+configuration file example. Alternatively,
+you can checkout Example Quest for a complete
+tree.
Manual Edit
- Open your preferred text editor.
-- Refer to the Configuration File documentation
+- Refer to the Configuration File documentation
- Make your changes.
- Save your changes.
@@ -109,7 +110,7 @@ trunk, and show you the first branch.
Save your changes.
-More details on the editor can be found in the Editor
+More details on the editor can be found in the Editor
documentation.
Contributing
@@ -131,7 +132,7 @@ guidelines.
diff --git a/doc/file.config_file.html b/doc/file.config_file.html
index 12013e7..03a9d92 100644
--- a/doc/file.config_file.html
+++ b/doc/file.config_file.html
@@ -126,7 +126,7 @@ branch", and the program will end after reaching it.
diff --git a/doc/file.config_file_example.html b/doc/file.config_file_example.html
index 3a46390..9374e60 100644
--- a/doc/file.config_file_example.html
+++ b/doc/file.config_file_example.html
@@ -100,7 +100,7 @@
diff --git a/doc/file.editor.html b/doc/file.editor.html
index 3a42c19..f2263ab 100644
--- a/doc/file.editor.html
+++ b/doc/file.editor.html
@@ -72,7 +72,7 @@ allows for editing all parts of a tree, from the trunk to the leaves.
diff --git a/doc/index.html b/doc/index.html
index 6476ee2..5348f78 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -75,7 +75,7 @@ branch represents a choice taken in the dialogue. Branches flow to each other
through leafs, which are the actual choices.
You can experience this yourself, by loading "Example Quest! - A Meta Dialogue
-Tree!". You can find the tree itself at trees/example_quest.yaml. To run it, just type sapling -t
+Tree!". You can find the tree itself at trees/example_quest.yaml. To run it, just type sapling -t
trees/example_quest.yaml .
Building a New Tree
@@ -83,16 +83,17 @@ trees/example_quest.yaml.
To build a new tree, you have two options. You can manually edit a configuration
file, or go through the construction wizard. Either way, the end result is a
plain-text configuration file, which can be easily shared, edited, and viewed.
-For more details on the configuration file itself, check out the Configuration
- File documentation, or the self-documented configuration
- file example. Alternatively, you can checkout
-Example Quest for a complete treel
+For more details on the configuration file itself, check out the Configuration
+File documentation, or the self-documented
+configuration file example. Alternatively,
+you can checkout Example Quest for a complete
+tree.
Manual Edit
- Open your preferred text editor.
-- Refer to the Configuration File documentation
+- Refer to the Configuration File documentation
- Make your changes.
- Save your changes.
@@ -109,7 +110,7 @@ trunk, and show you the first branch.
Save your changes.
-More details on the editor can be found in the Editor
+More details on the editor can be found in the Editor
documentation.
Contributing
@@ -131,7 +132,7 @@ guidelines.
diff --git a/doc/method_list.html b/doc/method_list.html
index b23b782..a22cb7c 100644
--- a/doc/method_list.html
+++ b/doc/method_list.html
@@ -45,6 +45,14 @@
+
+
+
+
+
#conversation
Dialogue::Speaker
@@ -52,6 +60,46 @@
+
+
+ #debug
+ Dialogue::Speaker
+
+
+
+
+
+
+ #dig
+ Planter::Spade
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#file
@@ -78,15 +126,15 @@
@@ -94,7 +142,7 @@
@@ -102,8 +150,8 @@
@@ -118,8 +166,32 @@
+
+
+
+
+
+ #tree
+ Planter::Plot
+
+
+
+
+
+
+
+
+
+
+
diff --git a/doc/top-level-namespace.html b/doc/top-level-namespace.html
index 33af615..3eae178 100644
--- a/doc/top-level-namespace.html
+++ b/doc/top-level-namespace.html
@@ -89,6 +89,91 @@
+ Constant Summary
+
+
+ - SKELE_TRUNK_TEXT =
+
+
+
+ The default trunk text of a new tree
+
+
+
+
+
+
+
+
+
+ "Welcome to the Sapling Editor. For details, please see the
+documentation!"
+
+ - SKELE_BRANCH_TEXT =
+
+
+
+ The default first-branch text of a new tree
+
+
+
+
+
+
+
+
+
+ "The first branch is always shown by default. It should act
+as the introduction to the story. From here, the user enters your world!"
+
+ - SKELE_LEAF_TEXT =
+
+
+
+ The default first-leaf text of the first branch of a new tree. The leaf
+points to it's own branch. The only way out of the program is to either
+force-quit or reply with option 0.
+
+
+
+
+
+
+
+
+
+ "Each branch can have any number of leaves, which represent
+the options a user has on that branch. Each leaf points to another branch, or
+can point to branch 0 to immediately exit."
+
+ - SKELETON_TREE =
+
+
+
+
+
+
+ [
+ {"trunk" => "#{SKELE_TRUNK_TEXT}"},
+ {"branch" => {
+ "number" => 1,
+ "text" => "#{SKELE_BRANCH_TEXT}",
+ "leaf" => [{
+ "text" => "#{SKELE_LEAF_TEXT}",
+ "branch" => 1
+ }]
+ }
+ }
+]
+
+
@@ -96,11 +181,160 @@
+
+
+ Instance Method Summary
+ collapse
+
+
+
+
+
+
+
+
+ Instance Method Details
+
+
+
+
+
+ #verify_tree(file) ⇒ Boolean
+
+
+
+
+
+
+
+
+ Verify that a file is a dialogue tree file.
+
+
+
+
+
+
+
+
+
+
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+ |
+
+ # File 'lib/sapling/utility.rb', line 43
+
+def verify_tree(file)
+ results = []
+ begin
+ tree = YAML.load_file(file)
+ results << tree[0].keys.include?("trunk")
+ results << tree[1]["branch"].keys.include?("number")
+ results << tree[1]["branch"].keys.include?("text")
+ results << tree[1]["branch"].keys.include?("leaf")
+ rescue
+ puts "Sorry chummer, I don't think this is a tree."
+ puts "Verify your YAML file is formatted properly."
+ results << false
+ end
+
+ results.include?(false) ? false : true
+
+end
+ |
+
+
+
+
+
|