{"id":17244832,"url":"https://github.com/ujihisa/static_literal_parser","last_synced_at":"2025-04-14T04:09:10.837Z","repository":{"id":56896752,"uuid":"302777512","full_name":"ujihisa/static_literal_parser","owner":"ujihisa","description":"Parse a Ruby string like '{a: [1, X], b: \"hello\"}' without eval. You don't call eval so it's safe.","archived":false,"fork":false,"pushed_at":"2025-04-14T04:06:54.000Z","size":18,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-14T04:08:50.472Z","etag":null,"topics":["gplv3","hacktoberfest","parser-library","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ujihisa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-09T23:58:11.000Z","updated_at":"2025-04-14T04:06:57.000Z","dependencies_parsed_at":"2022-08-21T01:20:39.957Z","dependency_job_id":null,"html_url":"https://github.com/ujihisa/static_literal_parser","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ujihisa%2Fstatic_literal_parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ujihisa%2Fstatic_literal_parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ujihisa%2Fstatic_literal_parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ujihisa%2Fstatic_literal_parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ujihisa","download_url":"https://codeload.github.com/ujihisa/static_literal_parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248819405,"owners_count":21166477,"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":["gplv3","hacktoberfest","parser-library","ruby"],"created_at":"2024-10-15T06:27:40.806Z","updated_at":"2025-04-14T04:09:10.831Z","avatar_url":"https://github.com/ujihisa.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Static Literal Parser for Ruby\n\n```ruby\n# data.txt\n{\n  name: 'ujihisa',\n  tags: ['ruby', 'vim'],\n  country: CANADA,\n  money: 10.02,\n}\n\n# main_code.rb\nrequire 'static_literal_parser'\nCANADA = ...\n\npp StaticLiteralParser.parse(\n  File.read('/tmp/data.txt'),\n  {CANADA: CANADA})\n#=\u003e {:name=\u003e\"ujihisa\", :tags=\u003e[\"ruby\", \"vim\"], :country=\u003e..., :money=\u003e10.02}\n```\n\nStaticLiteralParser is a RubyGems library that you can convert a String to a Ruby object, parsing the string as an executable Ruby code, but without actually executing it. This internally uses RubyVM::AbstractSyntaxTree to parse to construct the object.\n\n* This does not depend on any other libraries\n* This uses CRuby's `RubyVM::AbstractSyntaxTree` class\n    * This may not work with other Ruby implementations\n\n## API\n\n* `StaticLiteralParser.parse(str, constants)`\n    * Pass a String that can be parsed as Ruby code into str arg. Note that it\n      won't even try to execute anything, any dynamic things will end up raising\n      RuntimeError, such as \"#{1 + 2}\"\n    * Pass a Hash to constants arg. This hash is only used as constants to\n      lookup in the given str. Note that you must provide all the levels of\n      nested constants that you'd like to parse.\n\n## FAQ\n\n* Q. Why can't local variables, instance variables, or any other variables be passed like constants?\n    * A. Simply because the author had not found use cases for that yet. If there are use cases, let's add them.\n\n## Development\n\n```\nruby test/static_literal_parser_test.rb\n```\n\n## Author\n\nTatsuhiro Ujihisa\n\n## Licence\n\nStatic Literal Parser is released under the GPLv3 or any later versions.\nhttps://www.gnu.org/licenses/gpl-3.0.en.html\n\n## Changelog\n\n### 1.3.1\n\n* Support Ruby 3.4+ which uses Prism internally\n\n### 1.2.0\n\n* Support constants in Array as an alternative representation\n\n### 1.1.1\n\n* Support `nil`\n\n### 1.1.0\n\n* Support Ruby 2.6.6 or any later versions\n\n### 1.0.0\n\n* Initial release\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fujihisa%2Fstatic_literal_parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fujihisa%2Fstatic_literal_parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fujihisa%2Fstatic_literal_parser/lists"}