Skip to content

Instantly share code, notes, and snippets.

@cornelius
Created February 24, 2017 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cornelius/6e2804f98c6672b89b136e8c84764bbd to your computer and use it in GitHub Desktop.
Save cornelius/6e2804f98c6672b89b136e8c84764bbd to your computer and use it in GitHub Desktop.
Script to fix missing topics in inqlude-data
#!/usr/bin/ruby
require "json"
Dir.glob("*").each do |dir|
generic_manifest = "#{dir}/#{dir}.manifest"
if File.exist?(generic_manifest)
topics = JSON.parse(File.read(generic_manifest))["topics"]
if topics
puts "#{dir}: #{topics}"
end
end
Dir.glob("#{dir}/#{dir}.*.manifest").each do |manifest_file|
puts " #{manifest_file}"
manifest = JSON.parse(File.read(manifest_file))
if !manifest["topics"]
manifest["topics"] = topics
File.open(manifest_file, "w") do |file|
file.write(JSON.pretty_generate(manifest))
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment