Class: GitObjectBrowser::Dumper::IndexDumper
- Inherits:
-
Object
- Object
- GitObjectBrowser::Dumper::IndexDumper
- Defined in:
- lib/git-object-browser/dumper/index_dumper.rb
Instance Method Summary collapse
- #dump ⇒ Object
- #dump_object(input, output) ⇒ Object
-
#initialize(root, outdir) ⇒ IndexDumper
constructor
A new instance of IndexDumper.
Constructor Details
#initialize(root, outdir) ⇒ IndexDumper
Returns a new instance of IndexDumper.
9 10 11 12 |
# File 'lib/git-object-browser/dumper/index_dumper.rb', line 9 def initialize(root, outdir) @root = root @outdir = outdir end |
Instance Method Details
#dump ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/git-object-browser/dumper/index_dumper.rb', line 15 def dump index_file = File.join(@root, "index") out_file = File.join(@outdir, "index.json") return unless File.exist?(index_file) puts "Write: index\n" File.open(index_file) do |input| File.open(out_file, "w") do |output| dump_object(input, output) end end end |
#dump_object(input, output) ⇒ Object
29 30 31 32 33 |
# File 'lib/git-object-browser/dumper/index_dumper.rb', line 29 def dump_object(input, output) obj = GitObjectBrowser::Models::Index.new(input).parse wrapped = GitObjectBrowser::Models::WrappedObject.new(nil, 'index', obj) output << JSON.pretty_generate(wrapped.to_hash) end |