Class: PortalModule::Dts

Inherits:
Object
  • Object
show all
Includes:
Assertable
Defined in:
lib/portal_module/dts.rb

Constant Summary collapse

DL_FILENAME =
'2-LatestDTS.xml'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Assertable

#assert_dir_exists, #assert_dl_dir_is_configured, #assert_file_exists, #assert_org_is_configured

Constructor Details

#initialize(page_factory) ⇒ Dts

Returns a new instance of Dts.



20
21
22
# File 'lib/portal_module/dts.rb', line 20

def initialize(page_factory)
  @page_factory = page_factory
end

Instance Attribute Details

#page_factoryObject (readonly)

Returns the value of attribute page_factory.



18
19
20
# File 'lib/portal_module/dts.rb', line 18

def page_factory
  @page_factory
end

Instance Method Details

#activateObject



28
29
30
# File 'lib/portal_module/dts.rb', line 28

def activate
  dts_page.activate
end

#download(org, file_path) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/portal_module/dts.rb', line 37

def download org, file_path
  assert_org_is_configured org
  assert_dl_dir_is_configured
  assert_dir_exists file_path

  dts_page
    .load_org(org_string(org))
    .download

  file_path = Pathname(file_path)
  file_path = file_path + DL_FILENAME if file_path.directory?

  dl_file = download_dir + DL_FILENAME
  wait_for_file(dl_file, PortalModule.configuration.download_timeout)
  assert_file_exists dl_file

  FileUtils.mv dl_file, file_path

rescue Exception => e
  if e.message.include? 'No such file or directory'
    raise IOError, "No such directory - #{file_path}"
  else
    raise e
  end
end

#saveObject



24
25
26
# File 'lib/portal_module/dts.rb', line 24

def save
  dts_page.save
end

#set_org(org) ⇒ Object



32
33
34
35
# File 'lib/portal_module/dts.rb', line 32

def set_org org
  assert_org_is_configured org
  dts_page.load_org(org_string(org))
end

#upload(org, file_path) ⇒ Object

Import DTS configurations into the current environment from a file.



66
67
68
69
70
71
72
73
# File 'lib/portal_module/dts.rb', line 66

def upload org, file_path
  assert_org_is_configured org
  assert_file_exists file_path

  dts_page
    .load_org(org_string(org))
    .upload(Pathname(file_path).expand_path)
end