gnu-remind 0.1.7 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e19a29ab03bfa83dfcb3fcf0e55a656a46d3bc5a208f13e4328208603ff89d2
4
- data.tar.gz: 2f28f2c9cbb5f6be6f651b237eee7388fd0ccc8ec6fcc7fc18c61796c2ecbd81
3
+ metadata.gz: 852847d0fb94591dece3c07d9312aeb1a1a79f763d9c1d8b8fe12d54df58edc9
4
+ data.tar.gz: c187f80a3fb175b6f91c1ced9dbb95811a850a12e8380c1b83008eff5f98189a
5
5
  SHA512:
6
- metadata.gz: 0f01038165073462f41b21fa90f2c8d7cd04c9930aedc4b75d7da3e7ecf26a11fe92303f762a13488276aecf4943fd15615b4e79edb80e899ffa218b35eb4b7f
7
- data.tar.gz: 48deb1c49d4524cc6abd9b2e22a2fc802fdadf7b799a48adf2bc7ecc0edbbdd5f645386171fa3b19507a69e1739946f23d6cd706dac6e240e4f5e3ee5d62d317
6
+ metadata.gz: 719856762c828bc51c6983b0a05928f00f3dcabea349c6aa096e621667eea1ac7f57721150ec39e366c27295aa8780128a08a567909d73b96ec58ba5ab89241b
7
+ data.tar.gz: 5694f948015c39695dfae99a759323fe27936d39b25b8ab545adb45681f5af9a5c00fb5ea3ca7a4218ce194a2501c9e2ffd85d55ad246801d4215ef7a70eeaed
data/README.md CHANGED
@@ -24,59 +24,24 @@ gem build remind.gemspec
24
24
  require 'remind'
25
25
  ```
26
26
  ### Remind
27
- Use as a generic reminder handler.
27
+ A wapper around gnu remind.
28
28
 
29
- #### set
29
+ #### Set Reminders Collection
30
30
  Create local reminders from url.
31
31
  ```
32
- Remind['key'] = %[https://example.ics]
32
+ Remind.set(collection, "Binner at 8 tonight.")
33
33
  ```
34
34
 
35
- #### get
35
+ #### Get Reminders Collection
36
36
  Extract agenda from local reminders.
37
37
  ```
38
- Remind['key']
38
+ Remind.get(collection)
39
39
  ```
40
40
 
41
- #### all
41
+ #### Get System Reminders
42
42
  ```
43
- Remind.all
43
+ Remind.get!
44
44
  ```
45
45
 
46
-
47
- ### REM
48
- Use as a task specific tool
49
-
50
- #### collection
51
- ```
52
- REM['collection']
53
- ```
54
-
55
- #### entry
56
- ```
57
- REM['collection']['entry']
58
- ```
59
-
60
- #### entry attributes
61
- ```
62
- REM['collection']['entry'].attr = { type: "event type", date: "1 Jan 1970", lead: 7, repeat: 4, hour: "22", minute: "45", duration: "1:45", at: "Place Name" }
63
- ```
64
-
65
- #### entry reminder
66
- ```
67
- REM['collection'].to_rem
68
- ```
69
-
70
- #### save collection
71
- ```
72
- REM['collection'].to_rem!
73
- ```
74
-
75
- #### collection agenda
76
- ```
77
- REM['collection'].agenda
78
- ```
79
-
80
-
81
46
  ## Development
82
47
  You can also run `ruby bin/console` for an interactive prompt that will allow you to experiment.
Binary file
@@ -1,43 +1,54 @@
1
-
1
+ # Icalendar wrapper.
2
2
  module CAL
3
+
4
+ # Calendar object.
3
5
  class C
6
+ # Calendar +f+
4
7
  def initialize f
5
8
  @f = f
6
9
  end
10
+ # each calendar event
7
11
  def each &b
8
12
  @f.events.each { |e| b.call(E.new(e)) }
9
13
  return nil
10
14
  end
15
+ # map each calendar event
11
16
  def map &b
12
17
  a = []
13
18
  @f.events.each { |e| a << b.call(E.new(e)) }
14
19
  return a
15
20
  end
16
21
  end
17
-
22
+
23
+ # Calendar Event object
18
24
  class E
25
+ # Calendar Event +f+.
19
26
  def initialize f
20
27
  @f = f
21
28
  end
29
+ # Calendar Event location
22
30
  def where
23
31
  @f.location
24
32
  end
33
+ # Calendar Event focus
25
34
  def who
26
35
  @f.summary
27
36
  end
37
+ # Calendar Event details
28
38
  def what
29
39
  @f.description
30
40
  end
41
+ # Calendar Event scheduling
31
42
  def when
32
43
  { begin: @f.dtstart, end: @f.dtend }
33
44
  end
34
45
  end
35
-
46
+ # Load Calendar Event Collection from file +f+.
36
47
  def self.from_file f
37
48
  x = File.read(f)
38
49
  C.new(Icalendar::Calendar.parse(x).first)
39
50
  end
40
-
51
+ # Load Calendar Event Collection from url +u+.
41
52
  def self.from_url u
42
53
  x = Faraday.new().get(u).body
43
54
  C.new(Icalendar::Calendar.parse(x).first)
data/lib/remind/event.rb CHANGED
@@ -1,15 +1,20 @@
1
+ # Event Processor
1
2
  module EVENT
3
+
4
+ # Event object.
2
5
  class E
6
+ # Event +i+.
3
7
  def initialize i
4
- @event = Nickel.parse i
5
- puts %[EVENT::E: #{@event}]
6
- if event?
8
+ if @event = Nickel.parse i
9
+ puts %[EVENT event: #{@event}]
7
10
  @message = @event.message
8
11
  else
12
+ puts %[EVENT log]
9
13
  t = Time.now.utc
10
14
  @message = i
11
15
  end
12
16
  end
17
+ # is event?
13
18
  def event?
14
19
  if %[#{@event.message}].length > 0 && @event.occurrences.length > 0
15
20
  return true
@@ -17,6 +22,7 @@ module EVENT
17
22
  return false
18
23
  end
19
24
  end
25
+ # each event occourence
20
26
  def each &b
21
27
  @event.occurrences.each { |e|
22
28
  h = {
@@ -31,6 +37,7 @@ module EVENT
31
37
  return nil
32
38
  end
33
39
  end
40
+ # Process event.
34
41
  def self.[] k
35
42
  E.new(k)
36
43
  end
data/lib/remind/remind.rb CHANGED
@@ -1,32 +1,45 @@
1
+ # The Reminder wrapper.
1
2
  module REM
2
- class E
3
+ # The Reminder collection object.
4
+ class E
5
+ # Reminder collection +k+.
3
6
  def initialize k
4
7
  @id = k
5
8
  @r = Hash.new { |h,k| h[k] = R.new(k) }
6
9
  clear!
7
10
  end
11
+ # Reminder collection id.
8
12
  def id; @id; end
9
-
13
+
14
+ # get Reminder from collection.
10
15
  def [] k
11
16
  @rem << k
12
17
  @rem.uniq
13
18
  @r[k]
14
19
  end
15
-
16
- def get a
20
+
21
+ # get Reminder collection with arguments +a+.
22
+ def get a
23
+ if !File.exist?("rem/#{@id}.rem")
24
+ File.open("rem/#{@id}.rem",'w') { |f| f.write(""); }
25
+ end
17
26
  `remind #{a} rem/#{@id}.rem`.split("\n\n")
18
27
  end
19
-
28
+
29
+ # Clear Reminder collection.
20
30
  def clear!
21
31
  @rem = []
22
32
  end
23
-
33
+
34
+ # Reminder collection to string.
24
35
  def to_rem
25
36
  a = [];
26
37
  @rem.each { |e| a << @r[e].to_rem }
27
38
  return a.join("\n")
28
39
  end
29
40
 
41
+ # Write Reminder collection to file.
42
+ # +h[:append]+ append. (default: write)
30
43
  def to_rem! h={}
31
44
  if !Dir.exist? "rem"
32
45
  Dir.mkdir("rem")
@@ -39,18 +52,18 @@ module REM
39
52
  end
40
53
  end
41
54
 
42
-
55
+ # The Reminder object.
43
56
  class R
44
-
57
+ # high level event hash
45
58
  attr_accessor :attr
46
-
59
+ # Reminder +k+
47
60
  def initialize k
48
61
  @id = k
49
62
  @attr = {}
50
63
  end
51
-
64
+ # Reminder event id.
52
65
  def id; @id; end
53
-
66
+ # Reminder event hash to reminder string.
54
67
  def to_rem
55
68
  puts %[R[#{@id}] #{@attr}]
56
69
  a, i = [], [ @id ]
@@ -72,9 +85,11 @@ module REM
72
85
  end
73
86
 
74
87
  @@REM = Hash.new { |h,k| h[k] = E.new(k) }
88
+ # Get Reminder collection +k+.
75
89
  def self.[] k
76
90
  @@REM[k]
77
91
  end
92
+ # All Reminder collections
78
93
  def self.keys
79
94
  @@REM.keys
80
95
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Remind
4
- VERSION = "0.1.7"
4
+ # version.
5
+ VERSION = "0.1.9"
5
6
  end
data/lib/remind.rb CHANGED
@@ -16,27 +16,32 @@ require_relative "remind/calendar"
16
16
 
17
17
  require_relative "remind/event"
18
18
 
19
+ # The Remind wrapper.
19
20
  module Remind
21
+ # generic errors
20
22
  class Error < StandardError; end
21
23
 
22
24
  @@REM = REM['reminders']
23
25
 
24
26
  @@INIT = []
25
- def self.init h={}
27
+ # Add system event.
28
+ # +h+ event hash
29
+ # Remind.reminder what: "Sports ball vs. the other team.", when: "15 March 2024 AT 19:00"
30
+ def self.reminder h={}
26
31
  @@INIT << h
27
32
  end
28
33
 
29
34
  @@URL = []
35
+ # Add system ics url.
36
+ # +u+ the ics url
37
+ # Remind.url "https://your_domain.ics"
30
38
  def self.url u
31
39
  @@URL << u
32
40
  end
33
-
34
- @@SRC = []
35
- def self.src k
36
- @@SRC << k
37
- end
38
-
39
- def self.rebuild!
41
+
42
+ # Set system reminders
43
+ # Remind.build!
44
+ def self.build!
40
45
  @@REM.clear!
41
46
 
42
47
  [@@INIT].flatten.each do |x|
@@ -56,8 +61,11 @@ module Remind
56
61
 
57
62
  @@REM.to_rem!
58
63
  end
59
-
60
- def self.remind k, *src
64
+
65
+ # Set collection +k+ reminders.
66
+ # +src+ one or more input string to be processed.
67
+ # Remind.set("collection", "Dinner tonight at 8.", ...)
68
+ def self.set k, *src
61
69
  REM[k].clear!
62
70
  [src].flatten.each do |e|
63
71
  EVENT[e].each do |ee|
@@ -67,10 +75,16 @@ module Remind
67
75
  REM[k].to_rem! append: true
68
76
  end
69
77
 
78
+ # Get reminders container +k+
79
+ # +h[:args]+ can be set to get other filters.
80
+ # Remind.get("collection")
70
81
  def self.get k, h={}
71
82
  REM[k].get(h[:args] || '-t1')[1..-1]
72
83
  end
73
-
84
+ # Get system reminders
85
+ # Gets one week's agenda by default.
86
+ # +h[:args]+ can be set to get other filters.
87
+ # Remind.get!
74
88
  def self.get! h={}
75
89
  @@REM.get(h[:args] || '-t1')[1..-1]
76
90
  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.7
4
+ version: 0.1.9
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-24 00:00:00.000000000 Z
11
+ date: 2024-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -64,6 +64,7 @@ files:
64
64
  - LICENSE.txt
65
65
  - README.md
66
66
  - Rakefile
67
+ - gnu-remind-0.1.8.gem
67
68
  - lib/remind.rb
68
69
  - lib/remind/calendar.rb
69
70
  - lib/remind/event.rb