plansheet 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/exe/plansheet +1 -1
- data/lib/plansheet/project.rb +40 -12
- data/lib/plansheet/sheet.rb +1 -3
- data/lib/plansheet/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0df6d0d15bff6b0d639ea6561ad722308c02e00b1bd313649b952a48c7826ad4
|
4
|
+
data.tar.gz: 51faedcd44ccaeec7ee88a3e345bb8d5ae1597a5689324953a188e1725a465e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0eb27167a0d754f27df229da3e2e12a07734a1e90f8d1a19374a6d408fd822d67286b31efbaa223eae61ec97931727ed4d3ea70e4211035cb8f2ea68f728f207
|
7
|
+
data.tar.gz: 646ed78dd6f00b145ad61778fc7462b1ee1a3f9c52df3b3e27347c5d30ac199b2b4ef914239dd1a586d2e575e9fe8d44f664d5e152075a8ca5211150b4034838
|
data/Gemfile.lock
CHANGED
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
|
data/lib/plansheet/project.rb
CHANGED
@@ -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
|
53
|
+
desc: Project priority
|
43
54
|
type: str
|
44
55
|
enum:
|
45
56
|
- high
|
46
57
|
- low
|
47
58
|
"location":
|
48
|
-
desc: Location
|
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
|
-
|
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 <<
|
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
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
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.
|
144
|
-
Plansheet::PROJECT_STATUS_PRIORITY[project.status]
|
145
|
-
end
|
173
|
+
@projects.sort!
|
146
174
|
end
|
147
175
|
|
148
176
|
def yaml_dump
|
data/lib/plansheet/sheet.rb
CHANGED
@@ -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.
|
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
|
data/lib/plansheet/version.rb
CHANGED