Class: Devformance::LogWriter
- Inherits:
-
Object
- Object
- Devformance::LogWriter
- Defined in:
- lib/devformance/log_writer.rb
Constant Summary collapse
- LOG_BASE =
-> { Rails.root.join("log", "devformance", "runs") }
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(path) ⇒ LogWriter
constructor
A new instance of LogWriter.
- #path ⇒ Object
- #write(line) ⇒ Object
Constructor Details
#initialize(path) ⇒ LogWriter
11 12 13 14 |
# File 'lib/devformance/log_writer.rb', line 11 def initialize(path) @path = path @file = File.open(path, "w") end |
Class Method Details
.open(run_id, file_key) ⇒ Object
5 6 7 8 9 |
# File 'lib/devformance/log_writer.rb', line 5 def self.open(run_id, file_key) dir = LOG_BASE.call.join(run_id.to_s) FileUtils.mkdir_p(dir) new(dir.join("#{file_key}.log")) end |
Instance Method Details
#close ⇒ Object
21 22 23 |
# File 'lib/devformance/log_writer.rb', line 21 def close @file.close end |
#path ⇒ Object
25 26 27 |
# File 'lib/devformance/log_writer.rb', line 25 def path @path.to_s end |
#write(line) ⇒ Object
16 17 18 19 |
# File 'lib/devformance/log_writer.rb', line 16 def write(line) @file.puts(line) @file.flush end |