Class: Bard::CI::State

Inherits:
Object
  • Object
show all
Defined in:
lib/bard/ci/state.rb

Instance Method Summary collapse

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

#deleteObject



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

Returns:

  • (Boolean)


25
26
27
# File 'lib/bard/ci/state.rb', line 25

def exists?
  File.exist?(state_file)
end

#loadObject



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