public
Description: Examine the precise method lookup path of any ruby object in ways not possible in standard ruby.
Homepage:
Clone URL: git://github.com/oggy/looksee.git
name age message
file .autotest Sat Apr 11 10:42:40 -0700 2009 Hi. [oggy]
file .gitignore Fri Jul 24 11:36:14 -0700 2009 Fix up output when Wirble colorizing is on. [oggy]
file History.txt Sun Aug 30 01:58:29 -0700 2009 Update history. [oggy]
file Manifest.txt Fri Jul 24 12:44:35 -0700 2009 Update manifest. [oggy]
file README.rdoc Wed Sep 30 07:49:49 -0700 2009 Mention module style in README. [oggy]
file Rakefile Sun Jul 05 23:59:49 -0700 2009 Use email hoe plugin so we can send announcemen... [oggy]
directory ext/ Thu Aug 20 06:25:47 -0700 2009 Add methods undefined with Module#undef_method.... [oggy]
directory lib/ Sun Aug 30 01:58:59 -0700 2009 Bump version. Github already built 0.2.0. [oggy]
file looksee.gemspec Sun Aug 30 01:58:59 -0700 2009 Bump version. Github already built 0.2.0. [oggy]
directory script/ Sun Aug 30 01:44:30 -0700 2009 Put lib at the front of the load path when usin... [oggy]
directory spec/ Thu Aug 20 06:25:47 -0700 2009 Add methods undefined with Module#undef_method.... [oggy]
directory tasks/ Wed Jun 24 20:45:01 -0700 2009 Fix running under ruby 1.9. 1.9 defines RUBY_P... [oggy]
README.rdoc

Looksee

DESCRIPTION

Looksee lets you examine the method lookup path of objects in ways not possible in plain ruby.

SYNOPSIS

Pop this in your .irbrc :

    require 'looksee/shortcuts'

This defines a method lp ("lookup path") which lets you do:

    irb(main):001:0> lp []
    => Array
      &            concat      frozen?      push          taguri
      *            count       hash         rassoc        taguri=
      +            cycle       include?     reject        take
      -            delete      index        reject!       take_while
      <<           delete_at   indexes      replace       to_a
      <=>          delete_if   indices      reverse       to_ary
      ==           drop        insert       reverse!      to_s
      []           drop_while  inspect      reverse_each  to_yaml
      []=          each        join         rindex        transpose
      assoc        each_index  last         select        uniq
      at           empty?      length       shift         uniq!
      choice       eql?        map          shuffle       unshift
      clear        fetch       map!         shuffle!      values_at
      collect      fill        nitems       size          yaml_initialize
      collect!     find_index  pack         slice         zip
      combination  first       permutation  slice!        |
      compact      flatten     pop          sort
      compact!     flatten!    product      sort!
    Enumerable
      all?        each_slice       first     min        reverse_each
      any?        each_with_index  grep      min_by     select
      collect     entries          group_by  minmax     sort
      count       enum_cons        include?  minmax_by  sort_by
      cycle       enum_slice       inject    none?      take
      detect      enum_with_index  map       one?       take_while
      drop        find             max       partition  to_a
      drop_while  find_all         max_by    reduce     zip
      each_cons   find_index       member?   reject
    Object
      taguri  taguri=  to_yaml  to_yaml_properties  to_yaml_style
    Kernel
      ==        hash                        object_id
      ===       id                          private_methods
      =~        inspect                     protected_methods
      __id__    instance_eval               public_methods
      __send__  instance_exec               respond_to?
      class     instance_of?                send
      clone     instance_variable_defined?  singleton_methods
      display   instance_variable_get       taint
      dup       instance_variable_set       tainted?
      enum_for  instance_variables          tap
      eql?      is_a?                       to_a
      equal?    kind_of?                    to_enum
      extend    method                      to_s
      freeze    methods                     type
      frozen?   nil?                        untaint

It’ll also color the methods according to whether they’re public, protected, private, undefined (using Module#undef_method), or overridden. So pretty. The default colors are:

    public:     white
    public:     green
    protected:  yellow
    private:    red
    undefined:  blue
    overridden: black

By default, it shows public and protected methods. Add private ones like so:

    lp [], :private => true
    lp [], :private          # shortcut

Or if you don’t want protected:

    lp [], :protected => false

There are variations too. And you can configure things. And you can use it as a library without polluting the built-in classes. See:

    $ ri Looksee

Or do this in IRB for a quick reference:

    Looksee.help

Enjoy!

INSTALL

  gem install looksee

FEATURES/PROBLEMS

  • Currently only does MRI 1.8, 1.9.

LICENSE

(The MIT License)

Copyright © 2009 George Ogata

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.