plansheet 0.7.1 → 0.9.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: d9c1a116df170c31d73c29dce213b757743c0e49bbee8c86a47ce7ce09009730
4
- data.tar.gz: 2baeb58d82c15823d9beb3e6504bb452e14cabded159f9931bf2300fdaed5d8f
3
+ metadata.gz: a8132e26b8647ea119299716b5f88674af3e4264614f7b881133eb6cbd32d7db
4
+ data.tar.gz: c04f8bf586f6866acf03e809ab581b8010b6fb64be486791abb5fdd3274ae6e2
5
5
  SHA512:
6
- metadata.gz: a87a4f7386a651ca82d385600f7b32ee78ff436406d596b6c2966ed721bdcee16f9bd4ad73b158be03305541dceda0d525e68ea2dc520a028fb603a6b5f0c1c0
7
- data.tar.gz: d679906ef154e9b84e9282e1811ac0dff8da8b4dfb17c6e0e24d7f08226933346c4229468ddf51526e7532af7bdfd9a502557b64efc6439c128716a380e86d86
6
+ metadata.gz: 6426deb869f89a6ff87d5f760acbab8687a542dd3942cf829c536ceb49c3a8268b18ab188d0ad0cb91457fa435963eb7193dd9844a283ccdfb4114e4dece54d8
7
+ data.tar.gz: 4c03feeae9aed94d4e4df6c931c1317039f1100e67d7475cdbf8b67dae14e753899853291ad46f025e198d93def4b9c67c0c12da24d352d8db0880ae5ebb2f99
data/.rubocop_todo.yml CHANGED
@@ -1,17 +1,22 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2022-06-02 13:59:36 UTC using RuboCop version 1.29.1.
3
+ # on 2022-06-04 17:25:54 UTC using RuboCop version 1.29.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
+ # Offense count: 1
10
+ # Configuration parameters: CountComments, CountAsOne.
11
+ Metrics/ClassLength:
12
+ Max: 105
13
+
9
14
  # Offense count: 1
10
15
  # Configuration parameters: IgnoredMethods.
11
16
  Metrics/CyclomaticComplexity:
12
17
  Max: 8
13
18
 
14
- # Offense count: 1
19
+ # Offense count: 2
15
20
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
16
21
  Metrics/MethodLength:
17
22
  Max: 12
data/Gemfile CHANGED
@@ -6,7 +6,12 @@ source "https://rubygems.org"
6
6
  gemspec
7
7
 
8
8
  group :development, optional: true do
9
+ gem "guard", "~> 2.18"
10
+ gem "guard-minitest", "~> 2.4"
9
11
  gem "minitest", "~> 5.0"
10
12
  gem "rake", "~> 13.0"
13
+
11
14
  gem "rubocop", "~> 1.21"
15
+ gem "rubocop-minitest"
16
+ gem "rubocop-rake"
12
17
  end
data/Gemfile.lock CHANGED
@@ -1,20 +1,51 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- plansheet (0.7.1)
4
+ plansheet (0.9.0)
5
5
  dc-kwalify (~> 1.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  ast (2.4.2)
11
+ coderay (1.1.3)
11
12
  dc-kwalify (1.0.0)
13
+ ffi (1.15.5)
14
+ formatador (1.1.0)
15
+ guard (2.18.0)
16
+ formatador (>= 0.2.4)
17
+ listen (>= 2.7, < 4.0)
18
+ lumberjack (>= 1.0.12, < 2.0)
19
+ nenv (~> 0.1)
20
+ notiffany (~> 0.0)
21
+ pry (>= 0.13.0)
22
+ shellany (~> 0.0)
23
+ thor (>= 0.18.1)
24
+ guard-compat (1.2.1)
25
+ guard-minitest (2.4.6)
26
+ guard-compat (~> 1.2)
27
+ minitest (>= 3.0)
28
+ listen (3.7.1)
29
+ rb-fsevent (~> 0.10, >= 0.10.3)
30
+ rb-inotify (~> 0.9, >= 0.9.10)
31
+ lumberjack (1.2.8)
32
+ method_source (1.0.0)
12
33
  minitest (5.15.0)
34
+ nenv (0.3.0)
35
+ notiffany (0.1.3)
36
+ nenv (~> 0.1)
37
+ shellany (~> 0.0)
13
38
  parallel (1.22.1)
14
39
  parser (3.1.2.0)
15
40
  ast (~> 2.4.1)
41
+ pry (0.14.1)
42
+ coderay (~> 1.1)
43
+ method_source (~> 1.0)
16
44
  rainbow (3.1.1)
17
45
  rake (13.0.6)
46
+ rb-fsevent (0.11.1)
47
+ rb-inotify (0.10.1)
48
+ ffi (~> 1.0)
18
49
  regexp_parser (2.4.0)
19
50
  rexml (3.2.5)
20
51
  rubocop (1.29.1)
@@ -28,17 +59,27 @@ GEM
28
59
  unicode-display_width (>= 1.4.0, < 3.0)
29
60
  rubocop-ast (1.18.0)
30
61
  parser (>= 3.1.1.0)
62
+ rubocop-minitest (0.20.0)
63
+ rubocop (>= 0.90, < 2.0)
64
+ rubocop-rake (0.6.0)
65
+ rubocop (~> 1.0)
31
66
  ruby-progressbar (1.11.0)
67
+ shellany (0.0.1)
68
+ thor (1.2.1)
32
69
  unicode-display_width (2.1.0)
33
70
 
34
71
  PLATFORMS
35
72
  x86_64-linux
36
73
 
37
74
  DEPENDENCIES
75
+ guard (~> 2.18)
76
+ guard-minitest (~> 2.4)
38
77
  minitest (~> 5.0)
39
78
  plansheet!
40
79
  rake (~> 13.0)
41
80
  rubocop (~> 1.21)
81
+ rubocop-minitest
82
+ rubocop-rake
42
83
 
43
84
  BUNDLED WITH
44
85
  2.3.6
data/Guardfile ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ directories(%w[lib test].select { |d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist") })
4
+
5
+ guard :minitest do
6
+ watch(%r{^test/test_(.*)\.rb$}) { "test" }
7
+ watch(%r{^lib/plansheet/(.*)\.rb$}) { "test" }
8
+ watch(%r{^lib/plansheet\.rb$}) { "test" }
9
+ end
@@ -59,11 +59,16 @@ module Plansheet
59
59
  desc: Free-form notes string
60
60
  type: str
61
61
  "due":
62
- desc: Due date of the task (WIP)
62
+ desc: Due date of the task
63
63
  type: date
64
64
  "defer":
65
- desc: Defer task until this day (WIP)
65
+ desc: Defer task until this day
66
66
  type: date
67
+ "dependencies":
68
+ desc: The names of projects that need to be completed before this project can be started/completed
69
+ type: seq
70
+ sequence:
71
+ - type: str
67
72
  "externals":
68
73
  desc: List of external commitments, ie who else cares about project completion?
69
74
  type: seq
@@ -99,7 +104,7 @@ module Plansheet
99
104
  # NOTE: The order of these affects presentation!
100
105
  STRING_PROPERTIES = %w[priority status location notes].freeze
101
106
  DATE_PROPERTIES = %w[due defer].freeze
102
- ARRAY_PROPERTIES = %w[externals urls tasks done].freeze
107
+ ARRAY_PROPERTIES = %w[dependencies externals urls tasks done].freeze
103
108
 
104
109
  ALL_PROPERTIES = STRING_PROPERTIES + DATE_PROPERTIES + ARRAY_PROPERTIES
105
110
 
@@ -126,12 +131,70 @@ module Plansheet
126
131
  end
127
132
 
128
133
  def <=>(other)
129
- if @priority == other.priority
130
- # TODO: if planning status, then sort based on tasks? category? alphabetically?
131
- PROJECT_STATUS_PRIORITY[status] <=> PROJECT_STATUS_PRIORITY[other.status]
134
+ ret_val = 0
135
+ %i[
136
+ compare_completeness
137
+ compare_dependency
138
+ compare_priority
139
+ compare_due
140
+ compare_defer
141
+ compare_status
142
+ ].each do |method|
143
+ ret_val = send(method, other)
144
+ break if ret_val != 0
145
+ end
146
+ ret_val
147
+ end
148
+
149
+ def compare_priority(other)
150
+ PROJECT_PRIORITY[@priority] <=> PROJECT_PRIORITY[other.priority]
151
+ end
152
+
153
+ def compare_status(other)
154
+ PROJECT_STATUS_PRIORITY[status] <=> PROJECT_STATUS_PRIORITY[other.status]
155
+ end
156
+
157
+ def compare_due(other)
158
+ # -1 is receiving object being older
159
+
160
+ # Handle nil
161
+ if @due.nil?
162
+ return 0 if other.due.nil?
163
+
164
+ return 1
165
+ elsif other.due.nil?
166
+ return -1
167
+ end
168
+
169
+ @due <=> other.due
170
+ end
171
+
172
+ def compare_defer(other)
173
+ receiver = @defer.nil? || @defer < Date.today ? Date.today : @defer
174
+ comparison = other.defer.nil? || other.defer < Date.today ? Date.today : other.defer
175
+ receiver <=> comparison
176
+ end
177
+
178
+ def compare_dependency(other)
179
+ return 0 if @dependencies.nil? && other.dependencies.nil?
180
+ if @dependencies.nil?
181
+ return -1 if other.dependencies.any? {|dep|
182
+ @name.downcase == dep.downcase
183
+ }
132
184
  else
133
- PROJECT_PRIORITY[@priority] <=> PROJECT_PRIORITY[other.priority]
185
+ return 1 if @dependencies.any? {|dep|
186
+ other.name.downcase == dep.downcase
187
+ }
134
188
  end
189
+ return 0
190
+ end
191
+
192
+ # Projects that are dropped or done are considered "complete", insofar as
193
+ # they are only kept around for later reference.
194
+ def compare_completeness(other)
195
+ return 0 if self.dropped_or_done? && other.dropped_or_done?
196
+ return 0 if !self.dropped_or_done? && !other.dropped_or_done?
197
+ self.dropped_or_done? ? 1 : -1
135
198
  end
136
199
 
137
200
  def status
@@ -148,6 +211,10 @@ module Plansheet
148
211
  end
149
212
  end
150
213
 
214
+ def dropped_or_done?
215
+ status == "dropped" || status == "done"
216
+ end
217
+
151
218
  def to_s
152
219
  str = String.new
153
220
  str << "# #{@name}\n"
@@ -207,7 +274,14 @@ module Plansheet
207
274
  def initialize(path)
208
275
  @path = path
209
276
  # TODO: this won't GC, inline validation instead?
210
- @raw = YAML.load_file(path, permitted_classes: [Date])
277
+
278
+ # Handle pre-Ruby 3.1 psych versions (this is brittle)
279
+ @raw = if Psych::VERSION.split(".")[0].to_i >= 4
280
+ YAML.load_file(path, permitted_classes: [Date])
281
+ else
282
+ YAML.load_file(path)
283
+ end
284
+
211
285
  validate_schema
212
286
  @projects = @raw.map { |proj| Project.new proj }
213
287
  end
@@ -32,7 +32,7 @@ module Plansheet
32
32
  str = String.new
33
33
  str << "\\begin{minipage}{4.5cm}\n"
34
34
  str << project_header(proj)
35
- proj.tasks.each do |t|
35
+ proj&.tasks&.each do |t|
36
36
  str << "$\\square$ #{t} \\\\\n"
37
37
  end
38
38
  str << "\\end{minipage}\n"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Plansheet
4
- VERSION = "0.7.1"
4
+ VERSION = "0.9.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plansheet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Crosby
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-02 00:00:00.000000000 Z
11
+ date: 2022-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dc-kwalify
@@ -37,6 +37,7 @@ files:
37
37
  - CODE_OF_CONDUCT.md
38
38
  - Gemfile
39
39
  - Gemfile.lock
40
+ - Guardfile
40
41
  - LICENSE.txt
41
42
  - README.md
42
43
  - Rakefile