diff options
author | Thom May <thom@chef.io> | 2015-06-09 12:03:53 +0100 |
---|---|---|
committer | Thom May <thom@chef.io> | 2015-06-09 12:03:53 +0100 |
commit | 46f5377e00d97dcb896b8cab64fd4670c0c7916e (patch) | |
tree | b55146851d63d311ec79fe76c1c2942d927234ed /tasks | |
parent | 86feebefef96816fb5e080941dc2e95d65dc505e (diff) | |
download | chef-46f5377e00d97dcb896b8cab64fd4670c0c7916e.tar.gz |
Cope with toml not being installed
Diffstat (limited to 'tasks')
-rw-r--r-- | tasks/maintainers.rb | 74 |
1 files changed, 39 insertions, 35 deletions
diff --git a/tasks/maintainers.rb b/tasks/maintainers.rb index cdd682cb7c..5a2c8d9c2d 100644 --- a/tasks/maintainers.rb +++ b/tasks/maintainers.rb @@ -16,50 +16,54 @@ # require 'rake' -require 'tomlrb' SOURCE = File.join(File.dirname(__FILE__), "..", "MAINTAINERS.toml") TARGET = File.join(File.dirname(__FILE__), "..", "MAINTAINERS.md") -task :default => :generate +begin + require 'tomlrb' + task :default => :generate -namespace :maintainers do - desc "Generate MarkDown version of MAINTAINERS file" - task :generate do - maintainers = Tomlrb.load_file SOURCE - out = "<!-- This is a generated file. Please do not edit directly -->\n\n" - out << "# " + maintainers["Preamble"]["title"] + "\n\n" - out << maintainers["Preamble"]["text"] + "\n" - out << "# " + maintainers["Org"]["Lead"]["title"] + "\n\n" - out << person(maintainers["people"], maintainers["Org"]["Lead"]["person"]) + "\n\n" - out << components(maintainers["people"], maintainers["Org"]["Components"]) - File.open(TARGET, "w") { |fn| - fn.write out - } + namespace :maintainers do + desc "Generate MarkDown version of MAINTAINERS file" + task :generate do + maintainers = Tomlrb.load_file SOURCE + out = "<!-- This is a generated file. Please do not edit directly -->\n\n" + out << "# " + maintainers["Preamble"]["title"] + "\n\n" + out << maintainers["Preamble"]["text"] + "\n" + out << "# " + maintainers["Org"]["Lead"]["title"] + "\n\n" + out << person(maintainers["people"], maintainers["Org"]["Lead"]["person"]) + "\n\n" + out << components(maintainers["people"], maintainers["Org"]["Components"]) + File.open(TARGET, "w") { |fn| + fn.write out + } + end end -end -def components(list, cmp) - out = "## " + cmp.delete("title") + "\n\n" - out << cmp.delete("text") + "\n" if cmp.has_key?("text") - if cmp.has_key?("lieutenant") - out << "### Lieutenant\n\n" - out << person(list, cmp.delete("lieutenant")) + "\n\n" + def components(list, cmp) + out = "## " + cmp.delete("title") + "\n\n" + out << cmp.delete("text") + "\n" if cmp.has_key?("text") + if cmp.has_key?("lieutenant") + out << "### Lieutenant\n\n" + out << person(list, cmp.delete("lieutenant")) + "\n\n" + end + out << maintainers(list, cmp.delete("maintainers")) + "\n" if cmp.has_key?("maintainers") + cmp.delete("paths") + cmp.each {|k,v| out << components(list, v) } + out end - out << maintainers(list, cmp.delete("maintainers")) + "\n" if cmp.has_key?("maintainers") - cmp.delete("paths") - cmp.each {|k,v| out << components(list, v) } - out -end -def maintainers(list, people) - o = "### Maintainers\n\n" - people.each do |p| - o << person(list, p) + "\n" + def maintainers(list, people) + o = "### Maintainers\n\n" + people.each do |p| + o << person(list, p) + "\n" + end + o end - o -end -def person(list, person) - "* [#{list[person]["Name"]}](https://github.com/#{list[person]["GitHub"]})" + def person(list, person) + "* [#{list[person]["Name"]}](https://github.com/#{list[person]["GitHub"]})" + end +rescue LoadError + STDERR.puts "\n*** TomlRb not available.\n\n" end |