• Stars
    star
    1,479
  • Rank 31,787 (Top 0.7 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 16 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Opinionated tool for creating and managing Rubygem projects

Jeweler maintenance has now shifted to Fred Mitchell. I am now maintaining both Jeweler and its fork, juwelier. I will keep Jeweler at least functional with the latest Ruby releases, but put new features in Juwelier. Your input on this is more than welcome.

Jeweler: Craft the perfect RubyGem

Join the chat at https://gitter.im/technicalpickles/jeweler

Jeweler provides the noble ruby developer with two primary features:

  • a library for managing and releasing RubyGem projects
  • a scaffold generator for starting new RubyGem projects

PLEASE NOTE that if you are starting afresh, please use the successor Juwelier I (Fred Mitchell, flajann2) will be maintaining both Jeweler and Juwelier, but will be adding new features to Juwelier, and eventually "merge" this one into Juwelier after some namespace issues are dealt with.

Build Status Coverage Status Dependency Status Code Climate

Hello, world

Use RubyGems to install the heck out of jeweler to get started:

$ gem install jeweler

With jeweler installed, you can use the jeweler command to generate a new project. For the most basic use, just give it a name:

$ jeweler hello-gem

This requires some Git configuration (like name, email, GitHub account, etc), but jeweler will prompt along the way.

Your new hello-gem gem is ready in the hello-gem directory. Take a peek, and you'll see several files and directories

  • Rakefile setup for jeweler, running tests, generating documentation, and releasing to rubygems.org
  • README.rdoc with contribution guidelines and copyright info crediting you
  • LICENSE with the MIT licensed crediting you
  • Gemfile with development dependencies filled in
  • lib/hello-gem.rb waiting for you to code
  • test/ containing a (failing) shoulda test suite shoulda

More jeweler options

The jeweler command supports a lot of options. Mostly, they are for generating baked in support for this test framework, or that.

Check out jeweler --help for the most up to date options.

Hello, rake tasks

Beyond just editing source code, you'll be interacting with your gem using rake a lot. To see all the tasks available with a brief description, you can run:

$ rake -T

You'll need a version before you can start installing your gem locally. The easiest way is with the version:write Rake task. Let's imagine you start with 0.1.0

$ rake version:write MAJOR=0 MINOR=1 PATCH=0

You can now go forth and develop, now that there's an initial version defined. Eventually, you should install and test the gem:

$ rake install

The install rake task builds the gem and gem installs it. You're all set if you're using RVM, but you may need to run it with sudo if you have a system-installed ruby:

$ sudo rake install

Releasing

At last, it's time to ship it! Make sure you have everything committed and pushed, then go wild:

$ rake release

This will automatically:

  • Generate hello-gem.gemspec and commit it
  • Use git to tag v0.1.0 and push it
  • Build hello-gem-0.1.0.gem and push it to rubygems.org

rake release accepts REMOTE(default: origin), LOCAL_BRANCH(default: master), REMOTE_BRANCH(default: master) and BRANCH(default: master)as options.

$ rake release REMOTE=upstream LOCAL_BRANCH=critical-security-fix REMOTE_BRANCH=v3

This will tag and push the commits on your local branch named critical-security-fix to branch named v3 in remote named upstream (if you have commit rights on upstream) and release the gem.

$ rake release BRANCH=v3

If both remote and local branches are the same, use BRANCH option to simplify. This will tag and push the commits on your local branch named v3 to branch named v3 in remote named origin (if you have commit rights on origin) and release the gem.

Version bumping

It feels good to release code. Do it, do it often. But before that, bump the version. Then release it. There's a few ways to update the version:

# version:write like before
$ rake version:write MAJOR=0 MINOR=3 PATCH=0

# bump just major, ie 0.1.0 -> 1.0.0
$ rake version:bump:major

# bump just minor, ie 0.1.0 -> 0.2.0
$ rake version:bump:minor

# bump just patch, ie 0.1.0 -> 0.1.1
$ rake version:bump:patch

Then it's the same release we used before:

$ rake release

Customizing your gem

If you've been following along so far, your gem is just a blank slate. You're going to need to make it colorful and full of metadata.

You can customize your gem by updating your Rakefile. With a newly generated project, it will look something like this:

require 'jeweler'
Jeweler::Tasks.new do |gem|
  # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
  gem.name = "whatwhatwhat"
  gem.summary = %Q{TODO: one-line summary of your gem}
  gem.description = %Q{TODO: longer description of your gem}
  gem.email = "[email protected]"
  gem.homepage = "http://github.com/technicalpickles/whatwhatwhat"
  gem.authors = ["Joshua Nichols"]
end
Jeweler::RubygemsDotOrgTasks.new

It's crucial to understand the gem object is just a Gem::Specification. You can read up about it at guides.rubygems.org/specification-reference. This is the most basic way of specifying a gem, Jeweler-managed or not. Jeweler just exposes this to you, in addition to providing some reasonable defaults, which we'll explore now.

Project information

gem.name = "whatwhatwhat"

Every gem has a name. Among other things, the gem name is how you are able to gem install it. Reference

gem.summary = %Q{TODO: one-line summary of your gem}

This is a one line summary of your gem. This is displayed, for example, when you use gem list --details or view it on rubygems.org.

gem.description = %Q{TODO: longer description of your gem}

Description is a longer description. Scholars ascertain that knowledge of where the description is used was lost centuries ago.

gem.email = "[email protected]"

This should be a way to get a hold of you regarding the gem.

gem.homepage = "http://github.com/technicalpickles/whatwhatwhat"

The homepage should have more information about your gem. The jeweler generator guesses this based on the assumption your code lives on GitHub, using your Git configuration to find your GitHub username. This is displayed by gem list --details and on rubygems.org.

gem.authors = ["Joshua Nichols"]

Hey, this is you, the author (or me in this case). The jeweler generator also guesses this from your Git configuration. This is displayed by gem list --details and on rubygems.org.

Files

The quickest way to add more files is to git add them. Jeweler uses your Git repository to populate your gem's files by including added and committed and excluding .gitignored. In most cases, this is reasonable enough.

If you need to tweak the files, that's cool. Jeweler populates gem.files as a Rake::FileList. It's like a normal array, except you can include and exclude file globs:

gem.files.exclude 'tmp' # exclude temporary directory
gem.files.include 'lib/foo/bar.rb' # explicitly include lib/foo/bar.rb

If that's not enough, you can just set gem.files outright

gem.files = Dir.glob('lib/**/*.rb')

Dependencies

Dependencies let you define other gems that your gem needs to function. gem install your-gem will install your-gem's dependencies along with it, and when you use your-gem in an application, the dependencies will be made available. Use gem.add_dependency to register them. Reference

gem.add_dependency 'nokogiri'

This will ensure a version of nokogiri is installed, but it doesn't require anything more than that. You can provide extra args to be more specific:

gem.add_dependency 'nokogiri', '= 1.2.1' # exactly version 1.2.1
gem.add_dependency 'nokogiri', '>= 1.2.1' # greater than or equal to 1.2.1, ie, 1.2.1, 1.2.2, 1.3.0, 2.0.0, etc
gem.add_dependency 'nokogiri', '>= 1.2.1', '< 1.3.0' # greater than or equal to 1.2.1, but less than 1.3.0
gem.add_dependency 'nokogiri', '~> 1.2.1' # same thing, but more concise

When specifying which version is required, there's a bit of the condunrum. You want to allow the most versions possible, but you want to be sure they are compatible. Using >= 1.2.1 is fine most of the time, except until the point that 2.0.0 comes out and totally breaks backwards the API. That's when it's good to use ~> 1.2.1, which requires any version in the 1.2 family, starting with 1.2.1.

Executables

Executables let your gem install shell commands. Just put any executable scripts in the bin/ directory, make sure they are added using git, and Jeweler will take care of the rest.

When you need more finely grained control over it, you can set it yourself:

gem.executables = ['foo'] # note, it's the file name relative to `bin/`, not the project root

Versioning

We discussed earlier how to bump the version. The rake tasks are really just convience methods for manipulating the VERSION file. It just contains a version string, like 1.2.3.

VERSION is a convention used by Jeweler, and is used to populate gem.version. You can actually set this yourself, and Jeweler won't try to override it:

gem.version = '1.2.3'

A common pattern is to have this in a version constant in your library. This is convenient, because users of the library can query the version they are using at runtime.

# in lib/foo/version.rb
class Foo
  module Version
    MAJOR = 1
    MINOR = 2
    PATCH = 3
    BUILD = 'pre3'

    STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
  end
end

# in Rakefile
require 'jeweler'
require './lib/foo/version.rb'
Jeweler::Tasks.new do |gem|
  # snip
  gem.version = Foo::Version::STRING
end

Rake tasks

Jeweler lives inside of Rake. As a result, they are dear friends. But, that friendship doesn't interfere with typical Rake operations.

That means you can define your own namespaces, tasks, or use third party Rake libraries without cause for concern.

Contributing to Jeweler

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
  • Ask on the mailing list for feedback on your proposal, to see if somebody else has done it.
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for the feature/bugfix. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate it to its own commit so I can cherry-pick around it.

Copyright

Copyright (c) 2008-2010 Josh Nichols. Copyright (c) 2016 Fred Mitchell. See LICENSE for details.

More Repositories

1

homesick

Your home directory is your castle. Don't leave your dotfiles behind.
Ruby
2,389
star
2

capistrano-spec

Helpers and matchers for testing capistrano
Ruby
85
star
3

rspec-spies

test spies, for rspec
Ruby
79
star
4

shoulda_generator

Rails generators which produce tests using shoulda instead of straight up Test::Unit. Other goodies as well.
Ruby
59
star
5

sinatra-mongo

A light extension to sinatra for using mongo
Ruby
39
star
6

pickled-vim

My personal VIM configurations
Vim Script
38
star
7

sleepyq

SleepIQ API for Python
Python
34
star
8

factory_girl_on_rails

Some minor conveniences for using factory_girl on a Rails project
Ruby
34
star
9

pager_duty-connection

Ruby API wrapper for the PagerDuty REST API
Ruby
30
star
10

wheres-your-database-yml-dude

UNMAINTAINED A small Rails plugin to answer the question of "Where's your database.yml, dude?"
Ruby
26
star
11

gemstalker

A library for determining if GitHub has built a gem yet
Ruby
19
star
12

has_ip_address

An extension to ActiveRecord to store IP Addresses in the database as integers
Ruby
19
star
13

capistrano-campfire

A tiny shim for using campfire from capistrano
Ruby
19
star
14

safety_valve

Rails plugin to rescue common Rails exceptions, render an error with your look and feel, and return an appropriate HTTP status code
Ruby
18
star
15

dotfiles

My shareable dotfiles
Vim Script
17
star
16

ambitious-sphinx

Ambition adapter for Sphinx
Ruby
17
star
17

picklehome

Configuration & Planning for my Home Automation systems
Shell
14
star
18

has_markup

Manage markup close to home... right in the model! Caching, validation, etc
Ruby
14
star
19

mailinator-spec

a library for using mailinator for testing email from rspec and cucumber
Ruby
14
star
20

le-git

It's a GitHub party and you're invited! Ruby wrapper for the GitHub API
Ruby
13
star
21

isolate-scenarios

Tool for testing libraries using different senarios of gem versions
Ruby
11
star
22

rails-3-blog

Demo blog app using rails 3 and moonshine
Ruby
10
star
23

capistrano-mountaintop

Easily announce capistrano deploys to a Campfire room
Ruby
9
star
24

therapist

Helps you deal with your (GitHub) issues
Ruby
9
star
25

daywalker

A Ruby wrapper around the Sunlight Labs API using httparty and happymapper
Ruby
8
star
26

rankles

Ranking algorithms.
Ruby
8
star
27

g-gem

Tool for creating Gentoo ebuilds based on gems
Ruby
8
star
28

capistrano-benchmark

Benchmarking for capistrano tasks
Ruby
8
star
29

caveat_patch_kids

Manage caveatPatchor.js files for Propane
JavaScript
8
star
30

pickles-on-rails

A fresh Rails app, with some niceties and cleanup
Ruby
6
star
31

thescotchzone

thescotchzone.heroku.com
Ruby
6
star
32

mustache-ride

Example app that takes mustache for a ride in rails
Ruby
5
star
33

content_given

An ActionView helper for determining if content_for
5
star
34

nice_assert_select

make assert_select nicer
Ruby
5
star
35

obsidian-hook-scripts

Scripts to add to Hook for compatibility with Obsidian
JavaScript
5
star
36

technicalpickles.github.com

jekyll site for technicalpickles.com
HTML
5
star
37

ifib

A web service for providing the fibonacci sequence, implemented using sinatra and memcache
5
star
38

deliciousr

Ruby library for the del.icio.us API
Ruby
5
star
39

feedbarn

A 'planet' like feed aggregator using feedparser and erubis
Ruby
5
star
40

flvorflv

A tiny wrapper around flvstreamer, an open source command-line RTMP client
Ruby
5
star
41

hubot-irc-development-server

For quickly getting up and running in development with hubot-irc using ngircd
Shell
5
star
42

multiple-domain-demo

Demo of using subdomain_fu and proxy to handle subdomains and domain names
4
star
43

pickled-nvim

Lua
4
star
44

vlad-extras

Extra tasks for vlad
Ruby
4
star
45

alfred-system-audio

Alfred Workflow to quickly change the default system input audio and output
Swift
4
star
46

paperclip-in-attachment_fus-clothing

evil twin of paperclip to ease migration from attachment_fu
4
star
47

adopt-a-garden

Adopt a Garden, in Savannah, GA
Ruby
4
star
48

the-perfect-gem

Experiment for generating a jeweler-enabled project
Ruby
4
star
49

gimme-octo-kitty-wiki

A script to pull down a project's wiki on GitHub locally.
Ruby
3
star
50

feedra

Simple feed aggregation for Rails.
Ruby
3
star
51

pb2md

Convert the macOS clipboard (aka pasteboard) to Markdown
HTML
3
star
52

chester

chester the cheat.errtheblog.com clone
Ruby
3
star
53

flockup

site powering tweetfleet.heroku.com, formerly flockup.com
Ruby
3
star
54

mr_github

A tool to make it easy to clone and pull all your GitHub repositories
Ruby
3
star
55

voteontherandom

entry for barcamp boston programming contest
JavaScript
3
star
56

file_fixture

A helper method for loading files during test
Ruby
3
star
57

jquery.googlesearch

Simple jQuery wrapper around the Google AJAX Search API.
JavaScript
3
star
58

in-file-test

A tiny generator for creating a ruby file, that when executed, runs a test/unit suite
3
star
59

posterrrrous

Quick and dirty Ruby API wrapper for Posterous
Ruby
3
star
60

zomgblog

Ruby
2
star
61

moonshined

test app for moonshine
Ruby
2
star
62

puppet-flux

F.lux Puppet Module for Boxen
Shell
2
star
63

omgwtfcreaterepo

2
star
64

bcb4-attendees

TODO
Ruby
2
star
65

repo_creation_test

2
star
66

zomg-created

TODO: one-line summary of your gem
Ruby
2
star
67

snapchop

Grabs a snapshot of a movie using ffmpeg
Ruby
2
star
68

blueprint-layout

Rails helpers to generate Blueprint CSS-based structures
Ruby
2
star
69

railsconfcal

TODO
Ruby
2
star
70

glob-test

Test globs across different languages and libraries
Ruby
2
star
71

4tehlulz.biz

Ruby
1
star
72

pickledtunes

Notes, links, resources from experimenting making musics
Ruby
1
star
73

ghsup

JavaScript
1
star
74

pickled-atom

My personal Atom configuration
CoffeeScript
1
star
75

broadlinky

Python
1
star
76

ragamuffin

I'm a bad, bad man
Ruby
1
star
77

hello_extension

Hello world, but for making a gem with native extensions
1
star
78

my-created-gem

1
star
79

hello_rubyconf

An gem created for a lightning talk on a hacked version of jeweler with sinatra support
Ruby
1
star
80

hubot-test-harness

CoffeeScript
1
star
81

puppet-airfoil

Airfoil Puppet Module for Boxen
Shell
1
star
82

tools.scrollable

mirror of jQuery TOOLS Scrollable, since I couldn't find a version control for it
JavaScript
1
star
83

flamegraph-lighting-talk

Ruby
1
star
84

slackhubotbot

Hubot for developing hubot against SlackHQ
Shell
1
star