Create your own Gem

GEMS This is details how to make your own gem deploying, and solutions to the sample error you might encounter during creating or deployment. Here are the following steps to follow in creating your own gem upto deployment.
  
  
  1. $ gem install bundler

  2. $ bundle gem dogeify

  3. modify your gemspec

  # 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          = "dogeify"
  spec.version       = Dogeify::VERSION
  spec.authors       = ["Matt Huggins"]
  spec.email         = ["matt.huggins@gmail.com"]
  spec.description   = %q{Convert everyday boring English into doge speak!}
  spec.summary       = %q{English to doge translations}
  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

  4. modify your version lib/version.rb

  module Dogeify
  VERSION = "0.0.1"
  end

  5. Add your spec and passing code.

  $ bundle exec rspec spec
  TODO your code.

  6. Build you gem (localy)

  $ gem build dogeify.gemspec

  7. Install your gem (localy)

  $ gem install dogeify-0.0.0.gem

  ====== OR ======

  $ gem install ./dogeify-0.0.0.gem

  8. Run in irb

  $ irb
  $ require 'dogeify'
  $ Dogeify.process("Hello")

  9. Releasing your gem

  curl -u qrush https://rubygems.org/api/v1/api_key.yaml > ~/.gem/credentials; chmod 0600 ~/.gem/credentials

  10. Build gem first before pushing:

  $ gem build dogeify.gemspec
  $ gem push ./dogeify-0.0.1.gem
  
If got error in pushing to rubygems?
  
  
  1. Remove or comment these on your gemspec.
  (Pushing gem to https://rubygems.org...
  ERROR:  "https://rubygems.org" is not allowed by the gemspec, which only allows "TODO: Set to 'http://mygemserver.com'")


  # if spec.respond_to?(:metadata)
  #   spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
  # else
  #   raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
  # end
  
  
  
  2.  gem push ./hola-0.0.1.gem
  (Pushing gem to https://rubygems.org...
  Repushing of gem versions is not allowed.
  Please use `gem yank` to remove bad gem releases.)

  Solution:
  modify the gem version
  or best way avoid duplication of gem name already exists
  
  
  
  3. You do not have permission to push to this gem.
  You should modify your gemspec. It is posibly, duplicated name in rubygems website.

  from "hola" to "hola_test"

  spec.name          = "hola_test"
  spec.homepage      = "http://rubygems.org/gems/hola_test"
  

This article refers to this pages lunch and create you own gem and rails guides - make your own gem

No comments:

Post a Comment