Class: Aspera::Products::Other

Inherits:
Object
  • Object
show all
Defined in:
lib/aspera/products/other.rb

Overview

other Aspera products with ascp

Constant Summary collapse

INFO_META_FILE =

product information manifest: XML (part of aspera product)

'product-info.mf'
LOCATION_ON_THIS_OS =

:expected M app name is taken from the manifest if present, else defaults to this value :app_root M main folder for the application :log_root O location of log files (Linux uses syslog) :run_root O only for Connect Client, location of http port file :sub_bin O subfolder with executables, default : bin

case Aspera::Environment.instance.os
when Aspera::Environment::OS_WINDOWS then [{
  expected: CLI_V3,
  app_root: File.join('C:', 'Program Files', 'Aspera', 'cli'),
  log_root: File.join('C:', 'Program Files', 'Aspera', 'cli', 'var', 'log')
}, {
  expected: HSTS,
  app_root: File.join('C:', 'Program Files', 'Aspera', 'Enterprise Server'),
  log_root: File.join('C:', 'Program Files', 'Aspera', 'Enterprise Server', 'var', 'log')
}]
when Aspera::Environment::OS_MACOS then [{
  expected: CLI_V3,
  app_root: File.join(Dir.home, 'Applications', 'Aspera CLI'),
  log_root: File.join(Dir.home, 'Library', 'Logs', 'Aspera')
}, {
  expected: HSTS,
  app_root: File.join('', 'Library', 'Aspera'),
  log_root: File.join(Dir.home, 'Library', 'Logs', 'Aspera')
}, {
  expected: DRIVE,
  app_root: File.join('', 'Applications', 'Aspera Drive.app'),
  log_root: File.join(Dir.home, 'Library', 'Logs', 'Aspera_Drive'),
  sub_bin:  File.join('Contents', 'Resources')
}]
else [{ # other: Linux and Unix family
  expected: CLI_V3,
  app_root: File.join(Dir.home, '.aspera', 'cli')
}, {
  expected: HSTS,
  app_root: File.join('', 'opt', 'aspera')
}]
end

Class Method Summary collapse

Class Method Details

.find(scan_locations) ⇒ Array

Find installed products and provide paths for it.

Parameters:

  • scan_locations (Array)

    Array of Hash with keys: expected, app_root, sub_bin, ascp_path, name, version

Returns:

  • (Array)

    of products found, with filled missing fields

Raises:

  • Exception if no installed product found



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/aspera/products/other.rb', line 61

def find(scan_locations)
  product_names = []
  found = scan_locations.select do |item|
    product_names.push(item[:expected]) unless product_names.include?(item[:expected])
    # skip if not main folder
    Log.log.trace1{"Checking #{item[:app_root]}"}
    next false unless Dir.exist?(item[:app_root])
    Log.log.debug{"Found #{item[:expected]}"}
    sub_bin = item[:sub_bin] || 'bin'
    item[:ascp_path] = File.join(item[:app_root], sub_bin, Environment.instance.exe_file('ascp'))
    # skip if no ascp
    next false unless File.exist?(item[:ascp_path])
    # read info from product info file if present
    product_info_file = "#{item[:app_root]}/#{INFO_META_FILE}"
    if File.exist?(product_info_file)
      res_s = XmlSimple.xml_in(File.read(product_info_file), {'ForceArray' => false})
      item[:name] = res_s['name']
      item[:version] = res_s['version']
    else
      item[:name] = item[:expected]
    end
    true # select this version
  end
  raise "Product: #{product_names.join(', ')} not found, please install." if found.empty?
  found
end