diff --git a/recipes/mojo-yaml/image.png b/recipes/mojo-yaml/image.png new file mode 100644 index 00000000..a6fd3a7b Binary files /dev/null and b/recipes/mojo-yaml/image.png differ diff --git a/recipes/mojo-yaml/recipe.yaml b/recipes/mojo-yaml/recipe.yaml new file mode 100644 index 00000000..7856a1b6 --- /dev/null +++ b/recipes/mojo-yaml/recipe.yaml @@ -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 diff --git a/recipes/mojo-yaml/test_package.mojo b/recipes/mojo-yaml/test_package.mojo new file mode 100644 index 00000000..835cb60a --- /dev/null +++ b/recipes/mojo-yaml/test_package.mojo @@ -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")