Gems info showing up in PhoneBook object?

I was just playing with the recent "command" utility. It has a single class.

class PhoneBook < Cmd ..... end

When I install this as a gem, and execute a breakpoint to inspect the
current PhoneBook in irb, and look at "self", I get all kinds of stuff that
is has not been declared anywhere in PhoneBook, as far as I can tell.

self.class

#=> PhoneBook

self

#=>
.... all kinds of stuff about gems as part of "self", many pages long.
      @rubyforge_project=nil,
      @rubygems_version="0.8.10",
      @specification_version=1,
      @summary=
       "This package provides download sources for remote gem installation",
      @test_files=,
      @version=#<Gem::Version:0x2b286a0 @version="0.0.1">>,
     #<Gem::Specification:0x2b26828
      @authors=["Jamis Buck"],
      @autorequire="sqlite3",
      @bindir="bin",
      @date=#<Date: 4906833/2,0,2299161>,
      @default_executable=nil,
      @dependencies=,
      @email="jgb3@email.byu.edu",
      @executables=,
      @extensions=,
      @extra_rdoc_files=["README"],
      @files=
       ["doc/faq",
        "doc/faq/faq.html",
        "doc/faq/faq.yml",
        "doc/faq/faq.rb",
        "ext/sqlite3_api",
        "ext/sqlite3_api/post-clean.rb",
        "ext/sqlite3_api/extconf.rb",
        "ext/sqlite3_api/sqlite3_api.i",
        "ext/sqlite3_api/post-distclean.rb",
        "ext/sqlite3_api/MANIFEST",
        "lib/sqlite3.rb",
        "lib/sqlite3_api.so",
        "lib/sqlite3",
        "lib/sqlite3/statement.rb",
        "lib/sqlite3/database.rb",
        "lib/sqlite3/driver",
        "lib/sqlite3/constants.rb",
        "lib/sqlite3/translator.rb",
        "lib/sqlite3/resultset.rb",
        "lib/sqlite3/value.rb",
        "lib/sqlite3/version.rb",
        "lib/sqlite3/pragmas.rb",
        "lib/sqlite3/errors.rb",
        "lib/sqlite3/driver/dl",
        "lib/sqlite3/driver/native",
        "lib/sqlite3/driver/dl/driver.rb",
        "lib/sqlite3/driver/dl/api.rb",
        "lib/sqlite3/driver/native/driver.rb",
        "test/bm.rb",
        "test/mocks.rb",
        "test/tests.rb",
        "test/tc_integration.rb",
        "test/tc_errors.rb",
        "test/driver",
        "test/native-vs-dl.rb",
        "test/tc_database.rb",
        "test/driver/dl",
        "test/driver/dl/tc_driver.rb",
        "README"],
      @has_rdoc=true,

I am guessing this is gems-related. But of course I could be doing something
really very dumb. Could someone shed some light? Is it from breakpoint/irb?

Also, what method does irb call to display an object? I tried defining to_s
and inspect on PHoneBook but it had no effect.

Thanks.

itsme213 said:

When I install this as a gem, and execute a breakpoint to inspect the
current PhoneBook in irb, and look at "self", I get all kinds of stuff

[...]

self

#=>
.... all kinds of stuff about gems as part of "self", many pages long.

[... stuff elided ...]

I just tried it and got what I would expect in a command object. No wild
gem stuff anywhere. Could you trim it down to a minimum program that
still exhibits the strange behavior. I would like to see that.

Thanks.

···

--
-- Jim Weirich jim@weirichhouse.org http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

itsme213 wrote:

I was just playing with the recent "command" utility. It has a single class.

class PhoneBook < Cmd ..... end

When I install this as a gem, and execute a breakpoint to inspect the
current PhoneBook in irb, and look at "self", I get all kinds of stuff that
is has not been declared anywhere in PhoneBook, as far as I can tell.

What happens when you do 'p PhoneBook.new'?

self.class

#=> PhoneBook

self

#=>

Something important is missing here.

.... all kinds of stuff about gems as part of "self", many pages long.
      @rubyforge_project=nil,
      @rubygems_version="0.8.10",

I wonder why this is intended. Usually .inspect does not indentation.

I am guessing this is gems-related. But of course I could be doing something
really very dumb. Could someone shed some light? Is it from breakpoint/irb?

I've not heard anything about such behavior being caused by the breakpointing library and have personally not seen anything similar happening with IRB or breakpoints. I suspect it might be related to RubyGems or the PhoneBook, but I can't say for sure.

Also, what method does irb call to display an object? I tried defining to_s
and inspect on PHoneBook but it had no effect.

IRB uses .inspect in most cases, but can be configured to use .to_s instead. The breakpoint library does not change this, but there was discussion about exposing IRB's --noinspect option to the breakpoint_client options.

What happens when you do 'p PhoneBook.new'?

irb

Executing break point at phonebook.rb:45 in `do_irb'

irb:001:0> p PhoneBook.new
#<PhoneBook:0x3ab2730 @stop=false, @stdout=#<IO:0x279e7e8>,
@stdin=#<IO:0x279e800>, @

"12345677", "pfgasdsafg"=>nil, "steve 1234"=>nil, "mary"=>"123456"}>

=> nil

irb:002:0> self.class
=> PhoneBook

irb:003:0> p self
......... tons of stuff here, I've captured its head below

irb:004:0> p self.inspect[0...400]
"#<PhoneBook:0x2b3ac28 @command_abbreviations={\"delete\"=>\"delete\",
\"exi\"=>\"exit\", \"fin\"=>\
"find\", \"del\"=>\"delete\", \"lis\"=>\"list\", \"exit\"=>\"exit\",
\"add\"=>\"add\", \"help\"=>\"h
elp\", \"list\"=>\"list\", \"a\"=>\"add\", \"de\"=>\"delete\",
\"l\"=>\"list\", \"irb\"=>\"irb\", \"
ad\"=>\"add\", \"fi\"=>\"find\", \"d\"=>\"delete\", \"dele\"=>\"delete\",
\"delet\"=>\"delete\", \"h
el\"=>\"help\", \"e\"=>\"exit\", \"she\"=>\"shell\", \"f\"=>\"find\",
\"shel\"=>\"shell\", \"f"
=> nil

>>self
>
> #=>

Something important is missing here.

So much stuff prints out that my command-window buffer loses the front end.
It does not print out indented; I used 'pp' for that.

> Also, what method does irb call to display an object? I tried defining

to_s

> and inspect on PHoneBook but it had no effect.

IRB uses .inspect in most cases,

I redefined PhoneBook#inspect (in the irb breakpoint), and

self

still prints out the same stuff.

Like I said, I may be doing something patently dumb.

···

"Florian Groß" <florgro@gmail.com> wrote

itsme213 wrote:

I redefined PhoneBook#inspect (in the irb breakpoint), and

self

still prints out the same stuff.

Like I said, I may be doing something patently dumb.

I think what happens above makes sense, but I am not sure why it does not pick up your custom #inspect. Perhaps you can try using def self.inspect() instead?

Anyway, I'll be able to look into this in more detail easier if you could send me the full source code of your application.