Created
August 11, 2015 09:47
-
-
Save rkoster/8c179b1904e5ee0d499d to your computer and use it in GitHub Desktop.
A script for displaying the job dependencies of the cf-relase in a markdown table.
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
#! /usr/bin/env ruby | |
# coding: utf-8 | |
require 'yaml' | |
jobs = Dir['jobs/*'].map { |j| File.basename(j) } | |
print "∑ | Job | Property | Description\n --- | --- | --- | ---\n" | |
jobs.map! do |job| | |
spec = YAML.load_file(File.join("jobs", job, "spec")) | |
properties = spec['properties'].select do |k, v| | |
true if k =~ /\.machines|\.url|\.address/ | |
end | |
[job, properties] | |
end | |
jobs.sort! do |x, y| | |
x[1].length <=> y[1].length | |
end | |
def job_link(job) | |
"[#{job}](https://github.com/cloudfoundry/cf-release/blob/master/jobs/#{job}/spec)" | |
end | |
jobs.to_h.each do |job, properties| | |
if (properties.length == 0) | |
puts "0 | #{job_link(job)} | | " | |
else | |
first = true | |
properties.each do |k, v| | |
print first ? "#{properties.length} | #{job_link(job)}" : "| #{job}" | |
print " | #{k} | #{v['description']}\n" | |
first = false | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment