Search documentation of Metastatic

# Metastatic.Adapters.Ruby.Subprocess (Metastatic v0.13.2)

View Source

Subprocess management for Ruby parser and unparser.

Handles communication with Ruby scripts via stdin/stdout with JSON serialization.

## Summary

### Functions

parse(source)

Parse Ruby source code to AST JSON.

unparse(ast)

Unparse AST JSON back to Ruby source code.

## Functions

# parse(source)

    @spec parse(String.t()) :: {:ok, map()} | {:error, String.t()}

Parse Ruby source code to AST JSON.

## Examples

    iex> Metastatic.Adapters.Ruby.Subprocess.parse("x = 42")
    {:ok, %{"type" => "lvasgn", "children" => [...]}}

    iex> Metastatic.Adapters.Ruby.Subprocess.parse("x = ")
    {:error, "SyntaxError: ..."}

# unparse(ast)

    @spec unparse(map()) :: {:ok, String.t()} | {:error, String.t()}

Unparse AST JSON back to Ruby source code.

## Examples

    iex> ast = %{"type" => "lvasgn", "children" => [...]}
    iex> Metastatic.Adapters.Ruby.Subprocess.unparse(ast)
    {:ok, "x = 42"}