Skip to content

Commit

Permalink
Prep for 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tcd committed Nov 17, 2019
1 parent a3c4dcc commit da801af
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,8 @@

## master (unreleased)

## 0.2.0 (2019-11-17)

### Added

- Generate Functions with Yard doc comments. (`Ginny::Func`)
Expand Down
105 changes: 98 additions & 7 deletions README.md
@@ -1,19 +1,18 @@
# Ginny

[![Gem](https://img.shields.io/gem/v/ginny)](https://rubygems.org/gems/ginny)
[![Build Status](https://travis-ci.org/tcd/gql.svg?branch=master)](https://travis-ci.org/tcd/gql)
[![Coverage Status](https://coveralls.io/repos/github/tcd/ginny/badge.svg?branch=master)](https://coveralls.io/github/tcd/ginny?branch=master)
[![Documentation](http://img.shields.io/badge/docs-rubydoc.org-blue.svg)](https://rubydoc.org/github/tcd/ginny/master)
[![GitHub](https://img.shields.io/github/license/tcd/ginny)](https://github.com/tcd/ginny/blob/master/LICENSE.txt)

<!-- [![Inline docs](http://inch-ci.org/github/tcd/ginny.svg?branch=master&style=shields)](http://inch-ci.org/github/tcd/ginny)
[![Gem Version](https://badge.fury.io/rb/ginny.svg)](https://badge.fury.io/rb/ginny) -->
<!-- [![Inline docs](http://inch-ci.org/github/tcd/ginny.svg?branch=master&style=shields)](http://inch-ci.org/github/tcd/ginny) -->

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'ginny'
gem "ginny"
```

And then execute:
Expand All @@ -28,10 +27,102 @@ Or install it yourself as:
gem install ginny
```

## Development
## Usage

### From the command line

```yaml
# person.yml
---
name: Human
description: "This class models a person."
attrs:
- name: Name
type: String
- name: Age
description: Number of years the human has been alive.
type: Integer
read_only: true
```

```shell
$ ginny person.yml
```

### From Ruby code

```ruby
require "ginny"

data = {
name: "Human",
description: "This class models a person.",
parent: "Mammal"
attrs: [
{ name: "name", type: "String" },
{ name: "age", type: "Integer" read_only: true, description: "Number of years the human has been alive." }
]
}

c = Ginny::Class.create(data)
c.render() #=> Returns the generated code as a string.
c.generate() #=> Writes the generated code to a given folder, or the current directory if no argument is passed.
```

```ruby
# human.rb

# This class models a person.
class Human < Mammal
# @return [String]
attr_accessor :name
# Number of years the human has been alive.
# @return [Integer]
attr_reader :age
end
```

## Supported Arguments

### Class (`Ginny::Class`)

| Name | Type | Description |
| ----------- | -------------------- | -------------------------------------------------------------- |
| name | `String` | Name of the class. |
| description | `String` | Description of the class. [Markdown][markdown] is supported. |
| parent | `String` | Name of a class to inherit from. (Ex: `YourNewClass < Parent`) |
| attrs | `Array<Ginny::Attr>` | An array of Attrs. |

### Attribute (`Ginny::Attr`)

| Name | Type | Description |
| ----------- | --------- | ------------------------------------------------------------------------------------------------------------------------ |
| name | `String` | Name of the attribute. |
| description | `String` | Description of the attribute. [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) is supported. |
| type | `String` | [Type](https://rubydoc.info/gems/yard/file/docs/GettingStarted.md#Declaring_Types) of the attribute. |
| default | `Any` | Default value for the attribute; set in it's Class's `initialize` function. |
| read_only | `Boolean` | If `true`, an `attr_reader` will be generated for the attribute instead of an `attr_accessor`. |

### Function (`Ginny::Func`)

| Name | Type | Description |
| ----------- | --------------------- | ---------------------------------------------------------------------------------------------------------- |
| name | `String` | Name of the function. |
| description | `String` | Description of the function. [Markdown][markdown] is supported. |
| return_type | `String` | Return [type](https://rubydoc.info/gems/yard/file/docs/GettingStarted.md#Declaring_Types) of the function. |
| body | `String` | |
| params | `Array<Ginny::Param>` | An array of Params. |

### Parameter (`Ginny::Param`)

After checking out the repo, run `bin/setup` to install dependencies.
Then, run `rake test` to run the tests.
| Name | Type | Description |
| ----------- | --------- | -------------------------------------------------------------------------------------------------------------------- |
| name | `String` | Name of the param. |
| description | `String` | Description of the param. [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) is supported. |
| type | `String` | [Type](https://rubydoc.info/gems/yard/file/docs/GettingStarted.md#Declaring_Types) of the param. |
| default | `Any` | Default value for the param. Set `optional` as `true` for a default `nil` value. |
| optional | `Boolean` | If `true`, the default value will be `nil`. |
| keyword | `Boolean` | If `true`, the param will be generated as a [keyword argument](https://bugs.ruby-lang.org/issues/14183). |

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion ginny.gemspec
Expand Up @@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
"allowed_push_host" => "TODO: Set to 'http://mygemserver.com'",
"homepage_uri" => spec.homepage,
"source_code_uri" => spec.homepage,
"changelog_uri" => spec.homepage,
"changelog_uri" => "https://github.com/tcd/ginny/blob/master/CHANGELOG.md",
"yard.run" => "yri", # use "yard" to build full HTML docs.
}

Expand Down

0 comments on commit da801af

Please sign in to comment.