gnu-remind 0.1.6 → 0.1.8

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: f610a49a3e80516e18ba70530fe50d0b50a666b3465922d8ed6157d70e6ee203
4
- data.tar.gz: 6e0574e377bec86bb7688c2a1aace08cb04ef69cfcabbca4c75450cfd6e771f9
3
+ metadata.gz: 21529ecd1aa56da32a0cef066ad2439f4662c48323a7f1c78b3a3c15d93846c0
4
+ data.tar.gz: de27928dad2b75db75dc3fda5d66340d0c5b9c8aebb9c13b33da0cb9cd4724de
5
5
  SHA512:
6
- metadata.gz: 87646938569350ea700426211dabceeee39503dfde78ac240fcf6a03d35310832f96126cc0c1673b9bb3d18efb38327fd24d13f3c93c25d5a0d54c74ea596a3d
7
- data.tar.gz: 2520562a704f65c70b347c07efff3ab32bba6ac0f8b337718b9a14bb53fa3b446fc23e84a782832d8045f1c72fff7ce580f1b61482678879cd9b12c37cdc0369
6
+ metadata.gz: ed69e87f261df62e70e7e7fc1b2f604f859c1bc3a23189407d648003c3106c9dea183fee848f70a1fa5562c811791eed271f8c5c789307bd054f54cf07bd267a
7
+ data.tar.gz: 9660e7feb1de77993b54e82cf64a0af16d951d0135afa0dc555d2bd05c3e75b248cf4bf0b5e66f920d2e451407e7f522033ef793b9faa65856b1f02922dac4ce
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.
@@ -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,5 +1,9 @@
1
+ # Event Processor
1
2
  module EVENT
3
+
4
+ # Event object.
2
5
  class E
6
+ # Event +i+.
3
7
  def initialize i
4
8
  @event = Nickel.parse i
5
9
  puts %[EVENT::E: #{@event}]
@@ -10,6 +14,7 @@ module EVENT
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,42 @@
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
-
20
+
21
+ # get Reminder collection with arguments +a+.
16
22
  def get a
17
23
  `remind #{a} rem/#{@id}.rem`.split("\n\n")
18
24
  end
19
-
25
+
26
+ # Clear Reminder collection.
20
27
  def clear!
21
28
  @rem = []
22
29
  end
23
-
30
+
31
+ # Reminder collection to string.
24
32
  def to_rem
25
33
  a = [];
26
34
  @rem.each { |e| a << @r[e].to_rem }
27
35
  return a.join("\n")
28
36
  end
29
37
 
38
+ # Write Reminder collection to file.
39
+ # +h[:append]+ append. (default: write)
30
40
  def to_rem! h={}
31
41
  if !Dir.exist? "rem"
32
42
  Dir.mkdir("rem")
@@ -39,18 +49,18 @@ module REM
39
49
  end
40
50
  end
41
51
 
42
-
52
+ # The Reminder object.
43
53
  class R
44
-
54
+ # high level event hash
45
55
  attr_accessor :attr
46
-
56
+ # Reminder +k+
47
57
  def initialize k
48
58
  @id = k
49
59
  @attr = {}
50
60
  end
51
-
61
+ # Reminder event id.
52
62
  def id; @id; end
53
-
63
+ # Reminder event hash to reminder string.
54
64
  def to_rem
55
65
  puts %[R[#{@id}] #{@attr}]
56
66
  a, i = [], [ @id ]
@@ -72,9 +82,11 @@ module REM
72
82
  end
73
83
 
74
84
  @@REM = Hash.new { |h,k| h[k] = E.new(k) }
85
+ # Get Reminder collection +k+.
75
86
  def self.[] k
76
87
  @@REM[k]
77
88
  end
89
+ # All Reminder collections
78
90
  def self.keys
79
91
  @@REM.keys
80
92
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Remind
4
- VERSION = "0.1.6"
4
+ # version.
5
+ VERSION = "0.1.8"
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,11 +75,17 @@ module Remind
67
75
  REM[k].to_rem! append: true
68
76
  end
69
77
 
70
- def self.get a, k
71
- REM[k].get(a)[1..-1]
78
+ # Get reminders container +k+
79
+ # +h[:args]+ can be set to get other filters.
80
+ # Remind.get("collection")
81
+ def self.get k, h={}
82
+ REM[k].get(h[:args] || '-t1')[1..-1]
72
83
  end
73
-
74
- def self.get! a
75
- @@REM.get(a)[1..-1]
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!
88
+ def self.get! h={}
89
+ @@REM.get(h[:args] || '-t1')[1..-1]
76
90
  end
77
91
  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.6
4
+ version: 0.1.8
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-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday