ladybug 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/ladybug/debugger.rb +14 -0
- data/lib/ladybug/middleware.rb +38 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e754a38c616bafe8c321316d63c69761918f2a78
|
4
|
+
data.tar.gz: 504e0c72215d472c93a17d3d5c780ef16d1bc7d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c4a8090f910deb746e64a1e292f2dd95f857932e714ed0525a6db00672d9d1890cfc4246911c6eec2b0472969bd17e24cc76eb9c3d43e207e1f1973ca3a0f40
|
7
|
+
data.tar.gz: 7cec420eae32d21ed0cc51713fe49f8b414205615806beb41ef7750034317b1f84f9bbdcc2fb1b41da08ca7a7cb3131a8d1e4dec5bd4a94ed605956b668a781e
|
data/README.md
CHANGED
@@ -6,11 +6,11 @@ Chrome Devtools as a user interface.
|
|
6
6
|
It aims to provide a rich backend debugging experience in a UI that many
|
7
7
|
web developers are already familiar with for debugging frontend Javascript.
|
8
8
|
|
9
|
-
**This project is currently in an
|
9
|
+
**This project is currently in an experimental phase.** Expect many limitations and bugs. If you try it out, please file
|
10
10
|
Github issues or [email me](mailto:gklitt@gmail.com) to help make this a
|
11
11
|
more useful tool.
|
12
12
|
|
13
|
-

|
14
14
|
|
15
15
|
## Get started
|
16
16
|
|
@@ -53,7 +53,7 @@ execute code on your server without authenticating.
|
|
53
53
|
|
54
54
|
## Development status
|
55
55
|
|
56
|
-
* So far, ladybug has
|
56
|
+
* So far, ladybug has been tested with simple Rails applications running on
|
57
57
|
Rails 5 with the puma web server. Eventually it aims to support more Rack
|
58
58
|
applications and web servers (and perhaps even non-Rack applications).
|
59
59
|
* inspecting primtive objects like strings and numbers works okay; support for more complex objects is in development.
|
data/lib/ladybug/debugger.rb
CHANGED
@@ -82,6 +82,8 @@ module Ladybug
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def evaluate(expression)
|
85
|
+
raise InvalidExpressionError if !parseable?(expression)
|
86
|
+
|
85
87
|
@to_main_thread.push({
|
86
88
|
command: 'eval',
|
87
89
|
arguments: {
|
@@ -144,6 +146,17 @@ module Ladybug
|
|
144
146
|
|
145
147
|
private
|
146
148
|
|
149
|
+
# Try parsing an expression to see if we can safely eval it
|
150
|
+
def parseable?(expression)
|
151
|
+
begin
|
152
|
+
Parser::CurrentRuby.parse(expression)
|
153
|
+
rescue Parser::SyntaxError
|
154
|
+
return false
|
155
|
+
end
|
156
|
+
|
157
|
+
return true
|
158
|
+
end
|
159
|
+
|
147
160
|
# remove ladybug code from a callstack and prepare it for comparison
|
148
161
|
# this is a hack implemenetation for now, can be made better
|
149
162
|
def clean(callstack)
|
@@ -317,5 +330,6 @@ module Ladybug
|
|
317
330
|
memoize :deep_child_node_types
|
318
331
|
|
319
332
|
class InvalidBreakpointLocationError < StandardError; end
|
333
|
+
class InvalidExpressionError < StandardError; end
|
320
334
|
end
|
321
335
|
end
|
data/lib/ladybug/middleware.rb
CHANGED
@@ -39,6 +39,13 @@ module Ladybug
|
|
39
39
|
|
40
40
|
private
|
41
41
|
|
42
|
+
# Avoid eval'ing weird expressions that Chrome sends us,
|
43
|
+
# like Javascript functions and other things.
|
44
|
+
# This is an initial hack implementation, could be better.
|
45
|
+
def sanitize_expression(expression)
|
46
|
+
expression
|
47
|
+
end
|
48
|
+
|
42
49
|
def create_websocket(env)
|
43
50
|
ws = Faye::WebSocket.new(env)
|
44
51
|
|
@@ -155,7 +162,17 @@ module Ladybug
|
|
155
162
|
@debugger.step_out
|
156
163
|
result = {}
|
157
164
|
elsif data["method"] == "Debugger.evaluateOnCallFrame"
|
158
|
-
|
165
|
+
expression = data["params"]["expression"]
|
166
|
+
|
167
|
+
begin
|
168
|
+
evaluated = @debugger.evaluate(expression)
|
169
|
+
rescue Debugger::InvalidExpressionError
|
170
|
+
# A better thing to do would be to throw the syntax error
|
171
|
+
# back to the user, but for now we just return nil if
|
172
|
+
# given invalid input
|
173
|
+
evaluated = nil
|
174
|
+
end
|
175
|
+
|
159
176
|
result = {
|
160
177
|
result: @object_manager.serialize(evaluated)
|
161
178
|
}
|
@@ -197,6 +214,26 @@ module Ladybug
|
|
197
214
|
|
198
215
|
ws.send(message)
|
199
216
|
end
|
217
|
+
|
218
|
+
# Create a runtime context so Chrome can
|
219
|
+
# accept user input in the console
|
220
|
+
|
221
|
+
message = {
|
222
|
+
method: "Runtime.executionContextCreated",
|
223
|
+
params: {
|
224
|
+
context: {
|
225
|
+
id: 12, # random number for now
|
226
|
+
name: "",
|
227
|
+
origin: "http://localhost:3000" ,
|
228
|
+
auxData: {
|
229
|
+
isDefault: true,
|
230
|
+
frameId: SecureRandom.uuid
|
231
|
+
}
|
232
|
+
}
|
233
|
+
}
|
234
|
+
}.to_json
|
235
|
+
|
236
|
+
ws.send(message)
|
200
237
|
end
|
201
238
|
rescue => e
|
202
239
|
puts e.message
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ladybug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geoffrey Litt
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.10
|
19
|
+
version: '0.10'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.10
|
26
|
+
version: '0.10'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: parser
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.4
|
33
|
+
version: '2.4'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.4
|
40
|
+
version: '2.4'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: memoist
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.14
|
47
|
+
version: '0.14'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.14
|
54
|
+
version: '0.14'
|
55
55
|
description: Debug Ruby code using Chrome Devtools
|
56
56
|
email: gklitt@gmail.com
|
57
57
|
executables: []
|