Class: AffectedTests::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/affected_tests.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_path:, test_dir_path:, output_path:, revision:) ⇒ Configuration

Returns a new instance of Configuration.



12
13
14
15
16
17
18
# File 'lib/affected_tests.rb', line 12

def initialize(project_path:, test_dir_path:, output_path:, revision:)
  @project_path = project_path
  @test_dir_path = test_dir_path
  @bundler_path = Bundler.bundle_path.to_s
  @output_path = output_path
  @revision = revision
end

Instance Attribute Details

#bundler_pathObject (readonly)

Returns the value of attribute bundler_path.



10
11
12
# File 'lib/affected_tests.rb', line 10

def bundler_path
  @bundler_path
end

#output_pathObject (readonly)

Returns the value of attribute output_path.



10
11
12
# File 'lib/affected_tests.rb', line 10

def output_path
  @output_path
end

#project_pathObject (readonly)

Returns the value of attribute project_path.



10
11
12
# File 'lib/affected_tests.rb', line 10

def project_path
  @project_path
end

#revisionObject (readonly)

Returns the value of attribute revision.



10
11
12
# File 'lib/affected_tests.rb', line 10

def revision
  @revision
end

#test_dir_pathObject (readonly)

Returns the value of attribute test_dir_path.



10
11
12
# File 'lib/affected_tests.rb', line 10

def test_dir_path
  @test_dir_path
end

Instance Method Details

#format_path(path) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/affected_tests.rb', line 20

def format_path(path)
  if path&.start_with?(@project_path)
    path.sub(@project_path + "/", "")
  else
    path
  end
end

#target_path?(path) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
31
32
# File 'lib/affected_tests.rb', line 28

def target_path?(path)
  return false if path.nil?

  path.start_with?(@project_path) && !path.start_with?(@bundler_path)
end