Sha256: 615545880d93a3e91ca29bb21da123470830e34a82aaee3d332870fdc880f0df

Contents?: true

Size: 353 Bytes

Versions: 1

Compression:

Stored size: 353 Bytes

Contents

module Dotenv
  class Environment < Hash
    def initialize(filename)
      @filename = filename
      load
    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.1.0 lib/dotenv/environment.rb