looksee 0.2.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/CHANGELOG +14 -0
  2. data/LICENSE +22 -0
  3. data/README.markdown +161 -0
  4. data/Rakefile +9 -36
  5. data/ext/extconf.rb +9 -0
  6. data/ext/mri/1.9.2/debug.h +36 -0
  7. data/ext/mri/1.9.2/id.h +170 -0
  8. data/ext/mri/1.9.2/method.h +103 -0
  9. data/ext/mri/1.9.2/node.h +483 -0
  10. data/ext/mri/1.9.2/thread_pthread.h +27 -0
  11. data/ext/mri/1.9.2/vm_core.h +707 -0
  12. data/ext/mri/1.9.2/vm_opts.h +51 -0
  13. data/ext/mri/env-1.8.h +27 -0
  14. data/ext/mri/eval_c-1.8.h +27 -0
  15. data/ext/mri/mri.c +269 -0
  16. data/ext/{looksee → mri}/node-1.9.h +0 -0
  17. data/ext/rbx/rbx.c +13 -0
  18. data/lib/looksee.rb +4 -385
  19. data/lib/looksee/adapter.rb +10 -0
  20. data/lib/looksee/adapter/base.rb +100 -0
  21. data/lib/looksee/adapter/rubinius.rb +73 -0
  22. data/lib/looksee/clean.rb +122 -0
  23. data/lib/looksee/columnizer.rb +73 -0
  24. data/lib/looksee/core_ext.rb +59 -0
  25. data/lib/looksee/editor.rb +58 -0
  26. data/lib/looksee/help.rb +54 -0
  27. data/lib/looksee/inspector.rb +55 -0
  28. data/lib/looksee/lookup_path.rb +95 -0
  29. data/lib/looksee/rbx.bundle +0 -0
  30. data/lib/looksee/shortcuts.rb +1 -105
  31. data/lib/looksee/version.rb +9 -1
  32. data/lib/looksee/wirble_compatibility.rb +2 -3
  33. data/spec/adapter_spec.rb +546 -0
  34. data/spec/columnizer_spec.rb +52 -0
  35. data/spec/core_ext_spec.rb +41 -0
  36. data/spec/editor_spec.rb +128 -0
  37. data/spec/inspector_spec.rb +178 -0
  38. data/spec/lookup_path_spec.rb +84 -0
  39. data/spec/spec_helper.rb +13 -127
  40. data/spec/support/core_ext.rb +25 -0
  41. data/spec/support/temporary_classes.rb +102 -0
  42. data/spec/support/test_adapter.rb +72 -0
  43. data/spec/wirble_compatibility_spec.rb +20 -23
  44. metadata +91 -57
  45. data/.autotest +0 -9
  46. data/History.txt +0 -22
  47. data/Manifest.txt +0 -21
  48. data/README.rdoc +0 -129
  49. data/ext/looksee/extconf.rb +0 -6
  50. data/ext/looksee/looksee.c +0 -144
  51. data/looksee.gemspec +0 -44
  52. data/script/console +0 -7
  53. data/script/destroy +0 -14
  54. data/script/generate +0 -14
  55. data/spec/looksee_spec.rb +0 -425
  56. data/tasks/extconf.rake +0 -13
  57. data/tasks/extconf/looksee.rake +0 -43
data/CHANGELOG ADDED
@@ -0,0 +1,14 @@
1
+ == 1.0.0 2011-03-09
2
+
3
+ * New API.
4
+ * old: lp(object, :private => true, :undefined => false).grep(/blah/)
5
+ * new: object.ls :private, :noundefined, /blah/
6
+ * Configuration has changed accordingly.
7
+ * old: Looksee.default_lookup_path_options = {:private => true, :undefined => false}
8
+ * new: Looksee.default_specifiers = [:private, :noundefined]
9
+ * Require 'looksee' instead of 'looksee/shortcuts'. For
10
+ non-pollutiness, use "require 'looksee/clean'".
11
+ * All methods are now listed by default.
12
+ * Modules are now listed root class first.
13
+ * Support for Ruby MRI 1.9, JRuby, and Rubinius.
14
+ * Add Object#edit(METHOD), to open Object#METHOD in your text editor.
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License
2
+
3
+ Copyright (c) George Ogata
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,161 @@
1
+ # Looksee
2
+
3
+ A tool for illustrating the ancestry and method lookup path of
4
+ objects. Great for exploring unfamiliar codebases!
5
+
6
+ ## How
7
+
8
+ Install me:
9
+
10
+ gem install looksee
11
+
12
+ Pop this in your `.irbrc`:
13
+
14
+ require 'looksee'
15
+
16
+ Now each object has a method `ls`, which shows you all its methods.
17
+
18
+ irb> [].ls
19
+ => BasicObject
20
+ ! __send__ instance_eval singleton_method_added
21
+ != equal? instance_exec singleton_method_removed
22
+ == initialize method_missing singleton_method_undefined
23
+ Kernel
24
+ !~ freeze puts
25
+ <=> frozen? raise
26
+ === gem rand
27
+ =~ gem_original_require readline
28
+ Array gets readlines
29
+ Complex global_variables remove_instance_variable
30
+ Float hash require
31
+ Integer initialize_clone require_relative
32
+ Rational initialize_copy respond_to?
33
+ String initialize_dup respond_to_missing?
34
+ URI inspect select
35
+ __callee__ instance_of? send
36
+ __id__ instance_variable_defined? set_trace_func
37
+ __method__ instance_variable_get singleton_class
38
+ ` instance_variable_set singleton_methods
39
+ abort instance_variables sleep
40
+ at_exit is_a? spawn
41
+ autoload iterator? sprintf
42
+ autoload? kind_of? srand
43
+ binding lambda syscall
44
+ block_given? load system
45
+ caller local_variables taint
46
+ catch loop tainted?
47
+ class method tap
48
+ clone methods test
49
+ define_singleton_method nil? throw
50
+ display object_id to_enum
51
+ dup open to_s
52
+ enum_for p trace_var
53
+ eql? print trap
54
+ eval printf trust
55
+ exec private_methods untaint
56
+ exit proc untrace_var
57
+ exit! protected_methods untrust
58
+ extend public_method untrusted?
59
+ fail public_methods warn
60
+ fork public_send y
61
+ format putc
62
+ Looksee::ObjectMixin
63
+ edit ls
64
+ Object
65
+ default_src_encoding oauth taguri to_yaml_properties
66
+ in? patch taguri= to_yaml_style
67
+ irb_binding singleton_class timeout
68
+ load_if_available syck_to_yaml to_yaml
69
+ Enumerable
70
+ all? drop_while first min select
71
+ any? each_cons flat_map min_by slice_before
72
+ by each_entry grep minmax sort
73
+ chunk each_slice group_by minmax_by sort_by
74
+ collect each_with_index include? none? take
75
+ collect_concat each_with_object inject one? take_while
76
+ count entries map partition to_a
77
+ cycle find max reduce to_set
78
+ detect find_all max_by reject zip
79
+ drop find_index member? reverse_each
80
+ Array
81
+ & drop_while map! size
82
+ * each pack slice
83
+ + each_index permutation slice!
84
+ - empty? pop sort
85
+ << eql? product sort!
86
+ <=> fetch push sort_by!
87
+ == fill rassoc taguri
88
+ [] find_index reject taguri=
89
+ []= first reject! take
90
+ assoc flatten repeated_combination take_while
91
+ at flatten! repeated_permutation to_a
92
+ clear frozen? replace to_ary
93
+ collect hash reverse to_s
94
+ collect! include? reverse! to_yaml
95
+ combination index reverse_each transpose
96
+ compact initialize rindex uniq
97
+ compact! initialize_copy rotate uniq!
98
+ concat insert rotate! unshift
99
+ count inspect sample values_at
100
+ cycle join select yaml_initialize
101
+ delete keep_if select! zip
102
+ delete_at last shift |
103
+ delete_if length shuffle
104
+ drop map shuffle!
105
+
106
+ Methods are colored according to whether they're public, protected,
107
+ private, undefined (using Module#undef_method), or overridden.
108
+
109
+ You can hide, say, private methods like this:
110
+
111
+ irb> [].ls :noprivate
112
+
113
+ Or filter the list by Regexp:
114
+
115
+ irb> [].ls /^to_/
116
+ => BasicObject
117
+ Kernel
118
+ to_enum to_s
119
+ Looksee::ObjectMixin
120
+ Object
121
+ to_yaml to_yaml_properties to_yaml_style
122
+ Enumerable
123
+ to_a to_set
124
+ Array
125
+ to_a to_ary to_s to_yaml
126
+
127
+ And if you want to know more about any of those methods, Looksee can
128
+ take you straight to the source in your editor:
129
+
130
+ > [].edit('to_set')
131
+
132
+ By default, this uses `vi`; customize it like this:
133
+
134
+ # %f = file, %l = line number
135
+ Looksee.editor = "mate -l%l %f"
136
+
137
+ See more in the quick reference:
138
+
139
+ irb> Looksee.help
140
+
141
+ Enjoy!
142
+
143
+ ## Support
144
+
145
+ Looksee works with:
146
+
147
+ * MRI/REE (>= 1.8.6)
148
+ * JRuby (>= 1.5.6)
149
+ * Rubinius (>= 1.2.1)
150
+
151
+ ## Contributing
152
+
153
+ * [Bug reports](https://github.com/oggy/looksee/issues)
154
+ * [Source](https://github.com/oggy/looksee)
155
+ * Patches: Fork on Github, send pull request.
156
+ * Include tests where practical.
157
+ * Leave the version alone, or bump it in a separate commit.
158
+
159
+ ## Copyright
160
+
161
+ Copyright (c) George Ogata. See LICENSE for details.
data/Rakefile CHANGED
@@ -1,37 +1,10 @@
1
- require 'rubygems'
2
- gem 'hoe', '>= 2.1.0'
3
- require 'hoe'
4
- require 'fileutils'
5
-
6
- require './lib/looksee/version'
7
-
8
- Hoe.plugin :newgem
9
- Hoe.plugin :email # from seattlerb - configure via ~/.hoerc
10
-
11
- $hoe = Hoe.spec 'looksee' do
12
- self.developer 'George Ogata', 'george.ogata@gmail.com'
13
- self.rubyforge_name = self.name # TODO this is default value
14
- # self.extra_deps = [['activesupport','>= 2.0.2']]
15
- self.extra_dev_deps = [
16
- ['newgem', ">= #{::Newgem::VERSION}"],
17
- ['rspec', '>= 1.2.7'],
18
- ['mocha', '>= 0.9.5'],
19
- ]
1
+ require 'ritual'
2
+
3
+ case (Object.const_defined?(:RUBY_ENGINE) ? RUBY_ENGINE : 'ruby')
4
+ when 'ruby'
5
+ extension :mri
6
+ when 'rbx'
7
+ extension :rbx
8
+ when 'jruby'
9
+ extension :jruby, :type => :jruby
20
10
  end
21
-
22
- # Configure the clean and clobber tasks.
23
- require 'rake/clean'
24
- require 'rbconfig'
25
- CLEAN.include('**/*.o')
26
- CLOBBER.include("ext/looksee/looksee.#{Config::CONFIG['DLEXT']}")
27
-
28
- require 'newgem/tasks' # loads /tasks/*.rake
29
- Dir['tasks/**/*.rake'].each { |t| load t }
30
-
31
- desc "Rebuild the gem from scratch."
32
- task :regem => [:clobber, :gem]
33
-
34
- # Force build before running specs.
35
- Rake::Task['spec'].prerequisites << 'extconf:compile'
36
-
37
- task :default => :spec
data/ext/extconf.rb ADDED
@@ -0,0 +1,9 @@
1
+ ruby_engine = Object.const_defined?(:RUBY_ENGINE) ? RUBY_ENGINE : 'mri'
2
+ extension = ruby_engine == 'ruby' ? 'mri' : ruby_engine
3
+
4
+ require 'mkmf'
5
+ $CPPFLAGS << " -DRUBY_VERSION=#{RUBY_VERSION.tr('.', '')}"
6
+ if extension == 'mri'
7
+ $CPPFLAGS << " -Imri/1.9.2" if RUBY_VERSION >= '1.9.2'
8
+ end
9
+ create_makefile "looksee/#{extension}", extension
@@ -0,0 +1,36 @@
1
+ /**********************************************************************
2
+
3
+ debug.h - YARV Debug function interface
4
+
5
+ $Author: akr $
6
+ created at: 04/08/25 02:33:49 JST
7
+
8
+ Copyright (C) 2004-2007 Koichi Sasada
9
+
10
+ **********************************************************************/
11
+
12
+ #ifndef RUBY_DEBUG_H
13
+ #define RUBY_DEBUG_H
14
+
15
+ #include "ruby/ruby.h"
16
+ #include "node.h"
17
+
18
+ #define dpv(h,v) ruby_debug_print_value(-1, 0, h, v)
19
+ #define dp(v) ruby_debug_print_value(-1, 0, "", v)
20
+ #define dpi(i) ruby_debug_print_id(-1, 0, "", i)
21
+ #define dpn(n) ruby_debug_print_node(-1, 0, "", n)
22
+
23
+ #define bp() ruby_debug_breakpoint()
24
+
25
+ VALUE ruby_debug_print_value(int level, int debug_level, const char *header, VALUE v);
26
+ ID ruby_debug_print_id(int level, int debug_level, const char *header, ID id);
27
+ NODE *ruby_debug_print_node(int level, int debug_level, const char *header, const NODE *node);
28
+ int ruby_debug_print_indent(int level, int debug_level, int indent_level);
29
+ void ruby_debug_breakpoint(void);
30
+ void ruby_debug_gc_check_func(void);
31
+
32
+ #ifdef RUBY_DEBUG_ENV
33
+ void ruby_set_debug_option(const char *str);
34
+ #endif
35
+
36
+ #endif /* RUBY_DEBUG_H */
@@ -0,0 +1,170 @@
1
+ /* DO NOT EDIT THIS FILE DIRECTLY */
2
+ /**********************************************************************
3
+
4
+ id.h -
5
+
6
+ $Author: akr $
7
+ created at: Sun Oct 19 21:12:51 2008
8
+
9
+ Copyright (C) 2007 Koichi Sasada
10
+
11
+ **********************************************************************/
12
+
13
+ #ifndef RUBY_ID_H
14
+ #define RUBY_ID_H
15
+
16
+ #define ID_SCOPE_SHIFT 3
17
+ #define ID_SCOPE_MASK 0x07
18
+ #define ID_LOCAL 0x00
19
+ #define ID_INSTANCE 0x01
20
+ #define ID_GLOBAL 0x03
21
+ #define ID_ATTRSET 0x04
22
+ #define ID_CONST 0x05
23
+ #define ID_CLASS 0x06
24
+ #define ID_JUNK 0x07
25
+ #define ID_INTERNAL ID_JUNK
26
+
27
+ #ifdef USE_PARSE_H
28
+ #include "parse.h"
29
+ #endif
30
+
31
+ #define symIFUNC ID2SYM(idIFUNC)
32
+ #define symCFUNC ID2SYM(idCFUNC)
33
+
34
+ #if !defined tLAST_TOKEN && defined YYTOKENTYPE
35
+ #define tLAST_TOKEN tLAST_TOKEN
36
+ #endif
37
+
38
+ enum ruby_method_ids {
39
+ #ifndef tLAST_TOKEN
40
+ tUPLUS = 321,
41
+ tUMINUS = 322,
42
+ tPOW = 323,
43
+ tCMP = 324,
44
+ tEQ = 325,
45
+ tEQQ = 326,
46
+ tNEQ = 327,
47
+ tGEQ = 328,
48
+ tLEQ = 329,
49
+ tANDOP = 330,
50
+ tOROP = 331,
51
+ tMATCH = 332,
52
+ tNMATCH = 333,
53
+ tDOT2 = 334,
54
+ tDOT3 = 335,
55
+ tAREF = 336,
56
+ tASET = 337,
57
+ tLSHFT = 338,
58
+ tRSHFT = 339,
59
+ tLAMBDA = 352,
60
+ idNULL = 365,
61
+ idRespond_to = 366,
62
+ idIFUNC = 367,
63
+ idCFUNC = 368,
64
+ id_core_set_method_alias = 369,
65
+ id_core_set_variable_alias = 370,
66
+ id_core_undef_method = 371,
67
+ id_core_define_method = 372,
68
+ id_core_define_singleton_method = 373,
69
+ id_core_set_postexe = 374,
70
+ tLAST_TOKEN = 375,
71
+ #endif
72
+ idDot2 = tDOT2,
73
+ idDot3 = tDOT3,
74
+ idUPlus = tUPLUS,
75
+ idUMinus = tUMINUS,
76
+ idPow = tPOW,
77
+ idCmp = tCMP,
78
+ idPLUS = '+',
79
+ idMINUS = '-',
80
+ idMULT = '*',
81
+ idDIV = '/',
82
+ idMOD = '%',
83
+ idLT = '<',
84
+ idLTLT = tLSHFT,
85
+ idLE = tLEQ,
86
+ idGT = '>',
87
+ idGE = tGEQ,
88
+ idEq = tEQ,
89
+ idEqq = tEQQ,
90
+ idNeq = tNEQ,
91
+ idNot = '!',
92
+ idBackquote = '`',
93
+ idEqTilde = tMATCH,
94
+ idNeqTilde = tNMATCH,
95
+ idAREF = tAREF,
96
+ idASET = tASET,
97
+ idLAST_TOKEN = tLAST_TOKEN >> ID_SCOPE_SHIFT,
98
+ tIntern,
99
+ tMethodMissing,
100
+ tLength,
101
+ tSize,
102
+ tGets,
103
+ tSucc,
104
+ tEach,
105
+ tLambda,
106
+ tSend,
107
+ t__send__,
108
+ tInitialize,
109
+ #if SUPPORT_JOKE
110
+ tBitblt,
111
+ tAnswer,
112
+ #endif
113
+ tLAST_ID,
114
+ #define TOKEN2ID(n) id##n = ((t##n<<ID_SCOPE_SHIFT)|ID_LOCAL)
115
+ #if SUPPORT_JOKE
116
+ TOKEN2ID(Bitblt),
117
+ TOKEN2ID(Answer),
118
+ #endif
119
+ TOKEN2ID(Intern),
120
+ TOKEN2ID(MethodMissing),
121
+ TOKEN2ID(Length),
122
+ TOKEN2ID(Size),
123
+ TOKEN2ID(Gets),
124
+ TOKEN2ID(Succ),
125
+ TOKEN2ID(Each),
126
+ TOKEN2ID(Lambda),
127
+ TOKEN2ID(Send),
128
+ TOKEN2ID(__send__),
129
+ TOKEN2ID(Initialize)
130
+ };
131
+
132
+ #ifdef tLAST_TOKEN
133
+ struct ruby_method_ids_check {
134
+ #define ruby_method_id_check_for(name, value) \
135
+ int checking_for_##name[name == value ? 1 : -1]
136
+ ruby_method_id_check_for(tUPLUS, 321);
137
+ ruby_method_id_check_for(tUMINUS, 322);
138
+ ruby_method_id_check_for(tPOW, 323);
139
+ ruby_method_id_check_for(tCMP, 324);
140
+ ruby_method_id_check_for(tEQ, 325);
141
+ ruby_method_id_check_for(tEQQ, 326);
142
+ ruby_method_id_check_for(tNEQ, 327);
143
+ ruby_method_id_check_for(tGEQ, 328);
144
+ ruby_method_id_check_for(tLEQ, 329);
145
+ ruby_method_id_check_for(tANDOP, 330);
146
+ ruby_method_id_check_for(tOROP, 331);
147
+ ruby_method_id_check_for(tMATCH, 332);
148
+ ruby_method_id_check_for(tNMATCH, 333);
149
+ ruby_method_id_check_for(tDOT2, 334);
150
+ ruby_method_id_check_for(tDOT3, 335);
151
+ ruby_method_id_check_for(tAREF, 336);
152
+ ruby_method_id_check_for(tASET, 337);
153
+ ruby_method_id_check_for(tLSHFT, 338);
154
+ ruby_method_id_check_for(tRSHFT, 339);
155
+ ruby_method_id_check_for(tLAMBDA, 352);
156
+ ruby_method_id_check_for(idNULL, 365);
157
+ ruby_method_id_check_for(idRespond_to, 366);
158
+ ruby_method_id_check_for(idIFUNC, 367);
159
+ ruby_method_id_check_for(idCFUNC, 368);
160
+ ruby_method_id_check_for(id_core_set_method_alias, 369);
161
+ ruby_method_id_check_for(id_core_set_variable_alias, 370);
162
+ ruby_method_id_check_for(id_core_undef_method, 371);
163
+ ruby_method_id_check_for(id_core_define_method, 372);
164
+ ruby_method_id_check_for(id_core_define_singleton_method, 373);
165
+ ruby_method_id_check_for(id_core_set_postexe, 374);
166
+ ruby_method_id_check_for(tLAST_TOKEN, 375);
167
+ };
168
+ #endif
169
+
170
+ #endif /* RUBY_ID_H */