diff options
author | Kornelius Kalnbach <murphy@rubychan.de> | 2013-06-15 16:24:25 -0700 |
---|---|---|
committer | Kornelius Kalnbach <murphy@rubychan.de> | 2013-06-15 16:24:25 -0700 |
commit | 0fabc6b59fae5e7fd8d2138d7f3588850b132fcc (patch) | |
tree | f4eabf724edce1f6d512b0f7cebb2747d9bf6a73 /lib/coderay/tokens.rb | |
parent | dc9528456008216c265cfb6613cfa459c3c9ffad (diff) | |
parent | a6ddf469fadefcd61bf6bb079160d538f02ef427 (diff) | |
download | coderay-0fabc6b59fae5e7fd8d2138d7f3588850b132fcc.tar.gz |
Merge pull request #138 from rubychan/remove-dump
Remove dump/undump functionality from Tokens
Diffstat (limited to 'lib/coderay/tokens.rb')
-rw-r--r-- | lib/coderay/tokens.rb | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/lib/coderay/tokens.rb b/lib/coderay/tokens.rb index ad59b7f..54358d4 100644 --- a/lib/coderay/tokens.rb +++ b/lib/coderay/tokens.rb @@ -1,8 +1,5 @@ module CodeRay - # GZip library for writing and reading token dumps. - autoload :GZip, coderay_path('helpers', 'gzip') - # The Tokens class represents a list of tokens returned from # a Scanner. It's actually just an Array with a few helper methods. # @@ -148,53 +145,11 @@ module CodeRay parts end - # Dumps the object into a String that can be saved - # in files or databases. - # - # The dump is created with Marshal.dump; - # In addition, it is gzipped using GZip.gzip. - # - # The returned String object includes Undumping - # so it has an #undump method. See Tokens.load. - # - # You can configure the level of compression, - # but the default value 7 should be what you want - # in most cases as it is a good compromise between - # speed and compression rate. - # - # See GZip module. - def dump gzip_level = 7 - dump = Marshal.dump self - dump = GZip.gzip dump, gzip_level - dump.extend Undumping - end - # Return the actual number of tokens. def count size / 2 end - # Include this module to give an object an #undump - # method. - # - # The string returned by Tokens.dump includes Undumping. - module Undumping - # Calls Tokens.load with itself. - def undump - Tokens.load self - end - end - - # Undump the object using Marshal.load, then - # unzip it using GZip.gunzip. - # - # The result is commonly a Tokens object, but - # this is not guaranteed. - def Tokens.load dump - dump = GZip.gunzip dump - @dump = Marshal.load dump - end - alias text_token push def begin_group kind; push :begin_group, kind end def end_group kind; push :end_group, kind end |