Sha256: 46286b13f713b6d4f96463d6e07bc88ca3e93c68b31f91592d5daf883403362d

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 KB

Contents

# Author::    Nicolas Pouillard  <ertai@lrde.epita.fr>.
# Copyright:: Copyright (c) 2004, 2005 TTK team. All rights reserved.
# License::   LGPL
# $Id: Checkout.rb 575 2005-04-14 10:22:30Z polrop $


require 'checkout'
require 'filetype'

module TTK

  module Strategies

    class Checkout < Strategy
      include Concrete

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

      def run_impl
        begin
          file, out, err = @url.checkout
          @log.my_stdout = out.read unless out.nil? or out.size.zero?
          @log.my_stderr = err.read unless err.nil? or err.size.zero?
          file = FileType.guess(file)
          if file.is_a? FileType::Directory
            @symtbl[:extract_dir] = file.path
            pass
          end
          unless file.is_a? FileType::Extractable
            fail("Bad file type #{file}:#{file.class}, not extractable")
          end
          path = file.extract
          fail("cannot extract #{file} returned path is nil") if path.nil?
          @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 TTK

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ttk-0.1.576 lib/ttk/strategies/Checkout.rb
ttk-0.1.579 lib/ttk/strategies/Checkout.rb
ttk-0.1.580 lib/ttk/strategies/Checkout.rb