plansheet 0.23.2 → 0.24.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: e479f020bfa87192523fd231ec0704d07a2e0e92805eaf76720bf3ee62469c4a
4
- data.tar.gz: c197a3c2730522f7f70aa4793ff50670e91e04f57f15874bef174c0f94b44f83
3
+ metadata.gz: fae1a985802ab6da236f5f3d54224b4468ae5cc5e6beba86510293e7a92fe0a8
4
+ data.tar.gz: b2fe70fc1cb48dd794f561ff5037d2311366bb7e64c901cf4f32d33c0592e45b
5
5
  SHA512:
6
- metadata.gz: 77d8895595f834e4bf6f844aabd20178b3f50172071a2713e81f50e9e0e21f4c9cc29df0550cfba085419f7508eeb188417610ce8364b18fdcdd8a6012290eed
7
- data.tar.gz: 1da8aab0fe36a1775584afbdd140c3b0e0b6a6ed43202b2987311aa258bc3a2d59ce6109cb88c11c6a8a9335bd5770c9c2e66c1ff3f74c3f26cd4c0c07120733
6
+ metadata.gz: f68b48246ce4e8b10c66dd805f783fd822886b168aa57bb7db71012934bd2f21f8a76c8f26dab6c8bf4f8156529b897a5d33c02cba2e67d39224579626ee00a0
7
+ data.tar.gz: 751a5a7beffa1c35d7723521db61aa0ca26d1fafb6643017bfd2c3a3cb14e63dd5d4f775df34e2a9b644c24a8d582e0cd19d9cfd4a3b009673b9fb6d70faef55
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.24.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
@@ -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(updated_projects_string, yaml_dump(load_file)).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
@@ -182,6 +182,20 @@ module Plansheet
182
182
  PROJECT_STATUS_PRIORITY[status] <=> PROJECT_STATUS_PRIORITY[other.status]
183
183
  end
184
184
 
185
+ # This seems silly at first glance, but it's to keep projects from flipping
186
+ # around on each sort when they are equal in all other respects
187
+ def compare_name(other)
188
+ @name <=> other.name
189
+ end
190
+
191
+ def compare_completed_on(other)
192
+ retval = 0
193
+ retval += 1 if @completed_on
194
+ retval -= 1 if other.completed_on
195
+ retval = (other.completed_on <=> @completed_on) if retval.zero?
196
+ retval
197
+ end
198
+
185
199
  def compare_due(other)
186
200
  # -1 is receiving object being older
187
201
 
@@ -340,8 +354,6 @@ module Plansheet
340
354
  ALL_PROPERTIES.each do |prop|
341
355
  h[prop] = instance_variable_get("@#{prop}") if instance_variable_defined?("@#{prop}")
342
356
  end
343
- h.delete "priority" if h.key?("priority") && h["priority"] == "low"
344
- h.delete "status" if h.key?("status") && h["status"] == "idea"
345
357
  h
346
358
  end
347
359
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Plansheet
4
- VERSION = "0.23.2"
4
+ VERSION = "0.24.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.2
4
+ version: 0.24.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-11 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