{"id":31722834,"url":"https://github.com/phantom-node/grub-lexer","last_synced_at":"2025-10-09T04:19:45.313Z","repository":{"id":202653138,"uuid":"694586748","full_name":"phantom-node/grub-lexer","owner":"phantom-node","description":"Convert Grub boot loader configuration into tokens that can be fed into the parser.","archived":false,"fork":false,"pushed_at":"2025-04-07T17:09:57.000Z","size":69,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-21T14:19:13.299Z","etag":null,"topics":["grub","grub2","lexer","ruby"],"latest_commit_sha":null,"homepage":"https://phantomno.de/grub-lexer","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/phantom-node.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2023-09-21T09:45:16.000Z","updated_at":"2025-04-07T17:10:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"0e679379-0562-4c50-bd3c-c1d84a2c32b1","html_url":"https://github.com/phantom-node/grub-lexer","commit_stats":null,"previous_names":["phantom-node/grub-lexer"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/phantom-node/grub-lexer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phantom-node%2Fgrub-lexer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phantom-node%2Fgrub-lexer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phantom-node%2Fgrub-lexer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phantom-node%2Fgrub-lexer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phantom-node","download_url":"https://codeload.github.com/phantom-node/grub-lexer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phantom-node%2Fgrub-lexer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278830182,"owners_count":26053249,"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","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["grub","grub2","lexer","ruby"],"created_at":"2025-10-09T04:19:44.202Z","updated_at":"2025-10-09T04:19:45.308Z","avatar_url":"https://github.com/phantom-node.png","language":"Ruby","readme":"# Grub::Lexer\n\n[![Gem Version](https://badge.fury.io/rb/grub-lexer.svg)](https://badge.fury.io/rb/grub-lexer)\n\nConvert Grub boot loader configuration into tokens that can be fed into the parser.\n\n## Installation\n\nInstall the gem and add to the application's Gemfile by executing:\n\n    bundle add grub-lexer\n\nIf bundler is not being used to manage dependencies, install the gem by executing:\n\n    gem install grub-lexer\n\n## Usage\n\n### Basic example\n\n    require \"grub/lexer\"\n    lexer = Grub::Lexer.new\n    lexer.parse \"sleep 1\"\n    lexer.next_token   # =\u003e [:WORD, \"sleep\"]\n    lexer.next_token   # =\u003e [:WORD, \"1\"]\n    lexer.next_token   # =\u003e nil\n\n### Loading configuration from file\n\n    require \"grub/lexer\"\n    lexer = Grub::Lexer.new\n    lexer.parse_file \"/boot/grub/grub.cfg\"\n\n### Variables expansion\n\n    require \"grub/lexer\"\n    expander = -\u003e(var) { var == :greeting ? \"hello\" : \"awesome\" }\n    lexer = Grub::Lexer.new expander\n    lexer.parse %{echo \"$greeting ${adjective} world!\"\\n}\n    lexer.next_token   # =\u003e [:WORD, \"echo\"]\n    lexer.next_token   # =\u003e [:WORD, \"hello awesome world!\"]\n    lexer.next_token   # =\u003e [:SEPARATOR, \"\\n\"]\n\n### Variables detection and per-call expanders\n\n    require \"grub/lexer\"\n    lexer = Grub::Lexer.new -\u003e(_) { \"same\" }\n    lexer.parse '$var1 text \"$var2 text\"'\n    token = lexer.next_token                 # =\u003e [:WORD, \"same\"]\n    token[1].expandable?                     # =\u003e true\n    token = lexer.next_token                 # =\u003e [:WORD, \"text\"]\n    token[1].expandable?                     # =\u003e false\n    token = lexer.next_token                 # =\u003e [:WORD, \"same text\"]\n    token[1].to_s(-\u003e(v) { v.to_s.upcase })   # =\u003e \"VAR2 text\"\n\n## Limitations\n\nOnly Grub 2 is supported. Grub Legacy may work, but hasn't been tested.\n\nThe gem doesn't support Grub translations.\nI18n strings (`$\"translation key\"`) are treated like normal strings in double quotes.\n\nOnly subset of metacharacters are recognized as distinct token types.\nHowever, implementation of missing metacharacter types is trivial.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake spec` to run\nthe 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\nthe version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for\nthe version, push git commits and the created tag, 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 \u003chttps://github.com/phantom-node/grub-lexer\u003e. This project\nis intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to\nthe [code of conduct](https://github.com/[USERNAME]/grub-lexer/blob/master/CODE_OF_CONDUCT.md).\n\n## Author\n\nMy name is Paweł Pokrywka and I'm the author of grub-lexer.\n\nIf you want to contact me or get to know me better, check out\n[my blog](https://www.pawelpokrywka.com).\n\nThank you for your interest in this project :)\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Grub project's codebases, issue trackers, chat rooms and mailing lists is expected to\nfollow the [code of conduct](https://github.com/[USERNAME]/grub-lexer/blob/master/CODE_OF_CONDUCT.md).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphantom-node%2Fgrub-lexer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphantom-node%2Fgrub-lexer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphantom-node%2Fgrub-lexer/lists"}