gwtf 0.7.3 → 0.8.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.
@@ -12,9 +12,14 @@ module Gwtf
12
12
  require 'uri'
13
13
  require 'time'
14
14
  require 'readline'
15
+ require 'chronic'
15
16
 
16
17
  @@color = true
17
18
 
19
+ def self.parse_time(timespec)
20
+ Chronic.parse(timespec, :ambiguous_time_range => 8)
21
+ end
22
+
18
23
  def self.color=(value)
19
24
  @@color = value
20
25
  end
@@ -36,7 +36,7 @@ command [:edit, :vi, :e] do |c|
36
36
  if ["", " "].include?($1)
37
37
  item.due_date = nil
38
38
  else
39
- item.due_date = $1
39
+ item.due_date = item.date_to_due_date($1)
40
40
  end
41
41
  else
42
42
  item.due_date = nil # if the user just delete the line from the
@@ -47,7 +47,7 @@ command [:new, :add, :n, :a, :c] do |c|
47
47
  item = @items.new_item
48
48
  item.subject = subject
49
49
  item.description = description if description
50
- item.due_date = options[:due] if options[:due]
50
+ item.due_date = item.date_to_due_date(options[:due]) if options[:due]
51
51
 
52
52
  if options[:remind]
53
53
  STDOUT.sync
@@ -61,7 +61,7 @@ command [:remind, :rem] do |c|
61
61
  out = reminder.schedule_reminer(options[:at], options[:recipient], true, true)
62
62
 
63
63
  if out =~ /job (\d+) at (\d+-\d+-\d+)\s/
64
- reminder.due_date = $2
64
+ reminder.due_date = reminder.date_to_due_date($2)
65
65
  end
66
66
 
67
67
  reminder.record_work "Scheduled reminder for %s: %s" % [ options[:at], out.chomp ]
@@ -21,6 +21,12 @@ module Gwtf
21
21
  load_item if file
22
22
  end
23
23
 
24
+ def date_to_due_date(timespec)
25
+ Gwtf.parse_time(timespec).strftime("%Y-%m-%d")
26
+ rescue
27
+ raise "Could not parse time specification #{timespec}"
28
+ end
29
+
24
30
  def open?
25
31
  status == "open"
26
32
  end
@@ -193,6 +199,11 @@ module Gwtf
193
199
  command_args << "--done" if done
194
200
  command_args << "--ifopen" if ifopen
195
201
 
202
+ # attempt to parse the timespec with Chronic, if it cant then pass it onto at verbatim
203
+ if time = Gwtf.parse_time(timespec)
204
+ timespec = "-t %s" % [time.strftime("%Y%m%d%H%M")]
205
+ end
206
+
196
207
  command = "echo gwtf --project='%s' notify %s | at %s 2>&1" % [ @project, command_args.join(" "), timespec]
197
208
  out = %x[#{command}]
198
209
 
@@ -1,3 +1,3 @@
1
1
  module Gwtf
2
- VERSION = '0.7.3'
2
+ VERSION = '0.8.0'
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: 5
4
+ hash: 63
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 7
9
- - 3
10
- version: 0.7.3
8
+ - 8
9
+ - 0
10
+ version: 0.8.0
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-13 00:00:00 +01:00
18
+ date: 2012-04-19 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: chronic
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: