Module: Aspera::Products

Defined in:
lib/aspera/products.rb,
lib/aspera/products/hsts.rb,
lib/aspera/products/drive.rb,
lib/aspera/products/cli_v3.rb,
lib/aspera/products/connect.rb,
lib/aspera/products/desktop.rb,
lib/aspera/products/transferd.rb

Overview

Location of Aspera products with ascp: one class per product (Products::Connect, Products::Hsts...), each with APP_NAME and .locations

Defined Under Namespace

Classes: CliV3, Connect, Desktop, Drive, Hsts, Transferd

Constant Summary collapse

INFO_META_FILE =

product information manifest: XML (part of aspera product)

'product-info.mf'

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 (: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)

Returns:

  • (Array) —

    of products found, with filled missing fields

Raises:

  • (RuntimeError) —

    if no installed product found



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
# File 'lib/aspera/products.rb', line 26

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