Sha256: 091503fdcc6a503cf6a020e93d2030a919310a4cea868be83e135815b28e61c9

Contents?: true

Size: 608 Bytes

Versions: 1

Compression:

Stored size: 608 Bytes

Contents

# frozen_string_literal: true

module SolargraphTestCoverage
  module FileHelpers
    extend self

    def test_file(source)
      relative_filepath = source.location.filename.sub(Dir.pwd, '').split('/').reject(&:empty?)

      if relative_filepath.first == Config.test_dir && relative_filepath.last.end_with?(Config.test_file_suffix)
        return source.location.filename
      end

      relative_filepath[0] = Config.test_dir
      File.join(Dir.pwd, relative_filepath.join('/')).sub('.rb', Config.test_file_suffix)
    end

    def test_path
      File.join(Dir.pwd, Config.test_dir)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solargraph_test_coverage-0.3.0 lib/solargraph_test_coverage/file_helpers.rb