http://hints.macworld.com/article.php?story=20081217161612647
Month: December 2015
Gem Basics
Ruby gem is basically a library or plug-in, its have some functionality to which you can install it to full-fill your specific need.
1 .Naming Convention:
Naming should be consistent through out the gem. gems also follow ruby snake case naming convention. If gem name have more than one word then use ‘- ‘ for sepetation. For example: google-client.
2. Directory Structure:
gem also follow the same directory structure as normal ruby project follows.
$ tree
Gemfile Gemfile.lock README.md Rakefile bin console setup google_client.gemspec
lib
google-client google-client.rb
spec
google-client spec_helper.rb
.gemspec file is used to store all the information about the gem
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'google_client/version'
Gem::Specification.new do |spec|
spec.name = "google-client"
spec.version = GapiClient::VERSION
spec.authors = ["praveen shukla"]
spec.email = ["praveen.shukla@c42.in"]
if spec.respond_to?(:metadata)
spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
end
spec.summary = "HTTP client used to communicate to google"
spec.license = "MIT"
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.bindir = "bin"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.add_development_dependency "bundler", "~> 1.8"
spec.add_development_dependency "rake", "~> 10"
spec.add_development_dependency "rspec", "~> 3"
spec.add_development_dependency "vcr", "~> 2"
spec.add_development_dependency "webmock", "~> 1"
end
3. Gem versioning :
Initial gem version is 0.1.0.
- PATCH
0.0.x
level changes for implementation level detail changes, such as small bug fixes or code refactoring. - MINOR
0.x.0
level changes for any backwards compatible API changes, such as new functionality/features. - MAJOR
x.0.0
level changes for backwards incompatible API changes, such as changes that will break existing users code if they update.
Referencess: http://guides.rubygems.org/