Class: CFA::SystemdBoot
- Inherits:
-
BaseModel
- Object
- BaseModel
- CFA::SystemdBoot
- Extended by:
- Yast::Logger
- Includes:
- Yast::Logger
- Defined in:
- src/lib/cfa/systemd_boot.rb
Overview
CFA based class to handle systemd-boot configuration file
Class Method Summary collapse
-
.load(file_handler: Yast::TargetFile, file_path: PATH) ⇒ SystemdBoot
Instantiates and loads a file when possible.
Instance Method Summary collapse
-
#initialize(file_handler: Yast::TargetFile, file_path: PATH) ⇒ SystemdBoot
constructor
Constructor.
- #save ⇒ Object
Constructor Details
#initialize(file_handler: Yast::TargetFile, file_path: PATH) ⇒ SystemdBoot
Constructor
75 76 77 |
# File 'src/lib/cfa/systemd_boot.rb', line 75 def initialize(file_handler: Yast::TargetFile, file_path: PATH) super(AugeasParser.new(LENS), file_path, file_handler: file_handler) end |
Class Method Details
.load(file_handler: Yast::TargetFile, file_path: PATH) ⇒ SystemdBoot
Instantiates and loads a file when possible
This method is basically a shortcut to instantiate and load the content in just one call.
60 61 62 63 64 65 66 67 |
# File 'src/lib/cfa/systemd_boot.rb', line 60 def self.load(file_handler: Yast::TargetFile, file_path: PATH) file = new(file_path: file_path, file_handler: file_handler) file.tap(&:load) rescue Errno::ENOENT log.info("#{file_path} couldn't be loaded. Probably the file does not exist yet.") file end |
Instance Method Details
#save ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 |
# File 'src/lib/cfa/systemd_boot.rb', line 79 def save directory = File.dirname(@file_path) if !Yast::FileUtils.IsDirectory(directory) Yast::Execute.on_target("/usr/bin/mkdir", "--parents", directory) end super rescue Errno::EACCES log.info("Permission denied when writting to #{@file_path}") false end |