{"id":22588294,"url":"https://github.com/danini-the-panini/kdl-rb","last_synced_at":"2025-04-09T11:10:30.065Z","repository":{"id":45266054,"uuid":"324450108","full_name":"danini-the-panini/kdl-rb","owner":"danini-the-panini","description":"Ruby implementation of the KDL language","archived":false,"fork":false,"pushed_at":"2025-02-25T13:11:26.000Z","size":288,"stargazers_count":28,"open_issues_count":3,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T09:07:08.281Z","etag":null,"topics":["gem","kdl","ruby"],"latest_commit_sha":null,"homepage":"https://kdl.dev","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danini-the-panini.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-25T23:41:03.000Z","updated_at":"2025-03-06T13:51:40.000Z","dependencies_parsed_at":"2024-04-08T09:28:18.405Z","dependency_job_id":"f68bf935-74f0-4f1f-9af2-541e481a4114","html_url":"https://github.com/danini-the-panini/kdl-rb","commit_stats":{"total_commits":111,"total_committers":3,"mean_commits":37.0,"dds":0.3513513513513513,"last_synced_commit":"daaedf0e5b35fd5affc4ef8ea99c5b15dc576dd7"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danini-the-panini%2Fkdl-rb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danini-the-panini%2Fkdl-rb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danini-the-panini%2Fkdl-rb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danini-the-panini%2Fkdl-rb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danini-the-panini","download_url":"https://codeload.github.com/danini-the-panini/kdl-rb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248027407,"owners_count":21035594,"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":["gem","kdl","ruby"],"created_at":"2024-12-08T08:09:03.356Z","updated_at":"2025-04-09T11:10:30.026Z","avatar_url":"https://github.com/danini-the-panini.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KDL\n\n[![Gem Version](https://badge.fury.io/rb/kdl.svg)](https://badge.fury.io/rb/kdl)\n[![Actions Status](https://github.com/danini-the-panini/kdl-rb/workflows/Ruby/badge.svg)](https://github.com/danini-the-panini/kdl-rb/actions)\n[![Coverage Status](https://coveralls.io/repos/github/danini-the-panini/kdl-rb/badge.svg?branch=main)](https://coveralls.io/github/danini-the-panini/kdl-rb?branch=main)\n\nThis is a Ruby implementation of the [KDL Document Language](https://kdl.dev)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'kdl'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install kdl\n\n## Usage\n\n```ruby\nrequire 'kdl'\n\nKDL.parse(a_string) #=\u003e KDL::Document\nKDL.load_file('path/to/file') #=\u003e KDL::Document\n```\n\nYou can optionally provide your own type annotation handlers:\n\n```ruby\nclass Foo \u003c KDL::Value::Custom\nend\n\nKDL.parse(a_string, type_parsers: {\n  'foo' =\u003e Foo\n})\n```\n\nThe `foo` custom type will be called with instances of Value or Node with the type annotation `(foo)`.\n\nCustom types are expected to have a `call` method that takes the Value or Node, and the type annotation itself, as arguments, and is expected to return either an instance of `KDL::Value::Custom` or `KDL::Node::Custom` (depending on the input type) or `nil` to return the original value as is. Take a look at [the built in custom types](lib/kdl/types) as a reference.\n\nYou can also disable type annotation parsing entirely (including the built in ones):\n\n```ruby\nKDL.parse(a_string, parse_types: false)\n```\n\n## KDL v1\n\nkdl-rb maintains backwards compatibility with the KDL v1 spec. By default, KDL will attempt to parse a file with the v1 parser if it fails to parse with v2. This behaviour can be changed by specifying the `version` option:\n\n```ruby\nKDL.parse(a_string, version: 2)\n```\n\nThe resulting document will also serialize back to the same version it was parsed as. For example, if you parse a v2 document and call `to_s` on it, it will output a v2 document, and similarly with v1. This behaviour can be changed by specifying the `output_version` option:\n\n```ruby\nKDL.parse(a_string, output_version: 2)\n```\n\nThis allows you to to convert documents between versions:\n\n```ruby\nKDL.parse('foo \"bar\" true', version: 1, output_version: 2).to_s #=\u003e 'foo bar #true'\n```\n\nYou can also convert an already parsed document between versions with `to_v1` and `to_v2`:\n\n```ruby\ndoc = KDL.parse('foo \"bar\" true', version: 1)\ndoc.version #=\u003e 1\ndoc.to_v2.to_s #=\u003e 'foo bar #true'\n```\n\nYou can also set the default version globally:\n\n```ruby\nKDL.default_version = 2\nKDL.default_output_version = 2\n```\n\nYou can still force automatic version detection with `auto_parse`:\n\n```ruby\nKDL.default_version = 2\nKDL.parse('foo \"bar\" true') #=\u003e Error\nKDL.auto_parse('foo \"bar\" true') #=\u003e KDL::V1::Document\n```\n\nVersion directives are also respected:\n\n```ruby\nKDL.parse(\"/- kdl-version 2\\nfoo bar\", version: 1)\n#=\u003e Version mismatch, document specified v2, but this is a v1 parser (Racc::ParseError)\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/danini-the-panini/kdl-rb.\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanini-the-panini%2Fkdl-rb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanini-the-panini%2Fkdl-rb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanini-the-panini%2Fkdl-rb/lists"}