Class: CBin::LocalConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-lhj-bin/config/local_config.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.instanceObject



52
53
54
# File 'lib/cocoapods-lhj-bin/config/local_config.rb', line 52

def self.instance
  @instance ||= new
end

Instance Method Details

#configObject



48
49
50
# File 'lib/cocoapods-lhj-bin/config/local_config.rb', line 48

def config
  @config ||= load_config
end

#config_fileObject



6
7
8
# File 'lib/cocoapods-lhj-bin/config/local_config.rb', line 6

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

#config_file_nameObject



10
11
12
# File 'lib/cocoapods-lhj-bin/config/local_config.rb', line 10

def config_file_name
  'localizable_config.yml'
end

#default_configObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/cocoapods-lhj-bin/config/local_config.rb', line 18

def default_config
  { 'gen_en_dir' => 'local_gen/en.lproj',
    'gen_zh_hk_dir' => 'local_gen/zh-Hant.lproj',
    'gen_zh_cn_dir' => 'local_gen/zh-Hans.lproj',
    'gen_file_name' => 'Localizable.strings',
    'source_format_string' => 'NSLocalizedString(%s, @"")',
    'csv_key_col' => 0,
    'csv_cn_col' => 1,
    'csv_en_col' => 2,
    'read_csv_file' => '*.csv',
    'gen_zh_cn' => true,
    'trans_zh_hk' => false,
    'trans_zh_cn' => false,
    'download' => false,
    'download_csv' => 'zh_en.csv' }
end

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



40
41
42
43
44
45
46
# File 'lib/cocoapods-lhj-bin/config/local_config.rb', line 40

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



35
36
37
38
# File 'lib/cocoapods-lhj-bin/config/local_config.rb', line 35

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/cocoapods-lhj-bin/config/local_config.rb', line 14

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