Sha256: 47e8fc7f8ce0a4d66be32d65aa4f06b484c817964c164f411084559048f486f3

Contents?: true

Size: 892 Bytes

Versions: 3

Compression:

Stored size: 892 Bytes

Contents

require 'singleton'
require 'yaml'

module Tongues

  ## Provides a convenient way to edit configuration
  def self.configure(&block)
    if block_given?
      block.call(Configuration.instance)
    else
      Configuration.instance
    end
  end

  class Configuration
    include Singleton

    ## Returns the api url
    def self.api_url
      'http://ws.detectlanguage.com/0.2/detect'
    end

    ## Returns the api key
    def api_key
      @@api_key ||= ''
    end

    ## Modifies the api_key
    def api_key=(key)
      @@api_key = key
    end

    ## Returns the api key
    def self.api_key
      @@api_key ||= ''
    end

    ## Modifies the api_key
    def self.api_key=(key)
      @@api_key = key
    end

    ## Returns a hash of supported languages
    def self.languages
      YAML::load(File.open(File.dirname(__FILE__) + '/config.yml'))['correspondences']
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tongues-0.1.1 lib/tongues/config/configuration.rb
tongues-0.1.0 lib/tongues/config/configuration.rb
tongues-0.0.13 lib/tongues/config/configuration.rb