Permalink
Browse files

Hi.

  • Loading branch information...
0 parents commit cfde203458a2c1f37d1aebbfd4ac1ff245497371 @oggy committed Apr 11, 2009
Showing with 820 additions and 0 deletions.
  1. +9 −0 .autotest
  2. 0 History.txt
  3. +15 −0 Manifest.txt
  4. +120 −0 README.rdoc
  5. +35 −0 Rakefile
  6. +5 −0 ext/looksee/extconf.rb
  7. +56 −0 ext/looksee/looksee.c
  8. +229 −0 lib/looksee.rb
  9. +3 −0 lib/looksee/version.rb
  10. +10 −0 script/console
  11. +14 −0 script/destroy
  12. +14 −0 script/generate
  13. +254 −0 spec/looksee_spec.rb
  14. +13 −0 tasks/extconf.rake
  15. +43 −0 tasks/extconf/looksee.rake
@@ -0,0 +1,9 @@
+Autotest.add_hook :initialize do |at|
+ at.add_mapping(/ext\/.*\/(.*)\.[ch]/) do |_, m|
+ ["test/test_#{m[1]}_extn.rb"]
+ end
+end
+
+Autotest.add_hook :run_command do |at|
+ system "rake compile"
+end
No changes.
@@ -0,0 +1,15 @@
+.autotest
+History.txt
+Manifest.txt
+README.rdoc
+Rakefile
+ext/looksee/extconf.rb
+ext/looksee/looksee.c
+lib/looksee.rb
+lib/looksee/version.rb
+script/console
+script/destroy
+script/generate
+spec/looksee_spec.rb
+tasks/extconf.rake
+tasks/extconf/looksee.rake
@@ -0,0 +1,120 @@
+= Looksee
+
+* http://github.com/oggy/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'
+ def ls(*args)
+ Looksee.looksee(*args)
+ end
+
+Now:
+
+ irb(main):001:0> ls []
+ => 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, or overridden. So pretty. You gotta try it.
+
+By default, it shows public and protected methods. Add private ones
+with:
+
+ ls [], :private => true
+ ls [], :private # shortcut
+
+Or if you don't want protected:
+
+ ls [], :protected => false
+
+You can configure the defaults and colors:
+
+ ri Looksee
+
+Enjoy!
+
+== INSTALL:
+
+ gem install looksee
+
+== FEATURES/PROBLEMS:
+
+* Currently only does MRI 1.8, 1.9.
+
+== LICENSE:
+
+(The MIT License)
+
+Copyright (c) 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.
@@ -0,0 +1,35 @@
+%w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
+require File.dirname(__FILE__) + '/lib/looksee/version'
+
+$hoe = Hoe.new('looksee', Looksee::VERSION) do |p|
+ p.developer('FIXME full name', 'FIXME email')
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
+ #p.post_install_message = 'PostInstall.txt'
+ p.rubyforge_name = p.name
+ #p.extra_deps = [['gemname', 'version']]
+ p.extra_dev_deps = [
+ ['newgem', ">= #{::Newgem::VERSION}"],
+ ['rspec', '1.2.0'],
+ ['mocha', '0.9.5'],
+ ]
+
+ p.clean_globs |= %w[**/.DS_Store tmp *.log]
+ path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
+ p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
+ p.rsync_args = '-av --delete --ignore-errors'
+end
+
+# Configure the clean and clobber tasks.
+require 'rbconfig'
+CLEAN.include('**/*.o')
+CLOBBER.include("ext/looksee/looksee.#{Config::CONFIG['DLEXT']}")
+
+require 'newgem/tasks' # loads /tasks/*.rake
+Dir['tasks/**/*.rake'].each { |t| load t }
+
+task :default => :spec
+
+require 'spec/rake/spectask'
+Spec::Rake::SpecTask.new(:spec => :compile) do |t|
+ t.libs << 'lib'
+end
@@ -0,0 +1,5 @@
+require 'mkmf'
+
+dir_config("looksee")
+
+create_makefile("looksee")
@@ -0,0 +1,56 @@
+#include "ruby.h"
+
+//
+// Return the internal superclass of this class.
+//
+// This is either a Class or "IClass." IClasses represent Modules
+// included in the ancestry, and should be treated as opaque objects
+// in ruby space. Convert the IClass to a Module using #iclass_to_module
+// before using it in ruby.
+//
+VALUE Looksee_internal_superclass(VALUE self, VALUE internal_class) {
+ VALUE super = RCLASS(internal_class)->super;
+ // return BUILTIN_TYPE(super) == T_ICLASS ? RBASIC(super)->klass : super;
+ if (!super)
+ return Qnil;
+ return super;
+}
+
+//
+// Return the internal class of the given object.
+//
+// This is either the object's singleton class, if it exists, or the
+// object's birth class.
+//
+VALUE Looksee_internal_class(VALUE self, VALUE object) {
+ return RBASIC(object)->klass;
+}
+
+//
+// Return the class or module that the given internal class
+// represents.
+//
+// If a class is given, this is the class. If an iclass is given,
+// this is the module it represents in the lookup chain.
+//
+VALUE Looksee_internal_class_to_module(VALUE self, VALUE internal_class) {
+ if (!SPECIAL_CONST_P(internal_class)) {
+ switch (BUILTIN_TYPE(internal_class)) {
+ case T_ICLASS:
+ return RBASIC(internal_class)->klass;
+ case T_CLASS:
+ return internal_class;
+ }
+ }
+ rb_raise(rb_eArgError, "not an internal class: %s", RSTRING(rb_inspect(internal_class))->ptr);
+}
+
+//
+// Library initializer.
+//
+void Init_looksee(void) {
+ VALUE mLooksee = rb_define_module("Looksee");
+ rb_define_singleton_method(mLooksee, "internal_superclass", Looksee_internal_superclass, 1);
+ rb_define_singleton_method(mLooksee, "internal_class", Looksee_internal_class, 1);
+ rb_define_singleton_method(mLooksee, "internal_class_to_module", Looksee_internal_class_to_module, 1);
+}
Oops, something went wrong.

0 comments on commit cfde203

Please sign in to comment.