plansheet 0.5.1 → 0.6.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: 3546f42fdd342ea128be90bff2e19b7bcb5c0910990e2132b89b87cbf6a1f776
4
- data.tar.gz: 2ea5d505262832e19e77a63e7aa7c59c9fff0b98ddc3ee8218c68b010f4768eb
3
+ metadata.gz: 0df6d0d15bff6b0d639ea6561ad722308c02e00b1bd313649b952a48c7826ad4
4
+ data.tar.gz: 51faedcd44ccaeec7ee88a3e345bb8d5ae1597a5689324953a188e1725a465e2
5
5
  SHA512:
6
- metadata.gz: 335cb1a3e74ab82a1441ec034099427dc0caabaad8a87c1f2620c7143d1fd4772023fe089a7305063fb12a96d169e44dd0b01f8f20437f45bdfa945b03aa2422
7
- data.tar.gz: 5d618d61c6a07d8e32e46cfb4dba5df0264370f01d8b4ecef4c68f9fdcf6fcf600ca33bda0a8918e63992434e2a009e4d836f1f838851e0ee94de53128fe1ab2
6
+ metadata.gz: 0eb27167a0d754f27df229da3e2e12a07734a1e90f8d1a19374a6d408fd822d67286b31efbaa223eae61ec97931727ed4d3ea70e4211035cb8f2ea68f728f207
7
+ data.tar.gz: 646ed78dd6f00b145ad61778fc7462b1ee1a3f9c52df3b3e27347c5d30ac199b2b4ef914239dd1a586d2e575e9fe8d44f664d5e152075a8ca5211150b4034838
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- plansheet (0.5.1)
4
+ plansheet (0.6.0)
5
5
  dc-kwalify (~> 1.0)
6
6
 
7
7
  GEM
data/exe/plansheet CHANGED
@@ -32,7 +32,7 @@ elsif options[:sort]
32
32
  Plansheet.resort_projects_in_dir config["projects_dir"]
33
33
  elsif options[:cli]
34
34
  project_arr = Plansheet.load_projects_dir config["projects_dir"]
35
- project_arr.each do |proj|
35
+ project_arr.sort.each do |proj|
36
36
  puts proj
37
37
  puts "\n"
38
38
  end
@@ -13,6 +13,17 @@ module Plansheet
13
13
  "done" => 7
14
14
  }.freeze
15
15
 
16
+ PROJECT_PRIORITY = {
17
+ "high" => 1,
18
+ "medium" => 2,
19
+ "low" => 3
20
+ }.freeze
21
+ PROJECT_PRIORITY_REV = {
22
+ 1 => "high",
23
+ 2 => "medium",
24
+ 3 => "low"
25
+ }.freeze
26
+
16
27
  # Once there's some stability in plansheet and dc-kwalify, will pre-load this
17
28
  # to save the later YAML.load
18
29
  PROJECT_YAML_SCHEMA = <<~YAML
@@ -39,13 +50,13 @@ module Plansheet
39
50
  - done # project is finished, but want to keep around
40
51
  # for reference, etc.
41
52
  "priority":
42
- desc: Project priority (not currently implemented)
53
+ desc: Project priority
43
54
  type: str
44
55
  enum:
45
56
  - high
46
57
  - low
47
58
  "location":
48
- desc: Location (not currently implemented)
59
+ desc: Location
49
60
  type: str
50
61
  "tasks":
51
62
  desc: List of tasks to do
@@ -63,7 +74,8 @@ module Plansheet
63
74
  YAML
64
75
  PROJECT_SCHEMA = YAML.safe_load(PROJECT_YAML_SCHEMA)
65
76
  class Project
66
- attr_reader :name, :tasks, :done, :notes, :location
77
+ include Comparable
78
+ attr_reader :name, :tasks, :done, :notes, :location, :priority
67
79
 
68
80
  def initialize(options)
69
81
  @name = options["project"]
@@ -72,10 +84,25 @@ module Plansheet
72
84
  @done = options["done"] || []
73
85
 
74
86
  @notes = options["notes"] if options["notes"]
87
+ @priority = PROJECT_PRIORITY[options["priority"] || "medium"]
75
88
  @location = options["location"] if options["location"]
76
89
  @status = options["status"] if options["status"]
77
90
  end
78
91
 
92
+ def <=>(other)
93
+ if @priority == other.priority
94
+ # TODO: if planning status, then sort based on tasks? category? alphabetically?
95
+ PROJECT_STATUS_PRIORITY[status] <=> PROJECT_STATUS_PRIORITY[other.status]
96
+ else
97
+ @priority <=> other.priority
98
+ end
99
+ end
100
+
101
+ # TODO: clean up priority handling
102
+ def priority_string
103
+ PROJECT_PRIORITY_REV[@priority]
104
+ end
105
+
79
106
  def status
80
107
  return @status if @status
81
108
 
@@ -92,7 +119,8 @@ module Plansheet
92
119
 
93
120
  def to_s
94
121
  str = String.new
95
- str << "# #{@name}\n"
122
+ str << "# #{@name}\n"
123
+ str << "priority: #{priority_string}\n"
96
124
  str << "status: #{status}\n"
97
125
  str << "notes: #{notes}\n" unless @notes.nil?
98
126
  str << "location: #{location}\n" unless @location.nil?
@@ -106,8 +134,10 @@ module Plansheet
106
134
  end
107
135
  str
108
136
  end
137
+
109
138
  def to_h
110
139
  h = { "project" => @name }
140
+ h["priority"] = priority_string unless priority_string == "medium"
111
141
  h["status"] = status unless status == "idea"
112
142
  h["notes"] = @notes unless @notes.nil?
113
143
  h["location"] = @location unless @location.nil?
@@ -132,17 +162,15 @@ module Plansheet
132
162
  validator = Kwalify::Validator.new(Plansheet::PROJECT_SCHEMA)
133
163
  errors = validator.validate(@raw)
134
164
  # Check YAML validity
135
- if errors && !errors.empty?
136
- $stderr.write "Schema errors in #{l}\n"
137
- errors.each { |err| puts "- [#{err.path}] #{err.message}" }
138
- abort
139
- end
165
+ return unless errors && !errors.empty?
166
+
167
+ $stderr.write "Schema errors in #{l}\n"
168
+ errors.each { |err| puts "- [#{err.path}] #{err.message}" }
169
+ abort
140
170
  end
141
171
 
142
172
  def sort!
143
- @projects.sort_by! do |project|
144
- Plansheet::PROJECT_STATUS_PRIORITY[project.status]
145
- end
173
+ @projects.sort!
146
174
  end
147
175
 
148
176
  def yaml_dump
@@ -5,9 +5,7 @@ module Plansheet
5
5
  # The Sheet class constructs a Markdown/LaTeX file for use with pandoc
6
6
  class Sheet
7
7
  def initialize(output_file, project_arr)
8
- sorted_arr = project_arr.sort_by do |p|
9
- Plansheet::PROJECT_STATUS_PRIORITY[p.status]
10
- end
8
+ sorted_arr = project_arr.sort!
11
9
 
12
10
  projects_str = String.new
13
11
  projects_str << sheet_header
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Plansheet
4
- VERSION = "0.5.1"
4
+ VERSION = "0.6.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plansheet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Crosby