- fun branches: Array[Branch] do
- var res = new Array[Branch]
- var arr = json["branches"].as(JsonArray)
- for obj in arr do
- if not obj isa JsonObject then continue
- res.add api.load_branch(repo, obj["name"].to_s).as(not null)
+ var branches = new Array[Branch] is writable, optional
+end
+
+redef class GithubDeserializer
+
+ redef fun class_name_heuristic(json_object) do
+ if json_object.has_key("action") and json_object.has_key("commit") and json_object.has_key("comment") then
+ return "CommitCommentEvent"
+ else if json_object.has_key("ref") and json_object.has_key("master_branch") then
+ return "CreateEvent"
+ else if json_object.has_key("ref") and json_object.has_key("ref_type") then
+ return "DeleteEvent"
+ else if json_object.has_key("action") and json_object.has_key("sha") then
+ return "DeploymentEvent"
+ else if json_object.has_key("action") and json_object.has_key("state") then
+ return "DeploymentStatusEvent"
+ else if json_object.has_key("action") and json_object.has_key("forkee") then
+ return "ForkEvent"
+ else if json_object.has_key("action") and json_object.has_key("issue") and json_object.has_key("comment") then
+ return "IssueCommentEvent"
+ else if json_object.has_key("action") and json_object.has_key("issue") then
+ return "IssuesEvent"
+ else if json_object.has_key("action") and json_object.has_key("member") then
+ return "MemberEvent"
+ else if json_object.has_key("action") and json_object.has_key("number") then
+ return "PullRequestEvent"
+ else if json_object.has_key("action") and json_object.has_key("pull") and json_object.has_key("comment") then
+ return "PullRequestReviewCommentEvent"
+ else if json_object.has_key("head_commit") and json_object.has_key("commits") then
+ return "PushEvent"
+ else if json_object.has_key("action") and json_object.has_key("branches") then
+ return "StatusEvent"
+ else if json_object.has_key("action") and json_object.has_key("issue") then
+ return "GithubEvent"