Sha256: 6424edc0c6cf47f665a8ef83c0d9b5d0f6cab36ba15f351ed42cb6a373c5809f

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

# -*- encoding : utf-8 -*-
module Orion
  module Config

    class << self
      attr_reader :orion_url

      def load_config(orion_url)
        begin
          filename = "/config/initializers/fiware_orion_config.rb"
          # filename = "#{Rails.root}/config/initializers/fiware_orion_config.rb"
          if self.check_config_file(filename)
            require filename
            @orion_url = (orion_url.nil?) ? ORION_SERVER_IP : orion_url
          else
            @orion_url = orion_url
            puts @orion_url
          end
          {
              orion_url: @orion_url,
          }
        rescue => e
          puts e => e.message
        end
      end

      def check_config_file(filename)
        result = true
        unless File.exist?(filename)
          puts "|>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
          puts "|"
          puts "Please configure orion_url in #{filename}."
          puts "|"
          puts "|>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
          result = false
        end
        result
      end
    end


  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fiware-orion-geo-0.0.3 lib/orion/config.rb
fiware-orion-geo-0.0.2 lib/orion/config.rb