needy 0.0.1
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/README +83 -0
- data/lib/needy.rb +103 -0
- metadata +56 -0
data/README
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
Library to help you know which projects are getting a bit stale.
|
2
|
+
|
3
|
+
Sometimes it slowly creeps up on you that you haven't done anything with X in
|
4
|
+
a few weeks... or even months, and next thing you know getting started again
|
5
|
+
seems somewhat hard. I am pretty prone to this kind of problem; I guess that
|
6
|
+
part of my brain doesn't work very well. So this is a simple attempt to
|
7
|
+
factor that part of my brain out in to some code.
|
8
|
+
|
9
|
+
Sample output:
|
10
|
+
|
11
|
+
$FRIEND 475.0 hours
|
12
|
+
$BUDDY 256.6 hours
|
13
|
+
lj 235.0 hours
|
14
|
+
ol 191.9 hours
|
15
|
+
tumblr 167.6 hours
|
16
|
+
m0x65 94.6 hours
|
17
|
+
flickr 46.8 hours
|
18
|
+
twitter 24.3 hours
|
19
|
+
$GIG 22.0 hours
|
20
|
+
$PAL 1.1 hours
|
21
|
+
|
22
|
+
INSTALLATION
|
23
|
+
~~~~~~~~~~~~
|
24
|
+
|
25
|
+
Make sure you have gemcutter.org in your list of gem sources
|
26
|
+
|
27
|
+
gem install gemcutter
|
28
|
+
gem tumble
|
29
|
+
|
30
|
+
then just install the gem
|
31
|
+
|
32
|
+
gem install needy
|
33
|
+
|
34
|
+
USAGE
|
35
|
+
~~~~~
|
36
|
+
|
37
|
+
Put something like the below in ~/bin/needy
|
38
|
+
|
39
|
+
#!/usr/bin/env ruby
|
40
|
+
require 'rubygems'
|
41
|
+
require 'needy'
|
42
|
+
|
43
|
+
include Needy
|
44
|
+
|
45
|
+
# Your gmail account
|
46
|
+
gmail :username => 'USERNAME@gmail.com', :password => 'PASSWORD' do
|
47
|
+
recipient :aofriend, 'an.old.friend' # List one recipient per line
|
48
|
+
recipient :buddy # When was the last time you emailed buddy?
|
49
|
+
recipient :pal
|
50
|
+
recipient 'client.com'
|
51
|
+
end
|
52
|
+
|
53
|
+
# LiveJournal
|
54
|
+
feed :lj, 'http://USERNAME.livejournal.com/data/atom'
|
55
|
+
|
56
|
+
# Twitter
|
57
|
+
feed :twitter, 'http://twitter.com/statuses/user_timeline/SOME_NUMBER.rss'
|
58
|
+
|
59
|
+
# flickr
|
60
|
+
feed :flickr,
|
61
|
+
'http://api.flickr.com/services/feeds/photos_public.gne?id=SOME_NUMBER&lang=en-us&format=atom'
|
62
|
+
|
63
|
+
# Tumblr
|
64
|
+
feed :tumblr, 'http://TUMBLR_URL/rss'
|
65
|
+
|
66
|
+
# A git-svn setup, with other authors.
|
67
|
+
git :ep, '~/s/ep', 'remotes/git-svn' do |repo|
|
68
|
+
repo.exec 'svn fetch'
|
69
|
+
repo.author 'mattl'
|
70
|
+
end
|
71
|
+
|
72
|
+
# A git project I sometimes work on from other places
|
73
|
+
git :ol, '~/s/ol', 'origin/master' do |repo|
|
74
|
+
repo.exec 'fetch'
|
75
|
+
end
|
76
|
+
|
77
|
+
# A git project I never need to fetch
|
78
|
+
git :m0x65, '~/s/m0x65', 'prod/master'
|
79
|
+
|
80
|
+
# Print a line for each project
|
81
|
+
whens.sort_by{|k,v| v}.each do |k,v|
|
82
|
+
printf "%20.20s %6.1f hours\n", k, (Time.now - Time.at(v))/60/60
|
83
|
+
end
|
data/lib/needy.rb
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'feed_tools'
|
5
|
+
require 'net/imap'
|
6
|
+
require 'time'
|
7
|
+
|
8
|
+
module Needy
|
9
|
+
@@when = {}
|
10
|
+
@@threads = []
|
11
|
+
|
12
|
+
def imap_server host, args
|
13
|
+
args = { :port => 143, :ssl => false }.merge(args)
|
14
|
+
@@server = Net::IMAP.new host, args[:port], args[:ssl]
|
15
|
+
@@server.login args[:username], args[:password]
|
16
|
+
@@server.select args[:folder] if args[:folder]
|
17
|
+
thr { yield }
|
18
|
+
end
|
19
|
+
|
20
|
+
def gmail args, &block
|
21
|
+
self.imap_server 'imap.gmail.com', { :port => 993,
|
22
|
+
:ssl => true,
|
23
|
+
:folder => '[Gmail]/Sent Mail' }.merge(args), &block
|
24
|
+
end
|
25
|
+
|
26
|
+
def recipient abbrev, *others
|
27
|
+
recips = [abbrev.to_s] + others.map(&:to_s)
|
28
|
+
query = recips.map{|whom| "TO #{whom}"}.reduce{|memo,q| "OR #{q} #{memo}"}
|
29
|
+
last_id = @@server.search(query).max
|
30
|
+
set abbrev, Time.parse(@@server.fetch(last_id, 'envelope')[0].attr['ENVELOPE'].date)
|
31
|
+
end
|
32
|
+
|
33
|
+
def feed abbrev, url
|
34
|
+
thr do
|
35
|
+
feed = FeedTools::Feed.open(url)
|
36
|
+
set abbrev, feed.updated || feed.items.map(&:published).max
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def git abbrev, dir, branch, &block
|
41
|
+
thr do
|
42
|
+
g = Needy::Git.new(dir, branch)
|
43
|
+
yield(g) if block
|
44
|
+
set abbrev, g.when
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def whens
|
49
|
+
@@threads.each{|t| t.join}
|
50
|
+
@@threads = []
|
51
|
+
@@when
|
52
|
+
end
|
53
|
+
|
54
|
+
def thr &block
|
55
|
+
@@threads.push(Thread.new(&block))
|
56
|
+
end
|
57
|
+
|
58
|
+
def set abbrev, val
|
59
|
+
@@when[abbrev.to_s] = val
|
60
|
+
end
|
61
|
+
|
62
|
+
def ichat abbrev, name
|
63
|
+
thr do
|
64
|
+
Dir['/Users/mml/Documents/iChats/*'].sort.reverse.each do |dir|
|
65
|
+
Dir["#{dir}/*.ichat"].each do |path|
|
66
|
+
if path =~ /^#{name} on /
|
67
|
+
set abbrev, File.mtime(path)
|
68
|
+
Thread.exit
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
return Time.at(0)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
class Git
|
77
|
+
attr_accessor :dir, :branch, :log_opt
|
78
|
+
|
79
|
+
def initialize dir, branch
|
80
|
+
self.dir = File.join File.expand_path(dir), '.git'
|
81
|
+
self.branch = branch
|
82
|
+
self.log_opt = ''
|
83
|
+
end
|
84
|
+
|
85
|
+
def git_cmd
|
86
|
+
"git --git-dir=#{dir}"
|
87
|
+
end
|
88
|
+
|
89
|
+
def exec *args
|
90
|
+
system("#{git_cmd} #{args.map(&:to_s).join(' ')}")
|
91
|
+
end
|
92
|
+
|
93
|
+
def when
|
94
|
+
open "|#{git_cmd} log #{branch} #{log_opt} --pretty=%ct -n1" do |f|
|
95
|
+
Time.at(f.gets.chomp.to_i)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def author name
|
100
|
+
self.log_opt += " --author=#{name}"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: needy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matt Liggett
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-12 00:00:00 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: My brain is too dumb to get it right alone.
|
17
|
+
email: mml@pobox.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
|
+
files:
|
25
|
+
- lib/needy.rb
|
26
|
+
- README
|
27
|
+
has_rdoc: true
|
28
|
+
homepage: http://github.com/mml/needy
|
29
|
+
licenses: []
|
30
|
+
|
31
|
+
post_install_message:
|
32
|
+
rdoc_options: []
|
33
|
+
|
34
|
+
require_paths:
|
35
|
+
- lib
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: "0"
|
41
|
+
version:
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
version:
|
48
|
+
requirements: []
|
49
|
+
|
50
|
+
rubyforge_project:
|
51
|
+
rubygems_version: 1.3.5
|
52
|
+
signing_key:
|
53
|
+
specification_version: 3
|
54
|
+
summary: What needs my attention?
|
55
|
+
test_files: []
|
56
|
+
|