Sha256: 0b3c2b7eb69920c5f56d285806519f6dd6cfaef26e050d570f8d2d1d917af73c

Contents?: true

Size: 1.3 KB

Versions: 66

Compression:

Stored size: 1.3 KB

Contents

module SimpleCov
  #
  # Base filter class. Inherit from this to create custom filters,
  # and overwrite the passes?(source_file) instance method
  #
  # # A sample class that rejects all source files.
  # class StupidFilter < SimpleCov::Filter
  #   def passes?(source_file)
  #     false
  #   end
  # end
  #
  class Filter
    attr_reader :filter_argument
    def initialize(filter_argument)
      @filter_argument = filter_argument
    end

    def matches?(source_file)
      raise "The base filter class is not intended for direct use"
    end

    def passes?(source_file)
      warn "DEPRECATION: SimpleCov::Filter#passes?(x) has been renamed to #matches?. Please update your custom filters accordingly!"
      matches?(source_file)
    end
  end

  class StringFilter < SimpleCov::Filter
    # Returns true when the given source file's filename matches the
    # string configured when initializing this Filter with StringFilter.new('somestring)
    def matches?(source_file)
      (source_file.filename =~ /#{filter_argument}/)
    end
  end

  class BlockFilter < SimpleCov::Filter
    # Returns true if the block given when initializing this filter with BlockFilter.new {|src_file| ... }
    # returns true for the given source file.
    def matches?(source_file)
      filter_argument.call(source_file)
    end
  end
end

Version data entries

66 entries across 50 versions & 9 rubygems

Version Path
tdiary-5.0.8 vendor/bundle/gems/tdiary-5.0.7/vendor/bundle/gems/simplecov-0.9.2/lib/simplecov/filter.rb
tdiary-5.0.7 vendor/bundle/gems/simplecov-0.9.2/lib/simplecov/filter.rb
tdiary-5.0.6 vendor/bundle/gems/simplecov-0.9.2/lib/simplecov/filter.rb
tdiary-5.0.5 vendor/bundle/gems/simplecov-0.9.2/lib/simplecov/filter.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/simplecov-0.9.2/lib/simplecov/filter.rb
tdiary-5.0.4 vendor/bundle/gems/simplecov-0.9.2/lib/simplecov/filter.rb
tdiary-5.0.2 vendor/bundle/gems/simplecov-0.9.2/lib/simplecov/filter.rb
tdiary-5.0.1 vendor/bundle/gems/simplecov-0.9.2/lib/simplecov/filter.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/simplecov-0.9.0/lib/simplecov/filter.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/simplecov-0.9.0/lib/simplecov/filter.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/simplecov-0.9.0/lib/simplecov/filter.rb
simplecov-0.9.2 lib/simplecov/filter.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/simplecov-0.8.2/lib/simplecov/filter.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/simplecov-0.8.2/lib/simplecov/filter.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/simplecov-0.8.2/lib/simplecov/filter.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/simplecov-0.8.2/lib/simplecov/filter.rb
simplecov-0.9.1 lib/simplecov/filter.rb
simplecov-0.9.0 lib/simplecov/filter.rb
simplecov-0.8.2 lib/simplecov/filter.rb
simplecov-0.8.1 lib/simplecov/filter.rb