Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RubyGems - A quick intro

RubyGems - A quick intro

A quick introduction to making your own RubyGems.

Peter Hellberg

November 24, 2011
Tweet

More Decks by Peter Hellberg

Other Decks in Programming

Transcript

  1. I’m a Senior Systems Architect at Athega (where I build

    stuff in Ruby) ⃔ I’m also the owner o Code7 Interactive (where I build stuff in Ruby) ⃕
  2. Gem::Specification.new do |s| # The attributes end Gem Speci ication

    In order to create a gem, you need to define a gem specification, commonly called a “gemspec”.
  3. Required gemspec attributes name This gem’s name summary A short

    summary of this gem’s description. Displayed in `gem list -d`. version This gem’s version s.required_ruby_version = ">= 1.8.7" Required Ruby Version
  4. Name, Summary and Version s.name = "pinch" s.summary = "Retrieve

    a file from" + "inside a zip file, over" + "the network!" s.version = Pinch::VERSION I generally add a ProjectName::VERSION constant to all of my projects, this makes it easy to show the current version at runtime.
  5. s.has_rdoc = true s.rdoc_options = [ '--main', 'README.rdoc', '--charset=UTF-8' ]

    s.extra_rdoc_files = [ 'README.rdoc', 'MIT-LICENSE' ] Documentation
  6. s.add_development_dependency 'yard', '~> 0.7' s.add_development_dependency 'minitest','~> 2.8' s.add_development_dependency 'fakeweb', '~>

    1.3' s.add_development_dependency 'vcr', '~> 1.11' Dependencies No runtime dependencies in this particular project, otherwise I’d need a few calls to s.add_dependency
  7. $ gem build pinch.gemspec Building $ gem push pinch-0.2.1.gem Pushing

    http://guides.rubygems.org/command-reference/