Please help on gem packaging

M

Mohammad Khan

Hello,

First let me show you my gemspec file,

#########################
require 'rubygems'

SPEC =3D Gem::Specification.new do | s |
# Quick fix for Ruby 1.8.3 / YAML bug
#if (RUBY_VERSION =3D=3D '1.8.3')
# def spec.to_yaml
# out =3D super
# out =3D '--- ' + out unless out =3D~ /^---/
# out
# end
#end

s.name =3D "ruby-agi"
s.version =3D "1.0.0"
s.author =3D "Mohammad Khan"
s.email =3D "(e-mail address removed)"
s.homepage =3D "http://www.ruby-agi.or=
g"
s.platform =3D Gem::platform::RUBY
s.summary =3D "Ruby Language API
for Asterisk"
s.files =3D [
"README",
"LICENSE",
"INSTALL",
"DOWNLOAD",
"extconf.rb=
",
"lib/agi.rb=
",
=20
"lib/command.rb",
=20
"lib/asterisk_variable.rb",
"lib/error.=
rb",
=20
"lib/return_status.rb",
=20
"examples/call_log.rb"
]
s.require_path =3D "lib"
s.autorequire =3D "ruby-agi"
#s.test_file =3D "test/test.rb"
s.has_rdoc =3D true
s.extra_rdoc_files =3D ["README"]
s.required_ruby_version =3D '>=3D 1.8.3'
#s.signing_key =3D '/media/cdrom/gem-private_key.p=
em'
#s.cert_chain =3D ['gem-public_cert.pem']
end

if $0 =3D=3D __FILE__
Gem::manage_gems
Gem::Builder.new(SPEC).build
end

#####################
I could make ruby-agi-1.0.0.gem by executing
gem build <gemspec>

But problem is here:

[beeplove@vpn ruby-agi]$ irb
irb(main):001:0> require 'rubygems'
=3D> true
irb(main):002:0> require_gem 'ruby-agi'
ruby-agi
LoadError: no such file to load -- ruby-agi
from /usr/lib/site_ruby/1.8/rubygems/custom_require.rb:22:in `requi=
re__'
from /usr/lib/site_ruby/1.8/rubygems/custom_require.rb:22:in `requi=
re'
from /usr/lib/site_ruby/1.8/rubygems.rb:182:in `activate'
from /usr/lib/site_ruby/1.8/rubygems.rb:181:in `activate'
from /usr/lib/site_ruby/1.8/rubygems.rb:37:in `require_gem_with_opt=
ions'
from /usr/lib/site_ruby/1.8/rubygems.rb:31:in `require_gem'
from (irb):2
irb(main):003:0>

I am not sure, where I am doing wrong. Would anybody please show my mistake=
 
M

Mohammad Khan

Ohh yes, I did it by using,
gem install --local ruby-agi-1.0.0.gem
And getting the error posted in my earlier message.
Sorry, forgot to metion this step.
 
J

Jim Weirich

Mohammad said:
Hello,

First let me show you my gemspec file, [...]
s.files = [
"README",
"LICENSE",
"INSTALL",
"DOWNLOAD",
"extconf.rb",
"lib/agi.rb",
"lib/command.rb",
"lib/asterisk_variable.rb",
"lib/error.rb",
"lib/return_status.rb",
"examples/call_log.rb"
s.require_path = "lib"
s.autorequire = "ruby-agi"
[...]

You autorequire 'ruby-agi', but don't provide a file named 'ruby-agi.rb'
in your lib directory.

I would recommend just dropping the autorequire line. Since modern
versions of RubyGems automatically activates the gems, it is not very
useful.

Your users just need to write:

require 'rubygems'
require 'agi'

No need to invoke require_gem at all (unless you need to specify a
particular version).
 
M

Mohammad Khan

Hi Jim,

Thanks for your help.
Yes, I was not using autorequire correctly.
After looking at couple of other project's gemspec, I understood it better.

Thanks again,
Mohammad



Mohammad said:
Hello,

First let me show you my gemspec file, [...]
s.files =3D [
"README",
"LICENSE",
"INSTALL",
"DOWNLOAD",
"extconf.rb",
"lib/agi.rb",
"lib/command.rb",
"lib/asterisk_variable.rb",
"lib/error.rb",
"lib/return_status.rb",
"examples/call_log.rb"
s.require_path =3D "lib"
s.autorequire =3D "ruby-agi"
[...]

You autorequire 'ruby-agi', but don't provide a file named 'ruby-agi.rb'
in your lib directory.

I would recommend just dropping the autorequire line. Since modern
versions of RubyGems automatically activates the gems, it is not very
useful.

Your users just need to write:

require 'rubygems'
require 'agi'

No need to invoke require_gem at all (unless you need to specify a
particular version).
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,060
Latest member
BuyKetozenseACV

Latest Threads

Top