New Gem with Bundler - 29 Mar 2012
Creating and publishing a new Ruby gem is quick and simple with Bundler
. To get started, just make sure that you have Bundler installed:
gem install bundler
You can then create your gem with: bundle gem gem_name
. All of the configuration can then be done in your gem_name.gemspec
file.
# -*- encoding: utf-8 -*- require File.expand_path('../lib/jtv/version', __FILE__) Gem::Specification.new do |gem| gem.authors = ["Mockra"] gem.email = ["david@mockra.com"] gem.description = %q{Gem Description} gem.summary = %q{Gem Summary} gem.homepage = "" gem.files = `git ls-files`.split($\) gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.name = "jtv" gem.require_paths = ["lib"] gem.version = Jtv::VERSION gem.add_development_dependency 'rspec' gem.add_dependency 'json' gem.add_dependency 'oauth' end
Adding gem dependencies is simple with gem.add_dependency
. Simply run bundle install
to install your gem dependencies. You can also specify a gem description and summary.
Versioning of your gem is done through lib/gem_name/version.rb
. Building and publishing your gem can be done with the following command:
# This command will build, then publish your gem. rake release