{"id":18082676,"url":"https://github.com/kontena/yaml-safe_load_stream","last_synced_at":"2025-04-12T17:12:40.456Z","repository":{"id":48974486,"uuid":"162565766","full_name":"kontena/yaml-safe_load_stream","owner":"kontena","description":"Adds YAML.safe_load_stream to Ruby YAML","archived":false,"fork":false,"pushed_at":"2021-07-02T18:47:07.000Z","size":24,"stargazers_count":0,"open_issues_count":2,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-12T17:12:32.320Z","etag":null,"topics":["ruby","yaml"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kontena.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-20T10:45:04.000Z","updated_at":"2019-01-08T08:46:35.000Z","dependencies_parsed_at":"2022-08-27T19:51:33.967Z","dependency_job_id":null,"html_url":"https://github.com/kontena/yaml-safe_load_stream","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kontena%2Fyaml-safe_load_stream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kontena%2Fyaml-safe_load_stream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kontena%2Fyaml-safe_load_stream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kontena%2Fyaml-safe_load_stream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kontena","download_url":"https://codeload.github.com/kontena/yaml-safe_load_stream/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248602312,"owners_count":21131616,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ruby","yaml"],"created_at":"2024-10-31T14:05:32.703Z","updated_at":"2025-04-12T17:12:40.437Z","avatar_url":"https://github.com/kontena.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# YAMLSafeLoadStream\n[![Build Status](https://travis-ci.org/kontena/yaml-safe_load_stream.svg?branch=master)](https://travis-ci.org/kontena/yaml-safe_load_stream)\n[![Gem Version](https://badge.fury.io/rb/yaml-safe_load_stream.svg)](https://badge.fury.io/rb/yaml-safe_load_stream)\n[![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/github/kontena/yaml-safe_load_stream/master)\n\nThe Ruby standard library YAML/Psych module defines `YAML.safe_load` for safely loading YAML documents\n\nThere's also `YAML.load_stream` for loading multi-document streams.\n\nThe problem is, there's no `YAML.safe_load_stream` that would safely load a stream with multiple documents.\n\nThis gem adds a very bare bones implementation of that missing feature.\n\n## Usage\n\nThere is just one method: `safe_load_stream(yaml_content, optional_filename_to_be_used_in_exception_messages)`\n\nWhen used with a block, it will yield each document separately:\n\n```ruby\nYAMLSafeLoadStream.safe_load_stream(\"---\\nhello: world\\n\\n---\\nhello: universe\\n\") do |document|\n  puts document.inspect\nend\n\n# outputs:\n# { 'hello' =\u003e 'world' }\n# { 'hello' =\u003e 'universe' }\n```\n\nWhen used without a block, it will return an Array containing documents in the stream:\n\n```ruby\ndocs = YAMLSafeLoadStream.safe_load_stream(\"---\\nhello: world\\n\\n---\\nhello: universe\\n\")\nputs docs.inspect\n\n# outputs:\n# [{ 'hello' =\u003e 'world' }, { 'hello' =\u003e 'universe' }]\n```\n\n### Directly\n\n```ruby\nrequire 'yaml/safe_load_stream'\n\nYAMLSafeLoadStream.safe_load_stream(\"---\\nhello: world\\n\\n---\\nhello: universe\\n\")\n```\n\n### As a refinement\n\n```ruby\nrequire 'yaml/safe_load_stream'\nusing YAMLSafeLoadStream\n\nYAML.safe_load_stream(\"---\\nhello: world\\n\\n---\\nhello: universe\\n\")\n```\n\n### Requiring the `core-ext`\n\n```ruby\nrequire 'yaml/safe_load_stream/core-ext'\nYAML.safe_load_stream(\"---\\nhello: world\\n\\n---\\nhello: universe\\n\")\n```\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'yaml-safe_load_stream'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install yaml-safe_load_stream\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/kontena/yaml-safe_load_stream\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkontena%2Fyaml-safe_load_stream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkontena%2Fyaml-safe_load_stream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkontena%2Fyaml-safe_load_stream/lists"}