Class: Aspera::Products::Connect

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/aspera/products/connect.rb

Constant Summary collapse

APP_NAME =
'IBM Aspera Connect'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.locationsObject

standard folder locations

[View source]

14
15
16
17
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
# File 'lib/aspera/products/connect.rb', line 14

def locations
  case Aspera::Environment.os
  when Aspera::Environment::OS_WINDOWS then [{
    app_root: File.join(ENV.fetch('LOCALAPPDATA', nil), 'Programs', 'Aspera', 'Aspera Connect'),
    log_root: File.join(ENV.fetch('LOCALAPPDATA', nil), 'Aspera', 'Aspera Connect', 'var', 'log'),
    run_root: File.join(ENV.fetch('LOCALAPPDATA', nil), 'Aspera', 'Aspera Connect')
  }]
  when Aspera::Environment::OS_MACOS then [{
    app_root: File.join(Dir.home, 'Applications', 'Aspera Connect.app'),
    log_root: File.join(Dir.home, 'Library', 'Logs', 'Aspera_Connect'),
    run_root: File.join(Dir.home, 'Library', 'Application Support', 'Aspera', 'Aspera Connect'),
    sub_bin:  File.join('Contents', 'Resources')
  }, {
    app_root: File.join('', 'Applications', 'Aspera Connect.app'),
    log_root: File.join(Dir.home, 'Library', 'Logs', 'Aspera_Connect'),
    run_root: File.join(Dir.home, 'Library', 'Application Support', 'Aspera', 'Aspera Connect'),
    sub_bin:  File.join('Contents', 'Resources')
  }, {
    app_root: File.join(Dir.home, 'Applications', 'IBM Aspera Connect.app'),
    log_root: File.join(Dir.home, 'Library', 'Logs', 'Aspera_Connect'),
    run_root: File.join(Dir.home, 'Library', 'Application Support', 'Aspera', 'Aspera Connect'),
    sub_bin:  File.join('Contents', 'Resources')
  }, {
    app_root: File.join('', 'Applications', 'IBM Aspera Connect.app'),
    log_root: File.join(Dir.home, 'Library', 'Logs', 'Aspera_Connect'),
    run_root: File.join(Dir.home, 'Library', 'Application Support', 'Aspera', 'Aspera Connect'),
    sub_bin:  File.join('Contents', 'Resources')
  }]
  else [{ # other: Linux and Unix family
    app_root: File.join(Dir.home, '.aspera', 'connect'),
    run_root: File.join(Dir.home, '.aspera', 'connect')
  }]
  end.map { |i| i.merge({ expected: APP_NAME }) }
end

Instance Method Details

#cdn_apiObject

[View source]

50
51
52
# File 'lib/aspera/products/connect.rb', line 50

def cdn_api
  Rest.new(base_url: CDN_BASE_URL)
end

#versionsObject

retrieve structure from cloud (CDN) with all versions available

[View source]

55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/aspera/products/connect.rb', line 55

def versions
  if @connect_versions.nil?
    javascript = cdn_api.call(operation: 'GET', subpath: VERSION_INFO_FILE)
    # get result on one line
    connect_versions_javascript = javascript[:http].body.gsub(/\r?\n\s*/, '')
    Log.log.debug{"javascript=[\n#{connect_versions_javascript}\n]"}
    # get javascript object only
    found = connect_versions_javascript.match(/^.*? = (.*);/)
    raise Cli::Error, 'Problem when getting connect versions from internet' if found.nil?
    all_data = JSON.parse(found[1])
    @connect_versions = all_data['entries']
  end
  return @connect_versions
end