module TxOcr

Constants

VERSION

Public Class Methods

config() click to toggle source

configをyamlから@cofigに取得

# File lib/tx_ocr/helper/config_helper.rb, line 32
def self.config
  yml_path = get_config_path + '/settings.yml'
  yml_file = YAML.load_file(yml_path)
  if yml_file
    @config = yml_file
  else
    File.open(yml_path, 'w') { |f| YAML.dump(@config, f) }
  end
end
configure(opts = {}) click to toggle source

Configure through hash

# File lib/tx_ocr/helper/config_helper.rb, line 13
def self.configure(opts = {})
  config
  opts.each do |k, v|
    @config[k.to_sym] = v if @valid_config_keys.include? k.to_sym
  end
  save_config
end
get_config_path() click to toggle source
# File lib/tx_ocr/helper/config_helper.rb, line 21
def self.get_config_path
  config_path = Dir.home + '/.tx_ocr'
  if Dir.exist?(config_path)
    # use user settings
    config_path
  else
    raise "Can't find config directory. please init by command: 'mygem config'.'"
  end
end
save_config() click to toggle source

現在の@configをyamlに保存

# File lib/tx_ocr/helper/config_helper.rb, line 43
def self.save_config
  yml_path = get_config_path + '/settings.yml'
  if File.exist?(yml_path)
    File.open(yml_path, 'w') { |f| YAML.dump(@config, f) }
  else
    raise "Can't find #{yml_path}. please set configure."
  end
end