ghn 2.0.0.pre2 → 2.0.0.pre3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ghn/collector.rb +1 -1
- data/lib/ghn/notification.rb +45 -15
- data/lib/ghn/version.rb +1 -1
- data/spec/fixtures/release.json +76 -76
- data/spec/lib/ghn/notification_spec.rb +79 -28
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d94d9709ddd3bf7603f456f4ed78a2464e7b7f62
|
4
|
+
data.tar.gz: f2af501c2ee2cc73e00738209503662e8c6a7354
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12b3349afb5ee1899a904e309cf53ba8ebb6f34718fe14cfc035245d73cceaaa52e27a27bc6ac5970dcc9cd2a6970d02ab254443d08de823acc73df3dcfe4741
|
7
|
+
data.tar.gz: 0562454df324f03bd73ae7845e807a6e5da577f4dc04898fa2edd93b5482154fc0c9505df32af606875b55d75dd4f01efa18c6b28d40d7b751ebb1acb87a8163
|
data/lib/ghn/collector.rb
CHANGED
data/lib/ghn/notification.rb
CHANGED
@@ -6,10 +6,15 @@ class Ghn
|
|
6
6
|
@notification = notification
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
def type_class
|
10
|
+
klass = "#{subject_type}Notification"
|
11
|
+
Ghn.const_get(klass)
|
12
|
+
rescue NameError
|
13
|
+
Ghn::UnknownNotification
|
14
|
+
end
|
15
|
+
|
16
|
+
def url
|
17
|
+
if comment?
|
13
18
|
"https://github.com/#{repo_full_name}/#{type}/#{thread_number}#issuecomment-#{comment_number}"
|
14
19
|
else
|
15
20
|
"https://github.com/#{repo_full_name}/#{type}/#{thread_number}"
|
@@ -26,17 +31,8 @@ class Ghn
|
|
26
31
|
notification[:repository][:full_name]
|
27
32
|
end
|
28
33
|
|
29
|
-
def
|
30
|
-
|
31
|
-
when 'Issue'
|
32
|
-
'issues'
|
33
|
-
when 'PullRequest'
|
34
|
-
'pull'
|
35
|
-
when 'Commit'
|
36
|
-
'commit'
|
37
|
-
else
|
38
|
-
nil
|
39
|
-
end
|
34
|
+
def subject_type
|
35
|
+
notification[:subject][:type]
|
40
36
|
end
|
41
37
|
|
42
38
|
def thread_number
|
@@ -49,4 +45,38 @@ class Ghn
|
|
49
45
|
end
|
50
46
|
end
|
51
47
|
end
|
48
|
+
|
49
|
+
class IssueNotification < Notification
|
50
|
+
def type
|
51
|
+
'issues'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class PullRequestNotification < Notification
|
56
|
+
def type
|
57
|
+
'pull'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class CommitNotification < Notification
|
62
|
+
def type
|
63
|
+
'commit'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
class ReleaseNotification < Notification
|
68
|
+
def url
|
69
|
+
"https://github.com/#{repo_full_name}/releases/tag/#{tag}"
|
70
|
+
end
|
71
|
+
|
72
|
+
def tag
|
73
|
+
notification[:subject][:title].split(" ")[-1]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
class UnknownNotification < Notification
|
78
|
+
def url
|
79
|
+
warn "unknown subject type #{subject_type}"
|
80
|
+
end
|
81
|
+
end
|
52
82
|
end
|
data/lib/ghn/version.rb
CHANGED
data/spec/fixtures/release.json
CHANGED
@@ -1,79 +1,79 @@
|
|
1
1
|
{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
2
|
+
"id": "40477317",
|
3
|
+
"last_read_at": null,
|
4
|
+
"reason": "subscribed",
|
5
|
+
"repository": {
|
6
|
+
"archive_url": "https://api.github.com/repos/yandod/candycane/{archive_format}{/ref}",
|
7
|
+
"assignees_url": "https://api.github.com/repos/yandod/candycane/assignees{/user}",
|
8
|
+
"blobs_url": "https://api.github.com/repos/yandod/candycane/git/blobs{/sha}",
|
9
|
+
"branches_url": "https://api.github.com/repos/yandod/candycane/branches{/branch}",
|
10
|
+
"collaborators_url": "https://api.github.com/repos/yandod/candycane/collaborators{/collaborator}",
|
11
|
+
"comments_url": "https://api.github.com/repos/yandod/candycane/comments{/number}",
|
12
|
+
"commits_url": "https://api.github.com/repos/yandod/candycane/commits{/sha}",
|
13
|
+
"compare_url": "https://api.github.com/repos/yandod/candycane/compare/{base}...{head}",
|
14
|
+
"contents_url": "https://api.github.com/repos/yandod/candycane/contents/{+path}",
|
15
|
+
"contributors_url": "https://api.github.com/repos/yandod/candycane/contributors",
|
16
|
+
"description": "a port of Redmine to CakePHP from Ruby on Rails",
|
17
|
+
"downloads_url": "https://api.github.com/repos/yandod/candycane/downloads",
|
18
|
+
"events_url": "https://api.github.com/repos/yandod/candycane/events",
|
19
|
+
"fork": false,
|
20
|
+
"forks_url": "https://api.github.com/repos/yandod/candycane/forks",
|
21
|
+
"full_name": "yandod/candycane",
|
22
|
+
"git_commits_url": "https://api.github.com/repos/yandod/candycane/git/commits{/sha}",
|
23
|
+
"git_refs_url": "https://api.github.com/repos/yandod/candycane/git/refs{/sha}",
|
24
|
+
"git_tags_url": "https://api.github.com/repos/yandod/candycane/git/tags{/sha}",
|
25
|
+
"hooks_url": "https://api.github.com/repos/yandod/candycane/hooks",
|
26
|
+
"html_url": "https://github.com/yandod/candycane",
|
27
|
+
"id": 419430,
|
28
|
+
"issue_comment_url": "https://api.github.com/repos/yandod/candycane/issues/comments/{number}",
|
29
|
+
"issue_events_url": "https://api.github.com/repos/yandod/candycane/issues/events{/number}",
|
30
|
+
"issues_url": "https://api.github.com/repos/yandod/candycane/issues{/number}",
|
31
|
+
"keys_url": "https://api.github.com/repos/yandod/candycane/keys{/key_id}",
|
32
|
+
"labels_url": "https://api.github.com/repos/yandod/candycane/labels{/name}",
|
33
|
+
"languages_url": "https://api.github.com/repos/yandod/candycane/languages",
|
34
|
+
"merges_url": "https://api.github.com/repos/yandod/candycane/merges",
|
35
|
+
"milestones_url": "https://api.github.com/repos/yandod/candycane/milestones{/number}",
|
36
|
+
"name": "candycane",
|
37
|
+
"notifications_url": "https://api.github.com/repos/yandod/candycane/notifications{?since,all,participating}",
|
38
|
+
"owner": {
|
39
|
+
"avatar_url": "https://avatars.githubusercontent.com/u/103903?v=2",
|
40
|
+
"events_url": "https://api.github.com/users/yandod/events{/privacy}",
|
41
|
+
"followers_url": "https://api.github.com/users/yandod/followers",
|
42
|
+
"following_url": "https://api.github.com/users/yandod/following{/other_user}",
|
43
|
+
"gists_url": "https://api.github.com/users/yandod/gists{/gist_id}",
|
44
|
+
"gravatar_id": "9b69fbdeb0713def44a8731091ce5885",
|
45
|
+
"html_url": "https://github.com/yandod",
|
46
|
+
"id": 103903,
|
47
|
+
"login": "yandod",
|
48
|
+
"organizations_url": "https://api.github.com/users/yandod/orgs",
|
49
|
+
"received_events_url": "https://api.github.com/users/yandod/received_events",
|
50
|
+
"repos_url": "https://api.github.com/users/yandod/repos",
|
51
|
+
"site_admin": false,
|
52
|
+
"starred_url": "https://api.github.com/users/yandod/starred{/owner}{/repo}",
|
53
|
+
"subscriptions_url": "https://api.github.com/users/yandod/subscriptions",
|
54
|
+
"type": "User",
|
55
|
+
"url": "https://api.github.com/users/yandod"
|
56
|
+
},
|
57
|
+
"private": false,
|
58
|
+
"pulls_url": "https://api.github.com/repos/yandod/candycane/pulls{/number}",
|
59
|
+
"releases_url": "https://api.github.com/repos/yandod/candycane/releases{/id}",
|
60
|
+
"stargazers_url": "https://api.github.com/repos/yandod/candycane/stargazers",
|
61
|
+
"statuses_url": "https://api.github.com/repos/yandod/candycane/statuses/{sha}",
|
62
|
+
"subscribers_url": "https://api.github.com/repos/yandod/candycane/subscribers",
|
63
|
+
"subscription_url": "https://api.github.com/repos/yandod/candycane/subscription",
|
64
|
+
"tags_url": "https://api.github.com/repos/yandod/candycane/tags",
|
65
|
+
"teams_url": "https://api.github.com/repos/yandod/candycane/teams",
|
66
|
+
"trees_url": "https://api.github.com/repos/yandod/candycane/git/trees{/sha}",
|
67
|
+
"url": "https://api.github.com/repos/yandod/candycane"
|
56
68
|
},
|
57
|
-
"
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
"
|
64
|
-
"
|
65
|
-
"
|
66
|
-
"
|
67
|
-
"trees_url": "https://api.github.com/repos/username/reponame/git/trees{/sha}",
|
68
|
-
"statuses_url": "https://api.github.com/repos/username/reponame/statuses/{sha}",
|
69
|
-
"languages_url": "https://api.github.com/repos/username/reponame/languages",
|
70
|
-
"stargazers_url": "https://api.github.com/repos/username/reponame/stargazers",
|
71
|
-
"contributors_url": "https://api.github.com/repos/username/reponame/contributors",
|
72
|
-
"subscribers_url": "https://api.github.com/repos/username/reponame/subscribers",
|
73
|
-
"subscription_url": "https://api.github.com/repos/username/reponame/subscription",
|
74
|
-
"commits_url": "https://api.github.com/repos/username/reponame/commits{/sha}",
|
75
|
-
"git_commits_url": "https://api.github.com/repos/username/reponame/git/commits{/sha}",
|
76
|
-
"comments_url": "https://api.github.com/repos/username/reponame/comments{/number}"
|
77
|
-
},
|
78
|
-
"url": "https://api.github.com/notifications/threads/40414158"
|
69
|
+
"subject": {
|
70
|
+
"latest_comment_url": "https://api.github.com/repos/yandod/candycane/releases/510313",
|
71
|
+
"title": "CandyCane v0.9.4",
|
72
|
+
"type": "Release",
|
73
|
+
"url": "https://api.github.com/repos/yandod/candycane/releases/510313"
|
74
|
+
},
|
75
|
+
"subscription_url": "https://api.github.com/notifications/threads/40477317/subscription",
|
76
|
+
"unread": true,
|
77
|
+
"updated_at": "2014-08-23T12:45:11Z",
|
78
|
+
"url": "https://api.github.com/notifications/threads/40477317"
|
79
79
|
}
|
@@ -1,59 +1,110 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Ghn::Notification do
|
4
|
-
|
4
|
+
describe '#type_class' do
|
5
|
+
subject { Ghn::Notification.new(notification).type_class }
|
5
6
|
|
6
|
-
describe '#to_url' do
|
7
7
|
context 'issue' do
|
8
|
-
|
8
|
+
let(:notification) { fixture('issue.json') }
|
9
9
|
|
10
|
-
it {
|
10
|
+
it { is_expected.to eq Ghn::IssueNotification }
|
11
11
|
end
|
12
12
|
|
13
|
-
context '
|
14
|
-
|
13
|
+
context 'pull request' do
|
14
|
+
let(:notification) { fixture('pull_request.json') }
|
15
15
|
|
16
|
-
it {
|
16
|
+
it { is_expected.to eq Ghn::PullRequestNotification }
|
17
17
|
end
|
18
18
|
|
19
|
-
context '
|
20
|
-
|
19
|
+
context 'commit' do
|
20
|
+
let(:notification) { fixture('commit.json') }
|
21
21
|
|
22
|
-
it {
|
22
|
+
it { is_expected.to eq Ghn::CommitNotification }
|
23
23
|
end
|
24
24
|
|
25
|
-
context '
|
26
|
-
|
25
|
+
context 'release' do
|
26
|
+
let(:notification) { fixture('release.json') }
|
27
27
|
|
28
|
-
it {
|
28
|
+
it { is_expected.to eq Ghn::ReleaseNotification }
|
29
29
|
end
|
30
30
|
|
31
|
-
context '
|
32
|
-
|
31
|
+
context 'unknown' do
|
32
|
+
let(:notification) { fixture('unknown.json') }
|
33
33
|
|
34
|
-
it {
|
34
|
+
it { is_expected.to eq Ghn::UnknownNotification }
|
35
35
|
end
|
36
|
+
end
|
36
37
|
|
37
|
-
|
38
|
-
|
38
|
+
describe Ghn::IssueNotification do
|
39
|
+
describe '#url' do
|
40
|
+
it do
|
41
|
+
expect(
|
42
|
+
Ghn::IssueNotification.new(fixture('issue.json')).url
|
43
|
+
).to eq 'https://github.com/username/reponame/issues/305'
|
44
|
+
end
|
39
45
|
|
40
|
-
|
46
|
+
context 'with comment' do
|
47
|
+
it do
|
48
|
+
expect(
|
49
|
+
Ghn::IssueNotification.new(fixture('issue_with_comment.json')).url
|
50
|
+
).to eq 'https://github.com/username/reponame/issues/305#issuecomment-53070200'
|
51
|
+
end
|
52
|
+
end
|
41
53
|
end
|
54
|
+
end
|
42
55
|
|
43
|
-
|
44
|
-
|
45
|
-
|
56
|
+
describe Ghn::PullRequestNotification do
|
57
|
+
describe '#url' do
|
58
|
+
it do
|
59
|
+
expect(
|
60
|
+
Ghn::PullRequestNotification.new(fixture('pull_request.json')).url
|
61
|
+
).to eq 'https://github.com/username/reponame/pull/22'
|
62
|
+
end
|
46
63
|
|
47
|
-
|
48
|
-
|
64
|
+
context 'with comment' do
|
65
|
+
it do
|
66
|
+
expect(
|
67
|
+
Ghn::PullRequestNotification.new(fixture('pull_request_with_comment.json')).url
|
68
|
+
).to eq 'https://github.com/username/reponame/pull/22#issuecomment-16607215'
|
69
|
+
end
|
49
70
|
end
|
50
71
|
end
|
72
|
+
end
|
51
73
|
|
52
|
-
|
53
|
-
|
74
|
+
describe Ghn::CommitNotification do
|
75
|
+
describe '#url' do
|
76
|
+
it do
|
77
|
+
expect(
|
78
|
+
Ghn::CommitNotification.new(fixture('commit.json')).url
|
79
|
+
).to eq 'https://github.com/username/reponame/commit/6a4a135335acef4dfe15912d231429c07d4ad143'
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'with comment' do
|
83
|
+
it do
|
84
|
+
expect(
|
85
|
+
Ghn::CommitNotification.new(fixture('commit_with_comment.json')).url
|
86
|
+
).to eq 'https://github.com/username/reponame/commit/6a4a135335acef4dfe15912d231429c07d4ad143#issuecomment-7491006'
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe Ghn::ReleaseNotification do
|
93
|
+
describe '#url' do
|
94
|
+
it do
|
95
|
+
expect(
|
96
|
+
Ghn::ReleaseNotification.new(fixture('release.json')).url
|
97
|
+
).to eq 'https://github.com/yandod/candycane/releases/tag/v0.9.4'
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
54
101
|
|
55
|
-
|
56
|
-
|
102
|
+
describe Ghn::UnknownNotification do
|
103
|
+
describe '#url' do
|
104
|
+
it do
|
105
|
+
expect(
|
106
|
+
Ghn::UnknownNotification.new(fixture('release.json')).url
|
107
|
+
).to be nil
|
57
108
|
end
|
58
109
|
end
|
59
110
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ghn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.pre3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kensuke Nagae
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|