<commit_before>require 'shellwords'
require 'travis/build/addons/base'

module Travis
  module Build
    class Addons
      class Hosts < Base
        SUPER_USER_SAFE = true
        HOSTS_FILE = '/etc/hosts'
        TEMP_HOSTS_FILE = '/tmp/hosts'

        def after_prepare
          sh.fold 'hosts.before' do
            sh.echo ""
            sh.cmd "cat #{HOSTS_FILE}"
          end
          sh.fold 'hosts' do
            sh.cmd "sed -e 's/^\\(127\\.0\\.0\\.1.*\\)$/\\1 #{hosts}/' #{HOSTS_FILE} > #{TEMP_HOSTS_FILE}"
            sh.cmd "cat #{TEMP_HOSTS_FILE} | sudo tee #{HOSTS_FILE} > /dev/null"
          end
          sh.fold 'hosts.after' do
            sh.echo ""
            sh.cmd "cat #{HOSTS_FILE}"
          end
        end

        private

          def hosts
            Array(config).join(' ').shellescape
          end
      end
    end
  end
end
<commit_msg>Add newline after host file to fix fold<commit_after>require 'shellwords'
require 'travis/build/addons/base'

module Travis
  module Build
    class Addons
      class Hosts < Base
        SUPER_USER_SAFE = true
        HOSTS_FILE = '/etc/hosts'
        TEMP_HOSTS_FILE = '/tmp/hosts'

        def after_prepare
          sh.fold 'hosts.before' do
            sh.echo ""
            sh.cmd "cat #{HOSTS_FILE}"
            sh.echo ""
          end
          sh.fold 'hosts' do
            sh.cmd "sed -e 's/^\\(127\\.0\\.0\\.1.*\\)$/\\1 #{hosts}/' #{HOSTS_FILE} > #{TEMP_HOSTS_FILE}"
            sh.cmd "cat #{TEMP_HOSTS_FILE} | sudo tee #{HOSTS_FILE} > /dev/null"
          end
          sh.fold 'hosts.after' do
            sh.echo ""
            sh.cmd "cat #{HOSTS_FILE}"
            sh.echo ""
          end
        end

        private

          def hosts
            Array(config).join(' ').shellescape
          end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.12554585152838427, 'fraction_numerical': 0.007641921397379912, 'mean_word_length': 1.4375, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '5302785', 'n_tokens_mistral': 623, 'n_tokens_neox': 594, 'n_words': 141}