Class: Koine::TestRunner::Adapters::LastCommand::Storage
- Inherits:
-
Object
- Object
- Koine::TestRunner::Adapters::LastCommand::Storage
- Defined in:
- lib/koine/test_runner/adapters/last_command.rb
Instance Method Summary collapse
-
#initialize(file_path: '.cache/koine/last-test-command.cache') ⇒ Storage
constructor
A new instance of Storage.
- #retrieve ⇒ Object
- #store(value) ⇒ Object
Constructor Details
#initialize(file_path: '.cache/koine/last-test-command.cache') ⇒ Storage
21 22 23 |
# File 'lib/koine/test_runner/adapters/last_command.rb', line 21 def initialize(file_path: '.cache/koine/last-test-command.cache') @file_path = file_path end |
Instance Method Details
#retrieve ⇒ Object
25 26 27 28 29 |
# File 'lib/koine/test_runner/adapters/last_command.rb', line 25 def retrieve if File.exist?(@file_path) File.read(@file_path).strip end end |
#store(value) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/koine/test_runner/adapters/last_command.rb', line 31 def store(value) folder = File.dirname(@file_path) unless File.exist?(folder) FileUtils.mkdir_p(folder) end File.open(@file_path, 'w') { |f| f.puts(value) } end |