File: env.rb

package info (click to toggle)
ruby-configurate 0.0.8-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 144 kB
  • ctags: 55
  • sloc: ruby: 666; makefile: 5
file content (17 lines) | stat: -rw-r--r-- 625 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module Configurate; module Provider
  # This provider looks for settings in the environment.
  # For the setting +foo.bar_baz+ this provider will look for an
  # environment variable +FOO_BAR_BAZ+, joining all components of the 
  # setting with underscores and upcasing the result.
  # If an value contains any commas (,) it's split at them and returned as array.
  class Env < Base
    def lookup_path(setting_path, *args)
      value = ENV[setting_path.join("_").upcase]
      unless value.nil?
        value = value.dup
        value = value.split(",") if value.include?(",")
      end
      value
    end
  end
end; end