Module: RSpecTracer::Configuration

Included in:
RSpecTracer
Defined in:
lib/rspec_tracer/configuration.rb

Constant Summary collapse

DEFAULT_CACHE_DIR =
'rspec_tracer_cache'
DEFAULT_REPORT_DIR =
'rspec_tracer_report'
DEFAULT_COVERAGE_DIR =
'rspec_tracer_coverage'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#coverage_filtersObject



95
96
97
# File 'lib/rspec_tracer/configuration.rb', line 95

def coverage_filters
  @coverage_filters ||= []
end

#filtersObject



87
88
89
# File 'lib/rspec_tracer/configuration.rb', line 87

def filters
  @filters ||= []
end

Instance Method Details

#add_coverage_filter(filter = nil, &block) ⇒ Object



91
92
93
# File 'lib/rspec_tracer/configuration.rb', line 91

def add_coverage_filter(filter = nil, &block)
  coverage_filters << parse_filter(filter, &block)
end

#add_filter(filter = nil, &block) ⇒ Object



83
84
85
# File 'lib/rspec_tracer/configuration.rb', line 83

def add_filter(filter = nil, &block)
  filters << parse_filter(filter, &block)
end

#cache_dirObject



27
28
29
# File 'lib/rspec_tracer/configuration.rb', line 27

def cache_dir
  @cache_dir ||= (ENV['RSPEC_TRACER_CACHE_DIR'] || DEFAULT_CACHE_DIR)
end

#cache_pathObject



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/rspec_tracer/configuration.rb', line 31

def cache_path
  @cache_path ||= begin
    cache_path = File.expand_path(cache_dir, root)
    cache_path = File.join(cache_path, ENV['TEST_SUITE_ID'].to_s) if ENV['TEST_SUITE_ID']
    cache_path = File.join(cache_path, parallel_tests_id) if RSpecTracer.parallel_tests?

    FileUtils.mkdir_p(cache_path)

    cache_path
  end
end

#configure(&block) ⇒ Object



107
108
109
# File 'lib/rspec_tracer/configuration.rb', line 107

def configure(&block)
  Docile.dsl_eval(self, &block)
end

#coverage_dirObject



59
60
61
# File 'lib/rspec_tracer/configuration.rb', line 59

def coverage_dir
  @coverage_dir ||= (ENV['RSPEC_TRACER_COVERAGE_DIR'] || DEFAULT_COVERAGE_DIR)
end

#coverage_pathObject



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/rspec_tracer/configuration.rb', line 63

def coverage_path
  @coverage_path ||= begin
    coverage_path = File.expand_path(coverage_dir, root)
    coverage_path = File.join(coverage_path, ENV['TEST_SUITE_ID'].to_s) if ENV['TEST_SUITE_ID']
    coverage_path = File.join(coverage_path, parallel_tests_id) if RSpecTracer.parallel_tests?

    FileUtils.mkdir_p(coverage_path)

    coverage_path
  end
end

#coverage_track_files(glob) ⇒ Object



75
76
77
# File 'lib/rspec_tracer/configuration.rb', line 75

def coverage_track_files(glob)
  @coverage_track_files = glob
end

#coverage_tracked_filesObject



79
80
81
# File 'lib/rspec_tracer/configuration.rb', line 79

def coverage_tracked_files
  @coverage_track_files if defined?(@coverage_track_files)
end

#parallel_tests_lock_fileObject



99
100
101
# File 'lib/rspec_tracer/configuration.rb', line 99

def parallel_tests_lock_file
  '/tmp/parallel_tests.lock'
end

#project_nameObject



23
24
25
# File 'lib/rspec_tracer/configuration.rb', line 23

def project_name
  @project_name ||= File.basename(root).capitalize
end

#report_dirObject



43
44
45
# File 'lib/rspec_tracer/configuration.rb', line 43

def report_dir
  @report_dir ||= (ENV['RSPEC_TRACER_REPORT_DIR'] || DEFAULT_REPORT_DIR)
end

#report_pathObject



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/rspec_tracer/configuration.rb', line 47

def report_path
  @report_path ||= begin
    report_path = File.expand_path(report_dir, root)
    report_path = File.join(report_path, ENV['TEST_SUITE_ID'].to_s) if ENV['TEST_SUITE_ID']
    report_path = File.join(report_path, parallel_tests_id) if RSpecTracer.parallel_tests?

    FileUtils.mkdir_p(report_path)

    report_path
  end
end

#root(root = nil) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/rspec_tracer/configuration.rb', line 13

def root(root = nil)
  return @root if defined?(@root) && root.nil?

  @cache_path = nil
  @report_path = nil
  @coverage_path = nil

  @root = File.expand_path(root || Dir.getwd)
end

#verbose?Boolean

Returns:

  • (Boolean)


103
104
105
# File 'lib/rspec_tracer/configuration.rb', line 103

def verbose?
  @verbose ||= (ENV.fetch('RSPEC_TRACER_VERBOSE', 'false') == 'true')
end