Sha256: f0f992aae2ba0dbcd9fc7dfdcab612b884cc75cb957579b1ecc9f2142b900005

Contents?: true

Size: 978 Bytes

Versions: 6

Compression:

Stored size: 978 Bytes

Contents

module TestData
  module Configurators
    class WebpackerYaml
      def initialize
        @generator = WebpackerYamlGenerator.new
        @config = TestData.config
      end

      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

      def configure
        @generator.call
      end

      private

      def load_yaml(pathname)
        YAML.load_file(pathname)
      rescue
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
test_data-0.3.1 lib/test_data/configurators/webpacker_yaml.rb
test_data-0.3.0 lib/test_data/configurators/webpacker_yaml.rb
test_data-0.2.2 lib/test_data/configurators/webpacker_yaml.rb
test_data-0.2.1 lib/test_data/configurators/webpacker_yaml.rb
test_data-0.2.0 lib/test_data/configurators/webpacker_yaml.rb
test_data-0.1.0 lib/test_data/configurators/webpacker_yaml.rb