Sha256: 16fc0cce7ed94acb07b2fb25782e4d17bb8455cc0f0b004425dd2f13f5e0a564
Contents?: true
Size: 837 Bytes
Versions: 7
Compression:
Stored size: 837 Bytes
Contents
require 'open-uri' require 'stringio' require 'zlib' module Weskit::WML class Parser private_class_method :new class << self def string str, bck = :kpeg parse str, bck end def uri uri, bck = :kpeg begin str = open(uri).read rescue raise Errors::ReadError, "Couldn't open URI" ensure str = Zlib::GzipReader.new(StringIO.new str).read rescue str end parse str, bck end private def backends { :kpeg => Parsers::KPEG, :simple => Parsers::Simple } end def parse data, backend data = Preprocessor.new(data).remove_directives parser = backends[backend].new "#{data}\n" parser.parse parser.result end end end end
Version data entries
7 entries across 7 versions & 1 rubygems