A contributor/author/etc.

It comes from git or the metadata

TODO get more things from github by using the email as a key

"https://api.github.com/search/users?q={email}+in:email"

Introduced properties

private var _email: nullable String

nitc :: Person :: _email

The email, Eg "john.doe@example.com"
private var _gravatar: nullable String

nitc :: Person :: _gravatar

Gravatar id
private var _html_url: String

nitc :: Person :: _html_url

private var _name: String

nitc :: Person :: _name

The name. Eg "John Doe"
private var _page: nullable String

nitc :: Person :: _page

Some homepage. Eg "http://example.com/~jdoe"
init defaultinit(name: String, email: nullable String, page: nullable String)

nitc :: Person :: defaultinit

fun email: nullable String

nitc :: Person :: email

The email, Eg "john.doe@example.com"
fun email=(email: nullable String)

nitc :: Person :: email=

The email, Eg "john.doe@example.com"
fun gravatar: nullable String

nitc :: Person :: gravatar

Gravatar id
protected fun gravatar=(gravatar: nullable String)

nitc :: Person :: gravatar=

Gravatar id
fun html_id: String

nitc :: Person :: html_id

HTML uniq id
fun html_url: String

nitc :: Person :: html_url

HTML default URL
protected fun html_url=(html_url: String)

nitc :: Person :: html_url=

fun name: String

nitc :: Person :: name

The name. Eg "John Doe"
fun name=(name: String)

nitc :: Person :: name=

The name. Eg "John Doe"
fun page: nullable String

nitc :: Person :: page

Some homepage. Eg "http://example.com/~jdoe"
fun page=(page: nullable String)

nitc :: Person :: page=

Some homepage. Eg "http://example.com/~jdoe"
init parse(person: String)

nitc :: Person :: parse

Crete a new person from its standard textual representation.
fun to_html: String

nitc :: Person :: to_html

Render self as HTML

Redefined properties

redef type SELF: Person

nitc $ Person :: SELF

Type of this instance, automatically specialized in every class
redef fun core_serialize_to(v: Serializer)

nitc :: json_model $ Person :: core_serialize_to

Actual serialization of self to serializer
redef init from_deserializer(v: Deserializer)

nitc :: json_model $ Person :: from_deserializer

Create an instance of this class from the deserializer
redef fun html_url: String

nitc :: static_html $ Person :: html_url

HTML default URL
redef fun to_html: String

nitc :: nitcatalog $ Person :: to_html

Render self as HTML
redef fun to_s: String

nitc $ Person :: to_s

The standard representation of a person.

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
private var _email: nullable String

nitc :: Person :: _email

The email, Eg "john.doe@example.com"
private var _gravatar: nullable String

nitc :: Person :: _gravatar

Gravatar id
private var _html_url: String

nitc :: Person :: _html_url

private var _name: String

nitc :: Person :: _name

The name. Eg "John Doe"
private var _page: nullable String

nitc :: Person :: _page

Some homepage. Eg "http://example.com/~jdoe"
protected fun accept_json_serializer(v: JsonSerializer)

serialization :: Serializable :: accept_json_serializer

Refinable service to customize the serialization of this class to JSON
protected fun accept_msgpack_attribute_counter(v: AttributeCounter)

serialization :: Serializable :: accept_msgpack_attribute_counter

Hook to customize the behavior of the AttributeCounter
protected fun accept_msgpack_serializer(v: MsgPackSerializer)

serialization :: Serializable :: accept_msgpack_serializer

Hook to customize the serialization of this class to MessagePack
protected fun add_to_bundle(bundle: NativeBundle, key: JavaString)

serialization :: Serializable :: add_to_bundle

Called by []= to dynamically choose the appropriate method according
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
fun core_serialize_to(serializer: Serializer)

serialization :: Serializable :: core_serialize_to

Actual serialization of self to serializer
init defaultinit(name: String, email: nullable String, page: nullable String)

nitc :: Person :: defaultinit

fun email: nullable String

nitc :: Person :: email

The email, Eg "john.doe@example.com"
fun email=(email: nullable String)

nitc :: Person :: email=

The email, Eg "john.doe@example.com"
init from_deserializer(deserializer: Deserializer)

serialization :: Serializable :: from_deserializer

Create an instance of this class from the deserializer
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun gravatar: nullable String

nitc :: Person :: gravatar

Gravatar id
protected fun gravatar=(gravatar: nullable String)

nitc :: Person :: gravatar=

Gravatar id
fun hash: Int

core :: Object :: hash

The hash code of the object.
fun html_id: String

nitc :: Person :: html_id

HTML uniq id
fun html_url: String

nitc :: Person :: html_url

HTML default URL
protected fun html_url=(html_url: String)

nitc :: Person :: html_url=

init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
protected fun msgpack_extra_array_items: Int

serialization :: Serializable :: msgpack_extra_array_items

Hook to request a larger than usual metadata array
fun name: String

nitc :: Person :: name

The name. Eg "John Doe"
fun name=(name: String)

nitc :: Person :: name=

The name. Eg "John Doe"
private intern fun native_class_name: CString

core :: Object :: native_class_name

The class name of the object in CString format.
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun page: nullable String

nitc :: Person :: page

Some homepage. Eg "http://example.com/~jdoe"
fun page=(page: nullable String)

nitc :: Person :: page=

Some homepage. Eg "http://example.com/~jdoe"
init parse(person: String)

nitc :: Person :: parse

Crete a new person from its standard textual representation.
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
fun serialize_msgpack(plain: nullable Bool): Bytes

serialization :: Serializable :: serialize_msgpack

Serialize self to MessagePack bytes
fun serialize_to(serializer: Serializer)

serialization :: Serializable :: serialize_to

Serialize self to serializer
fun serialize_to_json(plain: nullable Bool, pretty: nullable Bool): String

serialization :: Serializable :: serialize_to_json

Serialize self to JSON
private fun serialize_to_or_delay(v: Serializer)

serialization :: Serializable :: serialize_to_or_delay

Accept references or force direct serialization (using serialize_to)
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
fun to_html: String

nitc :: Person :: to_html

Render self as HTML
fun to_json: String

serialization :: Serializable :: to_json

Serialize self to plain JSON
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_pretty_json: String

serialization :: Serializable :: to_pretty_json

Serialize self to plain pretty JSON
fun to_s: String

core :: Object :: to_s

User readable representation of self.
package_diagram nitc::Person Person serialization::Serializable Serializable nitc::Person->serialization::Serializable core::Object Object serialization::Serializable->core::Object ...core::Object ... ...core::Object->core::Object

Ancestors

interface Object

core :: Object

The root of the class hierarchy.

Parents

interface Serializable

serialization :: Serializable

Instances of this class can be passed to Serializer::serialize

Class definitions

nitc $ Person
# A contributor/author/etc.
#
# It comes from git or the metadata
#
# TODO get more things from github by using the email as a key
# "https://api.github.com/search/users?q={email}+in:email"
class Person
	# The name. Eg "John Doe"
	var name: String is writable

	# The email, Eg "john.doe@example.com"
	var email: nullable String is writable

	# Some homepage. Eg "http://example.com/~jdoe"
	var page: nullable String is writable

	# Gravatar id
	var gravatar: nullable String is lazy do
		var email = self.email
		if email == null then return null
		return email.md5.to_lower
	end

	# The standard representation of a person.
	#
	# ~~~
	# var jd = new Person("John Doe", "john.doe@example.com", "http://example.com/~jdoe")
	# assert jd.to_s == "John Doe <john.doe@example.com> (http://example.com/~jdoe)"
	# ~~~
	#
	# It can be used as the input of `parse`.
	#
	# ~~~
	# var jd2 = new Person.parse(jd.to_s)
	# assert jd2.to_s == jd.to_s
	# ~~~
	redef fun to_s
	do
		var res = name
		var email = self.email
		if email != null then res += " <{email}>"
		var page = self.page
		if page != null then res += " ({page})"
		return res
	end

	# Crete a new person from its standard textual representation.
	#
	# ~~~
	# var jd = new Person.parse("John Doe <john.doe@example.com> (http://example.com/~jdoe)")
	# assert jd.name == "John Doe"
	# assert jd.email == "john.doe@example.com"
	# assert jd.page == "http://example.com/~jdoe"
	# ~~~
	#
	# Emails and page are optional.
	#
	# ~~~
	# var jd2 = new Person.parse("John Doe")
	# assert jd2.name == "John Doe"
	# assert jd2.email == null
	# assert jd2.page == null
	# ~~~
	init parse(person: String)
	do
		var name = person
		var email = null
		var page = null
		# Regular expressions are broken, need to investigate.
		# So split manually.
		#
		#var re = "([^<(]*?)(<([^>]*?)>)?(\\((.*)\\))?".to_re
		#var m = (person+" ").search(re)
		#print "{person}: `{m or else "?"}` `{m[1] or else "?"}` `{m[3] or else "?"}` `{m[5] or else "?"}`"
		do
			var sp1 = person.split_once_on("<")
			if sp1.length < 2 then
				break
			end
			var sp2 = sp1.last.split_once_on(">")
			if sp2.length < 2 then
				break
			end
			name = sp1.first.trim
			email = sp2.first.trim
			var sp3 = sp2.last.split_once_on("(")
			if sp3.length < 2 then
				break
			end
			var sp4 = sp3.last.split_once_on(")")
			if sp4.length < 2 then
				break
			end
			page = sp4.first.trim
		end

		init(name, email, page)
	end
end
src/catalog/catalog.nit:145,1--243,3

nitc :: html_model $ Person
redef class Person

	# HTML uniq id
	fun html_id: String do return name.to_cmangle

	# HTML default URL
	#
	# Should be redefined in clients.
	fun html_url: String do return "person_{html_id}.html"

	# Link to this person `html_url`
	fun html_link: Link do return new Link(html_url, name)

	# Render `self` as HTML
	fun to_html: String do
		var tpl = new Template
		tpl.addn "<span>"
		var gravatar = self.gravatar
		if gravatar != null then
			tpl.addn "<img class='avatar' src='https://secure.gravatar.com/avatar/{gravatar}?size=14&amp;default=retro' />"
		end
		tpl.addn html_link
		tpl.addn "</span>"
		return tpl.write_to_string
	end
end
src/doc/templates/html_model.nit:356,1--381,3

nitc :: nitcatalog $ Person
redef class Person
	redef fun to_html do
		var res = ""
		var e = name.html_escape
		var page = self.page
		if page != null then
			res += "<a href=\"{page.html_escape}\">"
		end
		var gravatar = self.gravatar
		if gravatar != null then
			res += "<img src=\"https://secure.gravatar.com/avatar/{gravatar}?size=20&amp;default=retro\">&nbsp;"
		end
		res += e
		if page != null then res += "</a>"
		return res
	end
end
src/nitcatalog.nit:535,1--551,3

nitc :: static_html $ Person
redef class Person
	redef var html_url = "person_{html_id}.html" is lazy
end
src/doc/static/static_html.nit:410,1--412,3

nitc :: json_model $ Person
redef class Person
	serialize

	redef fun core_serialize_to(v) do
		super
		v.serialize_attribute("name", name)
		v.serialize_attribute("email", email)
		v.serialize_attribute("gravatar", gravatar)
	end
end
src/doc/templates/json_model.nit:438,1--447,3