pry-disasm 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/pry-disasm.rb +30 -0
- metadata +66 -0
data/lib/pry-disasm.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'internal/method'
|
2
|
+
|
3
|
+
Pry::Commands.block_command "disassemble", "Disassemble a method" do |class_and_method|
|
4
|
+
method = Pry::Method.from_str(class_and_method)
|
5
|
+
|
6
|
+
str = method.body.disasm
|
7
|
+
lines = str.split("\n")
|
8
|
+
|
9
|
+
# == disasm: <RubyVM::InstructionSequence:foo@(pry)>======================
|
10
|
+
lines[0].gsub!(/=+/) { |s| text.green(s) }
|
11
|
+
lines[0].gsub!(/<(.*?)@(.*?)>/) { '<' + colorize_code($1) + '@' + text.bold($2) + '>' }
|
12
|
+
|
13
|
+
# 0000 trace 8 ( 1)
|
14
|
+
# 0002 trace 1
|
15
|
+
# 0004 putobject 1
|
16
|
+
# 0006 putobject 1
|
17
|
+
# 0008 opt_plus <ic:1>
|
18
|
+
# 0010 trace 16
|
19
|
+
# 0012 leave
|
20
|
+
for i in 1..lines.length do
|
21
|
+
lines[i] = colorize_code(lines[i]) # TODO: not the best way to do this
|
22
|
+
lines[i].gsub!(/^(.*?)(\s+)(.*?)(\s+)/) { $1 + $2 + text.cyan($3) + $4 }
|
23
|
+
lines[i].gsub!(/<(.*?):(.*?)>/) { '<' + text.bright_blue($1) + ':' + $2 + '>' }
|
24
|
+
end
|
25
|
+
|
26
|
+
puts lines.join("\n")
|
27
|
+
end
|
28
|
+
|
29
|
+
Pry::Commands.alias_command 'disasm', 'disassemble'
|
30
|
+
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pry-disasm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Paul Brannan
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: ruby-internal
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: ! 'Pry-disasm is a pry plugin that displays YARV bytecode for a method
|
31
|
+
in a
|
32
|
+
|
33
|
+
nice colorized format.
|
34
|
+
|
35
|
+
'
|
36
|
+
email: curlypaul924@gmail.com
|
37
|
+
executables: []
|
38
|
+
extensions: []
|
39
|
+
extra_rdoc_files: []
|
40
|
+
files:
|
41
|
+
- lib/pry-disasm.rb
|
42
|
+
homepage: http://github.com/cout/pry-internal/
|
43
|
+
licenses: []
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
requirements: []
|
61
|
+
rubyforge_project:
|
62
|
+
rubygems_version: 1.8.24
|
63
|
+
signing_key:
|
64
|
+
specification_version: 3
|
65
|
+
summary: Pry plugin that displays YARV bytecode for a method
|
66
|
+
test_files: []
|