<commit_before># Community maintainers:
#
#   <NAME> <code dawg eu, @MartinNowak>
#
module Travis
  module Build
    class Script
      class D < Script
        DEFAULTS = {
          d: 'dmd-2.066.1'
        }

        def cache_slug
          super << "--d-" << config[:d]
        end

        def export
          super
          sh.export 'DC', compiler_cmd
          sh.export 'DMD', dmd_cmd
        end

        def setup
          super

          sh.fold("compiler-download") do
            sh.echo "Installing compiler and dub", ansi: :yellow

            case compiler_cmd
            when 'dmd'
              binpath, libpath = {'linux' => ['dmd2/linux/bin64', 'dmd2/linux/lib64'],
                                  'osx' => ['dmd2/linux/bin', 'dmd2/linux/lib']}[os]

              sh.cmd "curl -fsSL #{compiler_url} > ~/dmd.zip"
              sh.cmd "unzip -q -d ~ ~/dmd.zip"
            when 'ldc2'
              binpath, libpath = 'ldc/bin', 'ldc/lib'

              sh.cmd "mkdir ${HOME}/ldc", echo: false
              sh.cmd "curl -fsSL #{compiler_url} | tar --strip-components=1 -C ~/ldc -Jxf -"
            when 'gdc'
              binpath, libpath = 'gdc/bin', 'gdc/lib'

              sh.cmd "mkdir ${HOME}/gdc", echo: false
              sh.cmd "curl -fsSL #{compiler_url} | tar --strip-components=1 -C ~/gdc -Jxf -"
              sh.cmd 'curl -fsSL https://raw.githubusercontent.com/D-Programming-GDC/GDMD/master/dmd-script > '+
                "~/#{binpath}/gdmd && chmod +x ~/#{binpath}/gdmd"
            end

            sh.cmd 'LATEST_DUB=$('+
              'curl -fsSL https://api.github.com/repos/D-Programming-Language/dub/tags | '+
              'sed -n \'s|.*"name": "v\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)".*|\1|p\' |'+
              'sort | tail -n 1)', echo: false
            sh.cmd "curl -fsSL http://code.dlang.org/files/dub-${LATEST_DUB}-#{os}-x86_64.tar.gz | tar -C ~/#{binpath} -xzf -"
            sh.cmd "export PATH=\"${HOME}/#{binpath}:${PATH}\""
            sh.cmd "export LD_LIBRARY_PATH=\"${HOME}/#{libpath}:${LD_LIBRARY_PATH}\""
          end
        end

        def announce
          super
          if compiler_cmd == 'dmd'
            sh.cmd 'dmd --help | head -n 2'
          else
            sh.cmd "#{compiler_cmd} --version"
          end
        end

        def script
          sh.cmd "dub test --compiler=#{compiler_cmd}"
        end

        private

        def os
          config[:os] || 'linux'
        end
<commit_msg>use curl with retry option and prepend Travis-CI to curl's user-agent<commit_after># Community maintainers:
#
#   <NAME> <code dawg eu, @MartinNowak>
#
module Travis
  module Build
    class Script
      class D < Script
        DEFAULTS = {
          d: 'dmd-2.066.1'
        }

        def cache_slug
          super << "--d-" << config[:d]
        end

        def export
          super
          sh.export 'DC', compiler_cmd
          sh.export 'DMD', dmd_cmd
        end

        def setup
          super

          sh.fold("compiler-download") do
            sh.echo "Installing compiler and dub", ansi: :yellow

            sh.cmd 'alias curl="curl -fsSL --retry 3 -A \'Travis-CI $(curl --version | head -n 1)\'"'
            case compiler_cmd
            when 'dmd'
              binpath, libpath = {'linux' => ['dmd2/linux/bin64', 'dmd2/linux/lib64'],
                                  'osx' => ['dmd2/linux/bin', 'dmd2/linux/lib']}[os]

              sh.cmd "curl #{compiler_url} > ~/dmd.zip"
              sh.cmd "unzip -q -d ~ ~/dmd.zip"
            when 'ldc2'
              binpath, libpath = 'ldc/bin', 'ldc/lib'

              sh.cmd "mkdir ${HOME}/ldc", echo: false
              sh.cmd "curl #{compiler_url} | tar --strip-components=1 -C ~/ldc -Jxf -"
            when 'gdc'
              binpath, libpath = 'gdc/bin', 'gdc/lib'

              sh.cmd "mkdir ${HOME}/gdc", echo: false
              sh.cmd "curl #{compiler_url} | tar --strip-components=1 -C ~/gdc -Jxf -"
              sh.cmd 'curl https://raw.githubusercontent.com/D-Programming-GDC/GDMD/master/dmd-script > '+
                "~/#{binpath}/gdmd && chmod +x ~/#{binpath}/gdmd"
            end

            sh.cmd 'LATEST_DUB=$('+
              'curl https://api.github.com/repos/D-Programming-Language/dub/tags | '+
              'sed -n \'s|.*"name": "v\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)".*|\1|p\' |'+
              'sort | tail -n 1)', echo: false
            sh.cmd "curl http://code.dlang.org/files/dub-${LATEST_DUB}-#{os}-x86_64.tar.gz | tar -C ~/#{binpath} -xzf -"
            sh.cmd "export PATH=\"${HOME}/#{binpath}:${PATH}\""
            sh.cmd "export LD_LIBRARY_PATH=\"${HOME}/#{libpath}:${LD_LIBRARY_PATH}\""
          end
        end

        def announce
          super
          if compiler_cmd == 'dmd'
            sh.cmd 'dmd --help | head -n 2'
          else
            sh.cmd "#{compiler_cmd} --version"
          end
        end

        def script
          sh.cmd "dub test --compiler=#{compiler_cmd}"
        end

        private

        def os
          config[:os] || 'linux'
        end

{'fraction_non_alphanumeric': 0.16411764705882353, 'fraction_numerical': 0.01411764705882353, 'mean_word_length': 1.4714147286821706, 'pattern_counts': {'":': 2, '<': 17, '<?xml version=': 0, '>': 15, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2240233', 'n_tokens_mistral': 1797, 'n_tokens_neox': 1711, 'n_words': 379}