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
  @config = TestData.config
end

Instance Method Details

#configureObject



27
28
29
# File 'lib/test_data/configurators/webpacker_yaml.rb', line 27

def configure
  @generator.call
end

#verifyObject



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

def verify
  path = "config/webpacker.yml"
  pathname = Pathname.new("#{@config.pwd}/#{path}")
  return ConfigurationVerification.new(looks_good?: true) unless pathname.readable?
  yaml = load_yaml(pathname)
  if yaml.nil?
    ConfigurationVerification.new(problems: [
      "'#{path}' is not valid YAML"
    ])
  elsif !yaml.key?("test_data")
    ConfigurationVerification.new(problems: [
      "'#{path}' does not contain a 'test_data' section"
    ])
  else
    ConfigurationVerification.new(looks_good?: true)
  end
end