https://github.com/alexwayfer/gem_generator
Gem for new gems generation.
https://github.com/alexwayfer/gem_generator
Last synced: about 1 year ago
JSON representation
Gem for new gems generation.
- Host: GitHub
- URL: https://github.com/alexwayfer/gem_generator
- Owner: AlexWayfer
- License: mit
- Created: 2020-07-06T15:17:41.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2025-04-01T20:26:02.000Z (about 1 year ago)
- Last Synced: 2025-04-09T22:09:17.104Z (about 1 year ago)
- Language: Ruby
- Size: 179 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Gem Generator
[](https://cirrus-ci.com/github/AlexWayfer/gem_generator)
[](https://codecov.io/gh/AlexWayfer/gem_generator)
[](https://codeclimate.com/github/AlexWayfer/gem_generator)
[](LICENSE.txt)
[](https://rubygems.org/gems/gem_generator)
Gem for new gems generation.
It was created for myself, but you can suggest options for generation to adopt it for your usage.
## Installation
Install it globally:
```shell
gem install gem_generator
```
## Usage
### With local template
```sh
gem_generator --namespace=your_github_nickname name_of_a_new_gem path/to/template
```
### With GitHub template
```sh
gem_generator --namespace=your_github_nickname name_of_a_new_gem template_github_org/template_github_repo --git
```
Be aware: `gem_generator` uses `template/` directory from the GitHub repo, not the root one.
### Other options
`gem_generator` inherits [`project_generator`](https://github.com/AlexWayfer/project_generator),
so please check it's general options, like `--indentation`, or you can use `--help` at any moment.
### Config file
You can create a config file, `.gem_generator.yaml` (or `.yml`) like this:
```yaml
## This can be overwriten via `--namespace` CLI option, config just as default
:namespace: AlexWayfer
## These options have defaults from `git config --get user.*`
# :author:
# :name: Alexander Popov
# :email: alex.wayfer@gmail.com
```
Gem Generator will look for it in each directory from current to the root,
so the common place for it in the home directory, but you can redefine it,
for example, in some directory for work projects.
## Template creation
Example of gem template you can see at [AlexWayfer/gem_template](https://github.com/AlexWayfer/gem_template).
Available paths:
| Path part | Example of source | Example of result |
| ---------- | ----------------------------- | -------------------------------------- |
| `gem_name` | `gem_name.gemspec` | `faraday-my_middleware.gemspec` |
| `gem_path` | `lib/gem_path/version.rb.erb` | `lib/faraday/my_middleware/version.rb` |
Any `*.erb` file will be rendered via [ERB](https://ruby-doc.org/stdlib/libdoc/erb/rdoc/ERB.html);
if you want an `*.erb` file as result — name it as `*.erb.erb` (even if there are no tags).
Available variables:
| Variable | Example of result |
| ---------------------- | ---------------------------------------------------------- |
| `name` | `faraday-my_middleware` |
| `title` | `Faraday My Middleware` |
| `path` | `faraday/my_middleware` |
| `module_name` | `Faraday::MyMiddleware` |
| `modules` | `['Faraday', 'MyMiddleware']` |
| `version_constant` | `Faraday::MyMiddleware::VERSION` |
| `summary` | asked from user |
| `summary_string` | summary wrapped in `'` or `"`, depending on `'` inside |
| `description` | by default is `summary` with guaranteed dot at the end |
| `indentation` | `tabs` or `spaces`, as user specified by option |
| `github_path` | `AlexWayfer/faraday-my_middleware` |
| `github_namespace_uri` | `https://github.com/AlexWayfer` |
| `github_uri` | `https://github.com/AlexWayfer/faraday-my_middleware` |
| `author_name` | `Alexander Popov` |
| `author_name_string` | author name wrapped in `'` or `"`, depending on `'` inside |
| `author_email` | `alex.wayfer@gmail.com` |
By default indentation is `tabs`, but if a template spaces-indented — option will not affect.
So, this option only for tabs-indented templates.
### Git templates
You can create public git-templates and then guide users to call
`gem_generator gem_name your_org/your_repo --git`, but be aware that `gem_generator` will look
for template inside `template/` directory to allow you having out-of-template README,
specs (for the template itself), anything else.
## Development
After checking out the repo, run `bundle install` to install dependencies.
Then, run `bundle exec rspec` to run the tests.
To install this gem onto your local machine, run `toys gem install`.
To release a new version, run `toys gem release %version%`.
See how it works [here](https://github.com/AlexWayfer/gem_toys#release).
## Contributing
Bug reports and pull requests are welcome on [GitHub](https://github.com/AlexWayfer/gem_generator).
## License
The gem is available as open source under the terms of the
[MIT License](https://opensource.org/licenses/MIT).