Class Uttk::Strategies::Checkout
In: lib/uttk/strategies/Checkout.rb
Parent: Strategy

Methods

prologue   run_impl  

Included Modules

Concrete

Public Instance methods

[Source]

# File lib/uttk/strategies/Checkout.rb, line 13
      def prologue
        super
        @url = URI.parse(@url) unless @url.is_a? URI
      end

[Source]

# File lib/uttk/strategies/Checkout.rb, line 18
      def run_impl
        FileType.import!
        begin
          file, data = @url.checkout
          if data.is_a? OCmd::Datas::Data
            out, err = data.output, data.error
            @log.my_stdout = out.read unless out.nil? or out.size.zero?
            @log.my_stderr = err.read unless err.nil? or err.size.zero?
          end
          file = FileType.guess(file)
          if file.is_a? FileType::Directory
            @symtbl[:checkout_dir] = file.path
            @symtbl[:extract_dir] = file.path
            pass
          end
          unless file.extractable? or file.installable?
            fail("Bad file type #{file}:#{file.class}, " +
                 'neither extractable nor installable')
          end
          if file.extractable?
            path = file.extract
            fail("cannot extract #{file} returned path is nil") if path.nil?
          elsif file.installable?
            install_dir = TempPath.new
            install_dir.mkpath
            data = file.install(install_dir)
            if data.status != 0
              fail("cannot install #{file} returned path is nil")
            end
            path = install_dir + 'gems' + file.path.basename.extsplit.first
          end
          @symtbl[:checkout_dir] = path
          @symtbl[:extract_dir] = path
        rescue FileType::ExtractError => ex
          fail(ex)
        rescue URI::CheckoutError => ex
          fail(ex)
        end
        pass
      end

[Validate]