<commit_before>package rhogenwizard.sdk.task;

import rhogenwizard.ConsoleHelper;
import rhogenwizard.ILogDevice;
import rhogenwizard.SysCommandExecutor;

public class RubyExecTask extends RubyTask
{
    private final SysCommandExecutor m_executor;
    private ConsoleHelper.Console    m_console;

    private Integer                  m_exitValue;

    public RubyExecTask(String workDir, SysCommandExecutor.Decorator decorator, String... args)
    {
        super(workDir, decorator, args);

        m_executor = new SysCommandExecutor();
        m_console  = ConsoleHelper.getBuildConsole();

        m_exitValue = null;
    }

    @Override
    public boolean isOk()
    {
        if (m_exitValue == null)
        {
            throw new IllegalStateException("The task is not finished yet.");
        }

        return m_exitValue == 0;
    }

    public int getExitValue()
    {
        if (m_exitValue == null)
        {
            throw new IllegalStateException("The task is not finished yet.");
        }

        return m_exitValue;
    }

    public String getOutput()
    {
        return m_executor.getCommandOutput();
    }

    public String getError()
    {
        return m_executor.getCommandError();
    }

    public void disableConsole()
    {
        m_console = ConsoleHelper.nullConsole;
    }

    @Override
    protected void exec()
    {
        m_console.show();

        ConsoleHelper.Stream stream = m_console.getStream();

        stream.print(showCommand());

        m_executor.setOutputLogDevice(getLogDevice(m_console.getOutputStream()));
        m_executor.setErrorLogDevice(getLogDevice(m_console.getErrorStream()));

        int exitValue = -1;

        m_executor.setWorkingDirectory(m_workDir);

        try
        {
            exitValue = m_executor.runCommand(m_decorator, m_cmdLine);
        }
        catch (RuntimeException e)
        {
            throw e;
        }
        catch (Exception e)
        {
        }

        m_exitValue = exitValue;

        stream.print("RET: " + m_exitValue + "\n");
    }

    @SuppressWarnings("unused")
    private String showWorkingDir()
    {
        return m_workDir;
    }

    @SuppressWarnings("unused")
    private String showCommandLine()
    {
        StringBuilder sb = new StringBuilder();
        boolean first = true;

        for (String item : m_cmdLine)
        {
            if (first)
            {
                first = false;
            }
            else
            {
                sb.append(' ');
            }

            sb.append(item);
        }

        return sb.toString();
    }

    private static ILogDevice getLogDevice(final ConsoleHelper.Stream stream)
    {<commit_msg>rhogen-wizard/src/rhogenwizard/sdk/task/RubyExecTask.java: showWorkingDir and showCommandLine were removed.<commit_after>package rhogenwizard.sdk.task;

import rhogenwizard.ConsoleHelper;
import rhogenwizard.ILogDevice;
import rhogenwizard.SysCommandExecutor;

public class RubyExecTask extends RubyTask
{
    private final SysCommandExecutor m_executor;
    private ConsoleHelper.Console    m_console;

    private Integer                  m_exitValue;

    public RubyExecTask(String workDir, SysCommandExecutor.Decorator decorator, String... args)
    {
        super(workDir, decorator, args);

        m_executor = new SysCommandExecutor();
        m_console  = ConsoleHelper.getBuildConsole();

        m_exitValue = null;
    }

    @Override
    public boolean isOk()
    {
        if (m_exitValue == null)
        {
            throw new IllegalStateException("The task is not finished yet.");
        }

        return m_exitValue == 0;
    }

    public int getExitValue()
    {
        if (m_exitValue == null)
        {
            throw new IllegalStateException("The task is not finished yet.");
        }

        return m_exitValue;
    }

    public String getOutput()
    {
        return m_executor.getCommandOutput();
    }

    public String getError()
    {
        return m_executor.getCommandError();
    }

    public void disableConsole()
    {
        m_console = ConsoleHelper.nullConsole;
    }

    @Override
    protected void exec()
    {
        m_console.show();

        ConsoleHelper.Stream stream = m_console.getStream();

        stream.print(showCommand());

        m_executor.setOutputLogDevice(getLogDevice(m_console.getOutputStream()));
        m_executor.setErrorLogDevice(getLogDevice(m_console.getErrorStream()));

        int exitValue = -1;

        m_executor.setWorkingDirectory(m_workDir);

        try
        {
            exitValue = m_executor.runCommand(m_decorator, m_cmdLine);
        }
        catch (RuntimeException e)
        {
            throw e;
        }
        catch (Exception e)
        {
        }

        m_exitValue = exitValue;

        stream.print("RET: " + m_exitValue + "\n");
    }

    private static ILogDevice getLogDevice(final ConsoleHelper.Stream stream)
    {
{'fraction_non_alphanumeric': 0.0867367569753336, 'fraction_numerical': 0.0008087343307723412, 'mean_word_length': 2.0938086303939962, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5661744', 'n_tokens_mistral': 1424, 'n_tokens_neox': 1365, 'n_words': 289}