Sha256: 9f52ef11764252c4fee408c203ee58558c54b836541c8251a3215f1ae060a064

Contents?: true

Size: 861 Bytes

Versions: 1

Compression:

Stored size: 861 Bytes

Contents

= Ratch::Script

The Ratch::Script class is the context used for evaluating Ratch-based
batch files, aka shell scripts.

  require 'ratch/script'

In most every respect the Script class behaves like Ratch::Shell, except that
its initializer takes a file name to be evaluated.

Let's say we have a Ratch script called 'foo.ratch':

  #!/usr/bin/env ratch

  @test_message = "Hello World!"

We can load the script via Ratch::Script.new.

  script = Ratch::Script.new('foo.ratch')

The file name can be accessed from the script using #script_file.

  script.script_file.assert == 'foo.ratch'

To execute a script, use the `#execute!` method, or it's alias `#run!`.

  script.execute!

We can see that the script did indeed execute by plubming for the instance
variable it set.

  msg = script.instance_variable_get('@test_message')
  msg.assert == "Hello World!"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ratch-1.2.0 spec/02_script.rdoc