Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added recipes/mojo-yaml/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions recipes/mojo-yaml/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
context:
version: 0.1.2
mojo_version: "=0.26.1"

package:
name: mojo-yaml
version: ${{ version }}

source:
git: https://github.com/DataBooth/mojo-yaml.git
tag: v0.1.2

build:
number: 0
script:
- mkdir -p $PREFIX/lib/mojo/yaml
- cp -r src/yaml/* $PREFIX/lib/mojo/yaml/

requirements:
build:
- mojo-compiler ${{ mojo_version }}
host:
- mojo-compiler ${{ mojo_version }}
run:
- ${{ pin_compatible('mojo-compiler') }}

tests:
- script:
- test -f $PREFIX/lib/mojo/yaml/__init__.mojo
- test -f $PREFIX/lib/mojo/yaml/parser.mojo
- test -f $PREFIX/lib/mojo/yaml/lexer.mojo
- test -f $PREFIX/lib/mojo/yaml/value.mojo

about:
homepage: https://github.com/DataBooth/mojo-yaml
license: Apache-2.0
license_file: LICENSE
summary: YAML Lite parser for Mojo - Native, zero-dependency YAML reader
description: |
mojo-yaml is a YAML Lite parser covering ~80% of common YAML patterns,
providing native YAML configuration file parsing in Mojo with zero Python dependencies.

Features:
- Nested mappings and sequences (any depth)
- Inline list-mappings (- name: value\\n key2: value2)
- All scalar types (int, float, bool, null, string)
- Comments anywhere in files
- Mixed structures (lists in dicts, dicts in lists)
- Type-safe value access (as_string(), as_int(), as_bool())
- 91/91 tests passing (100% test coverage)
- Works with real configuration files (pre-commit, custom YAMLs)
- Performance: 9-21x faster than Python's pyyaml

Limitations:
- Multi-word strings require quotes
- Flow-style syntax not supported (use block style)
- Reader-only in v0.1.x (writer planned for future)

Perfect for configuration files, CI/CD pipelines, and any Mojo application
needing YAML configuration support.
documentation: https://github.com/DataBooth/mojo-yaml/blob/main/README.md
repository: https://github.com/DataBooth/mojo-yaml

extra:
recipe-maintainers:
- mjboothaus
46 changes: 46 additions & 0 deletions recipes/mojo-yaml/test_package.mojo
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""Test that mojo-yaml package is installed and functional."""

from yaml import parse

fn main() raises:
# Test basic YAML parsing
var yaml_str = """
name: test
count: 42
enabled: true
items:
- first
- second
config:
host: localhost
port: 8080
"""

# Parse YAML - should not crash
var data = parse(yaml_str)

# Validate basic access
var name = data.get("name").as_string()
if name != "test":
raise Error("Name parsing failed")

var count = data.get("count").as_int()
if count != 42:
raise Error("Integer parsing failed")

var enabled = data.get("enabled").as_bool()
if not enabled:
raise Error("Boolean parsing failed")

# Test nested mapping
var config = data.get("config")
var host = config.get("host").as_string()
if host != "localhost":
raise Error("Nested mapping failed")

# Test sequence
var items = data.get("items")
if len(items.sequence_value) != 2:
raise Error("Sequence parsing failed")

print("✓ All tests passed")