github-shush 0.2.0

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.
data/Gemfile ADDED
@@ -0,0 +1 @@
1
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,19 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ github-shush (0.2.0)
5
+ mechanize
6
+
7
+ GEM
8
+ specs:
9
+ mechanize (1.0.0)
10
+ nokogiri (>= 1.2.1)
11
+ nokogiri (1.4.4)
12
+ rake (0.8.7)
13
+
14
+ PLATFORMS
15
+ ruby
16
+
17
+ DEPENDENCIES
18
+ github-shush!
19
+ rake
data/Rakefile ADDED
@@ -0,0 +1,39 @@
1
+ begin
2
+ require "bundler"
3
+ Bundler.setup
4
+ rescue LoadError
5
+ $stderr.puts "You need to have Bundler installed to be able build this gem."
6
+ end
7
+
8
+ gemspec = eval(File.read(Dir["*.gemspec"].first))
9
+
10
+ task :default => :test
11
+
12
+ require 'rake/testtask'
13
+ Rake::TestTask.new(:test) do |test|
14
+ test.libs << "test"
15
+ test.test_files = FileList['test/test*.rb']
16
+ test.verbose = true
17
+ end
18
+
19
+ desc "Validate the gemspec"
20
+ task :gemspec do
21
+ gemspec.validate
22
+ end
23
+
24
+ desc "Build gem locally"
25
+ task :build => :gemspec do
26
+ system "gem build #{gemspec.name}.gemspec"
27
+ FileUtils.mkdir_p "pkg"
28
+ FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", "pkg"
29
+ end
30
+
31
+ desc "Install gem locally"
32
+ task :install => :build do
33
+ system "gem install pkg/#{gemspec.name}-#{gemspec.version}"
34
+ end
35
+
36
+ desc "Clean automatically generated files"
37
+ task :clean do
38
+ FileUtils.rm_rf "pkg"
39
+ end
data/bin/shush ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
3
+ require "shush"
@@ -0,0 +1,34 @@
1
+ # coding: UTF-8
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "github-shush"
5
+ s.version = "0.2.0"
6
+ s.platform = Gem::Platform::RUBY
7
+ s.authors = ["meeech"]
8
+ s.email = ["mitchell.amihod@gmail.com"]
9
+ s.homepage = "https://github.com/meeech/github-shush"
10
+ s.summary = "Easy way to mark all as read / or delete github notifications."
11
+ s.description = "Was driving me nuts always seeing the github notifications badge, after I read it in email."
12
+ s.rubyforge_project = s.name
13
+
14
+ s.required_rubygems_version = ">= 1.3.6"
15
+
16
+ # If you have runtime dependencies, add them here
17
+ # s.add_dependency "simpleconsole"
18
+ s.add_dependency "mechanize"
19
+
20
+ # If you have development dependencies, add them here
21
+ s.add_development_dependency "rake"
22
+ # s.add_development_dependency "redgreen"
23
+ # s.add_development_dependency "mocha"
24
+
25
+ # The list of files to be contained in the gem
26
+ s.files = `git ls-files`.split("\n")
27
+ s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
28
+ # s.extensions = `git ls-files ext/extconf.rb`.split("\n")
29
+
30
+ s.require_path = 'lib'
31
+
32
+ # For C extensions
33
+ # s.extensions = "ext/extconf.rb"
34
+ end
@@ -0,0 +1,5 @@
1
+ $github_config = {
2
+ :username => 'github-uname',
3
+ #md5 of your password. I will need this to get your auth token
4
+ :password => 'github-pw'
5
+ }
data/lib/shush.rb ADDED
@@ -0,0 +1,74 @@
1
+ require 'rubygems'
2
+ require 'mechanize'
3
+
4
+ CONFIG_FILE = "#{ENV['HOME']}/.github-shush-config.rb"
5
+
6
+ if("help" == ARGV.to_s)
7
+ puts "\nshush : will mark all notifications to as read"
8
+ puts "shush delete : will delete all UNREAD notifications"
9
+ puts "shush wipe : will delete ALL notifications"
10
+ puts "\nvisit https://github.com/meeech/github-shush"
11
+ exit
12
+ end
13
+
14
+ unless File.exists? CONFIG_FILE
15
+
16
+ CONFIG_SAMPLE_FILE = File.dirname(__FILE__)+"/config.sample.rb"
17
+ FileUtils.mkdir File.dirname(CONFIG_FILE) unless File.exists?(File.dirname(CONFIG_FILE))
18
+
19
+ puts "Creating #{CONFIG_FILE}..."
20
+ FileUtils.copy(CONFIG_SAMPLE_FILE, CONFIG_FILE)
21
+ puts "Edit #{CONFIG_FILE} and add your login info."
22
+ exit
23
+ end
24
+
25
+ require CONFIG_FILE
26
+
27
+ github = {
28
+ :base => 'https://github.com',
29
+ :login => 'https://github.com/login',
30
+ :notifications => "https://github.com/inbox/notifications"
31
+ }
32
+
33
+ # These containers are used for the matching.
34
+ # we may have some issues ie: when its the same message x2 or whatnot -
35
+ # github doesnt send enough of identifier to know which notification it is.
36
+ # so, we will only focus on unread messages, and then try to match the title/ text
37
+ # this is a hint - the original plan was this would receive clicks from gmail
38
+ # message_subject = nil
39
+ # message_text = nil
40
+
41
+ a = Mechanize.new { |agent|
42
+ agent.user_agent_alias = 'Mac Safari'
43
+ }
44
+
45
+ puts "shushing notifications for #{$github_config[:username]}"
46
+ a.get(github[:login]) do |page|
47
+ login_result = page.form_with(:action => '/session') do |login_form|
48
+ login_form.login = $github_config[:username]
49
+ login_form.password = $github_config[:password]
50
+ end.submit
51
+ end
52
+
53
+ action = "get"
54
+ selector = ".unread div.del a"
55
+
56
+ case ARGV.to_s
57
+
58
+ when "delete"
59
+ action = "delete"
60
+ puts 'deleting unread notifications...'
61
+
62
+ when "wipe"
63
+ action = "delete"
64
+ selector = "div.del a"
65
+ puts 'delete all notifications...'
66
+ end
67
+
68
+ a.get(github[:notifications]).search(selector).each do |link|
69
+ puts "#{action}> #{link.text}"
70
+ url = github[:base]+link.get_attribute('rel')
71
+ puts url
72
+ a.send(action, url)
73
+ sleep 0.4
74
+ end
data/license.txt ADDED
@@ -0,0 +1 @@
1
+ Have a good time and be excellent to each other.
data/readme.md ADDED
@@ -0,0 +1,44 @@
1
+ github-shush
2
+ ============
3
+
4
+ About
5
+ -----
6
+
7
+ You read your github notifications in email, but the badge still haunts the OCD elf in you when you are on the github site. shush is a simple gem which will go and mark them all as read.
8
+
9
+ Usage
10
+ -----
11
+
12
+ `gem install github-shush`
13
+
14
+ On first run, will create the file `~/.github-shush-config.rb`. You will need to go and edit that file.
15
+
16
+ **`shush`** : will mark all notifications to as read
17
+
18
+ **`shush delete`** : will delete all UNREAD notifications
19
+
20
+ **`shush wipe`** : will delete ALL notifications
21
+
22
+ shush is pretty basic - ie: no paginating, so if you have a ton of notifications to delete, you will want to just run it multiple times.
23
+
24
+ Feedback, forks and comments always welcome.
25
+
26
+ Background
27
+ ----------
28
+
29
+ "wondering if its possible to make gmail tool which deletes message notification on github if you've deleted the related email." [tweet](http://twitter.com/#!/meeech/status/30483727884750848)
30
+
31
+ The answer is yes and no. In the end, my use case was satisfied with this gem I can trigger from the cli. You can hook it up to gmail, fairly simply - I will outline how below if you interested in taking it to the next level.
32
+
33
+ re: gmail connection
34
+
35
+ Originally, I thought I could make a Component for Gmail that would add a button when it saw the message was a notification from Github. Turns out components are for Gmail for your domain only (I wish that had been clearer :) ). So, the next best solution would be to use chrome/safari extension, or a greasemonkey script.
36
+
37
+ Basic Imagined Flow:
38
+
39
+ `User Clicks on Archive + Mark as Read on Github >> pings github-shush running on a localhost:9999 >> github-shush then does some subject/text matching, marks the relevant message as read.`
40
+
41
+ Obviously, you could deploy to heroku, but the gem needs your github creds, and I have no interest in making a system where I'm responsible for storing your gh creds. Which is why I figured just running the gem on localhost.
42
+
43
+ But for me, my itch is scratched.
44
+
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: github-shush
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
+ platform: ruby
12
+ authors:
13
+ - meeech
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-01-30 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ prerelease: false
23
+ version_requirements: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ requirement: *id001
33
+ name: mechanize
34
+ type: :runtime
35
+ - !ruby/object:Gem::Dependency
36
+ prerelease: false
37
+ version_requirements: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ requirement: *id002
47
+ name: rake
48
+ type: :development
49
+ description: Was driving me nuts always seeing the github notifications badge, after I read it in email.
50
+ email:
51
+ - mitchell.amihod@gmail.com
52
+ executables:
53
+ - shush
54
+ extensions: []
55
+
56
+ extra_rdoc_files: []
57
+
58
+ files:
59
+ - Gemfile
60
+ - Gemfile.lock
61
+ - Rakefile
62
+ - bin/shush
63
+ - github-shush.gemspec
64
+ - lib/config.sample.rb
65
+ - lib/shush.rb
66
+ - license.txt
67
+ - readme.md
68
+ has_rdoc: true
69
+ homepage: https://github.com/meeech/github-shush
70
+ licenses: []
71
+
72
+ post_install_message:
73
+ rdoc_options: []
74
+
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ hash: 3
83
+ segments:
84
+ - 0
85
+ version: "0"
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ hash: 23
92
+ segments:
93
+ - 1
94
+ - 3
95
+ - 6
96
+ version: 1.3.6
97
+ requirements: []
98
+
99
+ rubyforge_project: github-shush
100
+ rubygems_version: 1.3.7
101
+ signing_key:
102
+ specification_version: 3
103
+ summary: Easy way to mark all as read / or delete github notifications.
104
+ test_files: []
105
+