needy 0.0.2 → 0.0.3

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.
Files changed (3) hide show
  1. data/README +5 -5
  2. data/lib/needy.rb +21 -12
  3. metadata +2 -2
data/README CHANGED
@@ -43,11 +43,11 @@ Put something like the below in ~/bin/needy
43
43
  include Needy
44
44
 
45
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'
46
+ gmail :username => 'USERNAME@gmail.com', :password => 'PASSWORD' do |g|
47
+ g.recipient :aofriend, 'an.old.friend' # List one recipient per line
48
+ g.recipient :buddy # When was the last time you emailed buddy?
49
+ g.recipient :pal
50
+ g.recipient 'client.com'
51
51
  end
52
52
 
53
53
  # LiveJournal
@@ -10,11 +10,8 @@ module Needy
10
10
  @@threads = []
11
11
 
12
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 }
13
+ i = Needy::IMAP.new(self, host, args)
14
+ thr { yield(i) }
18
15
  end
19
16
 
20
17
  def gmail args, &block
@@ -23,13 +20,6 @@ module Needy
23
20
  :folder => '[Gmail]/Sent Mail' }.merge(args), &block
24
21
  end
25
22
 
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
23
  def feed abbrev, url
34
24
  thr do
35
25
  feed = FeedTools::Feed.open(url)
@@ -64,6 +54,25 @@ module Needy
64
54
  yield(i)
65
55
  end
66
56
 
57
+ class IMAP
58
+ attr_accessor :target, :server
59
+
60
+ def initialize target, host, args
61
+ self.target = target
62
+ args = { :port => 143, :ssl => false }.merge(args)
63
+ self.server = Net::IMAP.new host, args[:port], args[:ssl]
64
+ server.login args[:username], args[:password]
65
+ server.select args[:folder] if args[:folder]
66
+ end
67
+
68
+ def recipient abbrev, *others
69
+ recips = [abbrev.to_s] + others.map(&:to_s)
70
+ query = recips.map{|whom| "TO #{whom}"}.reduce{|memo,q| "OR #{q} #{memo}"}
71
+ last_id = server.search(query).max
72
+ target.set abbrev, Time.parse(server.fetch(last_id, 'envelope')[0].attr['ENVELOPE'].date)
73
+ end
74
+ end
75
+
67
76
  class Git
68
77
  attr_accessor :dir, :branch, :log_opt
69
78
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: needy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Liggett
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-12 00:00:00 -04:00
12
+ date: 2009-10-14 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15