<commit_before>#include <puppet/compiler/environment.hpp>
#include <puppet/cast.hpp>
#include <boost/filesystem.hpp>

using namespace std;
namespace fs = boost::filesystem;
namespace sys = boost::system;

namespace puppet { namespace compiler {

    environment::environment(logging::logger& logger, string name, string base) :
        _logger(logger),
        _name(rvalue_cast(name)),
        _base(rvalue_cast(base))
    {
        // TODO: the modules path can come from an environment configuration file
        vector<string> module_directories = {
            (fs::path{_base} / "modules").string()
        };

        _modules = load_modules(_logger, module_directories);
    }

    logging::logger& environment::logger()
    {
        return _logger;
    }

    string const& environment::name() const
    {
        return _name;
    }

    string const& environment::base() const
    {
        return _base;
    }

    vector<string> environment::find_manifests() const
    {
        // Needed for LOG macro
        auto& logger = _logger;

        // TODO: the "manifests" directory is a configuration setting; should not be hard coded
        auto manifests_directory = fs::path{_base} / "manifests";

        LOG(debug, "searching '%1%' for manifest files.", manifests_directory.string());

        vector<string> paths;
        sys::error_code ec;
        if (!fs::is_directory(manifests_directory, ec) || ec) {
            return paths;
        }

        fs::directory_iterator it{manifests_directory};
        fs::directory_iterator end{};

        // Add all files to the
        for (; it != end; ++it) {
            if (fs::is_regular_file(it->status())) {
                paths.emplace_back(it->path().string());
            }
        }

        // Sort and return the paths
        sort(paths.begin(), paths.end());
        return paths;
    }

    module const* environment::find_module(string const& name) const
    {
        auto it = _modules.find(name);
        if (it == _modules.end()) {
            return nullptr;
        }
        return &it->second;
    }

}}  // namespace puppet::compiler<commit_msg>Limit default manifest files by .pp extension.<commit_after>#include <puppet/compiler/environment.hpp>
#include <puppet/cast.hpp>
#include <boost/filesystem.hpp>

using namespace std;
namespace fs = boost::filesystem;
namespace sys = boost::system;

namespace puppet { namespace compiler {

    environment::environment(logging::logger& logger, string name, string base) :
        _logger(logger),
        _name(rvalue_cast(name)),
        _base(rvalue_cast(base))
    {
        // TODO: the modules path can come from an environment configuration file
        vector<string> module_directories = {
            (fs::path{_base} / "modules").string()
        };

        _modules = load_modules(_logger, module_directories);
    }

    logging::logger& environment::logger()
    {
        return _logger;
    }

    string const& environment::name() const
    {
        return _name;
    }

    string const& environment::base() const
    {
        return _base;
    }

    vector<string> environment::find_manifests() const
    {
        // Needed for LOG macro
        auto& logger = _logger;

        // TODO: the "manifests" directory is a configuration setting; should not be hard coded
        auto manifests_directory = fs::path{_base} / "manifests";

        LOG(debug, "searching '%1%' for manifest files.", manifests_directory.string());

        vector<string> paths;
        sys::error_code ec;
        if (!fs::is_directory(manifests_directory, ec) || ec) {
            return paths;
        }

        fs::directory_iterator it{manifests_directory};
        fs::directory_iterator end{};

        // Add all files to the
        for (; it != end; ++it) {
            if (fs::is_regular_file(it->status()) && it->path().extension() == ".pp") {
                paths.emplace_back(it->path().string());
            }
        }

        // Sort and return the paths
        sort(paths.begin(), paths.end());
        return paths;
    }

    module const* environment::find_module(string const& name) const
    {
        auto it = _modules.find(name);
        if (it == _modules.end()) {
            return nullptr;
        }
        return &it->second;
    }

}}  // namespace puppet::compiler
{'fraction_non_alphanumeric': 0.1231549815498155, 'fraction_numerical': 0.00046125461254612545, 'mean_word_length': 2.3516228748068007, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2245907', 'n_tokens_mistral': 1237, 'n_tokens_neox': 1184, 'n_words': 305}