Class: Uttk::Strategies::Checkout

Inherits:
Strategy show all
Includes:
Concrete
Defined in:
lib/uttk/strategies/Checkout.rb

Instance Attribute Summary

Attributes inherited from Strategy

#status

Instance Method Summary collapse

Methods inherited from Strategy

#abort, #assign, #clean_instance_variables, #display_unexpected_exc, #display_unexpected_synflow_exc, #fail, #initialize, #initialize_flow_factory, #name=, #pass, #raise_error, #reject, #run, #running?, #skip, #skip_if_cached, #skip_wrt_rpath_and_rpath_exclude, #strategy, #strategy=, #symbols=, #symtbl, #symtbl=, #testify, #timeout=, to_form, #to_s, to_yaml_type, #wclass=

Constructor Details

This class inherits a constructor from Uttk::Strategies::Strategy

Instance Method Details

#prologueObject



13
14
15
16
# File 'lib/uttk/strategies/Checkout.rb', line 13

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

#run_implObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/uttk/strategies/Checkout.rb', line 18

def run_impl
  begin
    file, data = @url.checkout
    if data.is_a? Commands::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