plansheet 0.23.2 → 0.26.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: e479f020bfa87192523fd231ec0704d07a2e0e92805eaf76720bf3ee62469c4a
4
- data.tar.gz: c197a3c2730522f7f70aa4793ff50670e91e04f57f15874bef174c0f94b44f83
3
+ metadata.gz: e4064aa7163d4ad0b941b17a4b3f10541fde5188d2b84e1c5b8fe43fd82eadbb
4
+ data.tar.gz: a67509fae6401fd25e42ab35ef810a0bba0f82f73173ab2a5061206b2e4d9f62
5
5
  SHA512:
6
- metadata.gz: 77d8895595f834e4bf6f844aabd20178b3f50172071a2713e81f50e9e0e21f4c9cc29df0550cfba085419f7508eeb188417610ce8364b18fdcdd8a6012290eed
7
- data.tar.gz: 1da8aab0fe36a1775584afbdd140c3b0e0b6a6ed43202b2987311aa258bc3a2d59ce6109cb88c11c6a8a9335bd5770c9c2e66c1ff3f74c3f26cd4c0c07120733
6
+ metadata.gz: b4d07c885342474b0205fceec3e625fc000dd92b164987eaab1603ce453d1e7473c3281a30047470d8c15f7e4dce9e587f1c19365a0d7a56a12b93478f038024
7
+ data.tar.gz: 7ab35b12fcdc63e00d0dd6e2b2b54e4d27634d1b950c2298c55886b3f8c461cc272bbb507404edfad156ff646148802f099d3c1a054bd000284622f1f1e9ce72
data/.rubocop.yml CHANGED
@@ -11,6 +11,9 @@ Style/StringLiteralsInInterpolation:
11
11
  Enabled: true
12
12
  EnforcedStyle: double_quotes
13
13
 
14
+ Style/GuardClause:
15
+ Enabled: false
16
+
14
17
  Layout/LineLength:
15
18
  Max: 120
16
19
 
data/Gemfile.lock CHANGED
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- plansheet (0.23.2)
4
+ plansheet (0.26.0)
5
5
  dc-kwalify (~> 1.0)
6
+ diffy (= 3.4.2)
6
7
  rgl (= 0.5.8)
7
8
 
8
9
  GEM
@@ -11,6 +12,7 @@ GEM
11
12
  ast (2.4.2)
12
13
  coderay (1.1.3)
13
14
  dc-kwalify (1.0.0)
15
+ diffy (3.4.2)
14
16
  ffi (1.15.5)
15
17
  formatador (1.1.0)
16
18
  generator (0.0.1)
data/exe/plansheet CHANGED
@@ -59,7 +59,7 @@ elsif options[:sort]
59
59
  # Pool sorts projects, this now just matches old behaviour
60
60
  pool.write_projects
61
61
  elsif options[:"time-roi"]
62
- project_arr = pool.projects.select {|x| x.time_roi_payoff != 0 && !x.dropped_or_done?}.sort
62
+ project_arr = pool.projects.select { |x| x.time_roi_payoff != 0 && !x.dropped_or_done? }.sort
63
63
  project_arr.each do |proj|
64
64
  puts proj
65
65
  puts "time ROI payoff: #{proj.time_roi_payoff}"
@@ -10,12 +10,14 @@ module Plansheet
10
10
 
11
11
  DEFAULT_COMPARISON_ORDER = %w[
12
12
  completeness
13
+ completed_on
13
14
  dependency
14
15
  priority
15
16
  defer
16
17
  due
17
18
  time_roi
18
19
  status
20
+ name
19
21
  ].freeze
20
22
 
21
23
  def initialize(config, debug: false)
@@ -89,8 +91,7 @@ module Plansheet
89
91
  # to keep a list of project files to delete
90
92
  project_namespaces.each do |ns|
91
93
  pyf = ProjectYAMLFile.new "#{@projects_dir}/#{ns}.yml"
92
- pyf.projects = projects_in_namespace(ns)
93
- pyf.write
94
+ pyf.compare_and_write projects_in_namespace(ns)
94
95
  end
95
96
  end
96
97
 
@@ -189,12 +189,29 @@ module Plansheet
189
189
  @projects.sort!
190
190
  end
191
191
 
192
- def write
193
- File.write @path, yaml_dump
192
+ def compare_and_write(projects)
193
+ updated_projects_string = yaml_dump(projects)
194
+
195
+ # Compare the existing file to the newly generated one - we only want a
196
+ # write if something has changed
197
+ return if updated_projects_string == yaml_dump(load_file)
198
+
199
+ puts "#{@path} has changed, writing"
200
+ require "diffy"
201
+ puts Diffy::Diff.new(yaml_dump(load_file), updated_projects_string).to_s(:color)
202
+ File.write @path, updated_projects_string
194
203
  end
195
204
 
196
- def yaml_dump
197
- YAML.dump(@projects.map { |x| x.to_h.delete_if { |k, _| k == "namespace" } })
205
+ def yaml_dump(projects)
206
+ # binding.irb if projects.nil?
207
+ YAML.dump(projects.map do |x|
208
+ x.to_h.delete_if do |k, v|
209
+ # Remove low-value default noise from projects
210
+ k == "namespace" ||
211
+ (k == "priority" && v == "low") ||
212
+ (k == "status" && v == "idea")
213
+ end
214
+ end)
198
215
  end
199
216
  end
200
217
  end
@@ -138,13 +138,21 @@ module Plansheet
138
138
  # Convert the field to minutes
139
139
  @time_estimate_minutes = Plansheet.parse_time_duration(@time_estimate)
140
140
  end
141
- if @time_estimate_minutes # rubocop:disable Style/GuardClause
141
+ if @time_estimate_minutes
142
142
  # Rewrite time_estimate field
143
143
  @time_estimate = Plansheet.build_time_duration(@time_estimate_minutes)
144
144
 
145
145
  yms = yearly_minutes_saved
146
146
  @time_roi_payoff = yms.to_f / @time_estimate_minutes if yms
147
147
  end
148
+
149
+ if done?
150
+ @completed_on ||= Date.today unless recurring?
151
+ remove_instance_variable("@status") if @status
152
+ remove_instance_variable("@time_estimate") if @time_estimate
153
+ remove_instance_variable("@time_estimate_minutes") if @time_estimate
154
+ remove_instance_variable("@time_roi_payoff") if @time_roi_payoff
155
+ end
148
156
  end
149
157
 
150
158
  def yearly_minutes_saved
@@ -182,6 +190,20 @@ module Plansheet
182
190
  PROJECT_STATUS_PRIORITY[status] <=> PROJECT_STATUS_PRIORITY[other.status]
183
191
  end
184
192
 
193
+ # This seems silly at first glance, but it's to keep projects from flipping
194
+ # around on each sort when they are equal in all other respects
195
+ def compare_name(other)
196
+ @name <=> other.name
197
+ end
198
+
199
+ def compare_completed_on(other)
200
+ retval = 0
201
+ retval += 1 if @completed_on
202
+ retval -= 1 if other.completed_on
203
+ retval = (other.completed_on <=> @completed_on) if retval.zero?
204
+ retval
205
+ end
206
+
185
207
  def compare_due(other)
186
208
  # -1 is receiving object being older
187
209
 
@@ -273,11 +295,6 @@ module Plansheet
273
295
  task_based_status
274
296
  end
275
297
 
276
- def process_recurring
277
- # TODO: Tasks will be moved from done->tasks if recurring project is
278
- # starting again
279
- end
280
-
281
298
  # Due date either explicit or recurring
282
299
  def due
283
300
  return @due if @due
@@ -312,6 +329,8 @@ module Plansheet
312
329
 
313
330
  def last_for_deferral
314
331
  return @last_done + Plansheet.parse_date_duration(@last_for) if @last_done
332
+
333
+ Date.today
315
334
  end
316
335
 
317
336
  def lead_time_deferral
@@ -324,13 +343,17 @@ module Plansheet
324
343
  end
325
344
 
326
345
  def recurring?
327
- !@frequency.nil? || !@day_of_week.nil? || !@last_done.nil?
346
+ !@frequency.nil? || !@day_of_week.nil? || !@last_done.nil? || !@last_for.nil?
328
347
  end
329
348
 
330
349
  def dropped_or_done?
331
350
  status == "dropped" || status == "done"
332
351
  end
333
352
 
353
+ def done?
354
+ status == "done"
355
+ end
356
+
334
357
  def self.task_time_estimate(str)
335
358
  Plansheet.parse_time_duration(Regexp.last_match(1)) if str.match(TIME_EST_REGEX)
336
359
  end
@@ -340,8 +363,6 @@ module Plansheet
340
363
  ALL_PROPERTIES.each do |prop|
341
364
  h[prop] = instance_variable_get("@#{prop}") if instance_variable_defined?("@#{prop}")
342
365
  end
343
- h.delete "priority" if h.key?("priority") && h["priority"] == "low"
344
- h.delete "status" if h.key?("status") && h["status"] == "idea"
345
366
  h
346
367
  end
347
368
  end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "date"
4
+ module Plansheet
5
+ # The Sheet class constructs a Markdown/LaTeX file for use with pandoc
6
+ class Sheet
7
+ def initialize(output_file, project_arr)
8
+ projects_str = String.new
9
+ projects_str << sheet_header
10
+
11
+ project_arr.each do |p|
12
+ projects_str << project_minipage(p)
13
+ end
14
+ puts "Writing to #{output_file}"
15
+ File.write(output_file, projects_str)
16
+ end
17
+
18
+ def sheet_header
19
+ <<~FRONTMATTER
20
+ ---
21
+ geometry: margin=1.5cm
22
+ ---
23
+ \\thispagestyle{empty}
24
+
25
+ # Date: #{Date.today}
26
+ FRONTMATTER
27
+ end
28
+
29
+ def project_minipage(proj)
30
+ str = String.new
31
+ str << "\\begin{minipage}{6cm}\n"
32
+ str << project_header(proj)
33
+ proj&.tasks&.each do |t|
34
+ str << "$\\square$ #{sanitize_string(t)} \\\\\n"
35
+ end
36
+ str << "\\end{minipage}\n"
37
+ str
38
+ end
39
+
40
+ def sanitize_string(str)
41
+ str.gsub("_", '\_')
42
+ end
43
+
44
+ def project_header(proj)
45
+ str = String.new
46
+ str << "#{sanitize_string(proj.namespace)}: #{sanitize_string(proj.name)}\\\\\n"
47
+ str << proj.status.to_s
48
+ str << " - #{sanitize_string(proj.location)}" if proj.location
49
+ str << " due: #{proj.due}" if proj.due
50
+ str << " time: #{proj.time_estimate}" if proj.time_estimate
51
+ str << " \\\\\n"
52
+ str
53
+ end
54
+ end
55
+ end
@@ -1,55 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "date"
4
- module Plansheet
5
- # The Sheet class constructs a Markdown/LaTeX file for use with pandoc
6
- class Sheet
7
- def initialize(output_file, project_arr)
8
- projects_str = String.new
9
- projects_str << sheet_header
10
-
11
- project_arr.each do |p|
12
- projects_str << project_minipage(p)
13
- end
14
- puts "Writing to #{output_file}"
15
- File.write(output_file, projects_str)
16
- end
17
-
18
- def sheet_header
19
- <<~FRONTMATTER
20
- ---
21
- geometry: margin=1.5cm
22
- ---
23
- \\thispagestyle{empty}
24
-
25
- # Date: #{Date.today}
26
- FRONTMATTER
27
- end
28
-
29
- def project_minipage(proj)
30
- str = String.new
31
- str << "\\begin{minipage}{6cm}\n"
32
- str << project_header(proj)
33
- proj&.tasks&.each do |t|
34
- str << "$\\square$ #{sanitize_string(t)} \\\\\n"
35
- end
36
- str << "\\end{minipage}\n"
37
- str
38
- end
39
-
40
- def sanitize_string(str)
41
- str.gsub("_", '\_')
42
- end
43
-
44
- def project_header(proj)
45
- str = String.new
46
- str << "#{sanitize_string(proj.namespace)}: #{sanitize_string(proj.name)}\\\\\n"
47
- str << proj.status.to_s
48
- str << " - #{sanitize_string(proj.location)}" if proj.location
49
- str << " due: #{proj.due}" if proj.due
50
- str << " time: #{proj.time_estimate}" if proj.time_estimate
51
- str << " \\\\\n"
52
- str
53
- end
54
- end
55
- end
3
+ require_relative "sheet/latex"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Plansheet
4
- VERSION = "0.23.2"
4
+ VERSION = "0.26.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.23.2
4
+ version: 0.26.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-07-08 00:00:00.000000000 Z
11
+ date: 2022-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dc-kwalify
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: diffy
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 3.4.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 3.4.2
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rgl
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -62,6 +76,7 @@ files:
62
76
  - lib/plansheet/project/stringify.rb
63
77
  - lib/plansheet/project/yaml.rb
64
78
  - lib/plansheet/sheet.rb
79
+ - lib/plansheet/sheet/latex.rb
65
80
  - lib/plansheet/version.rb
66
81
  homepage: https://dafyddcrosby.com
67
82
  licenses: