rack_console 0.3.0 → 0.3.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.
- checksums.yaml +4 -4
- data/lib/rack_console/app.rb +6 -0
- data/lib/rack_console/app_helpers.rb +27 -3
- data/lib/rack_console/source_file.rb +0 -1
- data/lib/rack_console/template/haml/console/file.haml +4 -1
- data/lib/rack_console/template/haml/console/methods.haml +5 -0
- data/lib/rack_console/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6118a7bb2ae127448272b43fa93fded43d4dee30
|
4
|
+
data.tar.gz: 0d2bfcf921120bfb7897e4f609fc384df1b126fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da69edcfc2924e8606afa7c761c93b9d1d0a1b08738d8d3b1f35a57c7a279bc843f8995b4a288ef7305191b0465abf82a47ebf8b655aafe20aa3f1d400cae5de
|
7
|
+
data.tar.gz: afd218cc0f1f15b503a4d026025a9c880c18043358385564bb6a8d9600960f3a440cd78dc03975503f431e39f766890128467e6e0901d095a1b36e86b1b94f95
|
data/lib/rack_console/app.rb
CHANGED
@@ -36,6 +36,12 @@ module RackConsole
|
|
36
36
|
haml :'console/file', locals: locals, layout: layout
|
37
37
|
end
|
38
38
|
|
39
|
+
get "/methods/file/*" do
|
40
|
+
prepare_file!
|
41
|
+
@methods = methods_within_file(@source_file.file) if @source_file
|
42
|
+
haml :'console/methods', locals: locals, layout: layout
|
43
|
+
end
|
44
|
+
|
39
45
|
get "/css/:path" do | path |
|
40
46
|
halt 404 if path =~ /\.\./
|
41
47
|
content_type 'text/css'
|
@@ -216,20 +216,21 @@ module RackConsole
|
|
216
216
|
name_p = match_pred(params[:name], :to_sym)
|
217
217
|
kind_p = match_pred(params[:kind], :to_sym)
|
218
218
|
owner_p = match_pred(params[:owner])
|
219
|
+
file_p = match_pred(params[:file])
|
219
220
|
|
220
221
|
methods = [ ]
|
221
222
|
seen = { }
|
222
223
|
ObjectSpace.each_object(::Module) do | owner |
|
223
224
|
next unless (owner.name rescue nil)
|
224
225
|
next if owner_p && owner_p != owner.name
|
225
|
-
methods_for_module(owner, name_p, kind_p, seen, methods)
|
226
|
+
methods_for_module(owner, name_p, kind_p, file_p, seen, methods)
|
226
227
|
end
|
227
228
|
sort_methods! methods
|
228
229
|
methods
|
229
230
|
end
|
230
231
|
|
231
232
|
def match_pred value, m = nil
|
232
|
-
if value != '*' && value != ''
|
233
|
+
if value != nil && value != '*' && value != ''
|
233
234
|
value = value.send(m) if m
|
234
235
|
else
|
235
236
|
value = nil
|
@@ -237,7 +238,7 @@ module RackConsole
|
|
237
238
|
value
|
238
239
|
end
|
239
240
|
|
240
|
-
def methods_for_module owner, name_p = nil, kind_p = nil, seen = { }, to_methods = nil
|
241
|
+
def methods_for_module owner, name_p = nil, kind_p = nil, file_p = nil, seen = { }, to_methods = nil
|
241
242
|
methods = to_methods || [ ]
|
242
243
|
kind = :i
|
243
244
|
unless kind_p && kind_p != kind
|
@@ -245,6 +246,10 @@ module RackConsole
|
|
245
246
|
next if name_p && name_p != (name = name.to_sym)
|
246
247
|
if meth = (owner.instance_method(name) rescue nil) and key = [ owner, kind, name ] and ! seen[key]
|
247
248
|
seen[key] = true
|
249
|
+
if file_p
|
250
|
+
f = meth.source_location and f = f.first
|
251
|
+
next if f != file_p
|
252
|
+
end
|
248
253
|
methods << MockMethod.new(meth, name, kind, owner)
|
249
254
|
end
|
250
255
|
end
|
@@ -256,6 +261,10 @@ module RackConsole
|
|
256
261
|
next if name_p && name_p != (name = name.to_sym)
|
257
262
|
if meth = (owner.singleton_method(name) rescue nil) and key = [ owner, kind, name ] and ! seen[key]
|
258
263
|
seen[key] = true
|
264
|
+
if file_p
|
265
|
+
f = meth.source_location and f = f.first
|
266
|
+
next if f != file_p
|
267
|
+
end
|
259
268
|
methods << MockMethod.new(meth, name, kind, owner)
|
260
269
|
end
|
261
270
|
end
|
@@ -279,6 +288,16 @@ module RackConsole
|
|
279
288
|
owner.singleton_methods(false)
|
280
289
|
end
|
281
290
|
|
291
|
+
def methods_within_file file
|
292
|
+
methods = methods_matching(file: file)
|
293
|
+
sort_methods_by_source_location! methods
|
294
|
+
end
|
295
|
+
|
296
|
+
def sort_methods_by_source_location! methods
|
297
|
+
methods.sort_by!{|x| x.source_location || DUMMY_SOURCE_LOCATION }
|
298
|
+
end
|
299
|
+
DUMMY_SOURCE_LOCATION = [ "".freeze, 0 ].freeze
|
300
|
+
|
282
301
|
class MockMethod
|
283
302
|
attr_accessor :meth, :name, :kind, :owner
|
284
303
|
def initialize *args
|
@@ -307,6 +326,11 @@ module RackConsole
|
|
307
326
|
[ file, line && line.to_i ]
|
308
327
|
end
|
309
328
|
|
329
|
+
def source_file_methods_href file
|
330
|
+
link = file.sub(%r{^/}, '-')
|
331
|
+
link = url_root("/methods/file/#{link}")
|
332
|
+
end
|
333
|
+
|
310
334
|
def source_file source_location
|
311
335
|
source_location && SourceFile.new(source_location).load!
|
312
336
|
end
|
@@ -5,7 +5,10 @@
|
|
5
5
|
%dl
|
6
6
|
- if @result_ok
|
7
7
|
%dt File:
|
8
|
-
%dd.file_name
|
8
|
+
%dd.file_name
|
9
|
+
=file_name_tag(h @source_file.file)
|
10
|
+
%a{href: source_file_methods_href(@source_file.file)}
|
11
|
+
(methods)
|
9
12
|
%dt Source:
|
10
13
|
%dd.source
|
11
14
|
%table.source_listing
|
@@ -1,6 +1,11 @@
|
|
1
1
|
.rack_console
|
2
2
|
=haml :'console/server_info', locals: locals
|
3
3
|
.result
|
4
|
+
- if @source_file
|
5
|
+
%dl
|
6
|
+
%dt File:
|
7
|
+
%dd.file_name
|
8
|
+
=file_name_tag(h @source_file.file)
|
4
9
|
=haml :'console/methods_table', locals: locals.merge(methods: @methods)
|
5
10
|
=haml :'console/error', locals: locals
|
6
11
|
|
data/lib/rack_console/version.rb
CHANGED