plansheet 0.6.1 → 0.7.0

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: 36b1a62d85f75f6fe04c0ad37b6d344dc9d9192a02d093283979986f09532935
4
- data.tar.gz: 13a281430dfc803f940d05efa83c68758db7a4452912cfcfd6b5fe9a7247d69c
3
+ metadata.gz: 98932ed8f5a5d06da4b2f6135d1321e5376a1af2f837d4a65b9f806c7f06b8d9
4
+ data.tar.gz: 0ef6f026f7bcbc4712d008ca2843a0b5a9d1715038b2fc91534a8c9951697ec6
5
5
  SHA512:
6
- metadata.gz: fc3b217bf90a0333dc9f09b011c1f09caba8977a0f19bdd0a3695b76c519da54a5f2144897af49ee6e4f726a8abddc35532c51895c1c37a30422ddd39118676b
7
- data.tar.gz: a553efe99e604078e55ae0ea9cfdfa625a026a242ac92025e6600ebc5e04935c528a4d1807ecbe3a2a469ec6c37d3923cf22bad9c6f292d3ab79d1eca868c58b
6
+ metadata.gz: 95217512c48168c26ef2c5f937dd8b94530bccea1149c2e90df1db039243b9ffb4582efe26ea14ae6393845daa4d8f5a4fec36cff82231d7b6ab6fc6a1255ff6
7
+ data.tar.gz: '095dcda8264517252297a7aba139f8c51bddfbe04880acb9a16d2eb3f4a479003e1ee453902acf65fde2ad89720b522b6d6bd118e3f1f3202f2aab9f9ec50d04'
data/.rubocop.yml CHANGED
@@ -1,3 +1,5 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
1
3
  AllCops:
2
4
  TargetRubyVersion: 2.6
3
5
  NewCops: enable
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,26 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2022-06-02 13:34:43 UTC using RuboCop version 1.29.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Configuration parameters: IgnoredMethods.
11
+ Metrics/CyclomaticComplexity:
12
+ Max: 8
13
+
14
+ # Offense count: 1
15
+ # Configuration parameters: IgnoredMethods.
16
+ Metrics/PerceivedComplexity:
17
+ Max: 10
18
+
19
+ # Offense count: 2
20
+ # Configuration parameters: AllowedConstants.
21
+ Style/Documentation:
22
+ Exclude:
23
+ - 'spec/**/*'
24
+ - 'test/**/*'
25
+ - 'lib/plansheet.rb'
26
+ - 'lib/plansheet/project.rb'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- plansheet (0.6.1)
4
+ plansheet (0.7.0)
5
5
  dc-kwalify (~> 1.0)
6
6
 
7
7
  GEM
@@ -18,11 +18,6 @@ module Plansheet
18
18
  "medium" => 2,
19
19
  "low" => 3
20
20
  }.freeze
21
- PROJECT_PRIORITY_REV = {
22
- 1 => "high",
23
- 2 => "medium",
24
- 3 => "low"
25
- }.freeze
26
21
 
27
22
  # Once there's some stability in plansheet and dc-kwalify, will pre-load this
28
23
  # to save the later YAML.load
@@ -36,6 +31,13 @@ module Plansheet
36
31
  desc: Project name
37
32
  type: str
38
33
  required: yes
34
+ "priority":
35
+ desc: Project priority
36
+ type: str
37
+ enum:
38
+ - high
39
+ - medium
40
+ - low
39
41
  "status":
40
42
  desc: The current status of the project
41
43
  type: str
@@ -49,15 +51,22 @@ module Plansheet
49
51
  # want to keep around for reference, etc
50
52
  - done # project is finished, but want to keep around
51
53
  # for reference, etc.
52
- "priority":
53
- desc: Project priority
54
- type: str
55
- enum:
56
- - high
57
- - low
58
54
  "location":
59
55
  desc: Location
60
56
  type: str
57
+ "notes":
58
+ desc: Free-form notes string
59
+ type: str
60
+ "externals":
61
+ desc: List of external commitments, ie who else cares about project completion?
62
+ type: seq
63
+ sequence:
64
+ - type: str
65
+ "urls":
66
+ desc: List of URLs that may be pertinent
67
+ type: seq
68
+ sequence:
69
+ - type: str
61
70
  "tasks":
62
71
  desc: List of tasks to do
63
72
  type: seq
@@ -68,25 +77,44 @@ module Plansheet
68
77
  type: seq
69
78
  sequence:
70
79
  - type: str
71
- "notes":
72
- desc: Free-form notes string
73
- type: str
74
80
  YAML
75
81
  PROJECT_SCHEMA = YAML.safe_load(PROJECT_YAML_SCHEMA)
82
+
83
+ # The use of instance_variable_set/get probably seems a bit weird, but the
84
+ # intent is to avoid object allocation on non-existent project properties, as
85
+ # well as avoiding a bunch of copy-paste boilerplate when adding a new
86
+ # property. I suspect I'm guilty of premature optimization here, but it's
87
+ # easier to do this at the start than untangle that later (ie easier to
88
+ # unwrap the loops if it's not needed.
76
89
  class Project
77
90
  include Comparable
78
- attr_reader :name, :tasks, :done, :notes, :location, :priority
91
+
92
+ # NOTE: The order of these affects presentation!
93
+ STRING_PROPERTIES = %w[priority status location notes].freeze
94
+ ARRAY_PROPERTIES = %w[externals urls tasks done].freeze
95
+
96
+ ALL_PROPERTIES = STRING_PROPERTIES + ARRAY_PROPERTIES
97
+
98
+ attr_reader :name, *ALL_PROPERTIES
79
99
 
80
100
  def initialize(options)
81
101
  @name = options["project"]
82
102
 
83
- @tasks = options["tasks"] || []
84
- @done = options["done"] || []
103
+ ALL_PROPERTIES.each do |o|
104
+ instance_variable_set("@#{o}", options[o]) if options[o]
105
+ end
85
106
 
86
- @notes = options["notes"] if options["notes"]
87
- @priority = PROJECT_PRIORITY[options["priority"] || "medium"]
88
- @location = options["location"] if options["location"]
89
- @status = options["status"] if options["status"]
107
+ # The "priority" concept feels flawed - it requires *me* to figure out
108
+ # the priority, as opposed to the program understanding the project in
109
+ # relation to other tasks. If I truly understood the priority of all the
110
+ # projects, I wouldn't need a todo list program. The point is to remove
111
+ # the need for willpower/executive function/coffee. The long-term value
112
+ # of this field will diminish as I add more project properties that can
113
+ # automatically hone in on the most important items based on due
114
+ # date/external commits/penalties for project failure, etc
115
+ #
116
+ # Assume all projects are low priority unless stated otherwise.
117
+ @priority ||= "low"
90
118
  end
91
119
 
92
120
  def <=>(other)
@@ -94,20 +122,15 @@ module Plansheet
94
122
  # TODO: if planning status, then sort based on tasks? category? alphabetically?
95
123
  PROJECT_STATUS_PRIORITY[status] <=> PROJECT_STATUS_PRIORITY[other.status]
96
124
  else
97
- @priority <=> other.priority
125
+ PROJECT_PRIORITY[@priority] <=> PROJECT_PRIORITY[other.priority]
98
126
  end
99
127
  end
100
128
 
101
- # TODO: clean up priority handling
102
- def priority_string
103
- PROJECT_PRIORITY_REV[@priority]
104
- end
105
-
106
129
  def status
107
130
  return @status if @status
108
131
 
109
- if @tasks.count.positive?
110
- if @done.count.positive?
132
+ if @tasks&.count&.positive?
133
+ if @done&.count&.positive?
111
134
  "wip"
112
135
  else
113
136
  "planning"
@@ -120,29 +143,41 @@ module Plansheet
120
143
  def to_s
121
144
  str = String.new
122
145
  str << "# #{@name}\n"
123
- str << "priority: #{priority_string}\n"
124
- str << "status: #{status}\n"
125
- str << "notes: #{notes}\n" unless @notes.nil?
126
- str << "location: #{location}\n" unless @location.nil?
127
- str << "tasks:\n" unless @tasks.empty?
128
- @tasks.each do |t|
129
- str << "- #{t}\n"
146
+ STRING_PROPERTIES.each do |o|
147
+ str << stringify_string_property(o)
130
148
  end
131
- str << "done:\n" unless @done.empty?
132
- @done.each do |d|
133
- str << "- #{d}\n"
149
+ ARRAY_PROPERTIES.each do |o|
150
+ str << stringify_array_property(o)
151
+ end
152
+ str
153
+ end
154
+
155
+ def stringify_string_property(prop)
156
+ if instance_variable_defined? "@#{prop}"
157
+ "#{prop}: #{instance_variable_get("@#{prop}")}\n"
158
+ else
159
+ ""
160
+ end
161
+ end
162
+
163
+ def stringify_array_property(prop)
164
+ str = String.new
165
+ if instance_variable_defined? "@#{prop}"
166
+ str << "#{prop}:\n"
167
+ instance_variable_get("@#{prop}").each do |t|
168
+ str << "- #{t}\n"
169
+ end
134
170
  end
135
171
  str
136
172
  end
137
173
 
138
174
  def to_h
139
175
  h = { "project" => @name }
140
- h["priority"] = priority_string unless priority_string == "medium"
141
- h["status"] = status unless status == "idea"
142
- h["notes"] = @notes unless @notes.nil?
143
- h["location"] = @location unless @location.nil?
144
- h["tasks"] = @tasks unless @tasks.empty?
145
- h["done"] = @done unless @done.empty?
176
+ ALL_PROPERTIES.each do |prop|
177
+ h[prop] = instance_variable_get("@#{prop}") if instance_variable_defined?("@#{prop}")
178
+ end
179
+ h.delete "priority" if h.key?("priority") && h["priority"] == "low"
180
+ h.delete "status" if h.key?("status") && h["status"] == "idea"
146
181
  h
147
182
  end
148
183
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Plansheet
4
- VERSION = "0.6.1"
4
+ VERSION = "0.7.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.6.1
4
+ version: 0.7.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-05-31 00:00:00.000000000 Z
11
+ date: 2022-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dc-kwalify
@@ -33,6 +33,7 @@ extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
35
  - ".rubocop.yml"
36
+ - ".rubocop_todo.yml"
36
37
  - CODE_OF_CONDUCT.md
37
38
  - Gemfile
38
39
  - Gemfile.lock