plansheet 0.1.0 → 0.3.3

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: 6a563b95ceb3605f848e88baabd37ba4c2512d621bbac5b656b53333143ac22b
4
- data.tar.gz: b92dd0d8690e7bd164f396d898b0b2bc530092537d05024d4d01ac8211583f59
3
+ metadata.gz: e78fa7422ef53cce690b2d8500c406ac6bb2136d195725b3d839d67cc234c780
4
+ data.tar.gz: 65093bd8b89bf39b2a144de85867bcb4635e41f5a8c379b8486c0a8a0135cebb
5
5
  SHA512:
6
- metadata.gz: 82917bb297389a27eeda311ea87e940b73c84b7b1605f0b6887b2c4b32bd825ce84427446087144da1b1559c5afa0edcf51de0c3dc65562c1a0235f7c358b7c8
7
- data.tar.gz: be2d3efa2d984fba4bc23ed71be01788187a63d91166dd9baf51dac84e0ff74a7ec52e45b7fdfac9bfc92d370a71012fdd22d40dc43bd3a63b3a636a40ce6da2
6
+ metadata.gz: a70d01f6617f79041d95e4a1b596f68c36de68a9be8abd7be684f3d394dd15a5d49bc0a7560435670fab7d5fc59dd505c1f4adee0aba68d7feaed46cc2f61bcb
7
+ data.tar.gz: f63764aaaca3a1a7efa75c07f2776d279171dc297cee0d34306416690fb2b08f5c85697f7d1ebc1a40a03671727f3162f0293d552231405c0084438a61dfb9b6
data/.rubocop.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 2.6
3
3
  NewCops: enable
4
+ SuggestExtensions: false
4
5
 
5
6
  Style/StringLiterals:
6
7
  Enabled: true
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ source "https://rubygems.org"
6
6
  gemspec
7
7
 
8
8
  group :development, optional: true do
9
- gem "rake", "~> 13.0"
10
9
  gem "minitest", "~> 5.0"
10
+ gem "rake", "~> 13.0"
11
11
  gem "rubocop", "~> 1.21"
12
12
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- plansheet (0.1.0)
4
+ plansheet (0.3.3)
5
5
  dc-kwalify (~> 1.0)
6
6
 
7
7
  GEM
@@ -0,0 +1,10 @@
1
+ - project: Add snazzy patches to backpack
2
+ status: planning
3
+ tasks:
4
+ - gather patches around the house in one spot
5
+ - determine which patches to put on
6
+ - find thread that matches patch colors
7
+ - plug in sewing machine
8
+ - put thread onto bobbin
9
+ - sew patches onto backpack
10
+
data/exe/plansheet CHANGED
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
+ require "kwalify"
4
5
  require "yaml"
6
+ require "plansheet"
5
7
 
6
8
  begin
7
9
  config = YAML.load_file "#{Dir.home}/.plansheet.yml"
@@ -9,20 +11,19 @@ rescue StandardError
9
11
  abort "unable to load plansheet config file"
10
12
  end
11
13
 
12
- status_priority = {
13
- "wip" => 1,
14
- "ready" => 2,
15
- "blocked" => 3,
16
- "planning" => 4,
17
- "idea" => 5,
18
- "dropped" => 6,
19
- "done" => 7
20
- }
21
-
22
14
  project_hash = {}
23
15
  projects = Dir.glob("*yml", base: config["projects_dir"])
24
16
  projects.each do |l|
25
17
  contents = YAML.load_file(File.join(config["projects_dir"], l))
18
+ validator = Kwalify::Validator.new(Plansheet::PROJECT_SCHEMA)
19
+ errors = validator.validate(contents)
20
+ # Check YAML validity
21
+ if errors && !errors.empty?
22
+ $stderr.write "Schema errors in #{l}\n"
23
+ errors.each { |err| puts "- [#{err.path}] #{err.message}" }
24
+ abort
25
+ end
26
+
26
27
  key = l.gsub(".yml", "")
27
28
  contents.each do |project|
28
29
  key = project["project"]
@@ -42,10 +43,11 @@ projects.each do |l|
42
43
  end
43
44
  end
44
45
 
45
- sorted_hash = project_hash.sort_by { |_, v| status_priority[v[:status]] }
46
+ sorted_hash = project_hash.sort_by do |_, v|
47
+ Plansheet::PROJECT_STATUS_PRIORITY[v[:status]]
48
+ end
46
49
 
47
50
  def project_minipage(proj)
48
- p proj
49
51
  str = String.new
50
52
  str << "\\begin{minipage}{5cm}\n"
51
53
  str << "#{proj[:name]} - #{proj[:status]} \\\\\n"
@@ -56,7 +58,7 @@ def project_minipage(proj)
56
58
  str
57
59
  end
58
60
 
59
- require 'date'
61
+ require "date"
60
62
  projects_str = String.new
61
63
  projects_str << <<~FRONTMATTER
62
64
  ---
@@ -67,11 +69,13 @@ projects_str << <<~FRONTMATTER
67
69
  # Date: #{Date.today}
68
70
  FRONTMATTER
69
71
 
70
- sorted_hash.first(30).each do |_, p|
72
+ sorted_hash.first(60).each do |_, p|
71
73
  projects_str << project_minipage(p)
72
74
  end
73
75
 
76
+ output_file = "#{config["output_dir"]}/projects.md"
77
+ puts "Writing to #{output_file}"
74
78
  Dir.mkdir config["output_dir"] unless Dir.exist? config["output_dir"]
75
- f = File.open("#{config["output_dir"]}/projects.md", "w")
79
+ f = File.open(output_file, "w")
76
80
  f.write(projects_str)
77
81
  f.close
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # An ugly script to sort projects by status (and eventually priority)
5
+
6
+ require "yaml"
7
+ require "plansheet"
8
+
9
+ def project_priority(project)
10
+ if project["status"]
11
+ project["status"]
12
+ elsif project["tasks"]
13
+ "planning"
14
+ else
15
+ "idea"
16
+ end
17
+ end
18
+
19
+ filename = ARGV.first
20
+ contents = YAML.load_file(filename)
21
+ sorted_hash = contents.sort_by do |project|
22
+ Plansheet::PROJECT_STATUS_PRIORITY[project_priority project]
23
+ end
24
+
25
+ File.write(filename, YAML.dump(sorted_hash))
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "yaml"
4
+
5
+ module Plansheet
6
+ PROJECT_STATUS_PRIORITY = {
7
+ "wip" => 1,
8
+ "ready" => 2,
9
+ "blocked" => 3,
10
+ "planning" => 4,
11
+ "idea" => 5,
12
+ "dropped" => 6,
13
+ "done" => 7
14
+ }.freeze
15
+
16
+ # Once there's some stability in plansheet and dc-kwalify, will pre-load this
17
+ # to save the later YAML.load
18
+ PROJECT_YAML_SCHEMA = <<~YAML
19
+ desc: dc-tasks project schema
20
+ type: seq
21
+ sequence:
22
+ - type: map
23
+ mapping:
24
+ "project":
25
+ desc: Project name
26
+ type: str
27
+ required: yes
28
+ "status":
29
+ desc: The current status of the project
30
+ type: str
31
+ enum:
32
+ - wip # project is a work-in-progress
33
+ - ready # project is fully scoped, ready to go
34
+ - blocked # project is blocked, but otherwise ready/wip
35
+ - planning # project in planning phase
36
+ - idea # project is little more than an idea
37
+ - dropped # project has been explicitly dropped, but
38
+ # want to keep around for reference, etc
39
+ - done # project is finished, but want to keep around
40
+ # for reference, etc.
41
+ "priority":
42
+ desc: Project priority (not currently implemented)
43
+ type: str
44
+ enum:
45
+ - high
46
+ - low
47
+ "tasks":
48
+ desc: List of tasks to do
49
+ type: seq
50
+ sequence:
51
+ - type: str
52
+ "done":
53
+ desc: List of tasks which have been completed
54
+ type: seq
55
+ sequence:
56
+ - type: str
57
+ "notes":
58
+ desc: Free-form notes string
59
+ type: str
60
+ YAML
61
+ PROJECT_SCHEMA = YAML.safe_load(PROJECT_YAML_SCHEMA)
62
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Plansheet
4
- VERSION = "0.1.0"
4
+ VERSION = "0.3.3"
5
5
  end
data/lib/plansheet.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "plansheet/version"
4
+ require_relative "plansheet/project"
4
5
 
5
6
  module Plansheet
6
7
  class Error < StandardError; 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.1.0
4
+ version: 0.3.3
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-18 00:00:00.000000000 Z
11
+ date: 2022-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dc-kwalify
@@ -29,6 +29,7 @@ email:
29
29
  - dave@dafyddcrosby.com
30
30
  executables:
31
31
  - plansheet
32
+ - plansheet-sorter
32
33
  extensions: []
33
34
  extra_rdoc_files: []
34
35
  files:
@@ -39,15 +40,18 @@ files:
39
40
  - LICENSE.txt
40
41
  - README.md
41
42
  - Rakefile
43
+ - examples/backpack.yml
42
44
  - exe/plansheet
45
+ - exe/plansheet-sorter
43
46
  - lib/plansheet.rb
47
+ - lib/plansheet/project.rb
44
48
  - lib/plansheet/version.rb
45
- - project.schema.yaml
46
49
  homepage: https://dafyddcrosby.com
47
50
  licenses:
48
51
  - MIT
49
52
  metadata:
50
53
  homepage_uri: https://dafyddcrosby.com
54
+ rubygems_mfa_required: 'true'
51
55
  post_install_message:
52
56
  rdoc_options: []
53
57
  require_paths:
data/project.schema.yaml DELETED
@@ -1,41 +0,0 @@
1
- desc: dc-tasks project schema
2
- type: seq
3
- sequence:
4
- - type: map
5
- mapping:
6
- "project":
7
- desc: Project name
8
- type: str
9
- required: yes
10
- "status":
11
- desc: The current status of the project
12
- type: str
13
- enum:
14
- - wip # project is a work-in-progress
15
- - ready # project is fully scoped, ready to go
16
- - blocked # project is blocked, but otherwise ready/wip
17
- - planning # project in planning phase
18
- - idea # project is little more than an idea
19
- - dropped # project has been explicitly dropped, but
20
- # want to keep around for reference, etc
21
- - done # project is finished, but want to keep around
22
- # for reference, etc.
23
- "priority":
24
- desc: Project priority (not currently implemented)
25
- type: str
26
- enum:
27
- - high
28
- - low
29
- "tasks":
30
- desc: List of tasks to do
31
- type: seq
32
- sequence:
33
- - type: str
34
- "done":
35
- desc: List of tasks which have been completed
36
- type: seq
37
- sequence:
38
- - type: str
39
- "notes":
40
- desc: Free-form notes string
41
- type: str