Sha256: 7fc8a284fccb4284f0e0b0476304494b30237581ccfbf535a79a6fe6cb1ddada
Contents?: true
Size: 1.36 KB
Versions: 16
Compression:
Stored size: 1.36 KB
Contents
#include <internal/facts/external/yaml_resolver.hpp> #include <internal/util/yaml.hpp> #include <leatherman/logging/logging.hpp> #include <leatherman/locale/locale.hpp> #include <boost/algorithm/string.hpp> #include <boost/nowide/fstream.hpp> #include <yaml-cpp/yaml.h> #include <yaml-cpp/eventhandler.h> // Mark string for translation (alias for leatherman::locale::format) using leatherman::locale::_; using namespace std; using namespace YAML; using namespace facter::util::yaml; namespace facter { namespace facts { namespace external { bool yaml_resolver::can_resolve(string const& path) const { return boost::iends_with(path, ".yaml"); } void yaml_resolver::resolve(string const& path, collection& facts) const { LOG_DEBUG("resolving facts from YAML file \"{1}\".", path); boost::nowide::ifstream stream(path.c_str()); if (!stream) { throw external_fact_exception(_("file could not be opened.")); } try { Node node = YAML::Load(stream); for (auto const& kvp : node) { add_value(kvp.first.as<string>(), kvp.second, facts); } } catch (Exception& ex) { throw external_fact_exception(ex.msg); } LOG_DEBUG("completed resolving facts from YAML file \"{1}\".", path); } }}} // namespace facter::facts::external
Version data entries
16 entries across 16 versions & 2 rubygems