Sha256: 0015616d2fb05a134446c9f43595fd708857d38d77ebb1d22eb9bf02dc010a93

Contents?: true

Size: 757 Bytes

Versions: 8

Compression:

Stored size: 757 Bytes

Contents

require 'yaml'


module Sentimeta
  class << self

    attr_accessor :env, :sphere
    attr_writer :endpoint, :lang, :logger

    def endpoint
      @endpoint ||= begin
        config_path = File.join(File.dirname(File.expand_path(__FILE__)), '../../config/endpoint.yml')
        config = YAML.load_file(config_path)[env.to_s]
        config['url']
      end
    end

    def lang
      if defined?(::I18n) and ::I18n.respond_to?(:locale)
        self.lang = I18n.locale
      end
      @lang || :en
    end

    def init options
      options.each do |option, value|
        public_send("#{ option }=", value) if respond_to?("#{ option }=")
      end
    end

    def logger
      @logger ||= Logger.new STDOUT
    end
  end

  self.env = DEFAULT_ENV

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sentimeta-0.1.8 lib/sentimeta/init.rb
sentimeta-0.1.7 lib/sentimeta/init.rb
sentimeta-0.1.6 lib/sentimeta/init.rb
sentimeta-0.1.5 lib/sentimeta/init.rb
sentimeta-0.1.4 lib/sentimeta/init.rb
sentimeta-0.1.3 lib/sentimeta/init.rb
sentimeta-0.1.2 lib/sentimeta/init.rb
sentimeta-0.1.0 lib/sentimeta/init.rb