ghn 2.0.0.pre1 → 2.0.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5325ed6382865f92886a1024e31ba34255f8a346
4
- data.tar.gz: ece0d7bfeb7a7f16306f82af495563a5ee47bc8c
3
+ metadata.gz: 784b9d296d796af6ee80284b9114814515eacc8d
4
+ data.tar.gz: c87a10906695670e0bbd3e27f34cecb41b6aad2f
5
5
  SHA512:
6
- metadata.gz: 8e940eae3a0d39083421eb54b59ac07718a22dabd5a2bcbb6b2b6de5e69013a3598066ef2b9367ac99e189a3222e07e9183343464f7af51e06ad189edf466115
7
- data.tar.gz: 1bac48fee8313d951144a2888bd368db70ca83818930734988b5d93e6c9b89c4a210fd233973f0e67919a57e99d23b8e5517587044a9705132336b67b9290cfb
6
+ metadata.gz: 997f8ceca8a92eae4e41f7ec5ff53a747f0bdb736f3c2587eb28340dc8b9217f706f93b5203e6e753622c7a97b7872ab28b6b9c9d5f16504cd3c54b3a75290ca
7
+ data.tar.gz: ce41feed8fadfa532a9cde7b573fdc9584a3bbf154fa7b33868204a160ddfd17f9410b3a023408f5b73d00782fc3d30d914d6c5825aef8c931a04896f548b450
data/.travis.yml CHANGED
@@ -2,4 +2,4 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
- - rbx-2.1.1
5
+ - 2.1.1
data/lib/ghn/collector.rb CHANGED
@@ -14,7 +14,7 @@ class Ghn
14
14
  @count = notifications.count
15
15
  notifications.map { |notification|
16
16
  Notification.new(notification).to_url
17
- }
17
+ }.compact
18
18
  end
19
19
 
20
20
  def has_next?
@@ -7,7 +7,9 @@ class Ghn
7
7
  end
8
8
 
9
9
  def to_url
10
- if comment?
10
+ if type.nil?
11
+ warn "unknown subject type #{notification[:subject][:type]}"
12
+ elsif comment?
11
13
  "https://github.com/#{repo_full_name}/#{type}/#{thread_number}#issuecomment-#{comment_number}"
12
14
  else
13
15
  "https://github.com/#{repo_full_name}/#{type}/#{thread_number}"
@@ -24,7 +26,6 @@ class Ghn
24
26
  notification[:repository][:full_name]
25
27
  end
26
28
 
27
- # https://github.com/quipper/qlink/commit/6a4a135335acef4dfe15912d231429c07d4ad143
28
29
  def type
29
30
  case notification[:subject][:type]
30
31
  when 'Issue'
@@ -34,7 +35,7 @@ class Ghn
34
35
  when 'Commit'
35
36
  'commit'
36
37
  else
37
- raise RuntimeError, "unknown subject type #{notification[:subject][:type]}"
38
+ nil
38
39
  end
39
40
  end
40
41
 
data/lib/ghn/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Ghn
2
- VERSION = "2.0.0.pre1"
2
+ VERSION = "2.0.0.pre2"
3
3
  end
@@ -0,0 +1,79 @@
1
+ {
2
+ "subscription_url": "https://api.github.com/notifications/threads/40414158/subscription",
3
+ "id": "40414158",
4
+ "unread": true,
5
+ "reason": "subscribed",
6
+ "updated_at": "2014-08-22T15:16:26Z",
7
+ "last_read_at": null,
8
+ "subject": {
9
+ "type": "Release",
10
+ "latest_comment_url": "???",
11
+ "url": "???",
12
+ "title": "Title"
13
+ },
14
+ "repository": {
15
+ "releases_url": "https://api.github.com/repos/username/reponame/releases{/id}",
16
+ "labels_url": "https://api.github.com/repos/username/reponame/labels{/name}",
17
+ "notifications_url": "https://api.github.com/repos/username/reponame/notifications{?since,all,participating}",
18
+ "milestones_url": "https://api.github.com/repos/username/reponame/milestones{/number}",
19
+ "pulls_url": "https://api.github.com/repos/username/reponame/pulls{/number}",
20
+ "issues_url": "https://api.github.com/repos/username/reponame/issues{/number}",
21
+ "downloads_url": "https://api.github.com/repos/username/reponame/downloads",
22
+ "archive_url": "https://api.github.com/repos/username/reponame/{archive_format}{/ref}",
23
+ "merges_url": "https://api.github.com/repos/username/reponame/merges",
24
+ "compare_url": "https://api.github.com/repos/username/reponame/compare/{base}...{head}",
25
+ "contents_url": "https://api.github.com/repos/username/reponame/contents/{+path}",
26
+ "issue_comment_url": "https://api.github.com/repos/username/reponame/issues/comments/{number}",
27
+ "events_url": "https://api.github.com/repos/username/reponame/events",
28
+ "issue_events_url": "https://api.github.com/repos/username/reponame/issues/events{/number}",
29
+ "hooks_url": "https://api.github.com/repos/username/reponame/hooks",
30
+ "teams_url": "https://api.github.com/repos/username/reponame/teams",
31
+ "collaborators_url": "https://api.github.com/repos/username/reponame/collaborators{/collaborator}",
32
+ "keys_url": "https://api.github.com/repos/username/reponame/keys{/key_id}",
33
+ "forks_url": "https://api.github.com/repos/username/reponame/forks",
34
+ "url": "https://api.github.com/repos/username/reponame",
35
+ "id": 18326008,
36
+ "name": "reponame",
37
+ "full_name": "username/reponame",
38
+ "owner": {
39
+ "site_admin": false,
40
+ "following_url": "https://api.github.com/users/username/following{/other_user}",
41
+ "followers_url": "https://api.github.com/users/username/followers",
42
+ "html_url": "https://github.com/username",
43
+ "url": "https://api.github.com/users/username",
44
+ "gravatar_id": "68a1d93ef9b8b36a2658b2b6c77b1e2f",
45
+ "avatar_url": "https://avatars.githubusercontent.com/u/535481?v=2",
46
+ "id": 535481,
47
+ "login": "username",
48
+ "gists_url": "https://api.github.com/users/username/gists{/gist_id}",
49
+ "starred_url": "https://api.github.com/users/username/starred{/owner}{/repo}",
50
+ "subscriptions_url": "https://api.github.com/users/username/subscriptions",
51
+ "organizations_url": "https://api.github.com/users/username/orgs",
52
+ "repos_url": "https://api.github.com/users/username/repos",
53
+ "events_url": "https://api.github.com/users/username/events{/privacy}",
54
+ "received_events_url": "https://api.github.com/users/username/received_events",
55
+ "type": "Organization"
56
+ },
57
+ "private": true,
58
+ "html_url": "https://github.com/username/reponame",
59
+ "description": "",
60
+ "fork": false,
61
+ "assignees_url": "https://api.github.com/repos/username/reponame/assignees{/user}",
62
+ "branches_url": "https://api.github.com/repos/username/reponame/branches{/branch}",
63
+ "tags_url": "https://api.github.com/repos/username/reponame/tags",
64
+ "blobs_url": "https://api.github.com/repos/username/reponame/git/blobs{/sha}",
65
+ "git_tags_url": "https://api.github.com/repos/username/reponame/git/tags{/sha}",
66
+ "git_refs_url": "https://api.github.com/repos/username/reponame/git/refs{/sha}",
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"
79
+ }
@@ -0,0 +1,79 @@
1
+ {
2
+ "subscription_url": "https://api.github.com/notifications/threads/40414158/subscription",
3
+ "id": "40414158",
4
+ "unread": true,
5
+ "reason": "subscribed",
6
+ "updated_at": "2014-08-22T15:16:26Z",
7
+ "last_read_at": null,
8
+ "subject": {
9
+ "type": "Unknown",
10
+ "latest_comment_url": "???",
11
+ "url": "???",
12
+ "title": "Title"
13
+ },
14
+ "repository": {
15
+ "releases_url": "https://api.github.com/repos/username/reponame/releases{/id}",
16
+ "labels_url": "https://api.github.com/repos/username/reponame/labels{/name}",
17
+ "notifications_url": "https://api.github.com/repos/username/reponame/notifications{?since,all,participating}",
18
+ "milestones_url": "https://api.github.com/repos/username/reponame/milestones{/number}",
19
+ "pulls_url": "https://api.github.com/repos/username/reponame/pulls{/number}",
20
+ "issues_url": "https://api.github.com/repos/username/reponame/issues{/number}",
21
+ "downloads_url": "https://api.github.com/repos/username/reponame/downloads",
22
+ "archive_url": "https://api.github.com/repos/username/reponame/{archive_format}{/ref}",
23
+ "merges_url": "https://api.github.com/repos/username/reponame/merges",
24
+ "compare_url": "https://api.github.com/repos/username/reponame/compare/{base}...{head}",
25
+ "contents_url": "https://api.github.com/repos/username/reponame/contents/{+path}",
26
+ "issue_comment_url": "https://api.github.com/repos/username/reponame/issues/comments/{number}",
27
+ "events_url": "https://api.github.com/repos/username/reponame/events",
28
+ "issue_events_url": "https://api.github.com/repos/username/reponame/issues/events{/number}",
29
+ "hooks_url": "https://api.github.com/repos/username/reponame/hooks",
30
+ "teams_url": "https://api.github.com/repos/username/reponame/teams",
31
+ "collaborators_url": "https://api.github.com/repos/username/reponame/collaborators{/collaborator}",
32
+ "keys_url": "https://api.github.com/repos/username/reponame/keys{/key_id}",
33
+ "forks_url": "https://api.github.com/repos/username/reponame/forks",
34
+ "url": "https://api.github.com/repos/username/reponame",
35
+ "id": 18326008,
36
+ "name": "reponame",
37
+ "full_name": "username/reponame",
38
+ "owner": {
39
+ "site_admin": false,
40
+ "following_url": "https://api.github.com/users/username/following{/other_user}",
41
+ "followers_url": "https://api.github.com/users/username/followers",
42
+ "html_url": "https://github.com/username",
43
+ "url": "https://api.github.com/users/username",
44
+ "gravatar_id": "68a1d93ef9b8b36a2658b2b6c77b1e2f",
45
+ "avatar_url": "https://avatars.githubusercontent.com/u/535481?v=2",
46
+ "id": 535481,
47
+ "login": "username",
48
+ "gists_url": "https://api.github.com/users/username/gists{/gist_id}",
49
+ "starred_url": "https://api.github.com/users/username/starred{/owner}{/repo}",
50
+ "subscriptions_url": "https://api.github.com/users/username/subscriptions",
51
+ "organizations_url": "https://api.github.com/users/username/orgs",
52
+ "repos_url": "https://api.github.com/users/username/repos",
53
+ "events_url": "https://api.github.com/users/username/events{/privacy}",
54
+ "received_events_url": "https://api.github.com/users/username/received_events",
55
+ "type": "Organization"
56
+ },
57
+ "private": true,
58
+ "html_url": "https://github.com/username/reponame",
59
+ "description": "",
60
+ "fork": false,
61
+ "assignees_url": "https://api.github.com/repos/username/reponame/assignees{/user}",
62
+ "branches_url": "https://api.github.com/repos/username/reponame/branches{/branch}",
63
+ "tags_url": "https://api.github.com/repos/username/reponame/tags",
64
+ "blobs_url": "https://api.github.com/repos/username/reponame/git/blobs{/sha}",
65
+ "git_tags_url": "https://api.github.com/repos/username/reponame/git/tags{/sha}",
66
+ "git_refs_url": "https://api.github.com/repos/username/reponame/git/refs{/sha}",
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"
79
+ }
@@ -39,5 +39,22 @@ describe Ghn::Notification do
39
39
 
40
40
  it { expect(subject.to_url).to eq 'https://github.com/username/reponame/commit/6a4a135335acef4dfe15912d231429c07d4ad143#issuecomment-7491006' }
41
41
  end
42
+
43
+ # TODO: Release type JSON is unknown
44
+ context 'release' do
45
+ subject { Ghn::Notification.new fixture('release.json') }
46
+
47
+ it "does not raise error" do
48
+ expect(subject.to_url).to be nil
49
+ end
50
+ end
51
+
52
+ context 'unknown' do
53
+ subject { Ghn::Notification.new fixture('unknown.json') }
54
+
55
+ it "does not raise error" do
56
+ expect(subject.to_url).to be nil
57
+ end
58
+ end
42
59
  end
43
60
  end
data/spec/spec_helper.rb CHANGED
@@ -5,7 +5,7 @@ require 'json'
5
5
 
6
6
  module Helper
7
7
  def fixture(name)
8
- JSON.parse(File.read(File.join(__dir__, 'fixtures', name)), symbolize_names: true)
8
+ JSON.parse(File.read(File.join(File.dirname(__FILE__), 'fixtures', name)), symbolize_names: true)
9
9
  end
10
10
  end
11
11
 
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.pre1
4
+ version: 2.0.0.pre2
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-22 00:00:00.000000000 Z
11
+ date: 2014-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -110,6 +110,8 @@ files:
110
110
  - spec/fixtures/issue_with_comment.json
111
111
  - spec/fixtures/pull_request.json
112
112
  - spec/fixtures/pull_request_with_comment.json
113
+ - spec/fixtures/release.json
114
+ - spec/fixtures/unknown.json
113
115
  - spec/lib/ghn/notification_spec.rb
114
116
  - spec/spec_helper.rb
115
117
  homepage: https://github.com/kyanny/ghn
@@ -144,6 +146,8 @@ test_files:
144
146
  - spec/fixtures/issue_with_comment.json
145
147
  - spec/fixtures/pull_request.json
146
148
  - spec/fixtures/pull_request_with_comment.json
149
+ - spec/fixtures/release.json
150
+ - spec/fixtures/unknown.json
147
151
  - spec/lib/ghn/notification_spec.rb
148
152
  - spec/spec_helper.rb
149
153
  has_rdoc: