Sha256: d36dd8ec58952c1fcbbd62aa8139f7ddc0d679c297c09489ca261af27b9f28d6
Contents?: true
Size: 1.02 KB
Versions: 7
Compression:
Stored size: 1.02 KB
Contents
# -*- coding: utf-8 -*- module GitObjectBrowser module Dumper class DirectoriesDumper def initialize(root, outdir) @root = root @outdir = outdir end def dump dirs = [''] Dir.chdir(@root) do Dir.glob("**/*") do |path| next if path == 'dump' # FIXME dirs << path if File.directory?(path) end end dirs.each do |path| outfile = File.join(@outdir, (path == '') ? '_git.json' : "#{ path }.json") FileUtils.mkdir_p(File.dirname(outfile)) puts "Write: #{path}\n" obj_file = File.join(@root, path) File.open(outfile, "w") do |output| dump_object(path, output) end end end def dump_object(path, output) obj = GitObjectBrowser::Models::Directory.new(@root, path) wrapped = GitObjectBrowser::Models::WrappedObject.new(nil, path, obj) output << JSON.pretty_generate(wrapped.to_hash) end end end end
Version data entries
7 entries across 7 versions & 1 rubygems