denotificator 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +6 -0
- data/bin/denotificator +5 -0
- data/denotificator.gemspec +29 -0
- data/lib/denotificator/api_client.rb +27 -0
- data/lib/denotificator/runtime.rb +58 -0
- data/lib/denotificator/version.rb +3 -0
- data/lib/denotificator.rb +18 -0
- data/spec/denotificator_spec.rb +11 -0
- data/spec/spec_helper.rb +6 -0
- metadata +161 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ef0dbbcea0b8737257967681d4cefcc502f766f4
|
4
|
+
data.tar.gz: f29e2cd7eefaeac0aac13edecd2b6a951eb6e13e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 137e76865f4b3120fb8dca36d94dea7e7143d0dde8906213e60c6ff8683eba1788fbccddcead0ceac6f582c579578cd9278ae5b95307b312664effd52f8a66a7
|
7
|
+
data.tar.gz: ee279557dd46f9aa305dab935231b6b1e78b0b7433bf4d95e1c03d99e7cbd984d54059b1a0f888756f4545bc7896dafa5e3718f6cfa06dd8893d16d382d2477a
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Marcos Oliveira
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Denotificator
|
2
|
+
|
3
|
+
Denotificator unsubscribes you from the GitHub notifications where you aren't directed mentioned.
|
4
|
+
|
5
|
+
It uses the [GitHub Notifications API](http://developer.github.com/v3/activity/notifications/) in an effort to make your Inbox sane again.
|
6
|
+
|
7
|
+
You can create your GitHub authentication token following [this](https://help.github.com/articles/creating-an-access-token-for-command-line-use) instructions.
|
8
|
+
|
9
|
+
[![Build Status](https://travis-ci.org/marcosvm/denotificator.png)](https://travis-ci.org/marcosvm/denotificator)
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Or install it yourself as:
|
14
|
+
|
15
|
+
$ gem install denotificator
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
```shell
|
20
|
+
GITHUB_AUTH_TOKEN=your_token_here denotificator
|
21
|
+
```
|
22
|
+
|
23
|
+
You can run it manually or add it to a cronjob for it.
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/denotificator
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'denotificator/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "denotificator"
|
8
|
+
spec.version = Denotificator::VERSION
|
9
|
+
spec.authors = ["Marcos Oliveira"]
|
10
|
+
spec.email = ["marcosvm@gmail.com"]
|
11
|
+
spec.description = %q{Denotificator unsubscribes you from notifications where you aren't directed mentioned}
|
12
|
+
spec.summary = %q{Enough said}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "faraday", "~> 0.8.8"
|
22
|
+
spec.add_runtime_dependency "yajl-ruby"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "rspec"
|
27
|
+
spec.add_development_dependency "pry"
|
28
|
+
spec.add_development_dependency "pry-debugger"
|
29
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Denotificator
|
2
|
+
class APIClient
|
3
|
+
attr_reader :connection
|
4
|
+
attr_reader :user_agent
|
5
|
+
attr_reader :auth_token
|
6
|
+
|
7
|
+
def initialize url, user_agent, auth_token
|
8
|
+
@connection = Faraday.new url: url
|
9
|
+
@user_agent = user_agent
|
10
|
+
@auth_token = auth_token
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_http_response uri
|
14
|
+
connection.get uri do |request|
|
15
|
+
request.headers['User-Agent'] = user_agent
|
16
|
+
request.headers['Authorization'] = "token #{auth_token}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def put_http_response uri, payload
|
21
|
+
connection.put uri do |request|
|
22
|
+
request.headers['User-Agent'] = user_agent
|
23
|
+
request.headers['Authorization'] = "token #{auth_token}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'yajl/json_gem'
|
3
|
+
|
4
|
+
module Denotificator
|
5
|
+
class Runtime
|
6
|
+
|
7
|
+
attr_reader :api_client
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def run!
|
11
|
+
new.run!
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
@api_client = APIClient.new "https://api.github.com",
|
17
|
+
"denotificator/#{Denotificator::VERSION} (https://github.com/marcosvm/denotificator)",
|
18
|
+
Denotificator.auth_token
|
19
|
+
end
|
20
|
+
|
21
|
+
def run!
|
22
|
+
notifications = load_github_notifications
|
23
|
+
process_notifications(notifications)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def load_github_notifications
|
29
|
+
response = api_client.get_http_response '/notifications'
|
30
|
+
JSON.parse response.body
|
31
|
+
end
|
32
|
+
|
33
|
+
def process_notifications(notifications)
|
34
|
+
notifications.each do |notification|
|
35
|
+
|
36
|
+
id = notification["id"]
|
37
|
+
reason = notification["reason"]
|
38
|
+
title = notification["subject"]["title"]
|
39
|
+
|
40
|
+
if reason == 'subscribed'
|
41
|
+
subscription_uri = "/notifications/threads/#{id}/subscription"
|
42
|
+
subscription_response = api_client.get_http_response subscription_uri
|
43
|
+
if subscription_response.status == 404
|
44
|
+
subscription_url = notification['subject']['url']
|
45
|
+
puts "#{id}:unsubscribing at #{subscription_url} on #{title}"
|
46
|
+
payload = { "subscribed" => false, "ignored" => true }.to_json
|
47
|
+
|
48
|
+
api_client.put_http_response subscription_uri, payload
|
49
|
+
end
|
50
|
+
else
|
51
|
+
puts "#{id}:#{reason}:#{title}"
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "denotificator/version"
|
2
|
+
require "denotificator/runtime"
|
3
|
+
require "denotificator/api_client"
|
4
|
+
|
5
|
+
module Denotificator
|
6
|
+
def self.auth_token
|
7
|
+
unless defined? @@auth_token
|
8
|
+
@@auth_token = nil
|
9
|
+
end
|
10
|
+
@@auth_token
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.auth_token=(token)
|
14
|
+
@@auth_token = token
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
Denotificator.auth_token = ENV['AUTH_TOKEN']
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: denotificator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Marcos Oliveira
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.8.8
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.8.8
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: yajl-ruby
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
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
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry-debugger
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Denotificator unsubscribes you from notifications where you aren't directed
|
112
|
+
mentioned
|
113
|
+
email:
|
114
|
+
- marcosvm@gmail.com
|
115
|
+
executables:
|
116
|
+
- denotificator
|
117
|
+
extensions: []
|
118
|
+
extra_rdoc_files: []
|
119
|
+
files:
|
120
|
+
- ".gitignore"
|
121
|
+
- ".rspec"
|
122
|
+
- ".travis.yml"
|
123
|
+
- Gemfile
|
124
|
+
- LICENSE.txt
|
125
|
+
- README.md
|
126
|
+
- Rakefile
|
127
|
+
- bin/denotificator
|
128
|
+
- denotificator.gemspec
|
129
|
+
- lib/denotificator.rb
|
130
|
+
- lib/denotificator/api_client.rb
|
131
|
+
- lib/denotificator/runtime.rb
|
132
|
+
- lib/denotificator/version.rb
|
133
|
+
- spec/denotificator_spec.rb
|
134
|
+
- spec/spec_helper.rb
|
135
|
+
homepage: ''
|
136
|
+
licenses:
|
137
|
+
- MIT
|
138
|
+
metadata: {}
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options: []
|
141
|
+
require_paths:
|
142
|
+
- lib
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
requirements: []
|
154
|
+
rubyforge_project:
|
155
|
+
rubygems_version: 2.0.3
|
156
|
+
signing_key:
|
157
|
+
specification_version: 4
|
158
|
+
summary: Enough said
|
159
|
+
test_files:
|
160
|
+
- spec/denotificator_spec.rb
|
161
|
+
- spec/spec_helper.rb
|