class Webpacker::Configuration

def additional_paths

def additional_paths
  fetch(:additional_paths) + resolved_paths
end

def additional_paths_globbed

def additional_paths_globbed
  additional_paths.map { |p| globbed_path_with_extensions(p) }
end

def cache_manifest?

def cache_manifest?
  fetch(:cache_manifest)
end

def cache_path

def cache_path
  root_path.join(fetch(:cache_path))
end

def check_yarn_integrity=(value)

def check_yarn_integrity=(value)
  warn "Webpacker::Configuration#check_yarn_integrity=(value) has been deprecated. The integrity check has been removed from Webpacker so changing this setting will have no effect."
end

def compile?

def compile?
  fetch(:compile)
end

def data

def data
  @data ||= load
end

def defaults

def defaults
  @defaults ||= begin
    path = File.expand_path("../../install/config/webpacker.yml", __FILE__)
    config = begin
      YAML.load_file(path, aliases: true)
    rescue ArgumentError
      YAML.load_file(path)
    end
    HashWithIndifferentAccess.new(config[env])
  end
end

def dev_server

def dev_server
  fetch(:dev_server)
end

def extensions

def extensions
  fetch(:extensions)
end

def extract_css?

def extract_css?
  fetch(:extract_css)
end

def fetch(key)

def fetch(key)
  data.fetch(key, defaults[key])
end

def globbed_path_with_extensions(path)

def globbed_path_with_extensions(path)
  "#{path}/**/*{#{extensions.join(',')}}"
end

def initialize(root_path:, config_path:, env:)

def initialize(root_path:, config_path:, env:)
  @root_path = root_path
  @config_path = config_path
  @env = env
end

def load

def load
  config = begin
    YAML.load_file(config_path.to_s, aliases: true)
  rescue ArgumentError
    YAML.load_file(config_path.to_s)
  end
  config[env].deep_symbolize_keys
rescue Errno::ENOENT => e
  raise "Webpacker configuration file not found #{config_path}. " \
        "Please run rails webpacker:install " \
        "Error: #{e.message}"
rescue Psych::SyntaxError => e
  raise "YAML syntax error occurred while parsing #{config_path}. " \
        "Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \
        "Error: #{e.message}"
end

def public_manifest_path

def public_manifest_path
  public_output_path.join("manifest.json")
end

def public_output_path

def public_output_path
  public_path.join(fetch(:public_output_path))
end

def public_path

def public_path
  root_path.join(fetch(:public_root_path))
end

def resolved_paths

def resolved_paths
  paths = data.fetch(:resolved_paths, [])
  warn "The resolved_paths option has been deprecated. Use additional_paths instead." unless paths.empty?
  paths
end

def source_entry_path

def source_entry_path
  source_path.join(fetch(:source_entry_path))
end

def source_path

def source_path
  root_path.join(fetch(:source_path))
end

def source_path_globbed

def source_path_globbed
  globbed_path_with_extensions(source_path.relative_path_from(root_path))
end

def webpack_compile_output?

def webpack_compile_output?
  fetch(:webpack_compile_output)
end