<commit_before>require 'hashr'

module Travis
  module Worker
    module Builders

      class Config < Hashr; end

      class Base
        include Shell

        attr_reader :config

        def initialize(config)
          @config = Config.new(config)
        end

        def run
          setup_env
          install && run_scripts
        end

        # @api public
        def install
          true
        end

        def setup_env
          Array(config.env).each { |env| exec "export #{env}" unless env.empty? } if config.env
        end

        def run_scripts
          %w{before_script script after_script}.each do |type|
            script = config.send(type)
            return false if script && !run_script(script, :timeout => type)
          end && true
        end

        protected
          def pwd
            @pwd ||= evaluate('pwd').strip
          end
      end

    end
  end
end<commit_msg>add run_script back as its needed by run_scripts<commit_after>require 'hashr'

module Travis
  module Worker
    module Builders

      class Config < Hashr; end

      class Base
        include Shell

        attr_reader :config

        def initialize(config)
          @config = Config.new(config)
        end

        def run
          setup_env
          install && run_scripts
        end

        # @api public
        def install
          true
        end

        def setup_env
          Array(config.env).each { |env| exec "export #{env}" unless env.empty? } if config.env
        end

        def run_scripts
          %w{before_script script after_script}.each do |type|
            script = config.send(type)
            return false if script && !run_script(script, :timeout => type)
          end && true
        end

        def run_script(script, options = {})
          (script.is_a?(Array) ? script : script.split("\n")).each do |script|
            return false unless exec(script, options)
          end && true
        end

        protected
          def pwd
            @pwd ||= evaluate('pwd').strip
          end
      end

    end
  end
end
{'fraction_non_alphanumeric': 0.07559808612440191, 'fraction_numerical': 0.0, 'mean_word_length': 1.5253623188405796, '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': '4872548', 'n_tokens_mistral': 574, 'n_tokens_neox': 552, 'n_words': 174}