module GithubPages::JsonRakeExt
Public Class Methods
directory_mash()
click to toggle source
# File lib/ghpages_deploy/rake/json.rb, line 33 def directory_mash Hash[dirs: mash, files: []] end
directory_sitemap(files)
click to toggle source
# File lib/ghpages_deploy/rake/json.rb, line 12 def directory_sitemap(files) directory_mash.tap { |root| files.each { |path| map_file(root, path) } } end
expand_lists(directory, whitelist, blacklist)
click to toggle source
# File lib/ghpages_deploy/rake/json.rb, line 26 def expand_lists(directory, whitelist, blacklist) Dir.chdir(directory) do lists = [whitelist, blacklist].map { |list| sanitize_list(list) } lists.reduce(&:-).select { |f| File.file?(f) } end end
map_file(marker, path)
click to toggle source
# File lib/ghpages_deploy/rake/json.rb, line 16 def map_file(marker, path) *dirs, file = path.split('/') dirs.each { |dir| marker = marker[:dirs][dir] } marker[:files] << file end
mash()
click to toggle source
# File lib/ghpages_deploy/rake/json.rb, line 37 def mash Hash.new { |h, k| h[k] = directory_mash } end
sanitize_list(list)
click to toggle source
# File lib/ghpages_deploy/rake/json.rb, line 22 def sanitize_list(list) list.each_with_object(Set.new) { |glob, set| set.merge(Dir[glob]) } end
sitemap(directory, output, whitelist, blacklist)
click to toggle source
# File lib/ghpages_deploy/rake/json.rb, line 41 def sitemap(directory, output, whitelist, blacklist) files = expand_lists(directory, whitelist, blacklist) map = directory_sitemap(files) File.open(output, 'w+') { |f| f.puts map.to_json } end
Public Instance Methods
generate_json_sitemap( directory: '.', output: 'sitemap.json', whitelist: ['**/*'], blacklist: [] )
click to toggle source
# File lib/ghpages_deploy/rake/json.rb, line 49 def generate_json_sitemap( directory: '.', output: 'sitemap.json', whitelist: ['**/*'], blacklist: [] ) handler.handle_deploy do JsonRakeExt.sitemap(directory, output, whitelist, blacklist) [output] end end