class GitContext::Configuration

Attributes

config_data[R]
git[R]
home[R]
storages[R]
yaml[R]

Public Class Methods

new(home) click to toggle source
# File lib/git_context/configuration.rb, line 26
def initialize(home)
  @home = home
  @config_data = ConfigData.new(@home)
  @yaml = Storage::YML.new(@config_data)
  @git = Storage::Git.new(@config_data)

  @yaml.load
  @storages = [@yaml, @git]
end

Public Instance Methods

add_context(context) click to toggle source
# File lib/git_context/configuration.rb, line 55
def add_context(context)
  config_data.contexts << context
  config_data.contexts.sort_by!(&:work_dir)

  save_into_storage
end
add_profile(profile) click to toggle source
# File lib/git_context/configuration.rb, line 41
def add_profile(profile)
  config_data.profiles << profile
  save_into_storage
end
delete_profile(profile_name) click to toggle source
# File lib/git_context/configuration.rb, line 46
def delete_profile(profile_name)
  config_data.profiles.delete_if { |profile| profile.profile_name == profile_name }
  save_into_storage
end
list_profile_names() click to toggle source
# File lib/git_context/configuration.rb, line 51
def list_profile_names
  config_data.profiles.map(&:profile_name).sort
end
setup() click to toggle source
# File lib/git_context/configuration.rb, line 36
def setup
  create_base_dir
  setup_storage
end

Private Instance Methods

create_base_dir() click to toggle source
# File lib/git_context/configuration.rb, line 72
def create_base_dir
  FileUtils.mkdir(git_context_dir) unless FileTest.exists?(git_context_dir)
end
git_context_dir() click to toggle source
# File lib/git_context/configuration.rb, line 76
def git_context_dir
  File.join(home, BASE_STORAGE_DIR)
end
save_into_storage() click to toggle source
# File lib/git_context/configuration.rb, line 68
def save_into_storage
  storages.each(&:save)
end
setup_storage() click to toggle source
# File lib/git_context/configuration.rb, line 64
def setup_storage
  storages.each(&:setup)
end