Forum: Ruby Please help on gem packaging

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Mohammad K. (Guest)
on 2005-12-24 17:42
(Received via mailing list)
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 <gemspec>

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:in
`require'
        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_options'
        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.

Thanks,
Mohammad
Erik V. (Guest)
on 2005-12-24 18:18
(Received via mailing list)
> 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/
Mohammad K. (Guest)
on 2005-12-24 19:18
(Received via mailing list)
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.
Jim W. (Guest)
on 2005-12-24 20:28
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.
Mohammad K. (Guest)
on 2005-12-30 04:05
(Received via mailing list)
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
This topic is locked and can not be replied to.