Sha256: a0697d2494f68af0d09cf910cce06cb342d72578dc027d316d8d112d25a5234d

Contents?: true

Size: 381 Bytes

Versions: 1

Compression:

Stored size: 381 Bytes

Contents

module Dotenv
  class Environment < Hash
    def initialize(filename)
      @filename = filename
      load if File.exists? @filename
    end

    def load
      read.each do |line|
        self[$1] = $2 if line =~ /\A([\w_]+)=(.*)\z/
      end
    end

    def read
      File.read(@filename).split("\n")
    end

    def apply
      each { |k,v| ENV[k] ||= v }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dotenv-0.3.0 lib/dotenv/environment.rb