ghn 0.1.0 → 2.0.0.pre1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e5724f6a16a8915d8823faff64964dbed206ec7
4
- data.tar.gz: 7d632305fbee13434ffb8af94ee8dec38c6979e0
3
+ metadata.gz: 5325ed6382865f92886a1024e31ba34255f8a346
4
+ data.tar.gz: ece0d7bfeb7a7f16306f82af495563a5ee47bc8c
5
5
  SHA512:
6
- metadata.gz: 7cf318c5737801e38bfcc0c2057cdb09693125615c7cde9636088276e8802955d9b162335a723c7811588a31003dc9d8cf4ef94f146264c51126e22cad4072e1
7
- data.tar.gz: 54217e8cfed126854d31c73a8c8c311b79c65bb7933792a13b2e8ec1a1357db63448dfbccfa1b2a956162404eb42b11c81d65af6554348e07765d6158d364600
6
+ metadata.gz: 8e940eae3a0d39083421eb54b59ac07718a22dabd5a2bcbb6b2b6de5e69013a3598066ef2b9367ac99e189a3222e07e9183343464f7af51e06ad189edf466115
7
+ data.tar.gz: 1bac48fee8313d951144a2888bd368db70ca83818930734988b5d93e6c9b89c4a210fd233973f0e67919a57e99d23b8e5517587044a9705132336b67b9290cfb
data/CHANGELOG.md CHANGED
@@ -1,23 +1 @@
1
- # Changelog
2
-
3
- ## v0.0.3
4
-
5
- * Bugfix
6
- * Add missing option `--usage`
7
-
8
- ## v0.0.2
9
-
10
- * 1st Refactor
11
- * Refactor command and options processing
12
- * Separate classes by its responsibility
13
- * Add first tests
14
-
15
- ## v0.0.1
16
-
17
- * Initial release; Implement basic feature
18
- * `ghi list`
19
- * `ghi list user/repo`
20
- * `ghi --open list` open notifications in browser
21
- * `ghi --mark-as-read` mark notifications as read
22
- * `ghi --help` show help message
23
- * Create project page
1
+ See https://github.com/kyanny/ghn/releases
data/README.md CHANGED
@@ -1,32 +1,54 @@
1
1
  # Ghn
2
2
 
3
- [![Build Status](https://travis-ci.org/kyanny/ghn.png?branch=master)](https://travis-ci.org/kyanny/ghn) [![Coverage Status](https://coveralls.io/repos/kyanny/ghn/badge.png?branch=master)](https://coveralls.io/r/kyanny/ghn?branch=master) [![Code Climate](https://codeclimate.com/repos/526ade18c7f3a32c9704ea51/badges/23a96bd170e0a9cee203/gpa.png)](https://codeclimate.com/repos/526ade18c7f3a32c9704ea51/feed)
3
+ [![Build Status](https://travis-ci.org/kyanny/ghn.png?branch=master)](https://travis-ci.org/kyanny/ghn)
4
4
 
5
- Commandline tool for GitHub notifications.
5
+ List/Open unread GitHub Notifications.
6
6
 
7
7
  ## Installation
8
8
 
9
- $ gem install ghn
9
+ ```
10
+ $ gem install ghn
11
+ ```
10
12
 
11
13
  ## Usage
12
14
 
13
- Run `ghn list` to show all unread notifications in terminal.
15
+ ```
16
+ $ ghn help
17
+ Commands:
18
+ ghn help [COMMAND] # Describe available commands or one specific command
19
+ ghn list NAME # List unread notifications
20
+ ghn open NAME # Open unread notifications in browser
14
21
 
15
- `ghn list` takes argument `user/repo` to get notifications only target repository.
22
+ Options:
23
+ -a, [--all], [--no-all] # List/Open all unread notifications
24
+ ```
16
25
 
17
- If you give `--open` option, unread notifications are opened in your default browser.
26
+ NAME should be a username/reponame of repository.
18
27
 
19
- If you give `--mark-as-read` option, notifications are marked as read.
28
+ `$ ghn list` displays first 50 unread notifications to STDOUT.
20
29
 
21
- You can see usage by `-h`, `--help` or `--usage` option.
30
+ `$ ghn open rails/rails` opens first 50 unread notifications of rails/rails in your browser.
31
+
32
+ `$ ghn open -a` opens all unread notifications in your browser.
33
+
34
+ ## Aliases
35
+
36
+ You can set aliases as a shortcut of NAME.
37
+ Aliases should be stored to your global `.gitconfig` file.
38
+
39
+ `$ git config --global ghn.alias.play playframework/playframework`
40
+
41
+ Now `$ ghn open play` opens unread notifications of playframework/playframework in your browser.
42
+
43
+ NOTE: aliases must have **ghn.alias** namespace.
22
44
 
23
45
  ## Authentication
24
46
 
25
- Please set ghn.token to your .gitconfig.
47
+ Please set **ghn.token** to your `.gitconfig`.
26
48
 
27
49
  $ git config --global ghn.token [Your GitHub access token]
28
50
 
29
- You can also set access token via ACCESS_TOKEN environment variable.
51
+ You can also set access token via `GHN_ACCESS_TOKEN` environment variable.
30
52
 
31
53
  ## Contributing
32
54
 
data/bin/ghn CHANGED
@@ -1,23 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
2
+ require 'thor'
3
3
  require 'ghn'
4
- require 'optparse'
5
4
 
6
- token = Ghn::Token.new
7
- unless token.valid?
8
- token.print_no_access_token_exit!
9
- end
10
-
11
- options = Ghn::Options.new(ARGV.getopts(Ghn::Options.short_options, *Ghn::Options.long_options))
12
- if options.open_browser?
13
- options.mark_as_read = false
14
- end
15
-
16
- command = Ghn::Command.new(ARGV)
17
- unless command.valid?
18
- command.print_invalid
19
- Ghn::Options.print_usage_exit
20
- end
21
-
22
- ghn = Ghn.new(token, command, options)
23
- ghn.run_print
5
+ Ghn::Commands.start
data/ghn.gemspec CHANGED
@@ -1,4 +1,3 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path('../lib', __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'ghn/version'
@@ -18,11 +17,10 @@ Gem::Specification.new do |spec|
18
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
18
  spec.require_paths = ["lib"]
20
19
 
21
- spec.add_dependency "github_api"
22
- spec.add_dependency "faraday", "0.8.9"
20
+ spec.add_dependency "thor"
21
+ spec.add_dependency "octokit"
23
22
 
24
- spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "bundler"
25
24
  spec.add_development_dependency "rake"
26
25
  spec.add_development_dependency "rspec"
27
- spec.add_development_dependency "coveralls"
28
26
  end
@@ -0,0 +1,18 @@
1
+ class Ghn
2
+ class Aliases
3
+ def initialize
4
+ @aliases = {}
5
+
6
+ `git config --get-regexp ghn.alias`.each_line.each do |line|
7
+ line.chomp!
8
+ alias_name, repo_full_name = line.split(/\s+/)
9
+ alias_name = alias_name.split('.')[-1]
10
+ @aliases[alias_name] = repo_full_name
11
+ end
12
+ end
13
+
14
+ def find(alias_name)
15
+ @aliases[alias_name]
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,24 @@
1
+ class Ghn
2
+ class Collector
3
+ def initialize(client, repo_full_name = nil)
4
+ @client = client
5
+ @repo_full_name = repo_full_name
6
+ end
7
+
8
+ def collect(page = 1)
9
+ notifications = if @repo_full_name
10
+ @client.repo_notifications(@repo_full_name, page: page)
11
+ else
12
+ @client.notifications(page: page)
13
+ end
14
+ @count = notifications.count
15
+ notifications.map { |notification|
16
+ Notification.new(notification).to_url
17
+ }
18
+ end
19
+
20
+ def has_next?
21
+ @count == 50
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,65 @@
1
+ class Ghn
2
+ class Commands < Thor
3
+ class_option :all, type: :boolean, aliases: '-a', desc: 'List/Open all unread notifications'
4
+
5
+ desc 'list NAME', 'List unread notifications'
6
+ def list(name = nil)
7
+ repo_full_name = aliases.find(name) || name
8
+ puts collect(repo_full_name)
9
+ end
10
+
11
+ desc 'open NAME', 'Open unread notifications in browser'
12
+ def open(name = nil)
13
+ repo_full_name = aliases.find(name) || name
14
+ collect(repo_full_name).each do |url|
15
+ system "open #{url}"
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def collect(repo_full_name = nil)
22
+ threads = []
23
+ collector = Collector.new(client, repo_full_name)
24
+ # Unfortunately, GitHub v3 Notifications API doesn't accept octokit's auto_paginate option
25
+ # because this API doesn't return Link header so far.
26
+ loop.with_index(1) do |_, page|
27
+ threads += collector.collect(page)
28
+ break unless options['all']
29
+ break unless collector.has_next?
30
+ end
31
+
32
+ threads
33
+ end
34
+
35
+ def client
36
+ @client ||= Octokit::Client.new(access_token: access_token)
37
+ end
38
+
39
+ def aliases
40
+ @aliases ||= Aliases.new
41
+ end
42
+
43
+ def access_token
44
+ @access_token ||=
45
+ case
46
+ when ENV['GHN_ACCESS_TOKEN']
47
+ ENV['GHN_ACCESS_TOKEN']
48
+ when !`git config ghn.token`.chomp.empty?
49
+ `git config ghn.token`.chomp
50
+ else
51
+ puts <<MESSAGE
52
+ ** Authorization required.
53
+
54
+ Please set ghn.token to your .gitconfig.
55
+ $ git config --global ghn.token [Your GitHub access token]
56
+
57
+ To get new token, visit
58
+ https://github.com/settings/tokens/new
59
+
60
+ MESSAGE
61
+ exit!
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,51 @@
1
+ class Ghn
2
+ class Notification
3
+ attr_reader :notification
4
+
5
+ def initialize(notification)
6
+ @notification = notification
7
+ end
8
+
9
+ def to_url
10
+ if comment?
11
+ "https://github.com/#{repo_full_name}/#{type}/#{thread_number}#issuecomment-#{comment_number}"
12
+ else
13
+ "https://github.com/#{repo_full_name}/#{type}/#{thread_number}"
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def comment?
20
+ notification[:subject][:url] != notification[:subject][:latest_comment_url]
21
+ end
22
+
23
+ def repo_full_name
24
+ notification[:repository][:full_name]
25
+ end
26
+
27
+ # https://github.com/quipper/qlink/commit/6a4a135335acef4dfe15912d231429c07d4ad143
28
+ def type
29
+ case notification[:subject][:type]
30
+ when 'Issue'
31
+ 'issues'
32
+ when 'PullRequest'
33
+ 'pull'
34
+ when 'Commit'
35
+ 'commit'
36
+ else
37
+ raise RuntimeError, "unknown subject type #{notification[:subject][:type]}"
38
+ end
39
+ end
40
+
41
+ def thread_number
42
+ notification[:subject][:url].match(/[^\/]+\z/)[-1]
43
+ end
44
+
45
+ def comment_number
46
+ if comment?
47
+ notification[:subject][:latest_comment_url].match(/\d+\z/)[-1]
48
+ end
49
+ end
50
+ end
51
+ end
data/lib/ghn/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Ghn
2
- VERSION = "0.1.0"
2
+ VERSION = "2.0.0.pre1"
3
3
  end
data/lib/ghn.rb CHANGED
@@ -1,66 +1,6 @@
1
+ require 'octokit'
1
2
  require 'ghn/version'
2
- require 'ghn/token'
3
- require 'ghn/options'
4
- require 'ghn/command'
5
- require 'github_api'
6
-
7
- class Ghn
8
- def initialize(token, command, options)
9
- @token = token
10
- @command = command
11
- @options = options
12
- end
13
-
14
- def run
15
- send(@command.command, *@command.args)
16
- end
17
-
18
- def run_print
19
- run.each do |notification|
20
- if @options.open_browser?
21
- system "open #{notification}"
22
- else
23
- puts notification
24
- end
25
- end
26
- end
27
-
28
- def client
29
- @client ||= Github.new(oauth_token: @token.token)
30
- end
31
-
32
- def list(target = nil)
33
- params = {}
34
- unless target.nil?
35
- params['user'], params['repo'] = target.split('/')
36
- end
37
-
38
- client.activity.notifications.list(params).map { |notification|
39
- repo = notification.repository.full_name
40
- type = notification_type(notification.subject.url)
41
- number = notification.subject.url.match(/[^\/]+\z/).to_a.first
42
- if @options.mark_as_read?
43
- self.mark(notification.id)
44
- "[x] https://github.com/#{repo}/#{type}/#{number}"
45
- else
46
- "https://github.com/#{repo}/#{type}/#{number}"
47
- end
48
- }
49
- end
50
-
51
- def mark(id, read = true)
52
- client.activity.notifications.mark(thread_id: id, read: read)
53
- end
54
-
55
- private
56
- def notification_type(url)
57
- case url
58
- when /pulls/
59
- 'pull'
60
- when /issues/
61
- 'issues'
62
- else
63
- 'commit'
64
- end
65
- end
66
- end
3
+ require 'ghn/aliases'
4
+ require 'ghn/commands'
5
+ require 'ghn/collector'
6
+ require 'ghn/notification'
@@ -0,0 +1,79 @@
1
+ {
2
+ "subscription_url": "https://api.github.com/notifications/threads/40409864/subscription",
3
+ "id": "40409864",
4
+ "unread": true,
5
+ "reason": "subscribed",
6
+ "updated_at": "2014-08-22T14:34:59Z",
7
+ "last_read_at": null,
8
+ "subject": {
9
+ "type": "Commit",
10
+ "latest_comment_url": "https://api.github.com/repos/username/reponame/commits/6a4a135335acef4dfe15912d231429c07d4ad143",
11
+ "url": "https://api.github.com/repos/username/reponame/commits/6a4a135335acef4dfe15912d231429c07d4ad143",
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": 8796270,
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/40409864"
79
+ }
@@ -0,0 +1,79 @@
1
+ {
2
+ "subscription_url": "https://api.github.com/notifications/threads/40409864/subscription",
3
+ "id": "40409864",
4
+ "unread": true,
5
+ "reason": "subscribed",
6
+ "updated_at": "2014-08-22T14:34:59Z",
7
+ "last_read_at": null,
8
+ "subject": {
9
+ "type": "Commit",
10
+ "latest_comment_url": "https://api.github.com/repos/username/reponame/comments/7491006",
11
+ "url": "https://api.github.com/repos/username/reponame/commits/6a4a135335acef4dfe15912d231429c07d4ad143",
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": 8796270,
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/40409864"
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": "Issue",
10
+ "latest_comment_url": "https://api.github.com/repos/username/reponame/issues/305",
11
+ "url": "https://api.github.com/repos/username/reponame/issues/305",
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": "Issue",
10
+ "latest_comment_url": "https://api.github.com/repos/username/reponame/issues/comments/53070200",
11
+ "url": "https://api.github.com/repos/username/reponame/issues/305",
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/40286762/subscription",
3
+ "id": "40286762",
4
+ "unread": true,
5
+ "reason": "subscribed",
6
+ "updated_at": "2014-08-22T16:31:49Z",
7
+ "last_read_at": "2014-08-21T16:07:50Z",
8
+ "subject": {
9
+ "type": "PullRequest",
10
+ "latest_comment_url": "https://api.github.com/repos/username/reponame/pulls/22",
11
+ "url": "https://api.github.com/repos/username/reponame/pulls/22",
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": 15248475,
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": "ea5efa6071bc5fd5f9f74949cc743407",
45
+ "avatar_url": "https://avatars.githubusercontent.com/u/207834?v=2",
46
+ "id": 207834,
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/40286762"
79
+ }
@@ -0,0 +1,79 @@
1
+ {
2
+ "subscription_url": "https://api.github.com/notifications/threads/40286762/subscription",
3
+ "id": "40286762",
4
+ "unread": true,
5
+ "reason": "subscribed",
6
+ "updated_at": "2014-08-22T16:31:49Z",
7
+ "last_read_at": "2014-08-21T16:07:50Z",
8
+ "subject": {
9
+ "type": "PullRequest",
10
+ "latest_comment_url": "https://api.github.com/repos/username/reponame/pulls/comments/16607215",
11
+ "url": "https://api.github.com/repos/username/reponame/pulls/22",
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": 15248475,
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": "ea5efa6071bc5fd5f9f74949cc743407",
45
+ "avatar_url": "https://avatars.githubusercontent.com/u/207834?v=2",
46
+ "id": 207834,
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/40286762"
79
+ }
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ghn::Notification do
4
+ subject { Ghn::Notification.new(notification) }
5
+
6
+ describe '#to_url' do
7
+ context 'issue' do
8
+ subject { Ghn::Notification.new fixture('issue.json') }
9
+
10
+ it { expect(subject.to_url).to eq 'https://github.com/username/reponame/issues/305' }
11
+ end
12
+
13
+ context 'issue comment' do
14
+ subject { Ghn::Notification.new fixture('issue_with_comment.json') }
15
+
16
+ it { expect(subject.to_url).to eq 'https://github.com/username/reponame/issues/305#issuecomment-53070200' }
17
+ end
18
+
19
+ context 'pull request' do
20
+ subject { Ghn::Notification.new fixture('pull_request.json') }
21
+
22
+ it { expect(subject.to_url).to eq 'https://github.com/username/reponame/pull/22' }
23
+ end
24
+
25
+ context 'pull request with comment' do
26
+ subject { Ghn::Notification.new fixture('pull_request_with_comment.json') }
27
+
28
+ it { expect(subject.to_url).to eq 'https://github.com/username/reponame/pull/22#issuecomment-16607215' }
29
+ end
30
+
31
+ context 'commit' do
32
+ subject { Ghn::Notification.new fixture('commit.json') }
33
+
34
+ it { expect(subject.to_url).to eq 'https://github.com/username/reponame/commit/6a4a135335acef4dfe15912d231429c07d4ad143' }
35
+ end
36
+
37
+ context 'commit with comment' do
38
+ subject { Ghn::Notification.new fixture('commit_with_comment.json') }
39
+
40
+ it { expect(subject.to_url).to eq 'https://github.com/username/reponame/commit/6a4a135335acef4dfe15912d231429c07d4ad143#issuecomment-7491006' }
41
+ end
42
+ end
43
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,19 +1,14 @@
1
1
  require 'rspec'
2
+ require 'thor'
3
+ require 'ghn'
4
+ require 'json'
2
5
 
3
- require 'simplecov'
4
- require 'coveralls'
5
-
6
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
7
- SimpleCov::Formatter::HTMLFormatter,
8
- Coveralls::SimpleCov::Formatter
9
- ]
10
- SimpleCov.start do
11
- add_filter '.bundle/'
6
+ module Helper
7
+ def fixture(name)
8
+ JSON.parse(File.read(File.join(__dir__, 'fixtures', name)), symbolize_names: true)
9
+ end
12
10
  end
13
11
 
14
- require 'securerandom'
15
-
16
- require 'ghn'
17
-
18
12
  RSpec.configure do |config|
13
+ config.include Helper
19
14
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ghn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 2.0.0.pre1
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-02-17 00:00:00.000000000 Z
11
+ date: 2014-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: github_api
14
+ name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,35 +25,21 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: faraday
28
+ name: octokit
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.8.9
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.8.9
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '1.3'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '1.3'
55
- - !ruby/object:Gem::Dependency
56
- name: rake
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
45
  - - ">="
@@ -67,7 +53,7 @@ dependencies:
67
53
  - !ruby/object:Gem::Version
68
54
  version: '0'
69
55
  - !ruby/object:Gem::Dependency
70
- name: rspec
56
+ name: rake
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - ">="
@@ -81,7 +67,7 @@ dependencies:
81
67
  - !ruby/object:Gem::Version
82
68
  version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
- name: coveralls
70
+ name: rspec
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - ">="
@@ -113,11 +99,18 @@ files:
113
99
  - bin/ghn
114
100
  - ghn.gemspec
115
101
  - lib/ghn.rb
116
- - lib/ghn/command.rb
117
- - lib/ghn/options.rb
118
- - lib/ghn/token.rb
102
+ - lib/ghn/aliases.rb
103
+ - lib/ghn/collector.rb
104
+ - lib/ghn/commands.rb
105
+ - lib/ghn/notification.rb
119
106
  - lib/ghn/version.rb
120
- - spec/lib/ghn_spec.rb
107
+ - spec/fixtures/commit.json
108
+ - spec/fixtures/commit_with_comment.json
109
+ - spec/fixtures/issue.json
110
+ - spec/fixtures/issue_with_comment.json
111
+ - spec/fixtures/pull_request.json
112
+ - spec/fixtures/pull_request_with_comment.json
113
+ - spec/lib/ghn/notification_spec.rb
121
114
  - spec/spec_helper.rb
122
115
  homepage: https://github.com/kyanny/ghn
123
116
  licenses:
@@ -134,17 +127,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
127
  version: '0'
135
128
  required_rubygems_version: !ruby/object:Gem::Requirement
136
129
  requirements:
137
- - - ">="
130
+ - - ">"
138
131
  - !ruby/object:Gem::Version
139
- version: '0'
132
+ version: 1.3.1
140
133
  requirements: []
141
134
  rubyforge_project:
142
- rubygems_version: 2.2.0
135
+ rubygems_version: 2.2.2
143
136
  signing_key:
144
137
  specification_version: 4
145
138
  summary: Ghn is a commandline tool for GitHub notifications. You can listup all unread
146
139
  notifications and mark them as read.
147
140
  test_files:
148
- - spec/lib/ghn_spec.rb
141
+ - spec/fixtures/commit.json
142
+ - spec/fixtures/commit_with_comment.json
143
+ - spec/fixtures/issue.json
144
+ - spec/fixtures/issue_with_comment.json
145
+ - spec/fixtures/pull_request.json
146
+ - spec/fixtures/pull_request_with_comment.json
147
+ - spec/lib/ghn/notification_spec.rb
149
148
  - spec/spec_helper.rb
150
149
  has_rdoc:
data/lib/ghn/command.rb DELETED
@@ -1,46 +0,0 @@
1
- class Ghn
2
- class Command
3
- def self.commands
4
- ['list']
5
- end
6
-
7
- attr_reader :command
8
- attr_reader :args
9
-
10
- def initialize(argv)
11
- @argv = argv
12
- @valid = false
13
- process!
14
- end
15
-
16
- def process!
17
- @command = @argv.first
18
- if self.class.commands.include?(@command)
19
- @valid = true
20
- @args = @argv.drop(1)
21
- else
22
- @valid = false
23
- end
24
- end
25
-
26
- def valid?
27
- !!@valid
28
- end
29
-
30
- def print_invalid
31
- if @command.nil? || @command.empty?
32
- print_empty_command
33
- else
34
- print_invalid_command
35
- end
36
- end
37
-
38
- def print_empty_command
39
- puts "** No command"
40
- end
41
-
42
- def print_invalid_command
43
- puts "** Invalid command `#{@command}`"
44
- end
45
- end
46
- end
data/lib/ghn/options.rb DELETED
@@ -1,59 +0,0 @@
1
- require 'hashie/mash'
2
-
3
- class Ghn
4
- class Options < Hashie::Mash
5
- def open_browser=(bool)
6
- @open_browser = bool
7
- end
8
-
9
- def open_browser?
10
- !!(@open_browser || self['o'] || self['open'])
11
- end
12
-
13
- def mark_as_read=(bool)
14
- @mark_as_read = bool
15
- end
16
-
17
- def mark_as_read?
18
- !!(@mark_as_read || self['m'] || self['mark-as-read'])
19
- end
20
-
21
- def help?
22
- !!(self['h'] || self['help'])
23
- end
24
-
25
- class << self
26
- def short_options
27
- 'omh'
28
- end
29
-
30
- def long_options
31
- ['open', 'mark-as-read', 'help', 'usage']
32
- end
33
-
34
- def usage
35
- <<-USAGE
36
- Usage: #{File.basename $0} [options] [command] [user/repo]
37
- options: -o, --open Open notifications in browser
38
- -m, --mark-as-read Mark as read listed notifications
39
- -h, --help, --usage Show this message
40
-
41
- command: list List unread notifications
42
-
43
- user/repo: GitHub user and repository (e.g. github/hubot)
44
- You can specify it to narrow down target notifications
45
-
46
- USAGE
47
- end
48
-
49
- def print_usage
50
- puts usage
51
- end
52
-
53
- def print_usage_exit
54
- print_usage
55
- exit
56
- end
57
- end
58
- end
59
- end
data/lib/ghn/token.rb DELETED
@@ -1,42 +0,0 @@
1
- class Ghn
2
- class Token
3
- attr_reader :token
4
-
5
- def initialize
6
- @valid = false
7
- process!
8
- end
9
-
10
- def process!
11
- @token = ENV['ACCESS_TOKEN'] || `git config ghn.token`.chomp
12
-
13
- if @token.nil? || @token.empty?
14
- @valid = false
15
- else
16
- @valid = true
17
- end
18
- end
19
-
20
- def valid?
21
- !!@valid
22
- end
23
-
24
- def print_no_access_token
25
- puts <<MESSAGE
26
- ** Authorization required.
27
-
28
- Please set ghn.token to your .gitconfig.
29
- $ git config --global ghn.token [Your GitHub access token]
30
-
31
- To get new token, visit
32
- https://github.com/settings/tokens/new
33
-
34
- MESSAGE
35
- end
36
-
37
- def print_no_access_token_exit!
38
- print_no_access_token
39
- exit!
40
- end
41
- end
42
- end
data/spec/lib/ghn_spec.rb DELETED
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Ghn do
4
- let(:token) { double }
5
- let(:command) { double }
6
- let(:options) { double }
7
-
8
- describe '#initialize' do
9
- context 'if no arguments is passed' do
10
- it 'should raise error' do
11
- expect { described_class.new }.to raise_error
12
- end
13
- end
14
-
15
- context 'if token, command and options argument is passed' do
16
- it 'should not raise error' do
17
- expect { described_class.new(token, command, options) }.to_not raise_error
18
- end
19
- end
20
- end
21
- end