Project

nugem

0.0
There's a lot of open issues
Nugem creates a scaffold project for new gems. You can choose between Github and Bitbucket, Rubygems or Geminabox, with or without an executable, etc.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

>= 0
>= 0
>= 0
 Project Readme

Nugem Gem Version

Nugem creates a scaffold project for a new gem in a new git repository. After you add your special code to the gem scaffold and test it, the project can be released to a public or private gem server.

This gem generates a new working Visual Studio Code project with the following features:

  • Compatible with rbenv.
  • Gemfile and .gemspec files will be set up.
  • Generates a README.md with badges.
  • Generates a new Visual Studio Code project, set up with current Ruby extensions.
    • Rubocop is configured.
    • Shellcheck is configured.
    • Markdown lint is configured.
    • Launch configurations are set up for testing.
  • Nugem can automatically create a public or private git repository on GitHub, GitLab or Bitbucket for your new gem.
  • Creates a test infrastructure based on rspec.
  • Your gem can be publicly released to rubygems.org.
  • Optionally create the gem as:
    • A plain old Ruby gem.
    • A Jekyll plugin (block and inline tags).

The following features might be implemented in a future release:

  • Automatically creates git repositories on BitBucket or GitLab. Your gem can include executables.
  • Optionally create the gem as:
    • Jekyll plugins (filters, generators, or hooks).

Installation

$ gem install nugem

If you are using rbenv to manage Ruby instances, type:

$ rbenv rehash

To update the program:

$ gem update nugem

Subcommands and Option Positions

See subcommands.md for details on nugem subcommands and option positions.

Common Options

The ruby and jekyll subcommands have common options.

The default option values assume that:

  • You do not want an executable for your gem scaffold
  • The gem project will be hosted on a public GitHub git repository

Common options for the ruby and jekyll subcommands are:

-e --executable
add an executable based on OptionParser.
-H --host
specifies the git host; possible values are bitbucket, github and gitlab.
-o --out_dir
specifies the directory to write the generated gem to. The default is ~/nugem_generated/NAME, or if the `$my_gems` environment variable is set, $my_gems/NAME.
--private
the remote repository is made private.
--loglevel
specifies log level (one of trace, debug, verbose, info, warning, error, fatal, panic, quiet).
--no-todos
do not generate TODO: strings in generated code.

Common Behavior

The ruby and jekyll subcommands have common behavior.

Gem scaffolds are created by default within the ~/nugem_generated/NAME directory.

If your user name is not already stored in your git global config, you will be asked for your GitHub or BitBucket user name. You will also be asked to enter your GitHub or BitBucket password when the remote repository is created for you.

After you create the gem, edit the gemspec and change the summary and the description.

The supported test framework is rspec.

Commit the changes to git and invoke rake release, and your gem will be published.

ruby Subcommand

Options for the ruby subcommand can be specified anywhere after the ruby parameter.

$ nugem ruby NAME [COMMON_OPTIONS]

NAME is the name of the gem to be generated.

For more information, type:

$ nugem -h

jekyll Subcommand

The jekyll subcommand extends the ruby subcommand and creates a new Jekyll plugin with the given NAME: Options for the jekyll subcommand can be specified anywhere after the jekyll parameter.

$ nugem jekyll NAME [COMMON_OPTIONS | JEKYLL_OPTIONS]

NAME is the name of the Jekyll plugin gem to be generated.

JEKYLL_OPTIONS are:

--block, --blockn, --filter, --hooks, --tag, and --tagn.

Some of these options might cause nugem to prompt the user for additional input.

All of the above options can be specified more than once, except the --hooks option. For example:

$ nugem jekyll test_tags --tag my_tag1 --tag my_tag2

The above creates a Jekyll plugin called test_tags, which defines Jekyll tags called my_tag1 and my_tag2. You might use these tags in an HTML document like this:

<pre>
my_tag1 usage: {% my_tag1 %}
my_tag2 usage: {% my_tag2 %}
</pre>

For more information, type:

$ nugem -h

Did It Work?

The following shows all files that were committed to the newly created git repository, after nugem jekyll finished making two tag blocks:

$ git ls-tree --name-only --full-tree -r HEAD
.gitignore
.rspec
.rubocop.yml
.vscode/extensions.json
.vscode/launch.json
.vscode/settings.json
.vscode/%gem_name%.json.code-snippets
CHANGELOG.md
Gemfile
LICENCE.txt
README.md
Rakefile
bin/attach
bin/console
bin/rake
bin/setup
demo/Gemfile
demo/_bin/debug
demo/_config.yml
demo/_drafts/2022/2022-05-01-test2.html
demo/_includes/block_tag_template_wrapper
demo/_layouts/default.html
demo/_posts/2022/2022-01-02-redact-test.html
demo/assets/css/style.css
demo/assets/images/404-error.png
demo/assets/images/404-error.webp
demo/assets/images/favicon.png
demo/assets/images/jekyll.png
demo/assets/images/jekyll.webp
demo/assets/js/clipboard.min.js
demo/assets/js/jquery-3.4.1.min.js
demo/blog/blogsByDate.html
demo/blog/index.html
demo/index.html
jekyll_test.code-workspace
jekyll_test.gemspec
lib/jekyll_test.rb
lib/jekyll_test/version.rb
lib/my_block1.rb
lib/my_block2.rb
spec/jekyll_test_spec.rb
spec/spec_helper.rb
test/jekyll_test_test.rb
test/test_helper.rb

Visual Studio Code Support

Nugem Project

Plugins

If you have not installed the Snippets extension, Visual Studio Code will suggest that you do so the first time you open this project with Visual Studio Code. You can also review the list of suggested extensions of with the Ctrl-P Extensions: Show Recommended Extensions command.

Snippets

The predefined snippets for generated gem are defined in .vscode/nugem.json.code-snippets. These snippets are focused on maintaining nugem itself.

File Associations

.vscode/settings.json defines file associations for templates in the "files.associations" section. You can disable them by commenting out the definitions.

Generated Projects

Plugins

Similarly, for each gem project generated by nugem, Visual Studio Code will suggest the user install missing extensions the first time those projects are opened.

Snippets

The predefined snippets for gem projects generated by nugem are defined in their templates/common/gem_scaffold/.vscode/gem.json.code-snippets file. These snippets are focused on writing Jekyll plugins.

Development

After checking out the repository, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run:

$ bundle exec rake install

To release a new version, run:

$ bundle exec rake release

The above will create a git tag for the version, push git commits and tags, and push the .gem file to https://rubygems.org.

Tests

Run all tests with:

$ bin/rspec

Run a specific test file with:

$ bin/rspec spec/template_spec.rb

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/mslinn/nugem.

See Also