Sha256: 24b61c4ef1d274e7788e31b6476139b941ae231bb2de7a5b7d2ee63306ad5926

Contents?: true

Size: 808 Bytes

Versions: 13

Compression:

Stored size: 808 Bytes

Contents

($:.unshift '../..'; require 'coderay') unless defined? CodeRay
module CodeRay
module Encoders
  
  load :token_class_filter
  
  class CommentFilter < TokenClassFilter
    
    register_for :comment_filter
    
    DEFAULT_OPTIONS = superclass::DEFAULT_OPTIONS.merge \
      :exclude => [:comment]
    
  end
  
end
end

if $0 == __FILE__
  $VERBOSE = true
  $: << File.join(File.dirname(__FILE__), '..')
  eval DATA.read, nil, $0, __LINE__ + 4
end

__END__
require 'test/unit'

class CommentFilterTest < Test::Unit::TestCase
  
  def test_filtering_comments
    tokens = CodeRay.scan <<-RUBY, :ruby
#!/usr/bin/env ruby
# a minimal Ruby program
puts "Hello world!"
    RUBY
    assert_equal <<-RUBY_FILTERED, tokens.comment_filter.text
#!/usr/bin/env ruby

puts "Hello world!"
    RUBY_FILTERED
  end
  
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
coderay-0.9.8 ./lib/coderay/encoders/comment_filter.rb
coderay-0.9.8.pre ./lib/coderay/encoders/comment_filter.rb
coderay-0.9.7 ./lib/coderay/encoders/comment_filter.rb
coderay-0.9.7.pre ./lib/coderay/encoders/comment_filter.rb
coderay-0.9.6 ./lib/coderay/encoders/comment_filter.rb
coderay-0.9.6.pre2 ./lib/coderay/encoders/comment_filter.rb
coderay-0.9.6.pre ./lib/coderay/encoders/comment_filter.rb
coderay-0.9.5 ./lib/coderay/encoders/comment_filter.rb
coderay-0.9.4 ./lib/coderay/encoders/comment_filter.rb
coderay-0.9.3 ./lib/coderay/encoders/comment_filter.rb
coderay-0.9.2 ./lib/coderay/encoders/comment_filter.rb
coderay-0.9.1 ./lib/coderay/encoders/comment_filter.rb
coderay-beta-0.9.1 ./lib/coderay/encoders/comment_filter.rb