Class: Installation::SshConfigFile
- Inherits:
-
Object
- Object
- Installation::SshConfigFile
- Includes:
- Yast::Logger
- Defined in:
- src/lib/installation/ssh_config_file.rb
Overview
Class that allows to memorize a particular SSH config file found in a partition.
Used by the SSH configuration importing functionality.
Constant Summary collapse
- BACKUP_SUFFIX =
".yast.orig".freeze
Instance Attribute Summary collapse
-
#atime ⇒ Time
Access time of the original file.
-
#content ⇒ String
Content of the file.
-
#name ⇒ String
File name.
-
#permissions ⇒ Fixmum
Mode of the original file.
Instance Method Summary collapse
- #backup(filename) ⇒ Object protected
-
#initialize(name) ⇒ SshConfigFile
constructor
A new instance of SshConfigFile.
- #read(path) ⇒ Object
-
#to_s ⇒ Object
Override to_s method for logging.
- #write(dir) ⇒ Object
Constructor Details
#initialize(name) ⇒ SshConfigFile
Returns a new instance of SshConfigFile.
40 41 42 |
# File 'src/lib/installation/ssh_config_file.rb', line 40 def initialize(name) @name = name end |
Instance Attribute Details
#atime ⇒ Time
Returns access time of the original file.
34 35 36 |
# File 'src/lib/installation/ssh_config_file.rb', line 34 def atime @atime end |
#content ⇒ String
Returns content of the file.
36 37 38 |
# File 'src/lib/installation/ssh_config_file.rb', line 36 def content @content end |
#name ⇒ String
Returns file name.
32 33 34 |
# File 'src/lib/installation/ssh_config_file.rb', line 32 def name @name end |
#permissions ⇒ Fixmum
Returns mode of the original file. @see File.chmod.
38 39 40 |
# File 'src/lib/installation/ssh_config_file.rb', line 38 def @permissions end |
Instance Method Details
#backup(filename) ⇒ Object (protected)
65 66 67 |
# File 'src/lib/installation/ssh_config_file.rb', line 65 def backup(filename) ::FileUtils.mv(filename, filename + BACKUP_SUFFIX) if File.exist?(filename) end |
#read(path) ⇒ Object
44 45 46 47 48 |
# File 'src/lib/installation/ssh_config_file.rb', line 44 def read(path) self.content = File.read(path) self.atime = File.atime(path) self. = File.stat(path).mode end |
#to_s ⇒ Object
Override to_s method for logging.
59 60 61 |
# File 'src/lib/installation/ssh_config_file.rb', line 59 def to_s name.to_s end |
#write(dir) ⇒ Object
50 51 52 53 54 55 56 |
# File 'src/lib/installation/ssh_config_file.rb', line 50 def write(dir) log.info "Write SSH config file #{dir} to #{name}" path = File.join(dir, name) backup(path) File.write(path, content) File.chmod(, path) end |