Please help on gem packaging


#1

Hello,

First let me show you my gemspec file,

#########################
require ‘rubygems’

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

    s.name                                  = "ruby-agi"
    s.version                               = "1.0.0"
    s.author                                = "Mohammad K."
    s.email                                 = "removed_email_address@domain.invalid"
    s.homepage                              = 

http://www.ruby-agi.org
s.platform = Gem::Platform::RUBY
s.summary = “Ruby Language API
for Asterisk”
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”
#s.test_file = “test/test.rb”
s.has_rdoc = true
s.extra_rdoc_files = [“README”]
s.required_ruby_version = ‘>= 1.8.3’
#s.signing_key =
‘/media/cdrom/gem-private_key.pem’
#s.cert_chain = [‘gem-public_cert.pem’]
end

if $0 == FILE
Gem::manage_gems
Gem::Builder.new(SPEC).build
end

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

But problem is here:

[beeplove@vpn ruby-agi]$ irb
irb(main):001:0> require ‘rubygems’
=> 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
require__' from /usr/lib/site_ruby/1.8/rubygems/custom_require.rb:22:inrequire’
from /usr/lib/site_ruby/1.8/rubygems.rb:182:in activate' from /usr/lib/site_ruby/1.8/rubygems.rb:181:inactivate’
from /usr/lib/site_ruby/1.8/rubygems.rb:37:in
require_gem_with_options' from /usr/lib/site_ruby/1.8/rubygems.rb:31:inrequire_gem’
from (irb):2
irb(main):003:0>

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

Thanks,
Mohammad


#2

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

Between building a gem and using that gem, you probably have to
install it.

gegroet,
Erik V. - http://www.erikveen.dds.nl/


#3

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.


#4

Mohammad K. wrote:

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).


– Jim W.


#5

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