reminders_txt 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/reminders_txt.rb +59 -13
- metadata +7 -7
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7833e42aea7e1c22ce822a700b512ce739bda483
|
4
|
+
data.tar.gz: 47908e11f918d4d85f429d24e58f3bd8ca3cb05e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ced8f17dd7096cfe9b7d92a1925ad3c9257f3c5f4a707242d1d7efbf0926abd0faf471ee30288104bc953ff994c267b2587896f8397fd55caba909958b680e0e
|
7
|
+
data.tar.gz: 329aba39a779adfa91c9eb0e98e9192023b9ec0452e73bfbfa5e6a2f2e3f555a7ce9368046a99b6d76c1180fa736b6ccb498104fedc6a5e1f98ace2e41f54c24
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/reminders_txt.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# file: reminders_txt.rb
|
4
4
|
|
5
5
|
|
6
|
-
require '
|
6
|
+
require 'dynarex'
|
7
7
|
require 'app-routes'
|
8
8
|
require 'chronic_cron'
|
9
9
|
|
@@ -26,33 +26,80 @@ class RemindersTxt
|
|
26
26
|
|
27
27
|
attr_reader :expressions
|
28
28
|
|
29
|
-
def initialize(s, now
|
29
|
+
def initialize(s, now: Time.now, dxfilepath: 'reminders.xml')
|
30
30
|
|
31
31
|
@raw_input = s
|
32
|
+
@now = now
|
33
|
+
|
34
|
+
Dir.chdir File.dirname(dxfilepath) if dxfilepath
|
35
|
+
|
36
|
+
@dxfilepath = dxfilepath
|
37
|
+
|
32
38
|
super()
|
33
39
|
@params = {input: s}
|
34
40
|
expressions(@params)
|
35
41
|
buffer = s[2..-1]
|
36
42
|
|
37
|
-
@
|
43
|
+
@reminders = buffer.inject([]) do |r, x|
|
38
44
|
if (x.length > 1) then
|
39
|
-
@params[:input] = x
|
45
|
+
@params[:input] = x.strip
|
40
46
|
rx = find_expression(x)
|
41
|
-
rx.input = x
|
47
|
+
rx.input = x.strip
|
42
48
|
r << rx
|
43
49
|
end
|
44
50
|
r
|
45
51
|
end
|
52
|
+
|
53
|
+
update()
|
54
|
+
end
|
55
|
+
|
56
|
+
def create_dx()
|
57
|
+
|
58
|
+
dx = Dynarex.new('reminders/reminder(input, title, recurring, date, end_date)')
|
59
|
+
@reminders.each {|x| dx.create x.to_h}
|
60
|
+
dx.save @dxfilepath
|
61
|
+
|
46
62
|
end
|
47
63
|
|
48
64
|
def refresh()
|
49
65
|
|
50
|
-
|
51
|
-
|
66
|
+
@reminders.map! do |x|
|
67
|
+
x.date = x.date.is_a?(Time) ? x.date : Chronic.parse(x.date)
|
68
|
+
x
|
52
69
|
end
|
70
|
+
|
71
|
+
# synchronise with the XML file
|
72
|
+
# if XML file doesn't exist, create it
|
53
73
|
|
54
|
-
|
74
|
+
if File.exists? @dxfilepath then
|
75
|
+
|
76
|
+
dx = Dynarex.new @dxfilepath
|
77
|
+
|
78
|
+
@reminders.map do |reminder|
|
79
|
+
|
80
|
+
r = dx.find_by_input reminder.input
|
81
|
+
reminder.date = Date.parse r.date
|
82
|
+
|
83
|
+
reminder
|
84
|
+
end
|
85
|
+
|
86
|
+
else
|
87
|
+
create_dx()
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
# delete expired non-recurring reminders
|
92
|
+
@reminders.reject! {|x| x.date.to_time < @now }
|
93
|
+
|
94
|
+
@reminders.sort_by!(&:date)
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
def to_s()
|
99
|
+
@raw_input[0..2].join + @reminders.map(&:input).join("\n")
|
55
100
|
end
|
101
|
+
|
102
|
+
alias update refresh
|
56
103
|
|
57
104
|
protected
|
58
105
|
|
@@ -82,7 +129,7 @@ class RemindersTxt
|
|
82
129
|
end
|
83
130
|
|
84
131
|
|
85
|
-
|
132
|
+
OpenStruct.new input: input, title: title, recurring: recurring, date: date, end_date: end_date
|
86
133
|
#[0, title, recurring, time, date, end_date].inspect
|
87
134
|
end
|
88
135
|
|
@@ -90,21 +137,21 @@ class RemindersTxt
|
|
90
137
|
# some meeting First thursday of the month at 7:30pm
|
91
138
|
get /(.*)\s+(\w+ \w+day of (?:the|every) month at .*)/ do |title, recurring|
|
92
139
|
|
93
|
-
|
140
|
+
OpenStruct.new input: '', title: title, recurring: recurring
|
94
141
|
#[1, title, recurring].inspect
|
95
142
|
end
|
96
143
|
|
97
144
|
# some important day 24th Mar
|
98
145
|
get /(.*)\s+(\d+.*)/ do |title, date|
|
99
146
|
|
100
|
-
|
147
|
+
OpenStruct.new input: '', title: title, date: date
|
101
148
|
#[2, title, date].inspect
|
102
149
|
end
|
103
150
|
|
104
151
|
# 27-Mar@1436 some important day
|
105
152
|
get /(\d[^\s]+)\s+(.*)/ do |date, title|
|
106
153
|
|
107
|
-
|
154
|
+
OpenStruct.new input: '', title: title, date: date
|
108
155
|
#[3, title, date].inspect
|
109
156
|
end
|
110
157
|
|
@@ -120,4 +167,3 @@ class RemindersTxt
|
|
120
167
|
alias find_expression run_route
|
121
168
|
|
122
169
|
end
|
123
|
-
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reminders_txt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,28 +31,28 @@ cert_chain:
|
|
31
31
|
n+SSd9dm8JjhZ2pqHtX+bgMZ18hrN06xfR+UPtk5BKC8v1PC0FWxaVR4lom39rFU
|
32
32
|
seDxJNsJgamAKg==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2016-11-
|
34
|
+
date: 2016-11-11 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
37
|
+
name: dynarex
|
38
38
|
requirement: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
42
|
+
version: '1.7'
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
45
|
+
version: 1.7.15
|
46
46
|
type: :runtime
|
47
47
|
prerelease: false
|
48
48
|
version_requirements: !ruby/object:Gem::Requirement
|
49
49
|
requirements:
|
50
50
|
- - "~>"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
52
|
+
version: '1.7'
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
55
|
+
version: 1.7.15
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: app-routes
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
metadata.gz.sig
CHANGED
Binary file
|