Sha256: 05dfdc1f90af416790d2cbfff2207d3e7523907cde4d494d22955d77584b4a24
Contents?: true
Size: 718 Bytes
Versions: 3
Compression:
Stored size: 718 Bytes
Contents
# -*- encoding: utf-8 -*- require "rack/env/version" module Rack class Env def initialize(app, options = {}) @app = app @options = options end def call(env) set_env @app.call(env) end private def set_env if @options[:envfile] read_env_file(@options[:envfile]) else read_env_file(default_env_file) end end def default_env_file ::File.join(Dir.getwd, '.env') end def read_env_file(envfile) ::File.readlines(envfile).each {|line| next if line.chomp == "" || line =~ /^#/ key, value = line.chomp.split('=') ENV[key] = value } if ::File.exist?(envfile) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rack-env-0.1.2 | lib/rack/env.rb |
rack-env-0.1.1 | lib/rack/env.rb |
rack-env-0.1.0 | lib/rack/env.rb |