<commit_before># Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack import *


class Ruby(AutotoolsPackage):
    """A dynamic, open source programming language with a focus on
    simplicity and productivity."""

    homepage = "https://www.ruby-lang.org/"
    url      = "http://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.0.tar.gz"
    list_url = "http://cache.ruby-lang.org/pub/ruby/"
    list_depth = 1

    version('2.6.2', sha256='a0405d2bf2c2d2f332033b70dff354d224a864ab0edd462b7a413420453b49ab')
    version('2.5.3', sha256='9828d03852c37c20fa333a0264f2490f07338576734d910ee3fd538c9520846c')
    version('2.2.0', sha256='7671e394abfb5d262fbcd3b27a71bf78737c7e9347fa21c39e58b0bb9c4840fc')

    variant('openssl', default=True, description="Enable OpenSSL support")
    variant('readline', default=False, description="Enable Readline support")

    extendable = True

    depends_on('pkgconfig', type=('build'))
    depends_on('libffi')
    depends_on('zlib')
    depends_on('libx11')
    depends_on('tcl')
    depends_on('tk')
    depends_on('openssl@:1.0', when='@:2.3+openssl')
    depends_on('openssl', when='+openssl')
    depends_on('readline', when='+readline')

    # gcc-7-based build requires patches (cf. https://bugs.ruby-lang.org/issues/13150)
    patch('ruby_23_gcc7.patch', level=0, when='@2.2.0:2.2.999 %gcc@7:')
    patch('ruby_23_gcc7.patch', level=0, when='@2.3.0:2.3.4 %gcc@7:')
    patch('ruby_24_gcc7.patch', level=1, when='@2.4.0 %gcc@7:')

    resource(
        name='rubygems-updated-ssl-cert',
        url='https://raw.githubusercontent.com/rubygems/rubygems/master/lib/rubygems/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem',
        sha256='df68841998b7fd098a9517fe971e97890be0fc93bbe1b2a1ef63ebdea3111c80',
        when='+openssl',
        destination='',
        placement='rubygems-updated-ssl-cert',
        expand=False
    )

    def url_for_version(self, version):
        url = "http://cache.ruby-lang.org/pub/ruby/{0}/ruby-{1}.tar.gz"
        return url.format(version.up_to(2), version)

    def configure_args(self):
        args = []
        if '+openssl' in self.spec:
            args.append("--with-openssl-dir=%s" % self.spec['openssl'].prefix)
        if '+readline' in self.spec:
            args.append("--with-readline-dir=%s"
                        % self.spec['readline'].prefix)
        args.append('--with-tk=%s' % self.spec['tk'].prefix)<commit_msg>Ruby: add warning about Avira antivirus (#16882)<commit_after># Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack import *


class Ruby(AutotoolsPackage):
    """A dynamic, open source programming language with a focus on
    simplicity and productivity."""

    homepage = "https://www.ruby-lang.org/"
    url      = "http://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.0.tar.gz"
    list_url = "http://cache.ruby-lang.org/pub/ruby/"
    list_depth = 1

    version('2.6.2', sha256='a0405d2bf2c2d2f332033b70dff354d224a864ab0edd462b7a413420453b49ab')
    version('2.5.3', sha256='9828d03852c37c20fa333a0264f2490f07338576734d910ee3fd538c9520846c')
    version('2.2.0', sha256='7671e394abfb5d262fbcd3b27a71bf78737c7e9347fa21c39e58b0bb9c4840fc')

    variant('openssl', default=True, description="Enable OpenSSL support")
    variant('readline', default=False, description="Enable Readline support")

    extendable = True

    depends_on('pkgconfig', type=('build'))
    depends_on('libffi')
    depends_on('zlib')
    depends_on('libx11')
    depends_on('tcl')
    depends_on('tk')
    depends_on('openssl@:1.0', when='@:2.3+openssl')
    depends_on('openssl', when='+openssl')
    depends_on('readline', when='+readline')

    # Known build issues when Avira antivirus software is running:
    # https://github.com/rvm/rvm/issues/4313#issuecomment-374020379
    # TODO: add check for this and warn user

    # gcc-7-based build requires patches (cf. https://bugs.ruby-lang.org/issues/13150)
    patch('ruby_23_gcc7.patch', level=0, when='@2.2.0:2.2.999 %gcc@7:')
    patch('ruby_23_gcc7.patch', level=0, when='@2.3.0:2.3.4 %gcc@7:')
    patch('ruby_24_gcc7.patch', level=1, when='@2.4.0 %gcc@7:')

    resource(
        name='rubygems-updated-ssl-cert',
        url='https://raw.githubusercontent.com/rubygems/rubygems/master/lib/rubygems/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem',
        sha256='df68841998b7fd098a9517fe971e97890be0fc93bbe1b2a1ef63ebdea3111c80',
        when='+openssl',
        destination='',
        placement='rubygems-updated-ssl-cert',
        expand=False
    )

    def url_for_version(self, version):
        url = "http://cache.ruby-lang.org/pub/ruby/{0}/ruby-{1}.tar.gz"
        return url.format(version.up_to(2), version)

    def configure_args(self):
        args = []
        if '+openssl' in self.spec:
            args.append("--with-openssl-dir=%s" % self.spec['openssl'].prefix)
        if '+readline' in self.spec:
            args.append("--with-readline-dir=%s"
                        % self.spec['readline'].prefix)
        args.append('--with-tk=%s' % self.spec['tk'].prefix)
{'fraction_non_alphanumeric': 0.1560747663551402, 'fraction_numerical': 0.09682242990654205, 'mean_word_length': 3.5852613538988862, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 7, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4895362', 'n_tokens_mistral': 2254, 'n_tokens_neox': 1950, 'n_words': 287}