Sha256: 87a572544f8ef7d9dfe34d8fa66a9bab6c87278bf0010ac4686ab439f537d9bc
Contents?: true
Size: 1.28 KB
Versions: 13
Compression:
Stored size: 1.28 KB
Contents
require 'forwardable' module Retest class MatchingOptions class Path extend Forwardable def_delegators :pathname, :to_s, :basename, :extname, :dirname attr_reader :pathname def initialize(path) @pathname = Pathname(path) end def reversed_dirnames @reversed_dirnames ||= dirnames.reverse end def dirnames @dirnames ||= dirname.each_filename.to_a end def test?(test_directories: nil) if test_directories && (test_directories & dirnames).empty? return false end test_regexs.any? { |regex| regex =~ to_s } end def possible_test?(file) possible_test_regexs.any? { |regex| regex =~ file } end def similarity_score(file) String::Similarity.levenshtein(to_s, file) end private def test_regexs [ Regexp.new("^(.*\/)?.*_(?:spec|test)#{extname}$"), Regexp.new("^(.*\/)?(?:spec|test)_.*#{extname}$"), ] end def possible_test_regexs [ Regexp.new("^(.*\/)?.*#{filename}_(?:spec|test)#{extname}$"), Regexp.new("^(.*\/)?.*(?:spec|test)_#{filename}#{extname}$"), ] end def filename basename(extname) end end end end
Version data entries
13 entries across 13 versions & 1 rubygems