class LicenseAcceptance::Config

def default_license_locations

def default_license_locations
  if windows?
    l = [ File.join(ENV["HOMEDRIVE"], "chef/accepted_licenses/") ]
    unless is_root?
      # Look through a list of possible user locations and pick the first one that exists
      # copied from path_helper.rb in chef-config gem
      possible_dirs = []
      possible_dirs << ENV["HOME"] if ENV["HOME"]
      possible_dirs << ENV["HOMEDRIVE"] + ENV["HOMEPATH"] if ENV["HOMEDRIVE"] && ENV["HOMEPATH"]
      possible_dirs << ENV["HOMESHARE"] + ENV["HOMEPATH"] if ENV["HOMESHARE"] && ENV["HOMEPATH"]
      possible_dirs << ENV["USERPROFILE"] if ENV["USERPROFILE"]
      raise NoValidEnvironmentVar if possible_dirs.empty?
      possible_dirs.each do |possible_dir|
        if Dir.exist?(possible_dir)
          full_possible_dir = File.join(possible_dir, ".chef/accepted_licenses/")
          l << full_possible_dir
          break
        end
      end
    end
  else
    l = [ "/etc/chef/accepted_licenses/" ]
    l << File.join(ENV['HOME'], ".chef/accepted_licenses/") unless is_root?
  end
  l
end

def default_persist_location

def default_persist_location
  license_locations[-1]
end

def initialize(opts={})

def initialize(opts={})
  @output = opts.fetch(:output, $stdout)
  @logger = opts.fetch(:logger, ::Logger.new(IO::NULL))
  @license_locations = opts.fetch(:license_locations, default_license_locations)
  @license_locations = [ @license_locations ].flatten
  @persist_location = opts.fetch(:persist_location, default_persist_location)
  @persist = opts.fetch(:persist, true)
end

def is_root?

def is_root?
  Process.uid == 0
end

def windows?

def windows?
  !!(RUBY_PLATFORM =~ /(cygwin|mswin|mingw|bccwin|wince|emx)/i)
end