Sha256: a21a07d2e5a9ac257246116f3185ffcb6b09eabcc99641eaf818392e535b893a

Contents?: true

Size: 729 Bytes

Versions: 7

Compression:

Stored size: 729 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(File.dirname(__FILE__) + '/config.yml'))['correspondences']
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
tongues-0.0.11 lib/tongues/config/configuration.rb
tongues-0.0.10 lib/tongues/config/configuration.rb
tongues-0.0.9 lib/tongues/config/configuration.rb
tongues-0.0.8 lib/tongues/config/configuration.rb
tongues-0.0.7 lib/tongues/config/configuration.rb
tongues-0.0.6 lib/tongues/config/configuration.rb
tongues-0.0.5 lib/tongues/config/configuration.rb