<commit_before>package com.youdevise.gradle.plugins

import groovy.io.FileVisitResult
import org.gradle.api.DefaultTask
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction

import javax.script.ScriptEngineManager

class SassPlugin implements Plugin<Project> {
    def void apply(Project project) {
        def compileSass = project.tasks.create("compileSass", CompileSassTask)
        compileSass.inputDir = project.file('src/main/sass')
        compileSass.outputDir = new File(project.buildDir, 'sass')
        compileSass.cacheLocation = new File(project.buildDir, 'sass-cache')
        // should add our output to the war task's input ... somewhere; somewhere it will be right if it's changed by the script
    }
}

class CompileSassTask extends DefaultTask {

    @InputDirectory
    public File inputDir

    @OutputDirectory
    public File outputDir

    public File cacheLocation

    String driverScript = '''
        require 'rubygems'
        require 'sass'

        $mappings.each do |src, dst|
            engine = Sass::Engine.for_file(src, {:cache_location => $cacheLocation})
            css = engine.render
            File.open(dst, 'w') {|f| f.write(css) }
            puts "#{src} -> #{dst}"
        end
    '''

    @TaskAction
    def compileSass() {
        def mappings = new TreeMap()

        inputDir.traverse(preDir: {if (it.isHidden()) return FileVisitResult.SKIP_SUBTREE}) { inputFile ->
            if (inputFile.isFile() && (inputFile.name.endsWith('.sass') || inputFile.name.endsWith('.scss'))) {<commit_msg>SteveH: mark driverScript property as private<commit_after>package com.youdevise.gradle.plugins

import groovy.io.FileVisitResult
import org.gradle.api.DefaultTask
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction

import javax.script.ScriptEngineManager

class SassPlugin implements Plugin<Project> {
    def void apply(Project project) {
        def compileSass = project.tasks.create("compileSass", CompileSassTask)
        compileSass.inputDir = project.file('src/main/sass')
        compileSass.outputDir = new File(project.buildDir, 'sass')
        compileSass.cacheLocation = new File(project.buildDir, 'sass-cache')
        // should add our output to the war task's input ... somewhere; somewhere it will be right if it's changed by the script
    }
}

class CompileSassTask extends DefaultTask {

    @InputDirectory
    public File inputDir

    @OutputDirectory
    public File outputDir

    public File cacheLocation

    private String driverScript = '''
        require 'rubygems'
        require 'sass'

        $mappings.each do |src, dst|
            engine = Sass::Engine.for_file(src, {:cache_location => $cacheLocation})
            css = engine.render
            File.open(dst, 'w') {|f| f.write(css) }
            puts "#{src} -> #{dst}"
        end
    '''

    @TaskAction
    def compileSass() {
        def mappings = new TreeMap()

        inputDir.traverse(preDir: {if (it.isHidden()) return FileVisitResult.SKIP_SUBTREE}) { inputFile ->
            if (inputFile.isFile() && (inputFile.name.endsWith('.sass') || inputFile.name.endsWith('.scss'))) {
{'fraction_non_alphanumeric': 0.11002949852507375, 'fraction_numerical': 0.0, 'mean_word_length': 3.1404151404151404, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '5281535', 'n_tokens_mistral': 1023, 'n_tokens_neox': 979, 'n_words': 240}