Class: Installation::SshImporterPresenter

Inherits:
Object
  • Object
show all
Includes:
Yast::I18n
Defined in:
src/lib/installation/ssh_importer_presenter.rb

Overview

This class is responsible for building a summary for SshImporter objects. Moving the presentation to a different class, avoid SshImporter knowing about i18n and HTML.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(importer) ⇒ SshImporterPresenter

Returns a new instance of SshImporterPresenter.


31
32
33
34
35
36
37
# File 'src/lib/installation/ssh_importer_presenter.rb', line 31

def initialize(importer)
  Yast.import "Mode"
  Yast.import "HTML"

  textdomain "installation"
  @importer = importer
end

Instance Attribute Details

#importerSshImporter (readonly)

Returns Importer.

Returns:


29
30
31
# File 'src/lib/installation/ssh_importer_presenter.rb', line 29

def importer
  @importer
end

Instance Method Details

#summaryString

Build a formatted summary based on the status of the importer

Returns:

  • (String)

    HTML formatted summary.


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'src/lib/installation/ssh_importer_presenter.rb', line 42

def summary
  message =
    if importer.configurations.empty? && (Yast::Mode.installation || Yast::Mode.autoinst)
      _("No previous Linux installation found")
    elsif importer.device.nil?
      _("No existing SSH host keys will be copied")
    else
      name = ssh_config.system_name if ssh_config
      name ||= importer.device || "default"
      if importer.copy_config?
        # TRANSLATORS: %s is the name of a Linux system found in the hard
        # disk, like 'openSUSE 13.2'
        _("SSH host keys and configuration will be copied from %s") % name
      else
        # TRANSLATORS: %s is the name of a Linux system found in the hard
        # disk, like 'openSUSE 13.2'
        _("SSH host keys will be copied from %s") % name
      end
    end
  Yast::HTML.List([message])
end