Sha256: 02132be0a62593034f0dd0c445bdb1cf21cfd231f3fbef325c40d1935d4da069

Contents?: true

Size: 683 Bytes

Versions: 2

Compression:

Stored size: 683 Bytes

Contents

# frozen_string_literal: true

module SolargraphTestCoverage
  module FileHelpers
    extend self

    def test_file(filename)
      return filename if test_file?(filename)

      path     = relative_path(filename).split('/')
      path[0]  = Config.test_dir
      path[-1] = path.last.sub(/\.rb$/, Config.test_file_suffix)

      File.join(Dir.pwd, path.join('/'))
    end

    def relative_path(path)
      path.sub("#{Dir.pwd}/", '')
    end

    def relative_test_file(filename)
      relative_path test_file(filename)
    end

    def test_file?(filename)
      filename.start_with?(Config.full_test_dir) &&
        filename.end_with?(Config.test_file_suffix)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solargraph_test_coverage-0.3.1.1 lib/solargraph_test_coverage/file_helpers.rb
solargraph_test_coverage-0.3.1 lib/solargraph_test_coverage/file_helpers.rb