spinal_tap 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -28,8 +28,8 @@ You can then telnet into your process and type 'help' to view the default list o
28
28
  Currently, 'eval' is the main command you will use.
29
29
  For example, you can execute code such as 'eval 5 + 5' and it will return 10.
30
30
  The command set is limited, but in the future I will make it easy to add your own commands.
31
- For now you'll have to make your own helper class and execute them via 'eval'.
32
- Spinal Tap uses threads to run in the background of your process, but aware that you have full access to your processes's memory via 'eval'.
31
+ For now you'll have to make your own helper class and execute the methods via 'eval'.
32
+ Spinal Tap uses threads to run in the background of your process.
33
33
 
34
34
  SpinalTap.start accepts the following options:
35
35
 
@@ -47,7 +47,7 @@ Currently no authentication exists so anyone who can connect to Spinal Tap has c
47
47
  This includes changing memory, reloading classes, killing the process, and pretty much any other nasty thing you can do with Ruby's 'eval' method.
48
48
  Use at your own risk! You have been warned!
49
49
 
50
- # Contributing to Spinal Tap:
50
+ ## Contributing to Spinal Tap:
51
51
 
52
52
  1. Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
53
53
  2. Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
@@ -1,11 +1,17 @@
1
1
  module SpinalTap
2
+ class BindingWrapper
3
+ def binding
4
+ return Kernel.binding
5
+ end
6
+ end
2
7
 
3
8
  module ClientHelpers
4
9
  def setup(server)
5
10
  @server = server
6
11
  @history = SpinalTap::History.new
12
+ @binding = SpinalTap::BindingWrapper.new.binding
7
13
 
8
- reset
14
+ reset_cmd_line
9
15
 
10
16
  setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
11
17
 
@@ -27,6 +33,7 @@ module SpinalTap
27
33
  when 'help' then exec_help
28
34
  when 'history' then exec_history
29
35
  when 'eval' then exec_eval(args.join(' '))
36
+ when 'counts' then exec_counts
30
37
  when 'quit'
31
38
  close
32
39
  break
@@ -39,13 +46,13 @@ module SpinalTap
39
46
  @server.unregister(Thread.current)
40
47
  end
41
48
 
42
- def reset
49
+ def reset_cmd_line
43
50
  @buffer = @history.current
44
51
  @cursor_pos = 1
45
52
  end
46
53
 
47
54
  def read_parsed_line
48
- reset
55
+ reset_cmd_line
49
56
  redraw_cmd_line
50
57
 
51
58
  while byte = getbyte
@@ -133,7 +140,11 @@ module SpinalTap
133
140
  end
134
141
 
135
142
  def exec_help
136
- write("Commands: help quit history eval\r\n")
143
+ write("Commands:\r\n")
144
+ write(" help - display help information.\r\n")
145
+ write(" quit - quit this session.\r\n")
146
+ write(" eval - execute ruby code.\r\n")
147
+ write(" counts - display object counts.\r\n")
137
148
  end
138
149
 
139
150
  def exec_history
@@ -144,13 +155,28 @@ module SpinalTap
144
155
 
145
156
  def exec_eval(code)
146
157
  begin
147
- result = eval(code)
158
+ result = eval(code, @binding)
148
159
  write("=> #{result.to_s}\r\n")
149
160
  rescue Exception => e
150
161
  write(exception_to_s(e))
151
162
  end
152
163
  end
153
164
 
165
+ def exec_counts
166
+ GC.start
167
+
168
+ results = {}
169
+
170
+ ObjectSpace.each_object() do |o|
171
+ results[o.class] ||= 0
172
+ results[o.class] += 1
173
+ end
174
+
175
+ results = results.sort { |a, b| a[1] <=> b[1] }
176
+
177
+ results.each { |e| write("#{e[0]}: #{e[1]}\r\n") }
178
+ end
179
+
154
180
  def exception_to_s(e)
155
181
  "#{e.message}\r\n#{e.backtrace.join("\r\n")}"
156
182
  end
@@ -1,3 +1,3 @@
1
1
  module SpinalTap
2
- VERSION = '0.1.4'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spinal_tap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-14 00:00:00.000000000 Z
12
+ date: 2012-11-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -142,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
142
  version: '0'
143
143
  segments:
144
144
  - 0
145
- hash: -2867284756879300883
145
+ hash: -3882439637641971250
146
146
  required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  none: false
148
148
  requirements:
@@ -151,10 +151,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  version: '0'
152
152
  segments:
153
153
  - 0
154
- hash: -2867284756879300883
154
+ hash: -3882439637641971250
155
155
  requirements: []
156
156
  rubyforge_project:
157
- rubygems_version: 1.8.23
157
+ rubygems_version: 1.8.24
158
158
  signing_key:
159
159
  specification_version: 3
160
160
  summary: Spinal tap lets you easily connect into running ruby processes such as daemons