Sha256: 151321cb069dd5128d84090570f778e69ef9b782d3d1202aea2706c88911a34c

Contents?: true

Size: 718 Bytes

Versions: 3

Compression:

Stored size: 718 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 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('tongues/config/config.yml'))['correspondences']
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tongues-0.0.4 lib/tongues/config/configuration.rb
tongues-0.0.3 lib/tongues/config/configuration.rb
tongues-0.0.2 lib/tongues/config/configuration.rb