Skip to content

Instantly share code, notes, and snippets.

@mguentner
Created January 14, 2016 12:38
Show Gist options
  • Save mguentner/39d095a33a2a0a7054fc to your computer and use it in GitHub Desktop.
Save mguentner/39d095a33a2a0a7054fc to your computer and use it in GitHub Desktop.
require 'json'
file = File.read("chains.json")
data = JSON.parse(file)
unknowncount = 0
for effect in data
filename = ""
for element in effect
if element.class == String
if element != ""
filename = element
end
end
end
if filename == ""
filename = "unknown" + unknowncount.to_s
unknowncount+=1
end
filename = filename.gsub(/[^a-zA-Z0-9]/, "_") + ".chain"
file = File.new(filename, "w+")
file.puts(effect.to_json)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment