lib/marshal/structure.rb in marshal-structure-1.0 vs lib/marshal/structure.rb in marshal-structure-1.1

- old
+ new

@@ -7,11 +7,11 @@ class Marshal::Structure ## # Version of Marshal::Structure you are using - VERSION = '1.0' + VERSION = '1.1' ## # Supported major Marshal version MAJOR_VERSION = 4 @@ -194,9 +194,27 @@ if major != MAJOR_VERSION or minor > MINOR_VERSION then raise TypeError, "incompatible marshal file format (can't be read)\n\tformat version #{MAJOR_VERSION}.#{MINOR_VERSION} required; #{major}.#{minor} given" end new(data).construct + end + + ## + # Dumps the structure of each item in +argv+. If +argv+ is empty standard + # input is dumped. + + def self.run argv = ARGV + require 'pp' + + if argv.empty? then + pp load $stdin + else + argv.each do |file| + open file, 'rb' do |io| + pp load io + end + end + end end ## # Prepares processing of +stream+