Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It's actually not to hard to do this manually. Let's say you have a library <code>whatever.rb</code> that you want to distribute as a gem.</p> <ol> <li>make a directory <code>lib</code> and put a copy of <code>whatever.rb</code> in <code>lib/whatever.rb</code>.</li> <li>make a file <code>whatever.gemspec</code>, and put the following in there, filling in the appropriate values:<pre><code> Gem::Specification.new do |spec| spec.name = 'the-name-of-your-gem' spec.version ='0.0.1'<br> # this is important - it specifies which files to include in the gem. spec.files = ["lib/whatever.rb"]<br> # optional, but useful to your users spec.summary = "A more longwinded description of your gem" spec.author = 'Your Name' spec.email = 'you@yourdomain.com' spec.homepage = '<a href="http://www.yourpage.com" rel="noreferrer">http://www.yourpage.com</a>'<br> # you did document with RDoc, right? spec.has_rdoc = true<br> # if you have a ruby forge project spec.rubyforge_project = 'your-project-name-on-rubyforge'<br> # if you have any dependencies on other gems, list them thusly spec.add_dependency('hpricot') spec.add_dependency('log4r', '>= 1.0.5') end </code></pre></li> <li>now, to build the gem, use the <code>gem build</code> command:<pre> % gem build whatever.gemspec Successfully built RubyGem Name: the-name-of-your-gem Version: 0.0.1 File: the-name-of-your-gem-0.0.1.gem % </pre></li> <li>You can test locally by using <code>gem install the-name-of-your-gem-0.0.1.gem</code> To use your library in a script then, simply do the following at the top:<pre><code> require 'rubygems' # puts gem libraries in the require path require 'whatever' # loads your library </code></pre></li> </ol> <p>For more on what the various settings in the <code>gemspec</code> file, check the <a href="http://rubygems.org/read/chapter/20" rel="noreferrer">GemSpec Reference</a>.</p> <p>Personally, I use rubygems a lot to package executable scripts as well, and find it very handy for that.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload