Sha256: ca9d84c12fe916ead0a72db6d622f6b8d087621ff720561809cefbc557c896c6

Contents?: true

Size: 1.37 KB

Versions: 16

Compression:

Stored size: 1.37 KB

Contents

require 'yaml'
require 'cocoapods-lhj-bin/helpers/oss_helper'

module CBin
  class LocalConfig
    def config_file
      File.join(Pod::Config.instance.home_dir, config_file_name)
    end

    def config_file_name
      'localizable_config.yml'
    end

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

    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

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

    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

    def config
      @config ||= load_config
    end

    def self.instance
      @instance ||= new
    end

  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
cocoapods-aomi-bin-0.1.28 lib/cocoapods-lhj-bin/config/local_config.rb
cocoapods-aomi-bin-0.1.27 lib/cocoapods-lhj-bin/config/local_config.rb
cocoapods-aomi-bin-0.1.26 lib/cocoapods-lhj-bin/config/local_config.rb
cocoapods-aomi-bin-0.1.25 lib/cocoapods-lhj-bin/config/local_config.rb
cocoapods-aomi-bin-0.1.24 lib/cocoapods-lhj-bin/config/local_config.rb
cocoapods-aomi-bin-0.1.23 lib/cocoapods-lhj-bin/config/local_config.rb
cocoapods-aomi-bin-0.1.22 lib/cocoapods-lhj-bin/config/local_config.rb
cocoapods-aomi-bin-0.1.21 lib/cocoapods-lhj-bin/config/local_config.rb
cocoapods-aomi-bin-0.1.20 lib/cocoapods-lhj-bin/config/local_config.rb
cocoapods-aomi-bin-0.1.19 lib/cocoapods-lhj-bin/config/local_config.rb
cocoapods-aomi-bin-0.1.18 lib/cocoapods-lhj-bin/config/local_config.rb
cocoapods-aomi-bin-0.1.17 lib/cocoapods-lhj-bin/config/local_config.rb
cocoapods-aomi-bin-0.1.16 lib/cocoapods-lhj-bin/config/local_config.rb
cocoapods-aomi-bin-0.1.15 lib/cocoapods-lhj-bin/config/local_config.rb
cocoapods-aomi-bin-0.1.14 lib/cocoapods-lhj-bin/config/local_config.rb
cocoapods-aomi-bin-0.1.13 lib/cocoapods-lhj-bin/config/local_config.rb