RubyGems question: Knowing the correct name for add_dependency

J

James Britt

I'm trying to write a gemspec file. My code depends on Austin Ziegler's
Mime::Types library. I want to call to add_dependency, but I do not
know what to pass as the first argument.

In my code, I call

require 'mime/types'

So, in my gemspec file, would it be

add_dependency( 'mime/types', "> 1.12" )

Or do need to use a more abstract package name:

add_dependency( 'MIME::Types', "> 1.12" )

or maybe

add_dependency( 'mime-types', "> 1.12" )

There's a gem for the MIME::Types lib; can one use add_dependency even
when there is no gem for the dependency?

In general, how does one know how to refer to the dependency?

Thanks!

James
 
J

Jim Weirich

James said:
I'm trying to write a gemspec file. My code depends on Austin Ziegler's
Mime::Types library. I want to call to add_dependency, but I do not
know what to pass as the first argument.

The first argument should be the base name of the gem without version or
platform information ... E.g.

spec = Gem::Specification.new do |s|
...
s.add_dependency('rake', ">0.4.0")
...
end
There's a gem for the MIME::Types lib; can one use add_dependency even
when there is no gem for the dependency?

Ahh, if there is no gem for the library, then you can't list it as an
explicit dependency. However, you can document it by including it in
the requirements field (which is a list of strings) ... E.g.

s.requirements << "Needs Mime::Types library"

Perhaps Austin can be persuaded to offer MIME::Types as a gem, our
perhaps you could package it yourself.
 
A

Austin Ziegler

Perhaps Austin can be persuaded to offer MIME::Types as a gem, our
perhaps you could package it yourself.

MIME::Types does have a gem ... it just wasn't on the RubyForge
project. It's there now, which means it will be in the repository
soon.

I have other code for which I created RubyForge projects in the last
little while, but there have been no updates so there are no gems or
releases there -- they're still at my HaloStatue webpage.

-austin
 
J

James Britt

Jim said:
The first argument should be the base name of the gem without version or
platform information ... E.g.

spec = Gem::Specification.new do |s|
...
s.add_dependency('rake', ">0.4.0")
...
end


What is the "base name" of a gem? Given "FooBar.gem", is it "FooBar" ?

Is it something defined in that gem's gemspec file?

I looked into the gemspec for MIME::Types, but couldn't tell if I should
use

add_dependency( 'MIME::Types', "> 1.12" )

or

add_dependency( 'mime-types', "> 1.12" )

Thanks,

James
 
J

Jim Weirich

James said:
What is the "base name" of a gem? Given "FooBar.gem", is it "FooBar" ?

Given foobar-1.2.0.gem, it would be foobar. Sorry, I should have been
more explicity.

If you do a gem list command, the name is displayed followed by all the
available versions in parenthesis.
add_dependency( 'mime-types', "> 1.12" )

This is the one you want.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top