Skip to content
/ ecg Public

ERB(eRuby) based, simple and powerful configration file generator for general purpose.

License

Notifications You must be signed in to change notification settings

epaew/ecg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ecg

Gem Version Build Status Maintainability Test Coverage

ecg is an ERB(eRuby) based, simple and powerful configration file generator for general purpose.

Requirements

Ruby: 2.5 or higher

Install

gem install ecg

Usage

See also ecg --help

Simple example

ecg --values name=epaew --values email="[email protected]" < template.json.erb
{
  "type": "user",
  "name": "epaew",
  "email": "[email protected]"
}

or

ecg config.yml < template.json.erb
{
  "type": "user",
  "name": "epaew",
  "email": "[email protected]"
}

with

  • template.json.erb
    {
      "type": "user",
      "name": "<%= name %>",
      "email": "<%= email %>"
    }
  • config.yml
    name: epaew
    email: [email protected]

Using nested keys

ecg --values user.name=epaew --values user.email="[email protected]" < template.json.erb
{
  "user": {
    "name": "epaew",
    "email": "[email protected]"
  }
}

or

ecg config.yml < template.json.erb
{
  "user": {
    "name": "epaew",
    "email": "[email protected]"
  }
}

with

  • template.json.erb
    {
      "user": {
        "name": "<%= user.name %>",
        "email": "<%= user.email %>"
      }
    }
  • config.yml
    user:
      name: epaew
      email: [email protected]

Using array (JSON and YAML only)

ecg config.yml < template.json.erb
{
  "user": [
    {
      "name": "Kurimu"
    },
    {
      "name": "Chizuru"
    },
    {
      "name": "Minatsu"
    },
    {
      "name": "Mahuyu"
    }
  ]
}

with

  • template.json.erb
    {
      "user": [
    <% users.each_with_index do |user, i| %>
        {
          "name": "<%= user.name %>"
    <% unless i == users.count - 1 %>
        },
    <% else %>
        }
    <% end %>
    <% end %>
      ]
    }
  • config.yml
    users:
      - name: Kurimu
      - name: Chizuru
      - name: Minatsu
      - name: Mahuyu

License

MIT

About

ERB(eRuby) based, simple and powerful configration file generator for general purpose.

Topics

Resources

License

Stars

Watchers

Forks

Languages