{"id":19120145,"url":"https://github.com/tcd/ginny","last_synced_at":"2025-06-17T04:06:30.004Z","repository":{"id":56874191,"uuid":"221750044","full_name":"tcd/ginny","owner":"tcd","description":"🏗️ Generate ruby code","archived":false,"fork":false,"pushed_at":"2020-07-28T04:55:03.000Z","size":107,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-22T12:42:32.455Z","etag":null,"topics":["automation","code-generation","ruby","yard"],"latest_commit_sha":null,"homepage":"","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/tcd.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-14T17:18:19.000Z","updated_at":"2020-12-28T14:23:09.000Z","dependencies_parsed_at":"2022-08-20T10:11:06.102Z","dependency_job_id":null,"html_url":"https://github.com/tcd/ginny","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/tcd/ginny","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcd%2Fginny","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcd%2Fginny/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcd%2Fginny/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcd%2Fginny/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tcd","download_url":"https://codeload.github.com/tcd/ginny/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcd%2Fginny/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260288471,"owners_count":22986667,"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":["automation","code-generation","ruby","yard"],"created_at":"2024-11-09T05:12:56.744Z","updated_at":"2025-06-17T04:06:29.976Z","avatar_url":"https://github.com/tcd.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ginny\n\n[![Gem](https://img.shields.io/gem/v/ginny)][rubygems]\n[![Build Status](https://travis-ci.org/tcd/ginny.svg?branch=master)][travis-ci]\n[![Coverage Status](https://coveralls.io/repos/github/tcd/ginny/badge.svg?branch=master)][coveralls-ci]\n[![Documentation](http://img.shields.io/badge/docs-rubydoc.info-blue.svg)][rubydoc-gem]\n[![GitHub](https://img.shields.io/github/license/tcd/ginny)][license]\n\n[rubygems]: https://rubygems.org/gems/ginny\n[travis-ci]: https://travis-ci.org/tcd/ginny\n[coveralls-ci]: https://coveralls.io/github/tcd/ginny?branch=master\n[rubydoc-gem]: https://www.rubydoc.info/gems/ginny/0.6.3\n[license]: https://github.com/tcd/ginny/blob/master/LICENSE.txt\n\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem \"ginny\"\n```\n\nAnd then execute:\n\n```ruby\nbundle\n```\n\nOr install it yourself as:\n\n```ruby\ngem install ginny\n```\n\n## Usage\n\n### From the command line\n\n```yaml\n# person.yml\n---\nname: Human\ndescription: This class models a person.\nmodules: [MilkyWay, Earth]\nparent: Mammal\ndefault_constructor: true\nattrs:\n- name: Name\n  type: String\n- name: Age\n  description: Number of years the human has been alive.\n  type: Integer\n  read_only: true\n```\n\n```shell\n$ ginny person.yml\n```\n\n### From Ruby code\n\n```ruby\nrequire \"ginny\"\n\ndata = {\n  name: \"Human\",\n  description: \"This class models a person.\",\n  modules: [\"MilkyWay\", \"Earth\"],\n  parent: \"Mammal\",\n  default_constructor: true,\n  attrs: [\n    { name: \"name\", type: \"String\" },\n    { name: \"age\",  type: \"Integer\" read_only: true, description: \"Number of years the human has been alive.\" },\n  ],\n}\n\nc = Ginny::Class.create(data)\nc.render()   #=\u003e Returns the generated code as a string.\nc.generate() #=\u003e Writes the generated code to a given folder, or the current directory if no argument is passed.\n```\n\n```ruby\n# human.rb\nmodule MilkyWay\n  module Earth\n    # This class models a person.\n    class Human \u003c Mammal\n      # @return [String]\n      attr_accessor :name\n      # Number of years the human has been alive.\n      # @return [Integer]\n      attr_reader :age\n\n      # @param params [Hash]\n      # @return [self]\n      def self.create(params = {})\n        h = Human.new\n        h.name = params[:name]\n        h.age = params[:age]\n        return h\n      end\n    end\n  end\nend\n```\n\n## Supported Arguments\n\n### `Ginny::Class`\n\n|        Name         |         Type         |                                                                                         Description                                                                                          |\n| ------------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| name (required)     | `String`             | Name of the class.                                                                                                                                                                           |\n| description         | `String`             | Description of the class. [Markdown][markdown] is supported.                                                                                                                                 |\n| body                | `String`             | String to write into the body of the class.                                                                                                                                                  |\n| parent              | `String`             | Name of a class to inherit from. (Ex: `YourNewClass \u003c Parent`)                                                                                                                               |\n| modules             | `Array\u003cString\u003e`      | List of modules to declare the class inside of                                                                                                                                               |\n| default_constructor | `Boolean`            | If `true`, a method similar to [ActiveRecord::Base.create][create_method_link] will be generated for the class.                                                                              |\n| attrs               | `Array\u003cGinny::Attr\u003e` | An array of instance attributes.                                                                                                                                                             |\n| classify_name       | `Boolean`            | By default, names are *classified* using [Dry::Inflector#classify](https://github.com/dry-rb/dry-inflector#usage). Set this to `false` to disable *classification* and use raw `name` input. |\n\n[create_method_link]: https://apidock.com/rails/ActiveRecord/Persistence/ClassMethods/create \n\n### `Ginny::Attr`\n\n|      Name       |   Type    |                                                       Description                                                        |\n| --------------- | --------- | ------------------------------------------------------------------------------------------------------------------------ |\n| name (required) | `String`  | Name of the attribute.                                                                                                   |\n| description     | `String`  | Description of the attribute. [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) is supported. |\n| type            | `String`  | [Type](https://rubydoc.info/gems/yard/file/docs/GettingStarted.md#Declaring_Types) of the attribute.                     |\n| default         | `Any`     | Default value for the attribute; set in it's Class's `initialize` function.                                              |\n| read_only       | `Boolean` | If `true`, an `attr_reader` will be generated for the attribute instead of an `attr_accessor`.                           |\n\n### `Ginny::Func`\n\n|      Name       |         Type          |                                                Description                                                 |\n| --------------- | --------------------- | ---------------------------------------------------------------------------------------------------------- |\n| name (required) | `String`              | Name of the function.                                                                                      |\n| description     | `String`              | Description of the function. [Markdown][markdown] is supported.                                            |\n| return_type     | `String`              | Return [type](https://rubydoc.info/gems/yard/file/docs/GettingStarted.md#Declaring_Types) of the function. |\n| body            | `String`              | String to write into the body of the function.                                                             |\n| modules         | `Array\u003cString\u003e`       | List of modules to declare the function inside of                                                          |\n| params          | `Array\u003cGinny::Param\u003e` | An array of Params.                                                                                        |\n\n### `Ginny::Param`\n\n|      Name       |   Type    |                                                     Description                                                      |\n| --------------- | --------- | -------------------------------------------------------------------------------------------------------------------- |\n| name (required) | `String`  | Name of the param.                                                                                                   |\n| description     | `String`  | Description of the param. [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) is supported. |\n| type            | `String`  | [Type](https://rubydoc.info/gems/yard/file/docs/GettingStarted.md#Declaring_Types) of the param.                     |\n| default         | `Any`     | Default value for the param. Set `optional` as `true` for a default `nil` value.                                     |\n| optional        | `Boolean` | If `true`, the default value will be `nil`.                                                                          |\n| keyword         | `Boolean` | If `true`, the param will be generated as a [keyword argument](https://bugs.ruby-lang.org/issues/14183).             |\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/tcd/ginny.\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%2Ftcd%2Fginny","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftcd%2Fginny","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftcd%2Fginny/lists"}