Module: Orion::Config

Defined in:
lib/orion/config.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.orion_urlObject (readonly)

Returns the value of attribute orion_url.



6
7
8
# File 'lib/orion/config.rb', line 6

def orion_url
  @orion_url
end

Class Method Details

.check_config_file(filename) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/orion/config.rb', line 27

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

.load_config(orion_url) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/orion/config.rb', line 8

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