plansheet 0.23.0 → 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: 209e9e64f6e8f0ceba2e1182e60106ead59d0943331c940a9a38ff788ab2cd4f
4
- data.tar.gz: 559296847d7777c6d339fd941f43dc8b106b00b75efa354a95ff78adcfc715b3
3
+ metadata.gz: fae1a985802ab6da236f5f3d54224b4468ae5cc5e6beba86510293e7a92fe0a8
4
+ data.tar.gz: b2fe70fc1cb48dd794f561ff5037d2311366bb7e64c901cf4f32d33c0592e45b
5
5
  SHA512:
6
- metadata.gz: d883a334412977859444a6db5c33885ced07fabcfa8665aa0331be6609fc94bb7c3d15f4e5fa6a8b4c01bf7e537b4c281b88c90ac30337fcc3c326ef828dfb29
7
- data.tar.gz: 4033cae733fd661360022a705b9d3098d07431db2d2377406af95eeb52fc60ace9ba881803557e8146c8bd48524e3f07cd0ab5eff9859b83633c51fc41115306
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.0)
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
@@ -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(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
@@ -121,6 +121,12 @@ module Plansheet
121
121
  # Add a created_on field if it doesn't exist
122
122
  instance_variable_set("@created_on", Date.today) unless @created_on
123
123
 
124
+ # Handle nil-value tasks
125
+ if @tasks
126
+ @tasks.compact!
127
+ remove_instance_variable("@tasks") if @tasks.empty?
128
+ end
129
+
124
130
  # Generate time estimate from tasks if specified
125
131
  # Stomps time_estimate field
126
132
  if @tasks
@@ -176,6 +182,20 @@ module Plansheet
176
182
  PROJECT_STATUS_PRIORITY[status] <=> PROJECT_STATUS_PRIORITY[other.status]
177
183
  end
178
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
+
179
199
  def compare_due(other)
180
200
  # -1 is receiving object being older
181
201
 
@@ -334,8 +354,6 @@ module Plansheet
334
354
  ALL_PROPERTIES.each do |prop|
335
355
  h[prop] = instance_variable_get("@#{prop}") if instance_variable_defined?("@#{prop}")
336
356
  end
337
- h.delete "priority" if h.key?("priority") && h["priority"] == "low"
338
- h.delete "status" if h.key?("status") && h["status"] == "idea"
339
357
  h
340
358
  end
341
359
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Plansheet
4
- VERSION = "0.23.0"
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.0
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-05 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