Class: TestData::Configurators::WebpackerYaml

Inherits:
Object
  • Object
show all
Defined in:
lib/test_data/configurators/webpacker_yaml.rb

Instance Method Summary collapse

Constructor Details

#initializeWebpackerYaml

Returns a new instance of WebpackerYaml.



4
5
6
7
# File 'lib/test_data/configurators/webpacker_yaml.rb', line 4

def initialize
  @generator = WebpackerYamlGenerator.new
  @webpacker_config = Wrap::WebpackerConfig.new
end

Instance Method Details

#configureObject



29
30
31
# File 'lib/test_data/configurators/webpacker_yaml.rb', line 29

def configure
  @generator.call
end

#verifyObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/test_data/configurators/webpacker_yaml.rb', line 9

def verify
  if @webpacker_config.no_user_config_exists?
    ConfigurationVerification.new(looks_good?: true)
  elsif (user_config = @webpacker_config.user_config).nil?
    ConfigurationVerification.new(problems: [
      "`#{@webpacker_config.relative_user_config_path}' is not valid YAML"
    ])
  elsif !user_config.key?("test_data")
    ConfigurationVerification.new(problems: [
      "`#{@webpacker_config.relative_user_config_path}' does not contain a `test_data' section"
    ])
  elsif (entries = @webpacker_config.required_entries_missing_from_test_data_config)
    ConfigurationVerification.new(problems: [
      "`#{@webpacker_config.relative_user_config_path}' is missing #{"entry".pluralize(entries.size)} #{entries.map { |(k, v)| "`#{k}' (default: #{v.inspect})" }.join(", ")} in its `test_data' section"
    ])
  else
    ConfigurationVerification.new(looks_good?: true)
  end
end