{"id":27057911,"url":"https://github.com/mrange/carnelian","last_synced_at":"2025-04-05T11:34:00.866Z","repository":{"id":16861865,"uuid":"19622031","full_name":"mrange/carnelian","owner":"mrange","description":"A code generator tool written in ruby","archived":false,"fork":false,"pushed_at":"2017-09-29T20:32:12.000Z","size":38,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T02:09:04.830Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrange.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"License.html","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-09T18:57:41.000Z","updated_at":"2020-02-13T21:08:37.000Z","dependencies_parsed_at":"2022-09-24T10:44:25.335Z","dependency_job_id":null,"html_url":"https://github.com/mrange/carnelian","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrange%2Fcarnelian","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrange%2Fcarnelian/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrange%2Fcarnelian/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrange%2Fcarnelian/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrange","download_url":"https://codeload.github.com/mrange/carnelian/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247332060,"owners_count":20921849,"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":[],"created_at":"2025-04-05T11:33:59.861Z","updated_at":"2025-04-05T11:34:00.852Z","avatar_url":"https://github.com/mrange.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"carnelian - a ruby code generator tool\n======================================\n\n\"Become what you are... a meta programmer\"\n\nCarnelian is inspired by T4 (http://en.wikipedia.org/wiki/Text_Template_Transformation_Toolkit)\n\nCarnelian wants to be\n  1. Simple\n  2. Agnostic\n  3. Powerful\n  4. Lightweight\n  5. Free\n\nBy simple we mean that Carnelian should be understandable by almost anyone.\n\nBy agnostic we mean that Carnelian should be able to generate code for any text-based\n\nBy powerful we mean that Carnelian should be able to solve a big class of problems\n\nBy lightweight we mean that Carnelian should be able to execute from the command-line without the need of an IDE\n\nBy free we mean that Carnelian should be free to use and abuse with no strings attached\n\nUsing Carnelian\n---------------\n\nCarnelian is a ruby gem that requires ruby/1.9.3+\n```\ngem install --user carnelian\n```\n\nA silly example\n----------------\n\nCreate a file named `silly.mp` containing:\n```\n@@@ metaprogram\n@@@ extension cs\nclass SomeClass\n{\n@@\u003e for iter in 0..10\n    public int X@@=iter=@@ {get; set; }\n@@\u003e end\n}\n```\nThen create a file named `run.rb` containing:\n```\nrequire 'carnelian/executor'\n\nCarnelianExecutor.execute_metaprogram_to_file \"silly.mp\"\n```\n\nExecute the carnelian meta program by executing in a shell `ruby run.rb`\n\nThis will produce a file named `silly.cs` containing\n```\nclass SomeClass\n{\n    public int X0 {get; set; }\n    public int X1 {get; set; }\n    public int X2 {get; set; }\n    public int X3 {get; set; }\n    public int X4 {get; set; }\n    public int X5 {get; set; }\n    public int X6 {get; set; }\n    public int X7 {get; set; }\n    public int X8 {get; set; }\n    public int X9 {get; set; }\n    public int X10 {get; set; }\n}\n```\n\nAlthough simple silly as Carnelian is based on ruby it can generate code from XML, Database schemas, JSON giving the user power and flexibility.\n\nWe have used T4 and Carnelian to generate: TSQL, C#, C++, Java, XML\n\nFor more interesting samples see: https://github.com/mrange/carnelian/tree/master/src/samples/csharp\n\nAvailable Carnelian tags\n\n  1. `@@@` - Preprocessor tag, used to affect the code generation behavior\n  2. `@@\u003e` - Template tag, used to write template code\n  3. `@@+` - Code tag, used to write code outside the main template loop. Useful for creating support functions/classes\n  4. `@@=ruby_expression=@@` - Inject tag, used to inject the `ruby_expression` into the output text\n\nAvailable Carnelian preprocessor tags\n\n  1. `@@@ metaprogram` - The first line in a valid Carnelian meta program \n  2. `@@@ require ruby_package` - Adds `require 'ruby_package'` to the meta program\n  3. `@@@ extension cs` - The extension of the generated file (can be overriden)\n  4. `@@@ include meta_program.mp` - Includes a Carnelian meta program, similar to require in ruby\n  5. `@@@ inject_tokens begin end` - Advanced: Allows overriding of the inject tokens (default `@@=`, `=@@`), used id odd cases\n\nIf you happen to use sublime there's a carnelian sublime plugin: https://github.com/mrange/carnelian/tree/master/src/sublime\n\nBy the way - The Carnelian Gem is roughly 7 kib.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrange%2Fcarnelian","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrange%2Fcarnelian","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrange%2Fcarnelian/lists"}