Description
This is a rubygems plugin useful to generate new gem skeleton based on a default or custom template.
$ gem install gem-newgem
$ gem new fancy_stuff --summary "This newgem will do some fancy stuff"
Similar tools
You can achieve pretty much the same with bundle gem GEMNAME but you'll be stuck with bundler predefined template. I've based my template on that but added more automation and more features.
These tools are also out there, last time I checked (Dec 2013) only Ore is being maintained.
Ore | RubiGen | gem-init | prigner
If you like the idea of creating custom generators take a look at thor (used by this gem) and how to start the generator from your ruby script.
If you are looking to bootstrap new rails apps maybe rails-composer is for you.
Installation
$ gem install gem-newgem
Usage
Use either the long form $ gem newgem GEMNAME
or the short form $ gem new GEMNAME
$ gem new GEMNAME [--template TEMPLATE_NAME] [--summary "This newgem will do some awesome stuff"]
$ gem new --help
Usage: gem newgem GEMNAME [options]
Options:
-t, --template TEMPLATE_NAME Use TEMPLATE instead of `default` template
By default, all templates are looked at ~/.newgem-templates/
-s, --summary "SUMMARY_TEXT" Set the gem summary text now in case you want to save time.
Common Options:
-h, --help Get help on this command
-V, --[no-]verbose Set the verbose level of output
-q, --quiet Silence commands
--config-file FILE Use this config file instead of default
--backtrace Show stack backtrace on errors
--debug Turn on Ruby debugging
Arguments:
GEMNAME name of the gem skeleton to generate.
Summary:
Generate new gem skeleton based on a default or custom template.
Defaults:
--template default --summary "TODO: Write a gem summary"
You can't use templates absolute paths, so place your templates at ~/.newgem-templates/
and provide just the name of the template. A default template which I personally use will be placed there as a starting point, you can fork it to customize your preferences.
Example:
$ gem new play_piano -t default -s "Gem that plays all day"
create play_piano
create play_piano/play_piano.gemspec
create play_piano/.gitignore
create play_piano/.rspec
create play_piano/.travis.yml
create play_piano/CHANGELOG.md
create play_piano/Gemfile
create play_piano/LICENSE.md
create play_piano/README.md
create play_piano/Rakefile
create play_piano/lib/play_piano.rb
create play_piano/lib/play_piano/version.rb
create play_piano/spec/play_piano_spec.rb
create play_piano/spec/spec_helper.rb
INFO: Initializing git repo at play_piano/
git init
Initialized empty Git repository in ~/apps/gem-newgem/play_piano/.git/
git add .
INFO: Will add remote so you get ready to push to github
git remote add github git@github.com:elgalu/play_piano.git
INFO: Make branch tracking automatic
git config --add branch.master.remote github
git config --add branch.master.merge refs/heads/master
Contributing
- Fork it.
- Make your feature addition or bug fix and create your feature branch.
- Add specs/tests for it. This is important so I don't break it in a future version unintentionally.
- Commit, create a new Pull Request.
- Check that your pull request passes the build.
TODO
- Check what parts of this tool can be replaced with Ore https://github.com/ruby-ore/ore#readme http://postmodern.github.io/2012/05/20/you-dont-have-to-use-bundler-to-create-new-rubygems.html
- Add cucumber features like this https://github.com/drnic/newgem/blob/master/features/newgem_cli.feature
- Add specs (tests) so this gem can be decent
- Fix encoding issues in MS Windows
- Show configurations found banner, then pause, then continue the bootstrap.
- Make easier to use as a general bootstrap tool, not just for new gems
- Add yaml configuration file.
- Add support to install templates from git like Ore does.
- Add more integration with Bundler tasks: 'bundler/gem_tasks'
- Add to RubyGems plugin list https://github.com/rubygems/guides/blob/gh-pages/plugins.md
License
Released under the MIT License. See the LICENSE file for further details.