Sha256: e71f668ba8cf1f78d63def9370d730ad11590c6c0e9512390976086847c94e91

Contents?: true

Size: 1.64 KB

Versions: 42

Compression:

Stored size: 1.64 KB

Contents

# Usage:
#
#   Lambdagem::Extract::Ruby.new("2.5.0",
#     s3: "lambdagems",
#     build_root: cache_area, # defaults to /tmp/lambdagem
#     dest: cache_area, # defaults to . (project_root)
#   ).run
#
module Lambdagem::Extract
  class Ruby < Base
    class NotFound < RuntimeError; end

    def run
      say "Looking for #{full_ruby_name}"
      clean_downloads(:rubies) if @options[:clean]
      tarball_path = download_ruby
      unpack_tarball(tarball_path)
      say("Ruby #{full_ruby_name} unpacked at #{project_root}", :debug)
    end

    def download_ruby
      url = ruby_url
      tarball_dest = download_file(url, download_path(File.basename(url)))
      unless tarball_dest
        message = "Url: #{url} not found"
        if @options[:exit_on_error]
          say message
          # exit # TODO: ADD BACK IN
        else
          raise NotFound.new(message)
        end
      end
      say "Tarball downloaded to: #{tarball_dest}"
      tarball_dest
    end

    def download_path(filename)
      "#{@build_root}/downloads/rubies/#{filename}"
    end

    # If only the ruby version is given, then append ruby- in front. Otherwise
    # leave alone.
    #
    # Example:
    #
    #    2.5.0           -> ruby-2.5.0-linux-x86_64.tgz
    #    ruby-2.5.0      -> ruby-2.5.0-linux-x86_64.tgz
    #    test-ruby-2.5.0 -> test-ruby-2.5.0-linux-x86_64.tgz
    def full_ruby_name
      md = @name.match(/^(\d+\.\d+\.\d+)$/)
      if md
        ruby_version = md[1]
        "ruby-#{ruby_version}-linux-x86_64.tgz"
      else
        "#{@name}-linux-x86_64.tgz"
      end
    end

    def ruby_url
      "#{lambdagems_url}/rubies/#{full_ruby_name}"
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
jets-1.0.1 vendor/lambdagem/lib/lambdagem/extract/ruby.rb
jets-1.0.0 vendor/lambdagem/lib/lambdagem/extract/ruby.rb
jets-0.10.4 vendor/lambdagem/lib/lambdagem/extract/ruby.rb
jets-0.10.3 vendor/lambdagem/lib/lambdagem/extract/ruby.rb
jets-0.10.2 vendor/lambdagem/lib/lambdagem/extract/ruby.rb
jets-0.10.1 vendor/lambdagem/lib/lambdagem/extract/ruby.rb
jets-0.10.0 vendor/lambdagem/lib/lambdagem/extract/ruby.rb
jets-0.9.2 vendor/lambdagem/lib/lambdagem/extract/ruby.rb
jets-0.9.1 vendor/lambdagem/lib/lambdagem/extract/ruby.rb
jets-0.9.0 vendor/lambdagem/lib/lambdagem/extract/ruby.rb
jets-0.8.18 vendor/lambdagem/lib/lambdagem/extract/ruby.rb
jets-0.8.17 vendor/lambdagem/lib/lambdagem/extract/ruby.rb
jets-0.8.15 vendor/lambdagem/lib/lambdagem/extract/ruby.rb
jets-0.8.14 vendor/lambdagem/lib/lambdagem/extract/ruby.rb
jets-0.8.13 vendor/lambdagem/lib/lambdagem/extract/ruby.rb
jets-0.8.12 vendor/lambdagem/lib/lambdagem/extract/ruby.rb
jets-0.8.11 vendor/lambdagem/lib/lambdagem/extract/ruby.rb
jets-0.8.10 vendor/lambdagem/lib/lambdagem/extract/ruby.rb
jets-0.8.9 vendor/lambdagem/lib/lambdagem/extract/ruby.rb
jets-0.8.8 vendor/lambdagem/lib/lambdagem/extract/ruby.rb