lib/tryouts.rb in tryouts-0.4.1 vs lib/tryouts.rb in tryouts-0.5.0
- old
+ new
@@ -28,11 +28,11 @@
class Exception < RuntimeError; end
# = BadDreams
# Raised when there is a problem loading or parsing a Tryouts::Drill::Dream object
class BadDreams < Exception; end
- VERSION = "0.4.1"
+ VERSION = "0.5.0"
require 'tryouts/mixins'
require 'tryouts/tryout'
require 'tryouts/drill'
@@ -117,11 +117,10 @@
# NOTE: this is a standalone DSL-syntax method.
def self.command(*args)
@@instances.last.command(*args)
end
-
# Require +name+. If +path+ is supplied, it will "require path".
# * +name+ The name of the library in question (required). Stored as a Symbol to +@library+.
# * +path+ Add a path to the front of $LOAD_PATH (optional). Use this if you want to load
# a specific copy of the library. Otherwise, it loads from the system path.
def library(name=nil, path=nil)
@@ -163,10 +162,13 @@
# NOTE: This is a DSL-only method and is not intended for OO use.
def tryout(name, dtype=nil, command=nil, &block)
return if name.nil?
dtype ||= @dtype
command ||= @command if dtype == :cli
+
+ raise "No drill type specified for #{name}." if dtype.nil?
+
to = find_tryout(name, dtype)
if to.nil?
to = Tryouts::Tryout.new(name, dtype, command)
@tryouts[name] = to
end
@@ -259,10 +261,23 @@
# Call the Tryouts#dreams instance method
@@instances.last.dreams(*args, &block)
end
end
+ # Returns +@tryouts+.
+ #
+ # Also acts as a stub for Tryouts#tryout in case someone
+ # specifies "tryouts 'name' do ..." in the DSL.
+ def tryouts(*args, &block)
+ return tryout(*args, &block) unless args.empty?
+ @tryouts
+ end
+ # An alias for Tryouts.tryout.
+ def self.tryouts(*args, &block)
+ tryout(args, &block)
+ end
+
# +name+ of the Drill associated to this Dream
# +output+ A String or Array of expected output. A Dream object will be created using this value (optional)
# +definition+ is a block which will be run on an instance of Dream
#
# This method is different than Tryout#dream because this one stores
@@ -292,9 +307,18 @@
#
# NOTE: this is a standalone DSL-syntax method.
def self.dream(*args, &block)
@@instances.last.dream(*args, &block)
end
+
+ # This method does nothing. It provides a quick way to disable a dream.
+ #
+ # NOTE: This is a DSL-only method and is not intended for OO use.
+ def xdream(*args, &block); end
+ # This method does nothing. It provides a quick way to disable a dream.
+ #
+ # NOTE: this is a standalone DSL-syntax method.
+ def self.xdream(*args, &block); end
# Populate @@dreams with the content of the file +dpath+.
#
# NOTE: this is an OO syntax method
def load_dreams_file(dpath)