Module: Lich::Common::Frontend
- Defined in:
- documented/common/front-end.rb
Class Method Summary collapse
-
.cleanup_session_file ⇒ nil
Cleans up (deletes) the current session file if it exists.
-
.create_session_file(name, host, port, display_session: true) ⇒ nil
Creates a session file with the given parameters.
-
.session_file_location ⇒ String?
Returns the location of the current session file.
Class Method Details
.cleanup_session_file ⇒ nil
Note:
If the session file is nil, the method will return without doing anything.
Cleans up (deletes) the current session file if it exists.
46 47 48 49 |
# File 'documented/common/front-end.rb', line 46 def self.cleanup_session_file return if @session_file.nil? File.delete(@session_file) if File.exist? @session_file end |
.create_session_file(name, host, port, display_session: true) ⇒ nil
Note:
If the name is nil, the method will return without doing anything.
Creates a session file with the given parameters.
26 27 28 29 30 31 32 33 34 35 |
# File 'documented/common/front-end.rb', line 26 def self.create_session_file(name, host, port, display_session: true) return if name.nil? FileUtils.mkdir_p @tmp_session_dir @session_file = File.join(@tmp_session_dir, "%s.session" % name.downcase.capitalize) session_descriptor = { name: name, host: host, port: port }.to_json puts "writing session descriptor to %s\n%s" % [@session_file, session_descriptor] if display_session File.open(@session_file, "w") do |fd| fd << session_descriptor end end |
.session_file_location ⇒ String?
Returns the location of the current session file.
39 40 41 |
# File 'documented/common/front-end.rb', line 39 def self.session_file_location @session_file end |