plansheet 0.23.1 → 0.25.1

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: de86fd5b55207da728e3ed67e500a687576c6f10ce3bb9ad09df7cec56a6e7b1
4
- data.tar.gz: 785db3bae6f43dadb9ac2bdc95b05c6fc9cc7933e199a41d6316807c3899410a
3
+ metadata.gz: 1d6783f3c90e7d781de642be7c98e2a8469e48d8576405a5554cf92282632f2e
4
+ data.tar.gz: 39de90d2ad1d6c371c1626b56ffba32d79e293b9adaa0c01bb3d8113cc16225d
5
5
  SHA512:
6
- metadata.gz: e1082bae42f951c3c880247c0dbe34f24c4cfcbb3de58e8a0a804fa670d7616e077f60854db7e788cbb1b4234f17089524fd6779bf9308d3be1a32a0a2a9f7db
7
- data.tar.gz: 138a351986a9c11c6e6814bb2279e42dd39c35476b2e254b41a74aea4770b7d8017fcb4ac8f34ced403e3788fd6821d4ac453fdf8e6e4fe4331a068e80680059
6
+ metadata.gz: d30350f829b3db7e0b6d1163d55b835c55bef408c1c34ffc16a209837b9f4f1573b2d51d46fe294c4e48eeb1018a11a04701b100edce353c68c39becff5c9cca
7
+ data.tar.gz: fac00b40c31909b7d785e8938f49f877f02872875d72246bc8413dd84d34b857a0a3840605d0e22ac60a288091a6d28629eb915bb3ece4b2930c5e1ea8fbf841
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.1)
4
+ plansheet (0.25.1)
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
@@ -25,6 +25,10 @@ parser.on(
25
25
  "--stats",
26
26
  "Various stats (WIP)"
27
27
  )
28
+ parser.on(
29
+ "--time-roi",
30
+ "Show projects with a time return-on-investment"
31
+ )
28
32
  parser.on(
29
33
  "--calendar",
30
34
  "List of projects ordered by due date"
@@ -54,6 +58,13 @@ elsif options[:stats]
54
58
  elsif options[:sort]
55
59
  # Pool sorts projects, this now just matches old behaviour
56
60
  pool.write_projects
61
+ elsif options[:"time-roi"]
62
+ project_arr = pool.projects.select { |x| x.time_roi_payoff != 0 && !x.dropped_or_done? }.sort
63
+ project_arr.each do |proj|
64
+ puts proj
65
+ puts "time ROI payoff: #{proj.time_roi_payoff}"
66
+ puts "\n"
67
+ end
57
68
  elsif options[:calendar]
58
69
  # TODO: add a project filter method
59
70
  project_arr = pool.projects
@@ -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
@@ -331,6 +348,10 @@ module Plansheet
331
348
  status == "dropped" || status == "done"
332
349
  end
333
350
 
351
+ def done?
352
+ status == "done"
353
+ end
354
+
334
355
  def self.task_time_estimate(str)
335
356
  Plansheet.parse_time_duration(Regexp.last_match(1)) if str.match(TIME_EST_REGEX)
336
357
  end
@@ -340,8 +361,6 @@ module Plansheet
340
361
  ALL_PROPERTIES.each do |prop|
341
362
  h[prop] = instance_variable_get("@#{prop}") if instance_variable_defined?("@#{prop}")
342
363
  end
343
- h.delete "priority" if h.key?("priority") && h["priority"] == "low"
344
- h.delete "status" if h.key?("status") && h["status"] == "idea"
345
364
  h
346
365
  end
347
366
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Plansheet
4
- VERSION = "0.23.1"
4
+ VERSION = "0.25.1"
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.1
4
+ version: 0.25.1
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-12 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