Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A simple quick-and-dirty poor man's object inspector. #2433

Closed
wants to merge 1 commit into from

Conversation

privat
Copy link
Member

@privat privat commented May 11, 2017

Since Nit does not have introspection facilities, this module uses the serialization framework to inspect objects.
A plain webserver is used to present the inspection interface.
Feature:

To launch the object inspector, just call Serializable::http_inspect.

import serialization
Class A
  serialize
  var name: String
end
class B
  serialize
  var data: Int
  var a: A
end
var a = new A("my_a")
var b = new B(42, a)
b.http_inspect

Anti-features:

  • only serialized things from Serializable objects are exposed.
  • crappy UI (plain HTML 2.0)
  • crappy UI invocation (web server on localhost:8080 then xdg-open http://localhost:8080)
  • no clean terminaison (just Ctrl-C)

Signed-off-by: Jean Privat <jean@pryen.org>
@jcbrinfo
Copy link
Contributor

jcbrinfo commented May 12, 2017

crappy UI (plain HTML 2.0)

Then, where is the doctype (<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">)? Without doctype, it is “HTML 5 in quirks mode”. 😄

Copy link
Contributor

@xymus xymus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a nice use of the serialization framework.


var response = new HttpResponse(200)
response.body = i.doc.write_to_string
return response
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is where you would shutdown nitcorn?

# All known objects
var map = new HashMap[String, Inspected]

# Returns an
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...

doc.add "</ul>\n"
end
if false then
else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be cleaner with if true then 😉

@privat privat closed this Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants