Sha256: e551ea5f47313af7e88686dc33b1321593ea3e8fc955bd73677d7501592a55a1

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

# encoding: utf-8

# Copyright (C) 2015 Szymon Kopciewski
#
# This file is part of SinatraEnvToConfig
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

require "sinatra/base"

module Sinatra
  module EnvToConfig
    def env_to_config(*args)
      args.each { |key| set standarize_key(key), find_value_for_key(key) }
    end

    private

    def standarize_key(key)
      key.to_s.downcase
    end

    def find_value_for_key(key)
      key_string = key.to_s
      ENV[key_string]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sinatra-env_to_config-2.0.1 lib/sinatra/env_to_config.rb
sinatra-env_to_config-2.0.0 lib/sinatra/env_to_config.rb