Module: FileUtils

Defined in:
toplevel/lib/sumi/binaries/rake.rb

Overview

Extends FileUtils with Sumi script helpers for Rake tasks.

Instance Method Summary collapse

Instance Method Details

#sumi(file, *args, **kwargs) ⇒ Sumi::Executor::Result

Thin DSL wrapper to call a script without spawning a shell.

The script receives positional arguments through ARGA and keyword arguments through ARGH.

Examples:

Run a Sumi script from a Rake task

sumi "drawings/card", "front", theme: :dark

Parameters:

  • file (String) —

    Sumi script file, with or without .sumi extension

  • args (Array) —

    positional arguments exposed to the script as ARGA

  • kwargs (Hash) —

    keyword arguments exposed to the script as ARGH

Returns:

Raises:

See Also:



21
22
23
24
25
26
27
28
29
30
31
32
# File 'toplevel/lib/sumi/binaries/rake.rb', line 21

def sumi(file, *args, **kwargs)
  result = Sumi::Executor.__send__(:execute_file, Sumi::F.existing!(file, [Sumi::EXTENSION])) do
    extend(Sumi)

    const_set(:ARGA, args).freeze
    const_set(:ARGH, kwargs).freeze
  end

  raise result.error if result.error?

  result
end