cc8b6a4ff6528b5f352e716fe99ec005c12d6116
1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2014-2015 Alexandre Terrasa <alexandre@moz-code.org>
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # Generate Github events from repo data.
19 # Mainly used for testing and history importation.
20 module events_generator
24 # Github events generator
26 # Generates events from repo data.
29 # API client used to get github data.
34 # Generate a new IssuesEvent from an issue.
35 fun issues_event
(action
: String, issue
: Issue): IssuesEvent do
36 var e
= new IssuesEvent(api
)
43 # Generate a new IssuesEvent with an `opened` action.
44 fun issue_open
(issue
: Issue): IssuesEvent do return issues_event
("opened", issue
)
46 # Generate a new IssuesEvent with an `closed` action.
47 fun issue_close
(issue
: Issue): IssuesEvent do return issues_event
("closed", issue
)
49 # Generate a new IssuesEvent with an `reopened` action.
50 fun issue_reopen
(issue
: Issue): IssuesEvent do return issues_event
("reopened", issue
)
52 # Generate a new IssuesEvent from a IssueEvent.
53 fun issue_raw_event
(issue
: Issue, event
: IssueEvent): IssuesEvent do
54 var e
= issues_event
(event
.event
, issue
)
56 e
.assignee
= event
.assignee
62 # Generate a new PullRequestEvent from a `pull` request.
63 fun pull_event
(action
: String, pull
: PullRequest): PullRequestEvent do
64 var e
= new PullRequestEvent(api
)
71 # Generate a new PullRequestEvent with an `opened` action.
72 fun pull_open
(pull
: PullRequest): PullRequestEvent do return pull_event
("opened", pull
)
74 # Generate a new PullRequestEvent with an `closed` action.
75 fun pull_close
(pull
: PullRequest): PullRequestEvent do return pull_event
("closed", pull
)
77 # Generate a new PullRequestEvent with an `reopened` action.
78 fun pull_reopen
(pull
: PullRequest): PullRequestEvent do return pull_event
("reopened", pull
)
80 # Generate a new PullRequestEvent from a IssueEvent.
81 fun pull_raw_event
(pull
: PullRequest, event
: IssueEvent): PullRequestEvent do
82 return pull_event
(event
.event
, pull
)
85 # Generate a new IssueCommentEvent from a IssueComment.
86 fun issue_comment_event
(issue
: Issue, comment
: IssueComment): IssueCommentEvent do
87 var e
= new IssueCommentEvent(api
)