Sha256: e06e38dad8bc2c1985e809f28e9fcc39f23eb0d51b17fc4faf2dd0aa191a5c5f

Contents?: true

Size: 965 Bytes

Versions: 1

Compression:

Stored size: 965 Bytes

Contents

module Pbmenv
  class DownloadSrcService
    class DownloadError < StandardError; end

    attr_accessor :version

    def initialize(version)
      self.version = version
    end

    def execute!
      pathname = VersionPathname.new(version)
      pathname.src_pbm_path
      if ENV["DEBUG_INSTALL"]
        shell = <<~SHELL
          git clone https://github.com/splaplapla/procon_bypass_man.git #{pathname.src_pbm_path}
        SHELL
      else
        # TODO cache for testing
        shell = <<~SHELL
          curl -L https://github.com/splaplapla/procon_bypass_man/archive/refs/tags/v#{version}.tar.gz | tar xvz -C /tmp > /dev/null 2>&1
        SHELL
      end

      if Helper.system_and_puts(shell)
        unless File.exist?(pathname.src_pbm_project_template_path)
          raise Pbmenv::CreateVersionService::NotSupportVersionError, "This version is not support by pbmenv"
        end
      else
        raise DownloadError
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pbmenv-0.1.13 lib/pbmenv/services/download_src_service.rb