-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
65 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
module Linters | ||
module Default | ||
|
||
# | ||
def self.assert_pids(data) | ||
data.each_with_index do |d, i| | ||
warn Rainbow("WARNING: project number #{i} is missing a pid") unless d.key? 'pid' | ||
end | ||
pids = data.map{ |d| d['pid'] } | ||
dupes = pids.select { |p| pids.count(p) > 1 }.uniq! || [] | ||
warn Rainbow("WARNING: The following project pids are not unique!\n#{dupes}") unless dupes.empty? | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,24 @@ | ||
require 'rainbow' | ||
require 'vars' | ||
|
||
module Linters | ||
module Projects | ||
|
||
# | ||
def self.assert_people(projects) | ||
people = YAML.load_file(Vars::People.yml_file).map { |h| h['pid'] } | ||
projects.each do |project| | ||
project.dig('pis').each do |pi| | ||
warn Rainbow("WARNING: Published project '#{project['pid']}' references nonexisting person '#{pi}'.").orange unless people.include? pi | ||
end | ||
end | ||
end | ||
# | ||
def self.assert_categories(projects) | ||
categories = ['DH Seed Grant Recipient', 'Grad Fellowship Project', 'Other'] | ||
projects.each do |project| | ||
category = project.dig 'category' | ||
warn Rainbow("WARNING: Published project '#{project['pid']}' references nonexisting category '#{category}'.").orange unless categories.include? category | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require 'rainbow' | ||
require 'linters/default' | ||
require 'vars' | ||
require 'yaml' | ||
|
||
namespace :lint do | ||
desc 'lint the fetched courses yaml data' | ||
task :courses do | ||
courses = YAML.load_file Vars::Courses.yml_file | ||
|
||
Linters::Default.assert_pids courses | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require 'rainbow' | ||
require 'linters/default' | ||
require 'vars' | ||
require 'yaml' | ||
|
||
namespace :lint do | ||
desc 'lint the fetched people yaml data' | ||
task :people do | ||
people = YAML.load_file Vars::People.yml_file | ||
|
||
Linters::Default.assert_pids people | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters