Skip to content

Create a new project

agrimm edited this page Aug 22, 2010 · 4 revisions

Jeweler comes with a generator aptly named jeweler. It generates a basic project structure, sets up git, and prepares it to be on GitHub.

There are a number of choices you can make about your project, but the simplest incantation looks like:

$ bin/jeweler my_awesome_new_gem
        create  .gitignore
        create  Rakefile
        create  LICENSE
        create  README.rdoc
        create  .document
        create  lib
        create  lib/my_awesome_new_gem.rb
        create  test
        create  test/helper.rb
        create  test/test_my_awesome_new_gem.rb
Jeweler has prepared your gem in my_awesome_new_gem

Here’s some of the things it handles for you:

  • Creates a stub ruby file for your library to live in, lib/my_awesome_new_gem.rb
  • Creates a failing test using Shoulda, test/test_my_awesome_new_gem.rb
  • Creates a MIT license file
  • Creates a Rakefile with tasks for:
    • Managing your gem and releases
    • Running tests
    • Generating documentation
  • Initializes a git repository and adds all files, and ignores some reasonable files
    • Adds GitHub as the origin remote, using your GitHub username and the project name

Some choices

If you don’t like the defaults, you have some tough (or maybe easy if you’re opinionated) choices to make about your gem.

Creating repo

By default, jeweler only creates the project locally. If you want create the repo on GithHub, use --create-repo.

Testing framework

Jeweler defaults to shoulda, but jeweler supports a number of others as well:

  • test/unit (use --testunit)
  • minitest (use --minitest)
  • shoulda (use --shoulda)
  • rspec (use --rspec)
  • micronaut (use --micronaut)
  • bacon (use --bacon)

Additionally, you can generate a scaffold for cucumber features. It will automatically be setup for the testing framework you chose (except for bacon, which doesn’t seem to work inside of cucumber). Use --cucumber.

Releasing

Jeweler will automatically be able to release to GitHub, but you also have a few other options:

Documentation

Jeweler defaults to using the standard RDoc.

  • RDoc (use --rdoc)
  • YARD (use --yard)

Other tools

There’s a few other tools you can enable for your project:

Remember some defaults

Once you know your own defaults, you can set an environment variable JEWELER_OPTS, and from then on, jeweler will use those defaults.

In bash, for example, you’d add something like this to ~/.bashrc: export JEWELER_OPTS="--rspec"