Rubygems - did install went ok?

I think I have prepared my package for rubygems,
however I have no clue how to require it.

http://rubyforge.org/download.php/435/iterator-0.5.gem

I have tried

ruby concat1.rb
concat1.rb:1:in `require’: No such file to load – iterator (LoadError)
from concat1.rb:1
pwd
/usr/home/neoneye/stow/ruby/lib/ruby/gems/1.8/iterator-0.5/samples
expand -t2 concat1.rb
require ‘iterator’

concatenate following 3 strings together, so they

appear to be one string.

ary1 = “Hell”.split(//).to_a
ary2 = “O wO”.split(//).to_a
ary3 = “rld!”.split(//).to_a
i1 = ary1.create_iterator
i2 = ary2.create_iterator
i3 = ary3.create_iterator
iterator = Iterator::Concat.new([i1, i2, i3])
ary2.map!{|i|i.swapcase}
puts iterator.to_a.join #-> Hello World!

Have I done something wrong when releasing it?

···


Simon Strandgaard

gem --list
sources-0.0.1
iterator-0.5
RedCloth-2.0.2
expand -t2 specifications/iterator-0.5.gemspec
Gem::Specification.new do |s|
s.name = %q{iterator}
s.version = %q{0.5}
s.summary = %q{bidirectional external iterators}
s.files = [“LICENSE”, “README”, “TODO”, “lib/iterator.rb”, “samples/concat1.rb”, “samples/continuation1.rb”, “samples/filler1.rb”, “samples/implicit1.rb”, “samples/implicit2.rb”, “samples/multiway1.rb”, “samples/multiway2.rb”, “samples/transformer1.rb”, “test/test_all.rb”, “test/test_iterator.rb”]
s.require_paths = [“lib”]
s.autorequire = %q{iterator}
s.author = %q{Simon Strandgaard}
s.email = %q{neoneye@adslhome.dk}
s.homepage = %q{http://aeditor.rubyforge.org}
s.rubyforge_project = %q{aeditor}
s.description = <<-EOS
The overall design is stable. I don’t expect any big changes.

Collection, iterates over an Array or similar containers.
Reverse, decorator which reverses the iterator.
Range, iterate in the range between two iterators.
Concat, concat multiple iterators into one.
Continuation, turn #each_word/#each_byte into an iterator.
ProxyLast, remembers the last visited value.

Plus some StandardTemplateLibrary inspired methods that operate
on iterators.

#copy
#copy_n
#copy_backward
#fill
#fill_n
#transform
#transform2

EOS
end

Hi,

···

On Mar 19, 2004, at 8:14 PM, Simon Strandgaard wrote:

I think I have prepared my package for rubygems,
however I have no clue how to require it.

http://rubyforge.org/download.php/435/iterator-0.5.gem

I have tried

ruby concat1.rb
concat1.rb:1:in `require’: No such file to load – iterator (LoadError)
from concat1.rb:1
pwd
/usr/home/neoneye/stow/ruby/lib/ruby/gems/1.8/iterator-0.5/samples
expand -t2 concat1.rb
require ‘iterator’

I believe that should be:
require ‘rubygems’
require_gem ‘iterator’

–Mark

I think that you have to do

require ‘rubygems’
require_gem ‘iterator’

…and then use the library as you normally would. I had hoped the
RubyGems overloaded “require” in a clever way so that you could just

require ‘iterator’

and not have to worry about whether iterator is installed as a Gem or as
a “normal” package. It would be nice if there was something like this in
the standard library (perhaps named “rubygems-compat.rb”) that was
require’d automatically:[1] [Parts of this untested because I have
RubyGems installed, but the concept is clear]

rubygems_installed = true

begin
require ‘rubygems’
rescue LoadError
rubygems_installed = false
end

if rubygems_installed

Backwards compatability

alias _old_require require

def require(library)
begin
require_gem(library)
rescue LoadError
_old_require(library)
end
end
else

Forwards compatability

def require_gem(gem, need_version = false)
if need_version
warn “Version requirement #{need_version} given, unable to guarantee version used.”
end
require(gem)
end
end

[1] The more messing around we do with $LOAD_PATH, the more (IMHO) it
looks like it would be nice to have a system-wide “init.rb” that was
required automatically when Ruby starts. The default init.rb could look
something like this:

require ‘rubygems-compat’

We should check $SAFE before we do this, of course.

homeinit = File.join(ENV[“HOME”], “.rubyinit.rb”)
require homeinit if File.exist?(homeinit)

I proposed something like this in the past. I was basically told just to
use RUBYOPT, like so:

export RUBYOPT=“-r$HOME/prog/ruby/init”

…and then put whatever I wanted in ~/prog/ruby/init.rb. This works, but
it isn’t system-wide, which would be nice for some cases.

Whoa, two soapboxen in one post. Better stop now.

Jason Creighton

···

On Sat, 20 Mar 2004 05:07:55 +0100, Simon Strandgaard neoneye@adslhome.dk wrote:

I think I have prepared my package for rubygems,
however I have no clue how to require it.

http://rubyforge.org/download.php/435/iterator-0.5.gem

I have tried

ruby concat1.rb
concat1.rb:1:in `require’: No such file to load – iterator (LoadError)
from concat1.rb:1
pwd
/usr/home/neoneye/stow/ruby/lib/ruby/gems/1.8/iterator-0.5/samples
expand -t2 concat1.rb
require ‘iterator’

[snip]

I believe that should be:
require ‘rubygems’
require_gem ‘iterator’

Thanks, I forgot about require_gem… (must have been tired)

In my gem release would it be a good idea to replace
all occurrencies of
require ‘iterator’
with
require ‘rubygems’
require_gem ‘iterator’
so that the sample directory works ?

Is there some way to automaticly load ‘rubygems’ when ruby starts up?

···

On Sat, 20 Mar 2004 15:57:01 +0900, Mark Hubbart wrote:


Simon Strandgaard

irb(main):001:0> require ‘rubygems’
=> true
irb(main):002:0> require_gem ‘iterator’
=> true
irb(main):003:0> i = %w(a b c).create_iterator
=> #<Iterator::Collection:0x8339af8 @data=[“a”, “b”, “c”], @position=0>
irb(main):004:0> i.current
=> “a”
irb(main):005:0> i.next
=> #<Iterator::Collection:0x8339af8 @data=[“a”, “b”, “c”], @position=1>
irb(main):006:0> i.current
=> “b”
irb(main):007:0> i.has_next?
=> true
irb(main):008:0> i.next
=> #<Iterator::Collection:0x8339af8 @data=[“a”, “b”, “c”], @position=2>
irb(main):009:0> i.has_next?
=> true
irb(main):010:0> i.next
=> #<Iterator::Collection:0x8339af8 @data=[“a”, “b”, “c”], @position=3>
irb(main):011:0> i.has_next?
=> false
irb(main):012:0>

— Jason Creighton androflux@softhome.net.remove.to.reply wrote:

I think that you have to do

require ‘rubygems’
require_gem ‘iterator’

That is how I did it ™

[…snip…]

[1] The more messing around we do with $LOAD_PATH, the more (IMHO) it
looks like it would be nice to have a system-wide “init.rb” that was
required automatically when Ruby starts. The default init.rb could look
something like this:

This is a good idea and something that I thought about doing in the past.
At present there is a workaround for it, but as you say Jason, it is only
on a per-user basis.

export RUBYOPT=“-r$HOME/prog/ruby/init”

Oh well. Come what may, we shall see.

– Thomas Adam

···

=====
“The Linux Weekend Mechanic” – http://linuxgazette.net
“TAG Editor” – http://linuxgazette.net

“ We’ll just save up your sins, Thomas, and punish
you for all of them at once when you get better. The
experience will probably kill you. :)”

– Benjamin A. Okopnik (Linux Gazette Technical Editor)


Yahoo! Messenger - Communicate instantly…“Ping”
your friends today! Download Messenger Now
http://uk.messenger.yahoo.com/download/index.html

[snip]

In my gem release would it be a good idea to replace
all occurrencies of
require ‘iterator’
with
require ‘rubygems’
require_gem ‘iterator’
so that the sample directory works ?

I have just made the above gsub! in the rubygems release,
now all samples+tests should work.

http://rubyforge.org/download.php/437/iterator-0.5fix.gem

BTW: rubygems is our future.

···

On Sat, 20 Mar 2004 11:01:01 +0100, Simon Strandgaard wrote:


Simon Strandgaard

Simon Strandgaard wrote:

In my gem release would it be a good idea to replace
all occurrencies of
require ‘iterator’
with
require ‘rubygems’
require_gem ‘iterator’
so that the sample directory works ?

This seems reasonable to me for now, but I would hate to
see it everywhere for all time.

Is there some way to automaticly load ‘rubygems’ when ruby starts up?

I fear that gems may not be mature/stable enough for this yet. (Please
prove me wrong.)

I was also telling Chad and/or Rich that if gems become a standard, I
would like to see require_gem simply go away.

‘require’ would be modified so that it looked for a gem before anything
else. This would also make “require ‘rubygems’” unnecessary.

But I think we’re not there yet.

Hal

Simon Strandgaard wrote:

In my gem release would it be a good idea to replace
all occurrencies of require ‘iterator’ with require ‘rubygems’
require_gem ‘iterator’
so that the sample directory works ?

This seems reasonable to me for now, but I would hate to
see it everywhere for all time.

Is there some way to automaticly load ‘rubygems’ when ruby starts up?

I fear that gems may not be mature/stable enough for this yet. (Please
prove me wrong.)

“Alpha” would imply that you are right :slight_smile:

I was also telling Chad and/or Rich that if gems become a standard, I
would like to see require_gem simply go away.

‘require’ would be modified so that it looked for a gem before anything
else. This would also make “require ‘rubygems’” unnecessary.

That might be a good thing to do eventually, but I think it’s good to
keep things obviously separate while we stabilize RubyGems. We have
always said that RubyGems doesn’t replace the ‘require’ facility, but
it might be possible to augment that facility in the way that you Jason
Creighton have proposed.

Chad

···

On Mar 20, 2004, at 1:09 PM, Hal Fulton wrote:

The only issue here is that ‘require’ does not modify the $LOAD_PATH
like require_gem does. Changing the meaning of ‘require’ would
ultimately have to be something Matz decides, not us. Once RubyGems
system (especially the ‘runtime’ aspect of it) gets stable we will then
present it to Matz likely as an RCR and then figure out the final way
it will integrated into the Ruby runtime (if accepted).

-rich

···

On Mar 21, 2004, at 9:16 AM, Chad Fowler wrote:

I was also telling Chad and/or Rich that if gems become a standard, I
would like to see require_gem simply go away.

‘require’ would be modified so that it looked for a gem before
anything
else. This would also make “require ‘rubygems’” unnecessary.

That might be a good thing to do eventually, but I think it’s good to
keep things obviously separate while we stabilize RubyGems. We have
always said that RubyGems doesn’t replace the ‘require’ facility, but
it might be possible to augment that facility in the way that you
Jason Creighton have proposed.

Richard Kilmer wrote:

I was also telling Chad and/or Rich that if gems become a standard, I
would like to see require_gem simply go away.

‘require’ would be modified so that it looked for a gem before anything
else. This would also make “require ‘rubygems’” unnecessary.

That might be a good thing to do eventually, but I think it’s good to
keep things obviously separate while we stabilize RubyGems. We have
always said that RubyGems doesn’t replace the ‘require’ facility, but
it might be possible to augment that facility in the way that you
Jason Creighton have proposed.

The only issue here is that ‘require’ does not modify the $LOAD_PATH
like require_gem does. Changing the meaning of ‘require’ would
ultimately have to be something Matz decides, not us. Once RubyGems
system (especially the ‘runtime’ aspect of it) gets stable we will then
present it to Matz likely as an RCR and then figure out the final way it
will integrated into the Ruby runtime (if accepted).

Certainly. I was speaking of a more distant future when the gem spec was
stable and gems were common.

And obviously it would be Matz’s decision. All I’m saying is that

  1. In the long run, we shouldn’t have to do ‘require “gems”’ in
    (virtually) every single Ruby program
  2. The additional burden of a gem_require seems rather a nuisance
    to me. I grant you the semantics are different from require. But
    to me it is as if we had require_rb, require_so, require_dll
    (instead of simply require).

Anyway, my comments were meant to be highly conditional:

  • if/when gems stabilize
  • when/if gems are common as dirt
  • when/if someone suggests such an idea and Matz approves it

Cheers,
Hal

···

On Mar 21, 2004, at 9:16 AM, Chad Fowler wrote:

[snip]

And obviously it would be Matz’s decision. All I’m saying is that

  1. In the long run, we shouldn’t have to do ‘require “gems”’ in
    (virtually) every single Ruby program
  2. The additional burden of a gem_require seems rather a nuisance
    to me. I grant you the semantics are different from require. But
    to me it is as if we had require_rb, require_so, require_dll
    (instead of simply require).

Anyway, my comments were meant to be highly conditional:

  • if/when gems stabilize
  • when/if gems are common as dirt
  • when/if someone suggests such an idea and Matz approves it

Instead of making an RCR to change require, I think of:

Would it be possible to execute some Ruby code at that point when the Ruby
interpreter is invoked, and then add the ‘require_gem’ keyword ?

Is this more realistic ?

···

On Mon, 22 Mar 2004 04:16:21 +0900, Hal Fulton wrote:


Simon Strandgaard

Simon Strandgaard wrote:

···

On Mon, 22 Mar 2004 04:16:21 +0900, Hal Fulton wrote:
[snip]

And obviously it would be Matz’s decision. All I’m saying is that

  1. In the long run, we shouldn’t have to do ‘require “gems”’ in
    (virtually) every single Ruby program
  2. The additional burden of a gem_require seems rather a nuisance
    to me. I grant you the semantics are different from require. But
    to me it is as if we had require_rb, require_so, require_dll
    (instead of simply require).

Anyway, my comments were meant to be highly conditional:

  • if/when gems stabilize
  • when/if gems are common as dirt
  • when/if someone suggests such an idea and Matz approves it

Instead of making an RCR to change require, I think of:

Would it be possible to execute some Ruby code at that point when the Ruby
interpreter is invoked, and then add the ‘require_gem’ keyword ?

Is this more realistic ?

It could certainly be done. But see #2 above.

Hal