Class: Testgenai::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Configuration

Returns a new instance of Configuration.



5
6
7
8
9
10
11
12
# File 'lib/testgenai/configuration.rb', line 5

def initialize(options = {})
  @provider = options[:provider] || ENV["TESTGENAI_PROVIDER"]
  @model = options[:model] || ENV["TESTGENAI_MODEL"]
  @api_key = options[:api_key]
  @framework = options[:framework] || ENV["TESTGENAI_FRAMEWORK"] || "rspec"
  @output_dir = options[:output_dir] || ENV["TESTGENAI_OUTPUT_DIR"]
  @pause = (options[:pause] || ENV["TESTGENAI_PAUSE"] || 1).to_f
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



3
4
5
# File 'lib/testgenai/configuration.rb', line 3

def api_key
  @api_key
end

#frameworkObject (readonly)

Returns the value of attribute framework.



3
4
5
# File 'lib/testgenai/configuration.rb', line 3

def framework
  @framework
end

#modelObject (readonly)

Returns the value of attribute model.



3
4
5
# File 'lib/testgenai/configuration.rb', line 3

def model
  @model
end

#output_dirObject (readonly)

Returns the value of attribute output_dir.



3
4
5
# File 'lib/testgenai/configuration.rb', line 3

def output_dir
  @output_dir
end

#pauseObject (readonly)

Returns the value of attribute pause.



3
4
5
# File 'lib/testgenai/configuration.rb', line 3

def pause
  @pause
end

#providerObject (readonly)

Returns the value of attribute provider.



3
4
5
# File 'lib/testgenai/configuration.rb', line 3

def provider
  @provider
end

Instance Method Details

#generator_classObject



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

def generator_class
  case framework
  when "rspec" then Generator::RspecGenerator
  when "minitest" then Generator::MinitestGenerator
  else raise ConfigurationError, "Unknown framework: #{framework}"
  end
end

#validator_classObject



22
23
24
25
26
27
28
# File 'lib/testgenai/configuration.rb', line 22

def validator_class
  case framework
  when "rspec" then Validator::RspecValidator
  when "minitest" then Validator::MinitestValidator
  else raise ConfigurationError, "Unknown framework: #{framework}"
  end
end