Sha256: 4cfe5e39c2ea271b661b32e7054b611c2c0873514dc98229f7ff2db1a2bdeb66

Contents?: true

Size: 1.97 KB

Versions: 3

Compression:

Stored size: 1.97 KB

Contents

# Author::    Nicolas Pouillard  <ertai@lrde.epita.fr>.
# Copyright:: Copyright (c) 2004, 2005 Uttk team. All rights reserved.
# License::   LGPL
# $Id: /w/fey/uttk/trunk/lib/uttk/strategies/Checkout.rb 24394 2006-07-10T07:38:58.276210Z ertai  $

module Uttk

  module Strategies

    class Checkout < Strategy
      include Concrete

      def prologue
        super
        @url = URI.parse(@url) unless @url.is_a? URI
      end

      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

      attribute :url, 'url to checkout', :mandatory

    end # class Checkout

  end # module Strategies

end # module Uttk

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
uttk-0.4.6.1 lib/uttk/strategies/Checkout.rb
uttk-0.4.6.2 lib/uttk/strategies/Checkout.rb
uttk-0.4.5.0 lib/uttk/strategies/Checkout.rb