Class: GitContext::Storage::YML

Inherits:
Object
  • Object
show all
Defined in:
lib/git_context/storage/yml.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ YML

Returns a new instance of YML.



10
11
12
# File 'lib/git_context/storage/yml.rb', line 10

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/git_context/storage/yml.rb', line 8

def config
  @config
end

Instance Method Details

#loadObject



20
21
22
23
24
25
# File 'lib/git_context/storage/yml.rb', line 20

def load
  return unless config_filepath && FileTest.exist?(config_filepath)

  load_profiles_from_file
  load_contexts_from_file
end

#saveObject



27
28
29
30
31
# File 'lib/git_context/storage/yml.rb', line 27

def save
  File.open(config_filepath, 'w') do |file|
    file.write(YAML.dump(serialized_data))
  end
end

#setupObject



14
15
16
17
18
# File 'lib/git_context/storage/yml.rb', line 14

def setup
  return if FileTest.exist?(config_filepath)

  FileUtils.touch(config_filepath)
end