Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/epaew/ecg
ERB(eRuby) based, simple and powerful configration file generator for general purpose.
https://github.com/epaew/ecg
configration erb eruby json yaml
Last synced: about 1 month ago
JSON representation
ERB(eRuby) based, simple and powerful configration file generator for general purpose.
- Host: GitHub
- URL: https://github.com/epaew/ecg
- Owner: epaew
- License: mit
- Created: 2019-10-18T14:50:13.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-04-29T21:22:07.000Z (over 3 years ago)
- Last Synced: 2024-11-11T03:23:45.228Z (about 1 month ago)
- Topics: configration, erb, eruby, json, yaml
- Language: Ruby
- Homepage:
- Size: 47.9 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ecg
[![Gem Version](https://badge.fury.io/rb/ecg.svg)](https://badge.fury.io/rb/ecg)
[![Build Status](https://github.com/epaew/ecg/workflows/Run%20TestUnit/badge.svg)](https://github.com/epaew/ecg/actions?query=workflow%3A%22Run+TestUnit%22+branch%3A%22master%22)
[![Maintainability](https://api.codeclimate.com/v1/badges/a043130a95580dc41610/maintainability)](https://codeclimate.com/github/epaew/ecg/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/a043130a95580dc41610/test_coverage)](https://codeclimate.com/github/epaew/ecg/test_coverage)ecg is an ERB(eRuby) based, simple and powerful configration file generator for general purpose.
## Requirements
Ruby: 2.5 or higher## Install
```sh
gem install ecg
```## Usage
See also `ecg --help`### Simple example
```sh
ecg --values name=epaew --values email="[email protected]" < template.json.erb
{
"type": "user",
"name": "epaew",
"email": "[email protected]"
}
```
or
```sh
ecg config.yml < template.json.erb
{
"type": "user",
"name": "epaew",
"email": "[email protected]"
}
```
with
* template.json.erb
```json
{
"type": "user",
"name": "<%= name %>",
"email": "<%= email %>"
}
```
* config.yml
```yaml
name: epaew
email: [email protected]
```### Using nested keys
```sh
ecg --values user.name=epaew --values user.email="[email protected]" < template.json.erb
{
"user": {
"name": "epaew",
"email": "[email protected]"
}
}
```
or
```sh
ecg config.yml < template.json.erb
{
"user": {
"name": "epaew",
"email": "[email protected]"
}
}
```
with
* template.json.erb
```json
{
"user": {
"name": "<%= user.name %>",
"email": "<%= user.email %>"
}
}
```
* config.yml
```yaml
user:
name: epaew
email: [email protected]
```### Using array (JSON and YAML only)
```sh
ecg config.yml < template.json.erb
{
"user": [
{
"name": "Kurimu"
},
{
"name": "Chizuru"
},
{
"name": "Minatsu"
},
{
"name": "Mahuyu"
}
]
}
```
with
* template.json.erb
```json
{
"user": [
<% users.each_with_index do |user, i| %>
{
"name": "<%= user.name %>"
<% unless i == users.count - 1 %>
},
<% else %>
}
<% end %>
<% end %>
]
}
```
* config.yml
```yaml
users:
- name: Kurimu
- name: Chizuru
- name: Minatsu
- name: Mahuyu
```## License
[MIT](LICENSE)