icalPal 3.1.1 → 3.3.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.
data/lib/reminder.rb CHANGED
@@ -8,13 +8,13 @@ module ICalPal
8
8
 
9
9
  def [](k)
10
10
  case k
11
- when 'notes' then # Skip empty notes
12
- @self['notes'].length > 0? @self['notes'] : nil
11
+ when 'notes' # Skip empty notes
12
+ (@self['notes'].empty?)? @self['notes'] : nil
13
13
 
14
- when 'priority' then # Integer -> String
15
- EventKit::EKReminderProperty[@self['priority']] if @self['priority'] > 0
14
+ when 'priority' # Integer -> String
15
+ EventKit::EKReminderProperty[@self['priority']] if @self['priority'].positive?
16
16
 
17
- when 'sdate' then # For sorting
17
+ when 'sdate' # For sorting
18
18
  @self['title']
19
19
 
20
20
  else @self[k]
@@ -23,32 +23,34 @@ module ICalPal
23
23
 
24
24
  def initialize(obj)
25
25
  @self = {}
26
- obj.keys.each { |k| @self[k] = obj[k] }
26
+ obj.each_key { |k| @self[k] = obj[k] }
27
27
 
28
28
  # Priority
29
+ # rubocop: disable Style/NumericPredicate
29
30
  @self['prio'] = 0 if @self['priority'] == 1 # high
30
31
  @self['prio'] = 1 if @self['priority'] == 5 # medium
31
32
  @self['prio'] = 2 if @self['priority'] == 9 # low
32
33
  @self['prio'] = 3 if @self['priority'] == 0 # none
34
+ # rubocop: enable Style/NumericPredicate
33
35
 
34
36
  @self['long_priority'] = LONG_PRIORITY[@self['prio']]
35
37
 
36
38
  # For sorting
37
- @self['sdate'] = (@self['title'])? @self['title'] : ""
39
+ @self['sdate'] = (@self['title'])? @self['title'] : ''
38
40
 
39
41
  # Due date
40
42
  @self['due'] = RDT.new(*Time.at(@self['due_date'] + ITIME).to_a.reverse[4..]) if @self['due_date']
41
43
  @self['due_date'] = 0 unless @self['due_date']
42
44
 
43
45
  # Notes
44
- @self['notes'] = "" unless @self['notes']
46
+ @self['notes'] = '' unless @self['notes']
45
47
 
46
48
  # Color
47
49
  @self['color'] = nil unless $opts[:palette]
48
50
 
49
- if @self['color'] then
51
+ if @self['color']
50
52
  # Run command
51
- stdin, stdout, stderr, e = Open3.popen3(PL_CONVERT)
53
+ stdin, stdout, _stderr, _e = Open3.popen3(PL_CONVERT)
52
54
 
53
55
  # Send color bplist
54
56
  stdin.write(@self['color'])
@@ -65,23 +67,21 @@ module ICalPal
65
67
  end
66
68
  end
67
69
 
68
- private
69
-
70
- DEFAULT_COLOR = '#1BADF8'
71
- DEFAULT_SYMBOLIC_COLOR = 'blue'
70
+ DEFAULT_COLOR = '#1BADF8'.freeze
71
+ DEFAULT_SYMBOLIC_COLOR = 'blue'.freeze
72
72
 
73
73
  LONG_PRIORITY = [
74
- "High priority",
75
- "Medium priority",
76
- "Low priority",
77
- "No priority",
78
- ]
74
+ 'High priority',
75
+ 'Medium priority',
76
+ 'Low priority',
77
+ 'No priority',
78
+ ].freeze
79
79
 
80
- PL_CONVERT = '/usr/bin/plutil -convert xml1 -o - -'
80
+ PL_CONVERT = '/usr/bin/plutil -convert xml1 -o - -'.freeze
81
81
 
82
- DB_PATH = "#{Dir::home}/Library/Group Containers/group.com.apple.reminders/Container_v1/Stores"
82
+ DB_PATH = "#{Dir.home}/Library/Group Containers/group.com.apple.reminders/Container_v1/Stores".freeze
83
83
 
84
- QUERY = <<~SQL
84
+ QUERY = <<~SQL.freeze
85
85
  SELECT DISTINCT
86
86
 
87
87
  zremcdReminder.zAllday as all_day,
data/lib/store.rb CHANGED
@@ -3,7 +3,7 @@ module ICalPal
3
3
  class Store
4
4
  include ICalPal
5
5
 
6
- QUERY = <<~SQL
6
+ QUERY = <<~SQL.freeze
7
7
  SELECT DISTINCT
8
8
 
9
9
  Store.name AS account,
data/lib/utils.rb ADDED
@@ -0,0 +1,45 @@
1
+ # Convert a key/value pair to XML. The value should be +nil+, +String+,
2
+ # +Integer+, +Array+, or +ICalPal::RDT+
3
+ #
4
+ # @param key The key
5
+ # @param value The value
6
+ # @return [String] The key/value pair in a simple XML format
7
+ def xmlify(key, value)
8
+ case value
9
+ # Nil
10
+ when NilClass then "<#{key}/>"
11
+
12
+ # String, Integer
13
+ when String then "<#{key}>#{value}</#{key}>"
14
+ when Integer then "<#{key}>#{value}</#{key}>"
15
+
16
+ # Array
17
+ when Array
18
+ # Treat empty arrays as nil values
19
+ xmlify(key, nil) if value[0].nil?
20
+
21
+ retval = ''
22
+ value.each { |x| retval += xmlify("#{key}0", x) }
23
+ "<#{key}>#{retval}</#{key}>"
24
+
25
+ # RDT
26
+ when ICalPal::RDT then "<#{key}>#{value}</#{key}>"
27
+
28
+ # Unknown
29
+ else "<#{key}>#{value}</#{key}>"
30
+ end
31
+ end
32
+
33
+ # Get the application icalPal is most likely running in
34
+ #
35
+ # @return [Integer] The basename of the program whose parent process id is 1 (launchd)
36
+ def ancestor
37
+ ppid = Process.ppid
38
+
39
+ while (ppid != 1)
40
+ ps = `ps -p #{ppid} -o ppid,command | tail -1`
41
+ ppid = ps[/^[0-9 ]+ /].to_i
42
+ end
43
+
44
+ ps[ps.rindex('/') + 1..].chop
45
+ end
data/lib/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module ICalPal
2
- NAME = 'icalPal'
3
- VERSION = '3.1.1'
2
+ NAME = 'icalPal'.freeze
3
+ VERSION = '3.3.0'.freeze
4
4
  end
metadata CHANGED
@@ -1,43 +1,42 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icalPal
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Rosen
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-11-07 00:00:00.000000000 Z
10
+ date: 2025-03-24 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
- name: sqlite3
13
+ name: nokogiri-plist
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: '1'
18
+ version: 0.5.0
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: '1'
25
+ version: 0.5.0
27
26
  - !ruby/object:Gem::Dependency
28
- name: nokogiri-plist
27
+ name: sqlite3
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - "~>"
32
31
  - !ruby/object:Gem::Version
33
- version: 0.5.0
32
+ version: 2.6.0
34
33
  type: :runtime
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
37
  - - "~>"
39
38
  - !ruby/object:Gem::Version
40
- version: 0.5.0
39
+ version: 2.6.0
41
40
  description: |
42
41
  Inspired by icalBuddy and maintains close compatability. Includes
43
42
  many additional features for querying, filtering, and formatting.
@@ -62,12 +61,18 @@ files:
62
61
  - lib/rdt.rb
63
62
  - lib/reminder.rb
64
63
  - lib/store.rb
64
+ - lib/utils.rb
65
65
  - lib/version.rb
66
66
  homepage: https://github.com/ajrosen/icalPal
67
67
  licenses:
68
68
  - GPL-3.0-or-later
69
- metadata: {}
70
- post_install_message:
69
+ metadata:
70
+ bug_tracker_uri: https://github.com/ajrosen/icalPal/issues
71
+ post_install_message: |2+
72
+
73
+ Note: icalPal requires "Full Disk Access" in System Settings to access your calendar.
74
+ Make sure the program that runs icalPal, not icalPal itself, has these permissions.
75
+
71
76
  rdoc_options: []
72
77
  require_paths:
73
78
  - lib
@@ -82,8 +87,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
87
  - !ruby/object:Gem::Version
83
88
  version: '0'
84
89
  requirements: []
85
- rubygems_version: 3.5.23
86
- signing_key:
90
+ rubygems_version: 3.6.6
87
91
  specification_version: 4
88
92
  summary: Command-line tool to query the macOS Calendar
89
93
  test_files: []
94
+ ...