Example
Just to make sure you have bundler gem installed.
- $ gem install bundler
- $ bundle gem gem-post
$ tree gem-post gem-post ├── .gitignore ├── Gemfile ├── LICENSE.txt ├── README.md ├── Rakefile ├── gem-post.gemspec └── lib ├── gem-post │ └── version.rb └── gem-post.rb
gem-post.gemspec
in
this case). This file contains metadata about the gem, such as the
name, description, author, license, and any gem dependencies required
for it to work.# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'dogeify/version' Gem::Specification.new do |spec| spec.name = "gem-post" spec.version = GemPost::VERSION spec.authors = ["Author Name"] spec.email = ["[email protected]"] spec.description = %q{A short description!} spec.summary = %q{A short description!} spec.homepage = "" spec.license = "MIT" spec.files = `git ls-files`.split($/) spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] spec.add_dependency 'engtagger' spec.add_development_dependency 'bundler', '~> 1.3' spec.add_development_dependency 'rake' spec.add_development_dependency 'rspec' end
lib/gem-post.rb
and lib/gem-post/version.rb
files. These two files are initially very simple.First start with
version.rb
:module GemPost VERSION = "0.0.1" end
Now, look at the
gem-post.rb :
require "gem-post/version" module GemPost # This is the place, where you will put your GEM code. end
And, thats it, you are ready with your first gem to be released.
How to release a GEM
- Prerequisites :
- You must commit your GEM files to GIT, as Bundler assumes that you're working with some sort of git repository.
- You must have an account on rubygems.org in order to release your gem.
Now, as you have both the prerequisites setup, you can simply run :
$ bundle exec rake release
As its been released now, you can add this "gem-post" gem into your Gemfile.
Updating GEM
- Make changes into your GEM code,
- Update the version in
lib/gem-post/version.rb
file, - Make a commit of your changes, and run :
- $ bundle exec rake release
Perfect, It is very helpful!
ReplyDeletethanks for sharing this.
ReplyDeleteReally helpful blog !
ReplyDelete