Skip to content

Instantly share code, notes, and snippets.

Created January 23, 2015 11:23
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Reverse engineer * files to *.coffee
#!/usr/bin/env ruby
require "json"
require "fileutils"
# Find all * files in current directory
files = Dir["./**/*"]
# Parse out the JSON
mapfiles = { |f| JSON.parse }
# Set where the output should go
export_directory = "./source"
# Nuke the previous output
exec "rm -rf #{export_directory}" if
# Iterate over all the sources and resurrect them.
mapfiles.each do |mapfile|
mapfile["sources"].each_with_index do |source, index|
# Create a directory for each file.
outdir = File.dirname("#{export_directory}/#{source}")
FileUtils.mkdir_p(outdir) unless
# Create each file and write out the contents
outfile = "#{export_directory}/#{source}"
contents = mapfile["sourcesContent"][index], "w") { |f| f.write contents }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment