Class: Git::Dropbox::Config

Inherits:
Hash
  • Object
show all
Defined in:
lib/git/dropbox/config.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.config_fileObject



10
11
12
13
# File 'lib/git/dropbox/config.rb', line 10

def self.config_file
  folder = `git config dropbox.folder`.split.first
  "#{folder}/git-dropbox.yml"
end

.init!(folder) ⇒ Object



15
16
17
18
# File 'lib/git/dropbox/config.rb', line 15

def self.init!(folder)
  setup_git_folder(folder)
  self.new.save
end

.loadObject



6
7
8
# File 'lib/git/dropbox/config.rb', line 6

def self.load
  YAML.load_file(config_file)
end

.setup_git_folder(folder) ⇒ Object



20
21
22
23
# File 'lib/git/dropbox/config.rb', line 20

def self.setup_git_folder(folder)
  system "mkdir -p #{folder}"
  system "git config --global dropbox.folder '#{folder}'"
end

Instance Method Details

#saveObject



26
27
28
# File 'lib/git/dropbox/config.rb', line 26

def save
  File.open(Config.config_file(), 'w') { |f| f.write(self.to_yaml) }
end