Class: Bard::CI::State
- Inherits:
-
Object
- Object
- Bard::CI::State
- Defined in:
- lib/bard/ci/state.rb
Instance Method Summary collapse
- #delete ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(project_name) ⇒ State
constructor
A new instance of State.
- #load ⇒ Object
- #save(data) ⇒ Object
Constructor Details
#initialize(project_name) ⇒ State
Returns a new instance of State.
7 8 9 |
# File 'lib/bard/ci/state.rb', line 7 def initialize project_name @project_name = project_name end |
Instance Method Details
#delete ⇒ Object
21 22 23 |
# File 'lib/bard/ci/state.rb', line 21 def delete File.delete(state_file) if File.exist?(state_file) end |
#exists? ⇒ Boolean
25 26 27 |
# File 'lib/bard/ci/state.rb', line 25 def exists? File.exist?(state_file) end |
#load ⇒ Object
16 17 18 19 |
# File 'lib/bard/ci/state.rb', line 16 def load return nil unless File.exist?(state_file) JSON.parse(File.read(state_file)) end |
#save(data) ⇒ Object
11 12 13 14 |
# File 'lib/bard/ci/state.rb', line 11 def save data FileUtils.mkdir_p(state_dir) File.write(state_file, JSON.generate(data)) end |