Module: TTK::Loaders

Includes:
TTKModule
Defined in:
lib/ttk/loaders/Loader.rb,
lib/ttk.rb,
lib/ttk/loaders/Yaml.rb

Overview

TTK::Loaders are design to help you to make tests.

The ‘testify’ method is here to provide a usefull way to convert anything to a test.

For example Hash#testify instanciate a test from a hash:

doc = {
  :strategy => Cmd,
  :command  => 'echo -n foo',
  :output   => 'foo',
  :symtbl   => SYMTBL
}

test = doc.testify
test.run

You can also load a test from a string, an io or a file. In this case the format can change (YAML, XML…). To manage this you can use TTK::Loaders to add new loader easily.

To implement a loader you just need to subclass the abstract loader (TTK::Loaders::Loader), and implement the ‘load’ method.

The ‘load’ method take an IO as argument and return something which can be testified.

Defined Under Namespace

Classes: Loader, Yaml

Class Method Summary collapse

Methods included from TTKModule

included

Class Method Details

.get_class(aClassName) ⇒ Object

Raises:

  • (NameError)


38
39
40
41
42
43
# File 'lib/ttk/loaders/Loader.rb', line 38

def self.get_class ( aClassName )
  return aClassName if aClassName.is_a? Class
  aClassName = "TTK::Strategies::#{aClassName}" unless aClassName =~ /::/
  return eval(aClassName) if aClassName =~ /[\w:]+/
  raise NameError, "not a valid class name #{aClassName}"
end