class SmartlingRails::Config

Attributes

api_key[RW]
locales[RW]
project_id[RW]
rails_app_name[RW]

Public Class Methods

new() click to toggle source
# File lib/smartling_rails/config.rb, line 15
def initialize
  load_locales_from_yaml
  import_env_variables
end

Public Instance Methods

import_env_variables() click to toggle source
# File lib/smartling_rails/config.rb, line 26
def import_env_variables
  File.open('.env', 'rb') do |f|
    f.each_line do |line|
      key_val = line.split('=')
      @api_key = key_val[1].strip if key_val[0] == 'SMARTLING_API_KEY'
      @project_id = key_val[1].strip if key_val[0] == 'SMARTLING_PROJECT_ID'
      @rails_app_name = key_val[1].strip if key_val[0] == 'SMARTLING_APP_NAME'
    end
  end if File.exist?('.env')
end
load_locales_from_yaml() click to toggle source
# File lib/smartling_rails/config.rb, line 20
def load_locales_from_yaml
  config_file_path = 'config/smartling_rails.yml'
  throw "Localization File Missing '/config/smartling_rails.yml'" unless File.exist?(config_file_path)
  @locales = YAML.load_file(config_file_path)['locales']
end