class Fauxhai::Fetcher
def initialize(options = {}, &override_attributes)
def initialize(options = {}, &override_attributes) @options = options if !force_cache_miss? && cached? @data = cache else require "net/ssh" unless defined?(Net::SSH) Net::SSH.start(host, user, @options) do |ssh| @data = JSON.parse(ssh.exec!("ohai")) end # cache this data so we do not have to SSH again File.open(cache_file, "w+") { |f| f.write(@data.to_json) } end yield(@data) if block_given? if defined?(ChefSpec) data = @data ::ChefSpec::Runner.send :define_method, :fake_ohai do |ohai| data.each_pair do |attribute, value| ohai[attribute] = value end end end @data end