extract_amendments.rb 442 Bytes
Newer Older
Michael Witrant's avatar
Michael Witrant committed
1
2
3
4
5
#!/usr/bin/env ruby

require 'rubygems'
require 'bundler/setup'
require 'zippy'
Michael Witrant's avatar
Michael Witrant committed
6
require 'clik'
Michael Witrant's avatar
Michael Witrant committed
7

Michael Witrant's avatar
Michael Witrant committed
8
9
10
xml_dump_path = nil

cli '--xml-dump' => lambda { |path| xml_dump_path = path }
Michael Witrant's avatar
Michael Witrant committed
11
12
13
14
15
16
17
18
19

opendocument_path = ARGV.first
raise "usage: #$0 <OpenDocument file>" unless opendocument_path

xml = nil
Zippy.open(opendocument_path) do |zip|
  xml = zip['content.xml']
end

Michael Witrant's avatar
Michael Witrant committed
20
21
22
23
if xml_dump_path
  File.open(xml_dump_path, "w") { |f| f.write xml }
end

Michael Witrant's avatar
Michael Witrant committed
24
puts xml.size