Overview

Gem Version Code Climate GPA Code Climate Coverage Gemnasium Status Travis CI Status Gittip

Gemsmith allows you to easily craft new gems via the command line with custom settings (if desired).

Features

  • Builds a gem skeleton with Bundler functionality in mind.
  • Supports common settings to be applied when creating new gems.
  • Supports Thor command line functionality.
  • Supports Ruby on Rails.
  • Supports RSpec.
  • Supports Pry.
  • Supports Guard.
  • Supports Code Climate.
  • Supports Gemnasium.
  • Supports Travis CI.
  • Provides the ability to open the source code of any gem within your favorite editor.
  • Provides the ability to read the documentation of any gem within your default browser.
  • Adds commonly needed README, CHANGELOG, CONTRIBUTING, LICENSE, etc. template files.

Requirements

  1. A UNIX-based system.
  2. Any of the following Ruby VMs:
  3. RubyGems.
  4. Bundler.

Setup

For a secure install, type the following from the command line (recommended):

gem cert --add <(curl -Ls http://www.alchemists.io/gem-public.pem)
gem install gemsmith --trust-policy MediumSecurity

NOTE: A HighSecurity trust policy would be best but MediumSecurity enables signed gem verification while allowing the installation of unsigned dependencies since they are beyond the scope of this gem.

For an insecure install, type the following (not recommended):

gem install gemsmith

You can configure common settings for future gem builds by creating the following file:

~/.gemsmith/settings.yml

...using the following settings (for example):

---
:author_name: Brooke Kuhlmann
:author_email: [email protected]
:author_url: http://www.alchemists.io
:company_name: Alchemists

If no options are configured, then the defaults are as follows:

gem_platform: Gem::Platform::RUBY
gem_private_key: ~/.ssh/gem-private.pem
gem_public_key: ~/.ssh/gem-public.pem
author_name: <git name>
author_email: <git email>
author_url: https://www.unknown.com
gem_url: <author URL>
company_name: <author name>
company_url: <author URL>
github_user: <github user>
year: <current year>
ruby_version: 2.0.0
ruby_patch: p0
rails_version: 4.0

Usage

From the command line, type: gemsmith help

gemsmith -c, [create=CREATE]  # Create new gem.
gemsmith -e, [edit]           # Edit gem in default editor (assumes $EDITOR environment variable).
gemsmith -h, [--help=HELP]    # Show this message or get help for a command.
gemsmith -o, [open=OPEN]      # Open gem in default editor (assumes $EDITOR environment variable).
gemsmith -r, [read=READ]      # Open gem in default browser.
gemsmith -v, [--version]      # Show version.

For more gem creation options, type: gemsmith help create

-b, [--bin], [--no-bin]                    # Add binary support.
-r, [--rails], [--no-rails]                # Add Rails support.
-p, [--pry], [--no-pry]                    # Add Pry support.
                                           # Default: true
-g, [--guard], [--no-guard]                # Add Guard support.
                                           # Default: true
-s, [--rspec], [--no-rspec]                # Add RSpec support.
                                           # Default: true
-c, [--code-climate], [--no-code-climate]  # Add Code Climate support.
                                           # Default: true
-G, [--gemnasium], [--no-gemnasium]        # Add Gemnasium support.
                                           # Default: true
-t, [--travis], [--no-travis]              # Add Travis CI support.
                                           # Default: true

Once a gem skeleton has been created, the following tasks are available within the project via Bundler (i.e. rake -T):

rake build    # Build example-0.1.0.gem into the pkg directory
rake install  # Build and install example-0.1.0.gem into system gems
rake release  # Create tag v2.3.0 and build and push example-0.1.0.gem to Rubygems

Tests

To test, run:

bundle exec rspec spec

Security

To create a certificate for your gems, run the following:

cd ~/.ssh
gem cert --build [email protected]
chmod 600 gem-*.pem

The resulting *.pem keys can be referenced via the *gem_private_key- and *gem_public_key- settings mentioned in the Setup documentation.

To learn more about gem certificates, read the following:

Best Practices

  1. Semantic Versioning
  2. Best Practices While Cutting Gems.
  3. Ruby on Rails Gem Packaging.
  4. Gem Activation and You: Part I
  5. Gem Activation and You: Part II
  6. Why You Should Use a BSD Style License.
  7. Add -w to the RUBYOPT environment variable when testing. Details.

Documentation

In order to make your gem easier to use and adopt by others, good documentation is always a plus. Consider submitting your gem to RubyDocs[http://rubydoc.info] once your gem is released and available for use. RubyDocs supports both RDoc and YARD formats.

Promotion

Once your gem is released, you might like to let the world know about the new awesomeness. Here are several resources:

Versioning

Read Semantic Versioning for details. Briefly, it means:

  • Patch (x.y.Z) - Incremented for small, backwards compatible bug fixes.
  • Minor (x.Y.z) - Incremented for new, backwards compatible public API enhancements and/or bug fixes.
  • Major (X.y.z) - Incremented for any backwards incompatible public API changes.

Contributions

Read CONTRIBUTING for details.

Credits

Developed by Brooke Kuhlmann at Alchemists.

License

Copyright (c) 2011 Alchemists. Read the LICENSE for details.

History

Read the CHANGELOG for details.