Module: Configer

Extended by:
Configer
Included in:
Configer
Defined in:
lib/librr/configer.rb

Constant Summary collapse

FILENAME =
'dir.conf'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.load_dir_configObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/librr/configer.rb', line 15

def self.load_dir_config
  conf_path = self.check_config_dir

  dc_file = Settings.in_dir(FILENAME)
  if File.exists?(dc_file)
    Set.new(File.read(dc_file).split("\n")).delete("")
  else
    []
  end
end

.save_dir_config(config) ⇒ Object



26
27
28
29
30
31
# File 'lib/librr/configer.rb', line 26

def self.save_dir_config(config)
  conf_path = self.check_config_dir

  dc_file = Settings.in_dir(FILENAME)
  File.write(dc_file, config.to_a.join("\n"))
end

Instance Method Details

#check_config_dirObject



9
10
11
12
13
# File 'lib/librr/configer.rb', line 9

def check_config_dir
  conf_path = Settings::CONFIG_PATH
  FileUtils.mkpath(conf_path) unless File.directory?(conf_path)
  conf_path
end