<commit_before>package com.nesscomputing.velocity;

import java.lang.annotation.Annotation;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystemException;
import org.apache.commons.vfs2.VFS;
import org.apache.velocity.Template;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.runtime.log.Log4JLogChute;

import com.google.common.base.Charsets;
import com.google.common.base.Throwables;
import com.google.common.collect.Lists;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.name.Names;

public class VelocityGuiceModule extends AbstractModule {

    private final List<Runnable> bindingActions = Lists.newArrayList();
    private final Charset charset;

    public VelocityGuiceModule() {
        this (Charsets.UTF_8);
    }

    public VelocityGuiceModule(Charset charset) {
        this.charset = charset;
    }

    public VelocityGuiceModule bindTemplate(final Annotation annotation, final URI templateUri) {
        bindingActions.add(new Runnable() {
            @Override
            public void run() {
                bind (Template.class).annotatedWith(annotation).toProvider(new UriTemplateProvider(templateUri));
            }
        });
        return this;
    }

    public VelocityGuiceModule bindTemplateDirectory(final String prefix, final URI templateDirUri) {
        bindingActions.add(new Runnable() {
            @Override
            public void run() {
                try {
                    for (FileObject file : VFS.getManager().resolveFile(templateDirUri.toString()).getChildren()) {
                        if (file.getName().getBaseName().endsWith(".vm")) {
                            String bindName = prefix + "." + StringUtils.removeEndIgnoreCase(file.getName().getBaseName(), ".vm");
                            bind (Template.class).annotatedWith(Names.named(bindName)).toProvider(new UriTemplateProvider(file.getURL().toURI()));<commit_msg>Minor reformatting, bind singleton<commit_after>package com.nesscomputing.velocity;

import java.lang.annotation.Annotation;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystemException;
import org.apache.commons.vfs2.VFS;
import org.apache.velocity.Template;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.runtime.log.Log4JLogChute;

import com.google.common.base.Charsets;
import com.google.common.base.Throwables;
import com.google.common.collect.Lists;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.Scopes;
import com.google.inject.name.Names;

public class VelocityGuiceModule extends AbstractModule {

    private final List<Runnable> bindingActions = Lists.newArrayList();
    private final Charset charset;

    public VelocityGuiceModule() {
        this (Charsets.UTF_8);
    }

    public VelocityGuiceModule(Charset charset) {
        this.charset = charset;
    }

    public VelocityGuiceModule bindTemplate(final Annotation annotation, final URI templateUri) {
        bindingActions.add(new Runnable() {
            @Override
            public void run() {
                bind (Template.class).annotatedWith(annotation).toProvider(new UriTemplateProvider(templateUri)).in(Scopes.SINGLETON);
            }
        });
        return this;
    }

    public VelocityGuiceModule bindTemplateDirectory(final String prefix, final URI templateDirUri) {
        bindingActions.add(new Runnable() {
            @Override
            public void run() {
                try {
                    for (FileObject file : VFS.getManager().resolveFile(templateDirUri.toString()).getChildren()) {
                        if (file.getName().getBaseName().endsWith(".vm")) {
                            String templateName = StringUtils.removeEndIgnoreCase(file.getName().getBaseName(), ".vm");
                            String bindName = prefix + "." + templateName;

                            UriTemplateProvider provider = new UriTemplateProvider(file.getURL().toURI());
                            bind (Template.class).annotatedWith(Names.named(bindName)).toProvider(provider).in(Scopes.SINGLETON);
{'fraction_non_alphanumeric': 0.10383597883597884, 'fraction_numerical': 0.0026455026455026454, 'mean_word_length': 3.147166361974406, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5217250', 'n_tokens_mistral': 1263, 'n_tokens_neox': 1212, 'n_words': 228}