Class: Lhj::LocalConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/lhj/helper/local_config.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.instanceObject



35
36
37
# File 'lib/lhj/helper/local_config.rb', line 35

def self.instance
  @instance ||= new
end

Instance Method Details

#configObject



31
32
33
# File 'lib/lhj/helper/local_config.rb', line 31

def config
  @config ||= load_config
end

#config_fileObject



6
7
8
# File 'lib/lhj/helper/local_config.rb', line 6

def config_file
  File.join(Lhj::Config.instance.home_dir, config_file_name)
end

#config_file_nameObject



10
11
12
# File 'lib/lhj/helper/local_config.rb', line 10

def config_file_name
  'localizable_config.yml'
end

#get_col_by_name(file_name, col_name = 'csv_key_col') ⇒ Object



23
24
25
26
27
28
29
# File 'lib/lhj/helper/local_config.rb', line 23

def get_col_by_name(file_name, col_name = 'csv_key_col')
  m = config
  col = m[col_name]
  fo = m['read_targets'].find{ |o| /#{o['csv_file']}/ =~ file_name }
  col = fo[col_name] if fo
  col
end

#load_configObject



18
19
20
21
# File 'lib/lhj/helper/local_config.rb', line 18

def load_config
  syn_config_file unless File.exist?(config_file)
  YAML.load_file(config_file)
end

#syn_config_fileObject



14
15
16
# File 'lib/lhj/helper/local_config.rb', line 14

def syn_config_file
  Lhj::OSS::Helper.instance.down_load(config_file_name, config_file)
end