gwtf 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/gwtf.rb CHANGED
@@ -58,6 +58,12 @@ module Gwtf
58
58
  require 'gwtf/notifier/boxcar'
59
59
 
60
60
  return Notifier::Boxcar
61
+ when "notifo"
62
+ gem 'notifo'
63
+ require 'notifo'
64
+ require 'gwtf/notifier/notifo'
65
+
66
+ return Notifier::Notifo
61
67
  else
62
68
  raise "Do not know how to handle addresses of type #{protocol} for #{address}"
63
69
  end
data/lib/gwtf/item.rb CHANGED
@@ -5,13 +5,14 @@ module Gwtf
5
5
  attr_accessor :file
6
6
  attr_reader :project
7
7
 
8
- property :description, :default => nil, :validation => String
9
- property :subject, :default => nil, :validation => String
10
- property :status, :default => "open", :validation => ["open", "closed"]
11
- property :item_id, :default => nil, :validation => Integer
12
- property :work_log, :default => [], :validation => Array
13
- property :due_date, :default => nil, :validation => /^20\d\d[- \/.](0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])$/
14
- property :closed_at, :default => nil
8
+ property :description, :default => nil, :validation => String
9
+ property :subject, :default => nil, :validation => String
10
+ property :status, :default => "open", :validation => ["open", "closed"]
11
+ property :item_id, :default => nil, :validation => Integer
12
+ property :work_log, :default => [], :validation => Array
13
+ property :due_date, :default => nil, :validation => /^20\d\d[- \/.](0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])$/
14
+ property :at_job, :default => nil, :validation => Integer
15
+ property :closed_at, :default => nil
15
16
 
16
17
  def initialize(file=nil, project=nil)
17
18
  @file = file
@@ -133,6 +134,7 @@ module Gwtf
133
134
  summary.puts "Time Worked: %s" % [ Gwtf.seconds_to_human(time_worked) ] if time_worked > 0
134
135
  summary.puts " Created: %s" % [ Time.parse(created_at.to_s).strftime("%F %R") ]
135
136
  summary.puts " Closed: %s" % [ Time.parse(closed_at.to_s).strftime("%F %R") ] if closed?
137
+ summary.puts " At Job: %d" % [ at_job ] if at_job?
136
138
  summary.puts " ID: %s" % [ item_id ]
137
139
 
138
140
  if has_description?
@@ -186,16 +188,22 @@ module Gwtf
186
188
  end
187
189
 
188
190
  def schedule_reminer(timespec, recipient, done=false, ifopen=false)
189
- command_args = ["--remind"]
191
+ command_args = ["--remind=%s" % [item_id]]
190
192
  command_args << "--recipient=%s" % [ recipient ]
191
193
  command_args << "--done" if done
192
194
  command_args << "--ifopen" if ifopen
193
195
 
194
- command = "echo gwtf --project='%s' email %s %s | at %s 2>&1" % [ @project, command_args.join(" "), item_id, timespec]
196
+ command = "echo gwtf --project='%s' notify %s | at %s 2>&1" % [ @project, command_args.join(" "), timespec]
195
197
  out = %x[#{command}]
196
198
 
197
199
  raise "Failed to add at(1) job: %s" % [ out ] unless $? == 0
198
200
 
201
+ if out =~ /^job (\d+?) at \d/
202
+ update_property(:at_job, Integer($1))
203
+ else
204
+ raise "Could not parse at(1) output for jobid: #{out}"
205
+ end
206
+
199
207
  puts out
200
208
  out
201
209
  end
@@ -0,0 +1,35 @@
1
+ module Gwtf
2
+ module Notifier
3
+ class Notifo<Base
4
+ def notify
5
+ config_file = File.join(Etc.getpwuid.dir, ".notifo")
6
+
7
+ raise "Please configure notifo in ~/.notifo" unless File.exist?(config_file)
8
+
9
+ config = YAML.load_file(config_file)
10
+
11
+ raise "Config needs to be a hash" unless config.is_a?(Hash)
12
+ raise "Config must include :apiuser" unless config[:apiuser]
13
+ raise "Config must include :apisecret" unless config[:apisecret]
14
+ raise "Config must include :sender" unless config[:sender]
15
+
16
+ uri = URI.parse(recipient)
17
+
18
+ raise "Recipient must have a user portion" unless uri.user
19
+ raise "Recipient must have a host portion" unless uri.host
20
+
21
+ notifo = ::Notifo.new(config[:apiuser], config[:apisecret])
22
+
23
+ if item.project == "default"
24
+ msg = "%s: %s" % [ item.item_id, item.subject ]
25
+ else
26
+ msg = "%s:%s: %s" % [ item.project, item.item_id, item.subject ]
27
+ end
28
+
29
+ # notifo gem doesn't return anything on failure
30
+ notifo.post(uri.user, msg, config[:sender])
31
+
32
+ end
33
+ end
34
+ end
35
+ end
data/lib/gwtf/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gwtf
2
- VERSION = '0.7.1'
2
+ VERSION = '0.7.2'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gwtf
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 1
10
- version: 0.7.1
9
+ - 2
10
+ version: 0.7.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - R.I.Pienaar
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-12 00:00:00 +01:00
18
+ date: 2012-04-13 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -92,6 +92,20 @@ dependencies:
92
92
  version: 1.2.0
93
93
  type: :runtime
94
94
  version_requirements: *id005
95
+ - !ruby/object:Gem::Dependency
96
+ name: notifo
97
+ prerelease: false
98
+ requirement: &id006 !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ hash: 3
104
+ segments:
105
+ - 0
106
+ version: "0"
107
+ type: :runtime
108
+ version_requirements: *id006
95
109
  description: A Unix cli centric todo manager
96
110
  email: rip@devco.net
97
111
  executables:
@@ -116,6 +130,7 @@ files:
116
130
  - lib/gwtf/notifier/email.rb
117
131
  - lib/gwtf/notifier/boxcar.rb
118
132
  - lib/gwtf/notifier/base.rb
133
+ - lib/gwtf/notifier/notifo.rb
119
134
  - lib/gwtf/version.rb
120
135
  - lib/gwtf/item.rb
121
136
  - lib/gwtf/items.rb