Skip to content

Commit

Permalink
warn projects with pis who dont exist
Browse files Browse the repository at this point in the history
  • Loading branch information
mnyrop committed May 27, 2022
1 parent 5174d73 commit 8913e8f
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 9 deletions.
5 changes: 5 additions & 0 deletions lib/linters/default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Linters
module Default

end
end
2 changes: 2 additions & 0 deletions lib/tasks/fetch/projects.rake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ namespace :fetch do
puts "Parsing projects into #{Vars::Projects.yml_file}"
Utils.write_to_file(data.to_yaml, Vars::Projects.yml_file)

Rake::Task["lint:projects"].invoke

sh "bundle exec jekyll pagemaster projects --force"
sh "bundle exec jekyll pagemaster project_tags --force"
end
Expand Down
6 changes: 0 additions & 6 deletions lib/tasks/lint/all.rake

This file was deleted.

Empty file removed lib/tasks/lint/courses.rake
Empty file.
Empty file removed lib/tasks/lint/people.rake
Empty file.
20 changes: 20 additions & 0 deletions lib/tasks/lint/projects.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'rainbow'
require 'linters/default'
require 'linters/projects'
require 'vars'
require 'yaml'

namespace :lint do
desc 'lint the fetched project yaml data'
task :projects do
categories = %w(DH Seed Grant Recipient Grad Fellowship Project Other)
people = YAML.load_file(Vars::People.yml_file).map { |h| h['pid'] }
projects = YAML.load_file Vars::Projects.yml_file

projects.each do |project|
project.dig('pis').each do |pi|
puts Rainbow("WARNING: Project '#{project['pid']}' references nonexisting person '#{pi}'.").magenta unless people.include? pi
end
end
end
end
3 changes: 0 additions & 3 deletions lib/utils.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
require 'csv'
require 'fileutils'
require 'json'
require 'yaml'

module Utils
def self.wget_sheet(sheet_key, csv_file)
Expand All @@ -13,7 +11,6 @@ def self.csv_open(file)
CSV.open(file, headers: :first_row).map(&:to_h)
end


def self.write_to_file(content, file)
FileUtils.mkdir_p File.dirname(file)
File.open(file, "w") { |f| f.write content }
Expand Down

0 comments on commit 8913e8f

Please sign in to comment.