Class: FlakyTestTracker::Configuration

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

Overview

Configuration.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/flaky_test_tracker/configuration.rb', line 10

def initialize
  @pretend = false
  @context = {}
  @verbose = true
  @source_class = nil # NullSource
  @source_options = {}
  @storage_class = nil # NullStorage
  @storage_options = {}
  @reporter_class = nil # NullReporter
  @reporter_options = {}
end

Instance Attribute Details

#contextObject

Returns the value of attribute context.



6
7
8
# File 'lib/flaky_test_tracker/configuration.rb', line 6

def context
  @context
end

#pretendObject

Returns the value of attribute pretend.



6
7
8
# File 'lib/flaky_test_tracker/configuration.rb', line 6

def pretend
  @pretend
end

#reporter_classObject

Returns the value of attribute reporter_class.



8
9
10
# File 'lib/flaky_test_tracker/configuration.rb', line 8

def reporter_class
  @reporter_class
end

#reporter_optionsObject

Returns the value of attribute reporter_options.



8
9
10
# File 'lib/flaky_test_tracker/configuration.rb', line 8

def reporter_options
  @reporter_options
end

#source_classObject

Returns the value of attribute source_class.



8
9
10
# File 'lib/flaky_test_tracker/configuration.rb', line 8

def source_class
  @source_class
end

#source_optionsObject

Returns the value of attribute source_options.



8
9
10
# File 'lib/flaky_test_tracker/configuration.rb', line 8

def source_options
  @source_options
end

#storage_classObject

Returns the value of attribute storage_class.



8
9
10
# File 'lib/flaky_test_tracker/configuration.rb', line 8

def storage_class
  @storage_class
end

#storage_optionsObject

Returns the value of attribute storage_options.



8
9
10
# File 'lib/flaky_test_tracker/configuration.rb', line 8

def storage_options
  @storage_options
end

#verboseObject

Returns the value of attribute verbose.



6
7
8
# File 'lib/flaky_test_tracker/configuration.rb', line 6

def verbose
  @verbose
end

Instance Method Details

#reporterObject



130
131
132
133
134
# File 'lib/flaky_test_tracker/configuration.rb', line 130

def reporter
  self.reporter = reporter_class.build(**reporter_options) unless @reporter

  @reporter
end

#reporter=(reporter) ⇒ Object



119
120
121
122
123
124
125
126
127
128
# File 'lib/flaky_test_tracker/configuration.rb', line 119

def reporter=(reporter)
  reporter_methods = %i[tracked_tests resolved_tests]
  reporter_methods.each do |reporter_method|
    unless reporter.respond_to?(reporter_method)
      raise ArgumentError, "Expect reporter to respond to #{reporter_method}"
    end
  end

  @reporter = reporter
end

#reporter_class_name=(reporter_class_name) ⇒ Object



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

def reporter_class_name=(reporter_class_name)
  self.reporter_class = Object.const_get(reporter_class_name)
end

#sourceObject



56
57
58
59
60
# File 'lib/flaky_test_tracker/configuration.rb', line 56

def source
  self.source = source_class.build(**source_options) unless @source

  @source
end

#source=(source) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/flaky_test_tracker/configuration.rb', line 48

def source=(source)
  source_methods = %i[file_source_location_uri source_uri]
  source_methods.each do |source_method|
    raise ArgumentError, "Expect source to respond to #{source_method}" unless source.respond_to?(source_method)
  end
  @source = source
end

#source_class_name=(source_class_name) ⇒ Object



22
23
24
# File 'lib/flaky_test_tracker/configuration.rb', line 22

def source_class_name=(source_class_name)
  self.source_class = Object.const_get(source_class_name)
end

#source_type=(source_type) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/flaky_test_tracker/configuration.rb', line 26

def source_type=(source_type)
  self.source_class =
    case source_type.to_s
    when "github"
      FlakyTestTracker::Source::GitHubSource
    else
      raise ArgumentError, "Unkown source type #{source_type}"
    end
end

#storageObject



97
98
99
100
101
# File 'lib/flaky_test_tracker/configuration.rb', line 97

def storage
  self.storage = storage_class.build(**storage_options) unless @storage

  @storage
end

#storage=(storage) ⇒ Object



82
83
84
85
86
87
88
89
# File 'lib/flaky_test_tracker/configuration.rb', line 82

def storage=(storage)
  storage_methods = %i[all create update delete]
  storage_methods.each do |storage_method|
    raise ArgumentError, "Expect storage to respond to #{storage_method}" unless storage.respond_to?(storage_method)
  end

  @storage = storage
end

#storage_class_name=(storage_class_name) ⇒ Object



62
63
64
# File 'lib/flaky_test_tracker/configuration.rb', line 62

def storage_class_name=(storage_class_name)
  self.storage_class = Object.const_get(storage_class_name)
end

#storage_type=(storage_type) ⇒ Object



66
67
68
69
70
71
72
73
74
# File 'lib/flaky_test_tracker/configuration.rb', line 66

def storage_type=(storage_type)
  self.storage_class =
    case storage_type.to_s
    when "github_issue"
      FlakyTestTracker::Storage::GitHubIssueStorage
    else
      raise ArgumentError, "Unkown storage type #{storage_type}"
    end
end