gnu-remind 0.1.5 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/remind/event.rb +37 -0
- data/lib/remind/remind.rb +65 -73
- data/lib/remind/version.rb +1 -1
- data/lib/remind.rb +35 -38
- data/remind.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e19a29ab03bfa83dfcb3fcf0e55a656a46d3bc5a208f13e4328208603ff89d2
|
4
|
+
data.tar.gz: 2f28f2c9cbb5f6be6f651b237eee7388fd0ccc8ec6fcc7fc18c61796c2ecbd81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f01038165073462f41b21fa90f2c8d7cd04c9930aedc4b75d7da3e7ecf26a11fe92303f762a13488276aecf4943fd15615b4e79edb80e899ffa218b35eb4b7f
|
7
|
+
data.tar.gz: 48deb1c49d4524cc6abd9b2e22a2fc802fdadf7b799a48adf2bc7ecc0edbbdd5f645386171fa3b19507a69e1739946f23d6cd706dac6e240e4f5e3ee5d62d317
|
data/lib/remind/event.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
module EVENT
|
2
|
+
class E
|
3
|
+
def initialize i
|
4
|
+
@event = Nickel.parse i
|
5
|
+
puts %[EVENT::E: #{@event}]
|
6
|
+
if event?
|
7
|
+
@message = @event.message
|
8
|
+
else
|
9
|
+
t = Time.now.utc
|
10
|
+
@message = i
|
11
|
+
end
|
12
|
+
end
|
13
|
+
def event?
|
14
|
+
if %[#{@event.message}].length > 0 && @event.occurrences.length > 0
|
15
|
+
return true
|
16
|
+
else
|
17
|
+
return false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
def each &b
|
21
|
+
@event.occurrences.each { |e|
|
22
|
+
h = {
|
23
|
+
message: @message,
|
24
|
+
date: e.start_date.to_date.strftime("%-d %b %Y"),
|
25
|
+
hour: e.start_time.to_time.strftime("%k"),
|
26
|
+
minute: e.start_time.to_time.strftime("%M")
|
27
|
+
}
|
28
|
+
puts %[each message: #{h}]
|
29
|
+
b.call(h, e)
|
30
|
+
}
|
31
|
+
return nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
def self.[] k
|
35
|
+
E.new(k)
|
36
|
+
end
|
37
|
+
end
|
data/lib/remind/remind.rb
CHANGED
@@ -1,83 +1,76 @@
|
|
1
|
-
|
2
|
-
class E
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
8
|
-
def id; @id; end
|
9
|
-
|
10
|
-
def [] k
|
11
|
-
@rem << k
|
12
|
-
@r[k]
|
13
|
-
end
|
14
|
-
|
15
|
-
def agenda
|
16
|
-
`remind -t1 rem/#{@id}.rem`.split("\n\n")
|
17
|
-
end
|
18
|
-
|
19
|
-
def clear!
|
20
|
-
@rem = []
|
21
|
-
end
|
22
|
-
|
23
|
-
def to_rem
|
24
|
-
a = [];
|
25
|
-
@rem.each { |e| a << @r[e].to_rem }
|
26
|
-
return a.join("\n")
|
27
|
-
end
|
28
|
-
|
29
|
-
def to_rem!
|
30
|
-
if !Dir.exist? "rem"
|
31
|
-
Dir.mkdir("rem")
|
1
|
+
module REM
|
2
|
+
class E
|
3
|
+
def initialize k
|
4
|
+
@id = k
|
5
|
+
@r = Hash.new { |h,k| h[k] = R.new(k) }
|
6
|
+
clear!
|
32
7
|
end
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
def id; @id; end
|
48
|
-
|
49
|
-
def to_rem
|
50
|
-
a, i = [], [ @id ]
|
51
|
-
if @attr.has_key? :date
|
52
|
-
a << %[#{@attr[:date]}]
|
53
|
-
if @attr.has_key? :lead
|
54
|
-
a << %[++#{@attr[:lead]}]
|
55
|
-
end
|
56
|
-
if @attr.has_key? :repeat
|
57
|
-
a << %[*#{@attr[:repeat]}]
|
58
|
-
end
|
59
|
-
if @attr.has_key? :until
|
60
|
-
a << %[UNTIL #{@attr[:until]}]
|
61
|
-
end
|
8
|
+
def id; @id; end
|
9
|
+
|
10
|
+
def [] k
|
11
|
+
@rem << k
|
12
|
+
@rem.uniq
|
13
|
+
@r[k]
|
14
|
+
end
|
15
|
+
|
16
|
+
def get a
|
17
|
+
`remind #{a} rem/#{@id}.rem`.split("\n\n")
|
18
|
+
end
|
19
|
+
|
20
|
+
def clear!
|
21
|
+
@rem = []
|
62
22
|
end
|
63
|
-
|
64
|
-
|
65
|
-
|
23
|
+
|
24
|
+
def to_rem
|
25
|
+
a = [];
|
26
|
+
@rem.each { |e| a << @r[e].to_rem }
|
27
|
+
return a.join("\n")
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_rem! h={}
|
31
|
+
if !Dir.exist? "rem"
|
32
|
+
Dir.mkdir("rem")
|
33
|
+
end
|
34
|
+
if h[:append] == true
|
35
|
+
File.open("rem/#{@id}.rem",'a') { |f| f.write(to_rem); }
|
66
36
|
else
|
67
|
-
|
37
|
+
File.open("rem/#{@id}.rem",'w') { |f| f.write(to_rem); }
|
68
38
|
end
|
69
39
|
end
|
70
|
-
|
71
|
-
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
class R
|
44
|
+
|
45
|
+
attr_accessor :attr
|
46
|
+
|
47
|
+
def initialize k
|
48
|
+
@id = k
|
49
|
+
@attr = {}
|
72
50
|
end
|
73
|
-
|
74
|
-
|
51
|
+
|
52
|
+
def id; @id; end
|
53
|
+
|
54
|
+
def to_rem
|
55
|
+
puts %[R[#{@id}] #{@attr}]
|
56
|
+
a, i = [], [ @id ]
|
57
|
+
if @attr.has_key? :date
|
58
|
+
a << %[#{@attr[:date]}]
|
59
|
+
if @attr.has_key? :lead
|
60
|
+
a << %[++#{@attr[:lead]}]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
if @attr.has_key? :hour
|
64
|
+
if @attr.has_key? :minute
|
65
|
+
a << %[AT #{@attr[:hour]}:#{@attr[:minute]}]
|
66
|
+
else
|
67
|
+
a << %[AT #{@attr[:hour]}:00]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
return %[REM #{a.join(" ")} MSG #{i.join(" ")}\n]
|
75
71
|
end
|
76
|
-
return %[REM #{a.join(" ")} MSG #{i.join(" ")}]
|
77
72
|
end
|
78
|
-
|
79
|
-
|
80
|
-
module REM
|
73
|
+
|
81
74
|
@@REM = Hash.new { |h,k| h[k] = E.new(k) }
|
82
75
|
def self.[] k
|
83
76
|
@@REM[k]
|
@@ -86,4 +79,3 @@ module REM
|
|
86
79
|
@@REM.keys
|
87
80
|
end
|
88
81
|
end
|
89
|
-
|
data/lib/remind/version.rb
CHANGED
data/lib/remind.rb
CHANGED
@@ -1,80 +1,77 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'erb'
|
4
|
+
|
3
5
|
require 'faraday'
|
4
6
|
|
5
7
|
require 'icalendar'
|
6
8
|
|
9
|
+
require 'nickel'
|
10
|
+
|
7
11
|
require_relative "remind/version"
|
8
12
|
|
9
13
|
require_relative "remind/remind"
|
10
14
|
|
11
15
|
require_relative "remind/calendar"
|
12
16
|
|
17
|
+
require_relative "remind/event"
|
18
|
+
|
13
19
|
module Remind
|
14
20
|
class Error < StandardError; end
|
21
|
+
|
15
22
|
@@REM = REM['reminders']
|
23
|
+
|
16
24
|
@@INIT = []
|
17
|
-
@@URL = []
|
18
25
|
def self.init h={}
|
19
26
|
@@INIT << h
|
20
27
|
end
|
21
28
|
|
29
|
+
@@URL = []
|
22
30
|
def self.url u
|
23
31
|
@@URL << u
|
24
32
|
end
|
25
33
|
|
34
|
+
@@SRC = []
|
35
|
+
def self.src k
|
36
|
+
@@SRC << k
|
37
|
+
end
|
38
|
+
|
26
39
|
def self.rebuild!
|
27
40
|
@@REM.clear!
|
41
|
+
|
28
42
|
[@@INIT].flatten.each do |x|
|
43
|
+
puts %[rebuild! x: #{x}]
|
29
44
|
@@REM[x[:what]].attr = { date: x[:when] }
|
30
45
|
end
|
46
|
+
|
31
47
|
@@URL.each do |u|
|
48
|
+
puts %[rebuild! u: #{u}]
|
32
49
|
CAL.from_url(u).each do |e|
|
33
50
|
d = e.when[:begin].to_time.localtime.strftime("%Y/%m/%d-%R")
|
34
|
-
h = {
|
35
|
-
date: e.when[:begin].to_time.localtime.strftime("%-d %b %Y"),
|
36
|
-
hour: e.when[:begin].to_time.localtime.strftime("%k"),
|
37
|
-
minute: e.when[:begin].to_time.localtime.strftime("%M"),
|
38
|
-
at: e.where,
|
39
|
-
type: e.who,
|
40
|
-
lead: 1
|
41
|
-
}
|
51
|
+
h = { date: e.when[:begin].to_time.localtime.strftime("%-d %b %Y"), hour: e.when[:begin].to_time.localtime.strftime("%k"), minute: e.when[:begin].to_time.localtime.strftime("%M"), lead: 1 }
|
42
52
|
k = %[#{e.what} #{h[:type]} #{d}]
|
43
53
|
@@REM[k].attr = h
|
44
54
|
end
|
45
55
|
end
|
46
|
-
|
47
|
-
|
48
|
-
def self.remote x, u
|
49
|
-
r = REM[x]
|
50
|
-
r.clear!
|
51
|
-
Remind.rebuild!
|
52
|
-
CAL.from_url(u).each do |e|
|
53
|
-
d = e.when[:begin].to_time.localtime.strftime("%Y/%m/%d-%R")
|
54
|
-
h = {
|
55
|
-
date: e.when[:begin].to_time.localtime.strftime("%-d %b %Y"),
|
56
|
-
hour: e.when[:begin].to_time.localtime.strftime("%k"),
|
57
|
-
minute: e.when[:begin].to_time.localtime.strftime("%M"),
|
58
|
-
at: e.where,
|
59
|
-
type: e.who
|
60
|
-
}
|
61
|
-
|
62
|
-
k = %[#{e.what} #{h[:type]} #{d}]
|
63
|
-
puts "#{k}: #{h}"
|
64
|
-
r[k].attr = h
|
65
|
-
@@REM[k].attr = h
|
66
|
-
end
|
67
|
-
r.to_rem!
|
56
|
+
|
68
57
|
@@REM.to_rem!
|
69
|
-
|
70
|
-
end
|
58
|
+
end
|
71
59
|
|
72
|
-
def self.
|
73
|
-
REM[k].
|
60
|
+
def self.remind k, *src
|
61
|
+
REM[k].clear!
|
62
|
+
[src].flatten.each do |e|
|
63
|
+
EVENT[e].each do |ee|
|
64
|
+
REM[k][%[#{ee[:message]} #{ee[:date]}]].attr = { date: ee[:date], hour: ee[:hour], minute: ee[:minute], lead: 1 }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
REM[k].to_rem! append: true
|
74
68
|
end
|
75
69
|
|
76
|
-
def self.
|
77
|
-
|
78
|
-
|
70
|
+
def self.get k, h={}
|
71
|
+
REM[k].get(h[:args] || '-t1')[1..-1]
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.get! h={}
|
75
|
+
@@REM.get(h[:args] || '-t1')[1..-1]
|
79
76
|
end
|
80
77
|
end
|
data/remind.gemspec
CHANGED
@@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
|
|
33
33
|
# Uncomment to register a new dependency of your gem
|
34
34
|
spec.add_dependency "faraday"
|
35
35
|
spec.add_dependency "icalendar"
|
36
|
+
spec.add_dependency "nickel"
|
36
37
|
# For more information and examples about making a new gem, check out our
|
37
38
|
# guide at: https://bundler.io/guides/creating_gem.html
|
38
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gnu-remind
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erik Olson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: nickel
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: A wrapper around gnu remind leveraging ics files via url or locally.
|
42
56
|
email:
|
43
57
|
- xorgnak@gmail.com
|
@@ -52,6 +66,7 @@ files:
|
|
52
66
|
- Rakefile
|
53
67
|
- lib/remind.rb
|
54
68
|
- lib/remind/calendar.rb
|
69
|
+
- lib/remind/event.rb
|
55
70
|
- lib/remind/remind.rb
|
56
71
|
- lib/remind/version.rb
|
57
72
|
- remind.gemspec
|