-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Copyright (c) [2021] SUSE LLC | ||
# | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of version 2 of the GNU General Public License as published | ||
# by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
# more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, contact SUSE LLC. | ||
# | ||
# To contact SUSE LLC about this file by physical or electronic mail, you may | ||
# find current contact information at www.suse.com. | ||
|
||
require "yast" | ||
|
||
Yast.import "Mode" | ||
Yast.import "String" | ||
|
||
module Y2S390 | ||
module Presenters | ||
# This class is responsible of returning a configuration summary of the given devices | ||
class DasdSummary | ||
include Yast::Logger | ||
include Yast::I18n | ||
|
||
# @return [Y2S390::DasdsCollection] | ||
attr_accessor :devices | ||
|
||
# Constructor | ||
# | ||
# @param devices [Y2S390::DasdsCollection] | ||
def initialize(devices) | ||
@devices = devices | ||
end | ||
|
||
|
||
# Return a list with the configuration summary for all the devices given in text plain | ||
# | ||
# @return [Array<String>] | ||
def text | ||
ret = devices.map { |d| format(template, *params(d)) } | ||
log.info("Summary: #{ret}") | ||
ret | ||
end | ||
|
||
private | ||
|
||
# Convenience method to obtain the arguments needed by the configuration template to be used | ||
# depending on the {Yast::Mode} | ||
# | ||
# @param device [Y2S390::Dasd] | ||
def params(device) | ||
return [device.id, device.format, Yast::String.YesNo(device.use_diag)] if Yast::Mode.config | ||
|
||
[device.id, device.device_name, Yast::String.YesNo(device.use_diag)] | ||
end | ||
|
||
# Return the configuration summary template to be used depending on the {Yast::Mode} | ||
# | ||
# @return [String] | ||
def template | ||
return _("Channel ID: %s, Format: %s, DIAG: %s") if Yast::Mode.config | ||
|
||
_("Channel ID: %s, Device: %s, DIAG: %s") | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require "cwm/rspec" | ||
require "y2s390/presenters/summary" | ||
|
||
describe Y2S390::Presenters::Summary do | ||
subject { described_class.new } | ||
|
||
describe "#text" do | ||
it "returns a summary of the dasds configuration" do | ||
end | ||
end | ||
end |