icalPal 2.0.0 → 2.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f91434d02dd357bcd02342b2d79418b91e23ec789a6a069a01f2f508685d8ca
4
- data.tar.gz: 51cfa58c767650d0c7e62213ad4a58dbe9a2d5fc42f17d5ce18c8b65e6a178be
3
+ metadata.gz: 4dab143a05d8a63ae36b721ca6ba53180c75d8b4dd0f0cebdc84fb533968c248
4
+ data.tar.gz: 8d243a120762c90059e4206a2deb5e79b821e558cf9ad9a437ad84fbfbb6a21b
5
5
  SHA512:
6
- metadata.gz: 20b4a10406535baf33986bd6bdf859376a6dfd7055815b2f263d6971d6e8255d5d60fa019c49c4de54ec3a4178e3752136478aafa5937176c80adfdfc36cc8aa
7
- data.tar.gz: 8a5fbde979186c3347ed6c8c52f3b39b81fc6b303680e1923c0b011583b1c63651dc65b33e4e34a3794b5d01430cb7bd4dd66b2f12510374f13626e438aef079
6
+ metadata.gz: 24f4b88c592e59f2ffbc116761d6da41b60a7e5d4554feea9bdb023450967eaa7921f5c4708a66bf76554926ab4e0ca52965470f7576cef1cce5aec9a6112cbb
7
+ data.tar.gz: d69cc1d2cd63072020a4059a352ccdb2262a189e10c3c4e1891bd1c953ea2cb60a577fc83bd2ab55b561d0a752b0fb4198495bc2a5f57909d4216101cc7ea012
data/README.md CHANGED
@@ -4,16 +4,30 @@
4
4
 
5
5
  ## Description
6
6
 
7
- icalPal is a command-line tool to query a macOS Calendar database for
8
- accounts, calendars, and events. It can be run on any system with
9
- [Ruby](https://www.ruby-lang.org/) and access to a Calendar database
10
- file, or a Reminders database.
7
+ icalPal is a command-line tool to query a macOS Calendar and Reminders
8
+ databases for accounts, calendars, events, and tasks. It can be run
9
+ on any system with [Ruby](https://www.ruby-lang.org/) and access to a
10
+ Calendar or Reminders database.
11
11
 
12
12
  ## Installation
13
13
 
14
+ As a system-wide Ruby gem:
15
+
14
16
  ```
15
17
  gem install icalPal
16
- icalPal events
18
+ ```
19
+
20
+ or in your home diretory:
21
+
22
+ ```
23
+ gem install --user-install icalPal
24
+ ```
25
+
26
+ As a Homebrew formula:
27
+
28
+ ```
29
+ brew tap ajrosen/icalPal
30
+ brew install icalPal
17
31
  ```
18
32
 
19
33
  ## Features
@@ -21,7 +35,8 @@ icalPal events
21
35
  ### Compatability with [icalBuddy](https://github.com/ali-rantakari/icalBuddy)
22
36
 
23
37
  icalPal tries to be compatible with icalBuddy for command-line options
24
- and for output. There are a few differences to be aware of.
38
+ and for output. There are a some important differences to be aware
39
+ of.
25
40
 
26
41
  * Options require two hyphens, except for single-letter options that require one hyphen
27
42
  * *eventsFrom* is not supported. Instead there is *--from*, *--to*, and *--days*
@@ -184,27 +199,6 @@ Environment variables:
184
199
  (default: /Users/ajr/.icalPal)
185
200
  ```
186
201
 
187
- ## History
188
-
189
- I have used icalBuddy for many years. It's great for scripting,
190
- automation, and as a desktop widget for apps like
191
- [GeekTool](https://www.tynsoe.org/geektool/) and
192
- [Übersicht](https://tracesof.net/uebersicht/).
193
-
194
- As with many applications, I started to run into some limitations in
195
- icalBuddy. The biggest being that active development ended in 2014.
196
- It's only thanks to the efforts of [Jim
197
- Lawton](https://github.com/jimlawton) that it even compiles anymore.
198
-
199
- Instead of trying to understand and extend the existing code, I chose
200
- to start anew using my language of choice. Using Ruby means icalPal
201
- is multi-platform. It also meant *much* less code; about 1,200 lines
202
- vs. 7,000.
203
-
204
- I won't pretend to understand **why** you would want this on Linux or
205
- Windows. But since icalPal is written in Ruby and gets its data
206
- directly from the Calendar database file instead of an API, you *can*.
207
-
208
202
  ## Output formats
209
203
 
210
204
  icalPal supports several output formats. The **default** format tries
@@ -242,5 +236,29 @@ objects, one for each of the item's properties:
242
236
 
243
237
  The document will also include a number of
244
238
  [RDoc::Markup::Verbatim](https://ruby-doc.org/stdlib-2.6.10/libdoc/rdoc/rdoc/RDoc/Markup/Verbatim.html)
239
+ and
240
+ [RDoc::Markup::Raw](https://ruby-doc.org/stdlib-2.6.10/libdoc/rdoc/rdoc/RDoc/Markup/Raw.html)
245
241
  items. They are not included in the output, but are used to pass
246
242
  information about the item and property to the default formatter.
243
+
244
+ ## History
245
+
246
+ I used icalBuddy for many years. It's great for scripting,
247
+ automation, and as a desktop widget for apps like
248
+ [GeekTool](https://www.tynsoe.org/geektool/) and
249
+ [Übersicht](https://tracesof.net/uebersicht/).
250
+
251
+ As with many applications, I started to run into some limitations in
252
+ icalBuddy. The biggest being that active development ended in 2014.
253
+ It's only thanks to the efforts of [Jim
254
+ Lawton](https://github.com/jimlawton) that it even compiles anymore.
255
+
256
+ Instead of trying to understand and extend the existing code, I chose
257
+ to start anew using my language of choice: Ruby. Using Ruby meant
258
+ there is *much* less code; about 1,600 lines vs. 7,000. It also means
259
+ icalPal is multi-platform.
260
+
261
+ I won't pretend to understand **why** you would want to run this on
262
+ Linux or Windows. But since icalPal is written in Ruby and gets its
263
+ data directly from the Calendar and Reminders database files instead
264
+ of an API, you *can*.
data/bin/icalPal CHANGED
@@ -1,16 +1,25 @@
1
1
  #!/usr/bin/env ruby
2
- # *-*- mode: enh-ruby -*-*
3
2
 
4
- require 'logger'
3
+ begin
4
+ require 'logger'
5
+
6
+ require 'csv'
7
+ require 'json'
8
+ require 'rdoc'
9
+ require 'sqlite3'
10
+ require 'yaml'
11
+
12
+ require_relative '../lib/icalPal'
13
+ require_relative '../lib/options'
14
+ rescue LoadError => e
15
+ dep = e.message[/-- (.*)/, 1]
5
16
 
6
- require 'csv'
7
- require 'json'
8
- require 'rdoc'
9
- require 'sqlite3'
10
- require 'yaml'
17
+ $stderr.puts "FATAL: icalPal is missing a dependency: #{dep}"
18
+ $stderr.puts
19
+ $stderr.puts "Install with 'gem install --user-install #{dep}'"
11
20
 
12
- require_relative '../lib/icalPal'
13
- require_relative '../lib/options'
21
+ exit
22
+ end
14
23
 
15
24
 
16
25
  ##################################################
data/lib/event.rb CHANGED
@@ -114,6 +114,8 @@ module ICalPal
114
114
 
115
115
  # Repeat for multi-day events
116
116
  ((self['duration'] / 86400).to_i + 1).times do |i|
117
+ break if self['sdate'] > $opts[:to]
118
+
117
119
  $log.debug("multi-day event #{i + 1}") if (i > 0)
118
120
  self['daynum'] = i + 1
119
121
  retval.push(clone) if in_window?(self['sdate'])
data/lib/icalPal.rb CHANGED
@@ -58,6 +58,9 @@ module ICalPal
58
58
  rescue SQLite3::BusyException => e
59
59
  $log.error("Non-fatal error closing database #{db.filename}")
60
60
 
61
+ rescue SQLite3::SQLException => e
62
+ $log.info("#{db_file}: #{e}")
63
+
61
64
  rescue SQLite3::Exception => e
62
65
  abort("#{db_file}: #{e}")
63
66
 
@@ -92,28 +95,49 @@ module ICalPal
92
95
  CSV::Row::new(headers, values)
93
96
  end
94
97
 
98
+ # Convert +self+ to XML
99
+ #
95
100
  # @return [String] All fields in a simple XML format: <field>value</field>.
96
101
  # Fields with empty values return <field/>.
97
102
  def to_xml
98
103
  retval = ""
99
-
100
- @self.keys.each do |k|
101
- v = @self[k]
102
-
103
- if v.respond_to?(:length) then
104
- if v.length == 0 or v[0] == nil then
105
- retval += "<#{k}/>"
106
- else
107
- # Keep non-blank and whitespace, except form feeds and vertical whitespace
108
- v = v.gsub(/[^[[:print:]][[:space:]]]/, '.').gsub(/[\f\v]/, '.')
109
- retval += "<#{k}>#{v}</#{k}>"
110
- end
111
- end
112
- end
104
+ @self.keys.each { |k| retval += xmlify(k, @self[k]) }
113
105
 
114
106
  retval
115
107
  end
116
108
 
109
+ # Convert a key/value pair to XML. The value should be +nil+, +String+,
110
+ # +Integer+, +Array+, or +ICalPal::RDT+
111
+ #
112
+ # @param key The key
113
+ # @param value The value
114
+ # @return [String] The key/value pair in a simple XML format
115
+ def xmlify(key, value)
116
+ case value
117
+ # Nil
118
+ when NilClass then return("<#{key}/>")
119
+
120
+ # String, Integer
121
+ when String then return("<#{key}>#{value}</#{key}>")
122
+ when Integer then return("<#{key}>#{value}</#{key}>")
123
+
124
+ # Array
125
+ when Array then
126
+ # Treat empty arrays as nil values
127
+ return(xmlify(key, nil)) if value[0] == nil
128
+
129
+ retval = ""
130
+ value.each { |x| retval += xmlify("#{key}0", x) }
131
+ return("<#{key}>#{retval}</#{key}>")
132
+
133
+ # RDT
134
+ when ICalPal::RDT then return("<#{key}>#{value.to_s}</#{key}>")
135
+
136
+ # Unknown
137
+ else return("<#{key}>#{value.to_s}</#{key}>")
138
+ end
139
+ end
140
+
117
141
  # Get the +n+'th +dow+ in month +m+
118
142
  #
119
143
  # @param n [Integer] Integer between -4 and +4
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ICalPal
2
- VERSION = '2.0.0'
2
+ VERSION = '2.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icalPal
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Rosen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-14 00:00:00.000000000 Z
11
+ date: 2024-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  requirements: []
84
- rubygems_version: 3.5.4
84
+ rubygems_version: 3.5.9
85
85
  signing_key:
86
86
  specification_version: 4
87
87
  summary: Command-line tool to query the macOS Calendar