Module: Lich::Common::Frontend
- Defined in:
- lib/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 name, host, and port.
-
.session_file_location ⇒ String?
Returns the location of the current session file.
Class Method Details
.cleanup_session_file ⇒ nil
Note:
This method will do nothing if there is no session file set.
Cleans up (deletes) the current session file if it exists.
48 49 50 51 |
# File 'lib/common/front-end.rb', line 48 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
Creates a session file with the given name, host, and port.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/common/front-end.rb', line 22 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.
38 39 40 |
# File 'lib/common/front-end.rb', line 38 def self.session_file_location @session_file end |