mirror of
https://github.com/ksherlock/mpw.git
synced 2024-11-25 19:30:50 +00:00
44 lines
502 B
Ruby
44 lines
502 B
Ruby
#!/usr/bin/env ruby -w
|
|
|
|
|
|
#
|
|
# format
|
|
# -
|
|
# name # comment
|
|
#
|
|
|
|
file = nil
|
|
state = nil
|
|
#ARGF.binmode
|
|
#ARGF.set_encoding("BINARY")
|
|
ARGF.each { |line|
|
|
|
|
line.chomp!
|
|
|
|
case state
|
|
when nil
|
|
if line == '-'
|
|
state = :name
|
|
end
|
|
|
|
when :name
|
|
if line.match(/^([A-Za-z0-F]+)\s?#?/)
|
|
state = :data
|
|
filename = $1
|
|
file = File::new("MPW.Help/#{filename}", "w")
|
|
#file.set_encoding("BINARY")
|
|
end
|
|
|
|
when :data
|
|
if line == '-'
|
|
state = :name
|
|
file = nil
|
|
else
|
|
file.puts(line)
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
} |