Skip to content

Instantly share code, notes, and snippets.

@yannis
Last active December 30, 2015 08:59
Show Gist options
  • Save yannis/7806288 to your computer and use it in GitHub Desktop.
Save yannis/7806288 to your computer and use it in GitHub Desktop.
require "gimli"
require "yaml"
ROOT_PATH = "~/Documents/ember_guides/"
TABLE_OF_CONTENT_PATH = ROOT_PATH+"website/data/guides.yml"
GUIDE_FILES_PATH = ROOT_PATH+"website/source/guides/"
def concatenated_path
yaml_table_of_content = YAML.load_file TABLE_OF_CONTENT_PATH
concatenated_paths = []
yaml_table_of_content.each do |k,v|
unless k == "Views" # there is an error when generating this folder, ignoring this for now
v.each do |k1,v1|
path = k1["url"]
unless path.match /.html/
pathsplit = path.split "/"
path += "/index" if pathsplit.size == 1
path = GUIDE_FILES_PATH+path
unless File.exist? path+".md"
path = path+"/index"
p "file #{path} doe not exist" unless File.exist? path+".md"
end
concatenated_paths << path+".md"
end
end
end
end
return concatenated_paths.join(" ")
end
def remove_js_bin
file_name = "#{ROOT_PATH}ember_guides_combined.md"
text = File.read(file_name)
text.gsub! /### Live Preview/, ""
text.gsub! /<a class="jsbin-embed".+/, ""
File.open(file_name, "w") do |file|
file.puts text
end
end
system "mkdir #{ROOT_PATH}"
system "cd #{ROOT_PATH}"
system "git clone https://github.com/emberjs/website.git #{ROOT_PATH}website"
system "cat #{concatenated_path} > #{ROOT_PATH}ember_guides_combined.md"
remove_js_bin
system "gimli -file #{ROOT_PATH}ember_guides_combined.md > #{ROOT_PATH}ember_guides_combined.pdf"
system "open ember_guides_combined.pdf"
system "rm -fdr #{ROOT_PATH}"
p "done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment